Skip to content

feat(select,input,form-field): move test harnesses out of experimental #17874

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
Dec 10, 2019

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented Dec 4, 2019

Moves the test harnesses for the select, input and form-field packages out of material-experimental.

@crisbeto crisbeto added pr: merge safe target: minor This PR is targeted for the next minor release labels Dec 4, 2019
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Dec 4, 2019
import {
MatFormFieldControlHarness
} from '@angular/material-experimental/form-field/testing/control';
import {MatFormFieldControlHarness} from '@angular/material/form-field/testing/control';
import {SelectHarnessFilters} from './select-harness-filters';
import {MatSelectOptionHarness, MatSelectOptionGroupHarness} from './option-harness';
Copy link
Member Author

@crisbeto crisbeto Dec 4, 2019

Choose a reason for hiding this comment

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

Note that we have a harness for an option inside mat-select, as well as for an option in mat-autocomplete. Once this PR is merged in I can remove the duplication and add a single, fully-featured harness for mat-option in core.

Copy link
Contributor

Choose a reason for hiding this comment

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

It would be really nice if we could get that in before final. I forgot that autocomplete was already moved out of experimental with the split mat-option harness

@crisbeto crisbeto force-pushed the form-field-harness branch 4 times, most recently from 604f742 to 3554b2b Compare December 4, 2019 17:46
@crisbeto crisbeto added the P2 The issue is important to a large percentage of users, with a workaround label Dec 4, 2019
@crisbeto
Copy link
Member Author

crisbeto commented Dec 4, 2019

Setting to P2 since there's other work that depends on these changes.

@crisbeto crisbeto marked this pull request as ready for review December 4, 2019 17:55
@crisbeto crisbeto requested review from devversion, jelbourn, mmalerba and a team as code owners December 4, 2019 17:55
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker labels Dec 4, 2019
Copy link
Member

@devversion devversion left a comment

Choose a reason for hiding this comment

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

LGTM.

@mmalerba mmalerba removed action: merge The PR is ready for merge by the caretaker pr: merge safe labels Dec 4, 2019
@mmalerba
Copy link
Contributor

mmalerba commented Dec 4, 2019

Sorry, it won't let me add comments inline since the lines are unedited, but here's a breakdown by class of changes I think we should make before moving this API out of experimental:

FormFieldHarnessFilters
	+ floatingLabelText?: string | RegExp
	+ hasErrors?: boolean

MatFormFieldHarness
	+ hasErrors(): Promise<boolean>
	+ getHarnessLoaderForInfix(): Promise<HarnessLoader>
	getPrefixContainer => getHarnessLoaderForPrefix
	getSuffixContainer => getHarnessLoaderForSuffix
	getErrorMessages => getTextErrors
	getHintMessages => getTextHints

InputHarnessFilters
	+ placeholder?: string | RegExp

SelectHarnessFilters
	+ placeholder?: string | RegExp
	+ value?: string | RegExp

MatSelectHarness
	+ select(filters?: SelectOptionHarnessFilters): Promise<void>
	getOptions => add optional filters
	getOptionGroups => add optional filters

Also, do a pass on the API docs, make sure they are consistent with other harnesses (in particular I noticed with method, move description of filter options to the filter class).

@crisbeto
Copy link
Member Author

crisbeto commented Dec 5, 2019

@mmalerba I've updated the harnesses based on your feedback, aside from a couple of issues:

  1. I'm not sure how getHarnessLoaderForInfix(): Promise<HarnessLoader> is supposed to work and what it would be useful for. We already have harnesses for the input and select which expose the content inside the infix.
  2. I don't think we can do the value and placeholder filters for the select harness, because the values aren't always in the DOM so we can't extract them reliably.

@mmalerba
Copy link
Contributor

mmalerba commented Dec 5, 2019

Discussed with @crisbeto on slack. After thinking about it more, I agree that those two don't make sense

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.

Do you have a particular use case in mind for MatSelectHarness#getPanel? I'd prefer to remove it, it goes against my rule of thumb about exposing TestElement.

@crisbeto crisbeto force-pushed the form-field-harness branch 2 times, most recently from 9dc54c7 to 13e1fab Compare December 6, 2019 09:00
@crisbeto
Copy link
Member Author

crisbeto commented Dec 6, 2019

I added getPanel, because I thought that it might useful if somebody wants to get info that we haven't exposed directly in the harness. I've removed it, can you take a look @mmalerba?

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.

  • Do you disagree on renaming getErrorMessages and getHintMessages or did you just miss it? My reasoning is that in other harnesses we named methods like that when they returned the text of the element rather than the element itself
  • It looks like option is not exported from public-api for select
  • getOptionGroups should also take optional filters
  • The doc comments for filter classes and with methods still needs to be udated

const [isMultiple, options] = await Promise.all([this.isMultiple(), this.getOptions(filter)]);

if (isMultiple) {
await Promise.all(options.map(option => option.click()));
Copy link
Contributor

Choose a reason for hiding this comment

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

Based on the name of this method, I would expect it to call select on the option rather than click (which is effectively toggle). Maybe we can change this to call select() on the options and then also have a deselect() method that calls deselect() on the options.

Copy link
Member Author

Choose a reason for hiding this comment

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

These are the custom mat-option elements so we don't have access to the select/deselect methods. Should I rename it to click instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

You can leave it as is for now and leave a TODO to split out separate select/deselect methods later

@crisbeto
Copy link
Member Author

crisbeto commented Dec 6, 2019

@mmalerba I've addressed the latest set the feedback, aside from exposing the option harnesses. I haven't exposed or documented them properly yet, because their code is duplicated between mat-select and mat-autocomplete. Once this PR is merged in I'll add proper, fully-featured harnesses that are exposed through material/core/testing.

@mmalerba
Copy link
Contributor

mmalerba commented Dec 6, 2019

I'm hesitant about just merging this and doing the option stuff in a follow up because I don't want this temporary state API to wind up in an RC, or worse final if the follow-up doesn't make it in in time. I would suggest doing the common option first and putting this one on hold until that's in.

cc @jelbourn

@crisbeto
Copy link
Member Author

crisbeto commented Dec 6, 2019

I can put together the option PR for Monday so we have some time to merge it in for final. I would've made a shared option harness to begin with, but the autocomplete and select harnesses started off in experimental and we don't have a material-experimental/core to put it in.

@jelbourn
Copy link
Member

jelbourn commented Dec 6, 2019

I'm fine with doing this in two steps since I just did an RC today and will know not to do another one until we consolidate

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.

Ok, last couple things then we can merge

@crisbeto
Copy link
Member Author

crisbeto commented Dec 6, 2019

Addressed the last few things @mmalerba.

@mmalerba mmalerba added the action: merge The PR is ready for merge by the caretaker label Dec 6, 2019
Moves the test harnesses for the `select`, `input` and `form-field` packages out of `material-experimental`.
@mmalerba mmalerba merged commit 1c1af58 into angular:master Dec 10, 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 Jan 10, 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 P2 The issue is important to a large percentage of users, with a workaround target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants