Skip to content

feat(material/snackbar): add isDismissed harness method #18766

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
Mar 12, 2020

Conversation

jelbourn
Copy link
Member

@jelbourn jelbourn commented Mar 9, 2020

No description provided.

@jelbourn jelbourn added the target: minor This PR is targeted for the next minor release label Mar 9, 2020
@jelbourn jelbourn requested review from devversion and mmalerba March 9, 2020 19:23
@jelbourn jelbourn requested a review from crisbeto as a code owner March 9, 2020 19:23
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Mar 9, 2020
// We consider the snackbar dismissed if it's not in the DOM. We can assert that the
// element isn't in the DOM by seeing that its width and height are zero.
const dimensions = await (await this.host()).getDimensions();
return dimensions.height === 0 && dimensions.width === 0;
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure how this would behave if it was called mid-animation, right after dismiss was called. Does the test harness guarantee that all the animations have settled?

Copy link
Member

@devversion devversion Mar 9, 2020

Choose a reason for hiding this comment

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

Technically the element is already gone, and could not be loaded by the HarnessLoader again. Though consumers still have a reference to it, so it might be good to expose a method to TestElement?

The method could then use protractor isPresent, and in testbed, check if a parent element exists.

Copy link
Member Author

Choose a reason for hiding this comment

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

@devversion I don't follow what you mean- while the exit animation plays, the snackbar container would still be in the DOM, no?

Seems like the easiest thing to do for the animation would be to add a marker attribute to an existing snackbar and check for that as well.

As for the logic of checking whether the element is in the DOM: checking the geometry gets the job done for now, I would rather just use that until we need to add an isInDom method for some other use case.

Copy link
Member

@devversion devversion Mar 9, 2020

Choose a reason for hiding this comment

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

@jelbourn Sorry. I was not chatting about the mid-animation thing @crisbeto mentioned. I was basically saying that figuring out whether an element is in the DOM is a general use-case for such harnesses, and that checking the geometry is a symptom of the problem that consumers can have references to harnesses while the actual host element is already gone.

I agree that checking the geometry does the job for now, but I think long-term adding a method for isPresent might be useful in TestElement.

Copy link
Member Author

Choose a reason for hiding this comment

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

@crisbeto added handling for the animation, PTAL

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 (needs API golden update)

@devversion devversion added the lgtm label Mar 9, 2020
@jelbourn jelbourn force-pushed the snackbar-isdismissed branch 2 times, most recently from 3922efe to 25110d9 Compare March 9, 2020 22:01
@jelbourn jelbourn requested a review from a team as a code owner March 9, 2020 22:01
// Mark this element with a 'dismissing' attribute to indicate that the snackbar has
// been dismissed and will soon be removed from the DOM. This is used by the snackbar
// test harness.
this._elementRef.nativeElement.setAttribute('exit', '');
Copy link
Contributor

Choose a reason for hiding this comment

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

should we call it mat-exit? also the comment says dismissing

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I debated this with myself- I figured the prefix wouldn't be strictly necessary since we control the snackbar container and only add it once it's dismissed, but it's fair to say that people might still see it somehow and wonder where it comes from. Added (and fixed the comment).

@jelbourn jelbourn force-pushed the snackbar-isdismissed branch from 25110d9 to 9a0b751 Compare March 10, 2020 23:22
@jelbourn jelbourn force-pushed the snackbar-isdismissed branch from 9a0b751 to adcba68 Compare March 10, 2020 23:25
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

@mmalerba mmalerba added the action: merge The PR is ready for merge by the caretaker label Mar 10, 2020
@andrewseguin andrewseguin merged commit 6e70cc7 into angular:master Mar 12, 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 Apr 12, 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 target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants