Skip to content

feat(chips): add test harness #20028

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 28, 2020
Merged

Conversation

crisbeto
Copy link
Member

Adds test harnesses for the Material chips and the related components.

Note: I didn't add harnesses for MatChipAvatar and MatChipTrailingIcon because they don't have any functionality tied to them.

@crisbeto crisbeto added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent merge safe target: minor This PR is targeted for the next minor release labels Jul 17, 2020
@crisbeto crisbeto requested review from devversion, jelbourn, mmalerba and a team as code owners July 17, 2020 16:30
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jul 17, 2020
@crisbeto crisbeto force-pushed the chips-harness branch 2 times, most recently from f2ae6a8 to 964cdef Compare July 17, 2020 16:55
Adds test harnesses for the Material chips and the related components.
@crisbeto
Copy link
Member Author

The feedback has been addressed.

@mmalerba mmalerba added lgtm action: merge The PR is ready for merge by the caretaker labels Jul 20, 2020
Copy link
Contributor

@mmalerba mmalerba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

/** Only find instances whose text matches the given value. */
text?: string | RegExp;
/** Only find chip instances whose selected state matches the given value. */
selected?: boolean;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mdc versions of chips has types of chips that don't have a selected state- this would affect the filter as well as the chip harness API. Would it make sense to author the harness for the existing chip-list against the concepts of the MDC-based chips so that we're going in the direction we want? (e.g MatChipListbox, MatChipOption, etc.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't those just always return false? I think that no matter what, we'll have some differences in the harnesses between the current ones and MDC, because the public API is different.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC the MDC-based mat-chip-listbox should be equivalent to the current mat-chip-list, so maybe the end result should look something like

MatChipHarness - any kind of chip, no selection API
MatChipSetHarness - any kind of chip container, no selection API

MatChipOptionHarness - specifically a listbox (option) chip, extends MatChipHarness, selection API
MatChipListboxHarness - specifically listbox chip container, extends MatChipSetHarness, selection API
MatChipListHarness becomes an alias for MatChipListboxHarness

Thoughts?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO that makes sense for the MDC chips, but not for the existing ones. Somebody that hasn't used the MDC chips won't know what a "chip listbox" is referring to. I don't think it's worth it to avoid breaking changes in the harnesses, considering that the component's public API has breaking changes already.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think since one of the main goals for the harnesses is to help with the MDC migration, we should align the API with the current version of chips for now. Once the migration is done we may want to change it to align better with the new API of the MDC version.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would this all work with the current version of chips though? Would there would be 2 different harnesses for MatChip (MatChipHarness, MatChipOptionHarness) and users just pick the ones that gives the functionality they want in their test?

Copy link
Member Author

@crisbeto crisbeto Jul 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's worth noting that selectable is an input so a chip could change type between change detection runs. That means that people might have to use two harnesses for the same element.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could just use MatOptionHarness exclusively and it would report false if it wasn't selectable, so I don't think you'd need to use both for a single element (unless MatChipHarness does something that MatChipOptionHarness doesn't)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the point I was making above about always using MatChipOption. Anyway, I don't think that we can get away with using the exact same set of harnesses for both MDC and the current version, because they're fundamentally different APIs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose I had just been imagining that we could just completely omit the selection APIs from MatChipHarness for now, and only add them to the mdc ones.

I admit it's not ideal. Thinking about it more, I can live with going with this API for now and just committing to writing migration schematics for chips specifically because the APIs should be pretty easy to transform.

@jelbourn jelbourn added action: merge The PR is ready for merge by the caretaker and removed action: merge The PR is ready for merge by the caretaker merge safe labels Jul 20, 2020
@jelbourn
Copy link
Member

(marking as not merge-safe because this touches mat-chip-list)

@jelbourn jelbourn merged commit 165622e into angular:master Jul 28, 2020
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Aug 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants