Skip to content

Commit 80d3e28

Browse files
devversionmmalerba
authored andcommitted
test(material/expansion): fix failing unit test on iOS14 safari
An expansion test seems to be flaky/failing in Safari on iOS14 because the `visibility: hidden` style from the expansion panel content is not applied immediately. We fix this by enforcing a style recalulcation like we do in the ripple. An alternative would have been to switch the test to actual async/await where we then need to wait at least until the next tick. It seems more idiomatic to stick with `fakeAsync` here though.
1 parent 384ce51 commit 80d3e28

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/material/expansion/expansion.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,11 @@ describe('MatExpansionPanel', () => {
201201
fixture.detectChanges();
202202
tick(250);
203203

204+
// Enforce a style recalculation as otherwise browsers like Safari on iOS 14 require
205+
// us to wait until the next tick using actual async/await. Not retrieving the computed
206+
// styles would result in the `visibility: hidden` on the expansion content to not apply.
207+
getComputedStyle(button).getPropertyValue('visibility');
208+
204209
button.focus();
205210
expect(document.activeElement).not.toBe(button, 'Expected button to no longer be focusable.');
206211
}));

0 commit comments

Comments
 (0)