Skip to content

feat(material-experimental): add test harness for mat-tooltip #16676

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

Closed
wants to merge 1 commit into from

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented Aug 3, 2019

Sets up a test harness for the current Material tooltip.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Aug 3, 2019
@crisbeto crisbeto force-pushed the tooltip-test-harness branch from c878a24 to 0b1e1fb Compare August 3, 2019 11:05
@crisbeto crisbeto changed the title feat(mdc-experimental): add test harness for mat-tooltip feat(material-experimental): add test harness for mat-tooltip Aug 3, 2019
Sets up a test harness for the current Material tooltip.
@crisbeto crisbeto force-pushed the tooltip-test-harness branch from 0b1e1fb to 230d552 Compare August 3, 2019 11:06
@crisbeto crisbeto added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent pr: merge safe labels Aug 3, 2019
@crisbeto crisbeto marked this pull request as ready for review August 3, 2019 11:22

// TODO(crisbeto): this fails because we have a setTimeout inside the tooltip which
// can't be flushed. Talk to Miles about how we should approach this in harnesses.
// it('should be able to close a tooltip', async () => {
Copy link
Member Author

@crisbeto crisbeto Aug 3, 2019

Choose a reason for hiding this comment

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

@mmalerba In the tooltip's hide method we do something like setTimeout(/* some close logic */, 0) which I wasn't able to flush during the unit tests. I tried awaiting a setTimeout, but it didn't help. I could probably get it to work if I use fakeAsync with a tick for the test, but that means that whoever is consuming the harness would have to know to that they have to use it. How should we handle this case? I'm guessing that we don't want to lock ourselves into using fakeAsync or async around some tests.

Copy link
Member

Choose a reason for hiding this comment

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

When you say awaiting a setTimeout, what did that code look like?

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 had something like this:

function wait(time: number) {
    return new Promise(resolve => {
        setTimeout(resolve, time);
    });
}

Then I had await wait(20000) right before the assertions, but the timer still hadn't fired.

*/

export type TooltipHarnessFilters = {
id?: string;
Copy link
Member

Choose a reason for hiding this comment

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

triggerId?

/** Gets an attribute value from the tooltip trigger. */
async getAttribute(attributeName: string): Promise<string|null> {
return (await this.host()).getAttribute(attributeName);
}
Copy link
Member

Choose a reason for hiding this comment

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

I think we should just let people do host().getAttribute themselves if they really need to get this level of flexibility


// TODO(crisbeto): this fails because we have a setTimeout inside the tooltip which
// can't be flushed. Talk to Miles about how we should approach this in harnesses.
// it('should be able to close a tooltip', async () => {
Copy link
Member

Choose a reason for hiding this comment

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

When you say awaiting a setTimeout, what did that code look like?

@crisbeto
Copy link
Member Author

Closing since this too out of date now. I'll take whatever I can from here and resubmit.

@crisbeto crisbeto closed this Apr 22, 2020
crisbeto added a commit to crisbeto/material2 that referenced this pull request Apr 22, 2020
This is redo of angular#16676. Adds a test harness for `mat-tooltip`, as well as an API to move the pointer away from an element, as an opposite to `TestElement.hover`.
crisbeto added a commit to crisbeto/material2 that referenced this pull request Apr 22, 2020
This is redo of angular#16676. Adds a test harness for `mat-tooltip`, as well as an API to move the pointer away from an element, as an opposite to `TestElement.hover`.
crisbeto added a commit to crisbeto/material2 that referenced this pull request Apr 23, 2020
This is redo of angular#16676. Adds a test harness for `mat-tooltip`, as well as an API to move the pointer away from an element, as an opposite to `TestElement.hover`.
jelbourn pushed a commit that referenced this pull request May 18, 2020
This is redo of #16676. Adds a test harness for `mat-tooltip`, as well as an API to move the pointer away from an element, as an opposite to `TestElement.hover`.
@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 May 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants