Skip to content
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

feat(material/tabs/testing): polish harness API #17417

Merged
merged 5 commits into from
Oct 17, 2019

Conversation

mmalerba
Copy link
Contributor

@mmalerba mmalerba commented Oct 15, 2019

  • Add label filter for MatTabHarness
  • Add ability to filter returned harnesses in MatTabGroupHarness#getTabs
  • Add a method for selecting a child tab to the MatTabGroupHarness
  • Remove getContentElement and replace it with getHarnessLoaderForContent

@jelbourn @devversion Curious about your opinions: My reason for removing getContentElement is that I want to avoid returning TestElement objects from our harnesses. I don't think they're particularly useful to test authors, and instead we probably want APIs that are more focused in purpose. I do think it makes sense, however, to allow users to get some handle on the content. I think the thing users are most likely to do with the content element is either query for more harnesses within it, or query outside of the harness system (e.g. document.querySelector). I settled on returning a selector because it allows the user to do either of those things. Another option would be to provide a method for loading a sub-harness directly (they pass the harness class and we return an instance). We either could provide this method instead of or in addition to the getSelectorForContent method.

Update: Changed getSelectorForContent to getHarnessLoaderForContent

@mmalerba mmalerba added P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful target: major This PR is targeted for the next major release labels Oct 15, 2019
@mmalerba mmalerba added this to the 9.0.0 milestone Oct 15, 2019
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Oct 15, 2019
@mmalerba mmalerba force-pushed the tabs-harness-polish branch from 7b1c2ea to 32d4db8 Compare October 15, 2019 23:32
/** Gets the element id for the content of the current tab. */
private async _getContentId(): Promise<string> {
/** Gets a selector that can be used to locate the tab's content element. */
async getSelectorForContent(): Promise<string> {
Copy link
Member

Choose a reason for hiding this comment

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

What about getting a locator scoped to the content?

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 in general.

@mmalerba I'm somewhat hesitant in thinking that returning TestElement's is an anti-pattern. For simple assertions where someone wants to get a handle on the content element, it feels totally expected to me that a TestElement instance is returned that works for both e2e and test bed tests.

The abstraction of the elements we are dealing with in the harnesses is not only useful to implementer's of harnesses, but also to consumers of harnesses as they do not need to deal with platform-specific things (i.e. calling querySelector). I don't see any big impact on providing such a harness method (it seems like it can be quite useful and commonly used)

@mmalerba mmalerba force-pushed the tabs-harness-polish branch from 32d4db8 to 497e7eb Compare October 16, 2019 21:12
@mmalerba
Copy link
Contributor Author

As discussed on slack, switch to returning a HarnessLoader for the tab content, PTAL.

@mmalerba mmalerba requested a review from a team as a code owner October 16, 2019 21:50
@mmalerba mmalerba force-pushed the tabs-harness-polish branch from ba9e030 to 21328f6 Compare October 16, 2019 21:50
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 Oct 17, 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.

Nice! I really like that harness loader method 🎉

@devversion devversion removed the action: merge The PR is ready for merge by the caretaker label Oct 17, 2019
@mmalerba mmalerba force-pushed the tabs-harness-polish branch from 21328f6 to 25daee6 Compare October 17, 2019 18:48
@mmalerba mmalerba added the action: merge The PR is ready for merge by the caretaker label Oct 17, 2019
@mmalerba mmalerba force-pushed the tabs-harness-polish branch from 25daee6 to 50a1b19 Compare October 17, 2019 22:36
@mmalerba mmalerba merged commit 05600a2 into angular:master Oct 17, 2019
@mmalerba mmalerba deleted the tabs-harness-polish branch October 17, 2019 22:56
@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 Nov 17, 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 P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants