Repository navigation
Block Editor: Fix flaky text gradient contrast warning test - #86403
Conversation
The popover that holds the warning fades in from opacity 0, and toBeVisible() counts opacity 0 as hidden. The test checked once, right after the notice appeared, so it failed whenever the fade had not started yet. Wait for the popover to finish opening first.
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the 📦 Bundle sizeSize Change: 0 B Total Size: 8.61 MB
|
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the test update that waits for popover positioning before asserting warning visibility.
No open issues 🎉
What changed in this PR
Stabilizes the text-gradient contrast warning test added in #86148 by waiting for the popover to finish opening before checking visibility.
Changes:
- Uses
waitForwith the existingtoBePositionedPopovermatcher. - Preserves the visibility assertion and explains the opacity-related timing issue.
| File | Description |
|---|---|
packages/block-editor/src/components/global-styles/test/typography-panel.browser.test.tsx |
Waits for popover positioning before asserting that the contrast warning is visible. |
Review effort: Balanced
|
I'll get this in and monitor. |
|
Thanks for getting this fix up and merged 🙇 |
What?
Follow-up to #86148.
Fixes the flaky
shows the contrast warning on the gradient control when the text is a gradienttest intypography-panel.browser.test.tsx, reported here. The test now waits for the popover to finish opening before it checks that the warning is visible. It uses the existingtoBePositionedPopovermatcher to wait.The testing docs prefer
await expect.element( ... ).toBeVisible()in Browser Mode, but it isn't used here. Vitest's version ignores opacity, so it would pass while the popover is still atopacity: 0.Why?
The popover that holds the warning fades in from
opacity: 0, andtoBeVisible()countsopacity: 0as hidden. The test checked once, as soon as the warning appeared, so it failed whenever the fade hadn't started yet. It failed this way on two trunk runs on 5 November. Locally, with every CPU core busy, I ran the test 50 times in each of 20 runs: 10 runs failed before this change and none after.Trade-off
The test takes about 0.2s longer per run, because the popover's slide-in has to finish before the popover counts as positioned.