Chore(UI): Fix the CustomizeWidget CustomizeLandingPage tests - #31551
Conversation
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
✅ Playwright Results — workflow succeededValidated commit ✅ 657 passed · ❌ 0 failed · 🟡 2 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky PerformanceBlocking targets: ✅ met · Optimization targets: 🟡 in progress Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting. 🕒 Full workflow signal wall (to summary) 37m 39s ⏱️ Max setup 3m 9s · max shard execution 19m 38s · max shard-job elapsed before upload 23m 5s · reporting 6s 🌐 220.96 requests/attempt · 2.90 app boots/UI scenario · 11.71% common-shard skew Optimization targets still in progress:
🟡 2 flaky test(s) (passed on retry)
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
🚦 Removed from the merge queue —
|
DataInsight.spec.ts called waitForLandingPageWidget(page, 'kpi-widget'),
but kpi-widget is a child div of the widget - KPIWidget renders
KnowledgePanel.KPI on its WidgetWrapper and that is the key its
DeferredWidget slot is named after.
That worked only by accident: the old helper's loop blind-scrolled the
landing page on every iteration whether or not the key resolved, which
mounted the deferred widget and made the inner testid appear. The
rewritten helper only scrolls a locator it can resolve, so the inner
testid now reveals nothing and the widget never mounts - the spec failed
in playwright-ci-postgresql (chromium-01) with "getByTestId('kpi-widget')
element(s) not found".
Pass the layout key and assert the inner testid against the returned
locator, which also proves the widget's content rendered rather than just
locating a div. Document the contract on waitForLandingPageWidget so the
next caller does not repeat it. Audited every call site: this was the only
one passing an inner testid.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Code Review ✅ Approved 1 resolved / 1 findingsRefactors landing page widget test utilities and isolation to fix flaky E2E tests for CustomizeWidget and CustomizeLandingPage. The revealLandingPageWidget scroll error handling finding was successfully addressed. ✅ 1 resolved✅ Edge Case: revealLandingPageWidget scroll no longer swallows errors
OptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
This pull request refactors the landing page widget test utilities in
customizeLandingPage.tsto improve reliability and clarity when interacting with deferred (lazy-loaded) widgets. The main changes focus on robustly revealing, asserting, and verifying the presence or absence of widgets that may not be immediately present in the DOM due to deferred rendering.Improvements to widget detection and interaction:
getLandingPageWidgetSlotto accurately locate widget slots by matching both exact and suffixed layout keys, handling cases where widgets are added dynamically and may have unique IDs.revealLandingPageWidgetto ensure that widgets are scrolled into view only if their slot or widget DOM node is present, preventing unnecessary or stalled scroll actions.Simplification and reliability of widget visibility checks:
isLandingPageWidgetVisibleto userevealLandingPageWidgetand a direct visibility assertion, removing manual scrolling and polling logic for more reliable checks.waitForLandingPageWidgetto always reveal the widget before asserting its visibility and waiting for any skeleton loaders to disappear, ensuring that loading is complete before proceeding.Correctness of widget removal assertions:
removeAndVerifyWidgetto assert on the absence of the deferred slot rather than the widget itself, ensuring that the test correctly distinguishes between a widget being removed and merely being out of view (deferred).Test flow improvements:
addAndVerifyWidgetto rely onwaitForLandingPageWidgetfor web-first assertions, removing redundant polling and making the flow more straightforward and reliable.