Skip to content

fix(material-experimental): use harnesses for mat-option #17009

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
Sep 27, 2019

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented Sep 8, 2019

Follow-up from #16620 and #16710. Adds a dedicated harness for mat-option and mat-optgroup.

Note that some of the code is duplicated. This is because we don't have a shared place where to put the harness so that mat-autocomplete and mat-select don't have to depend on each other. I've intentionally kept the harnesses to only the methods we need, but once we have experimental/core, I'll combine them and implement all of the states that are supported by mat-option.

@crisbeto crisbeto added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent pr: merge safe target: patch This PR is targeted for the next patch release labels Sep 8, 2019
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Sep 8, 2019
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.

See comments below

@crisbeto crisbeto force-pushed the option-harness branch 2 times, most recently from 3979a6f to b3348e9 Compare September 22, 2019 10:45
@crisbeto
Copy link
Member Author

Sorry for the delay @mmalerba, I must've missed the notification. The feedback is addressed now.

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.

Now that BaseHarnessFilters has some built-in options, we should give all classes a static with function. This will allow users to filter based on selector or ancestor element

Follow-up from angular#16620 and angular#16710. Adds a dedicated harness for `mat-option` and `mat-optgroup`.

Note that some of the code is duplicated. This is because we don't have a shared place where to put the harness so that `mat-autocomplete` and `mat-select` don't have to depend on each other. I've intentionally kept the harnesses to only the methods we need, but once we have `experimental/core`, I'll combine them and implement all of the states that are supported by `mat-option`.
@crisbeto
Copy link
Member Author

@mmalerba I've addressed the latest set of feedback.

@mmalerba mmalerba added pr: lgtm action: merge The PR is ready for merge by the caretaker labels Sep 25, 2019
@@ -85,12 +86,12 @@ export class MatSelectHarness extends ComponentHarness {
}

/** Gets the options inside the select panel. */
async getOptions(): Promise<TestElement[]> {
async getOptions(): Promise<MatSelectOptionHarness[]> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Did we want to make this optionally take a HarnessPredicate? I seem to remember discussing that at some point. So we can search for a specific option more easily

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure what that would look like. Here's what I got to compile, but it feels a little weird so I don't know if it's correct:

async getOptions(predicate?: HarnessPredicate<MatSelectOptionHarness>): Promise<MatSelectOptionHarness[]> {
  return this._documentRootLocator.locatorForAll(predicate || MatSelectOptionHarness)();
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I think I meant OptionHarnessFilters not HarnessPredicate. That way people can do getOptions({text: 'Option 1'}). Under the hood that would use a harness predicate: ...locatorForAll(MatSelectOptions.with(options)). My bad for not explaining that right

@andrewseguin andrewseguin merged commit f084f13 into angular:master Sep 27, 2019
@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 Oct 28, 2019
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: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants