Skip to content

[TAN-8455] Flaky E2E Fix: language_switch.cy.ts — await builder boot - #14512

Merged
Stef-Rousset merged 1 commit into
masterfrom
TAN-8455-language-switch
Aug 17, 2026
Merged

[TAN-8455] Flaky E2E Fix: language_switch.cy.ts — await builder boot#14512
Stef-Rousset merged 1 commit into
masterfrom
TAN-8455-language-switch

Conversation

@Stef-Rousset

@Stef-Rousset Stef-Rousset commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

This PR has been generated by Claude using the fix-flaky-e2e skill.

Changelog

Technical

  • Fixed the flaky language_switch.cy.ts E2E spec. It now waits for the project
    page builder to finish booting before interacting with the toolbox, restores the
    login cookie before the per-test locale reset, and saves the layout after
    deleting a widget so the live-page assertions verify something real.

Generated by Claude

Spec: front/cypress/e2e/project_description_builder/language_switch.cy.ts

Root cause

Three separate defects, all confirmed by running rather than by inspection:

  1. Test isolation vs. the beforeEach locale reset. testIsolation defaults to
    true (Cypress 15), so cookies are cleared and the page is reset to about:blank
    before every test after the first. apiUpdateCurrentUser early-returns when the
    cl2_jwt cookie is missing, so switchLocale('en') in beforeEach silently did
    nothing, cy.reload() reloaded a blank page, and setAdminLoginCookie() ran
    after the reload. The tolerant /Language \d text\./ matcher in the delete test
    was a workaround for this broken reset.

  2. The nightly flake. The first test relied on the page before() visited
    surviving into the test, reloaded it, then immediately queried
    #e2e-draggable-text. ProjectPageBuilderPage renders null until the tenant
    locales and layout query resolve, so a slow boot under CI contention blew the
    15s default timeout — matching the nightly failure exactly
    (Expected to find element: #e2e-draggable-text, but never found it).

  3. The delete test asserted nothing. It deleted a widget but never saved (the
    builder has no autosave), then asserted should('not.exist') on the live page
    immediately after a reload — passing by racing a blank page. Adding only a
    positive control, with no other change, turns it red:
    Expected not to find content: 'Language 1 text.' but continuously found it.

Why this addresses the cause rather than suppressing it

  • The builder gate is #e2e-project-page-content-builder-page, the container that
    renders only once the app's own readiness condition is met — not a sleep. The
    explicit 60s budget covers admin-bundle boot on a contended node.
  • The login cookie is restored before anything that reads it, so the locale reset
    actually happens instead of failing silently.
  • switchLocale asserts the URL locale prefix afterwards. The user's locale wins
    over the URL's in utils/locale.ts, and the app rewrites the prefix — so the
    assertion proves the switch was applied.
  • The delete is persisted and each not.exist is preceded by asserting the project
    title is visible, so absence means absence.
  • No bare cy.wait(<ms>) was added, no assertions loosened, no retries relied on.
    The two pre-existing cy.wait(1000) calls guarding the craftjs debounce are
    untouched.

Stability evidence

  • Local: 10/10 green with retries=0 (Cypress's 2 retries disabled, so these are
    first-attempt passes). The first attempt at this fix scored 2/10 and was discarded —
    a cy.intercept + cy.wait gate tripped on cy.wait's 5s request timeout.
  • CI: pipeline 346670,
    spec ×3 — 3/3 nodes green, 6/6 test records success.
  • Nightly history: 1 failure in the last 60 runs (2026-07-22), so the trend over the
    next few weeks is the real verdict.

@notion-workspace

Copy link
Copy Markdown

…diness, persist the delete

Cypress test isolation clears cookies and resets the page between tests, so
the beforeEach locale reset ran without an auth cookie and silently did
nothing, then reloaded about:blank. Restore the login cookie first and let
each test visit the page it needs instead of inheriting one from before().

Gate the builder on #e2e-project-page-content-builder-page, which only
renders once the tenant locales and the layout query have resolved, rather
than racing the toolbox selector against the admin bundle boot. This is the
condition behind the nightly failure ("Expected to find element:
#e2e-draggable-text, but never found it").

The delete test never saved, so its live-page not.exist assertions passed
against a page that had not painted yet — verified by adding a positive
control, which turns them red. Save the layout and assert the project title
is visible before checking for absence.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@Stef-Rousset
Stef-Rousset force-pushed the TAN-8455-language-switch branch from 9df592b to f1070af Compare August 11, 2026 06:54
@cl-dev-bot

Copy link
Copy Markdown
Collaborator
Messages
📖 Changelog provided 🎉
📖 Notion issue: TAN-8455
📖

Run the e2e tests

📖 Check translation progress

Generated by 🚫 dangerJS against f1070af

@Stef-Rousset
Stef-Rousset requested review from amanda-anderson and a lite review from Copilot August 11, 2026 07:55
@Stef-Rousset
Stef-Rousset removed the request for review from Copilot August 11, 2026 07:56

@amanda-anderson amanda-anderson left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code LGTM!

@Stef-Rousset
Stef-Rousset merged commit bca4c55 into master Aug 17, 2026
21 checks passed
@Stef-Rousset
Stef-Rousset deleted the TAN-8455-language-switch branch August 17, 2026 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants