Skip to content

test: add RTL smoke test for dashboard shell - #1138

Open
Emelie-Dev wants to merge 1 commit into
Stellopay:mainfrom
Emelie-Dev:fix/issue-821-rtl-smoke-test
Open

test: add RTL smoke test for dashboard shell#1138
Emelie-Dev wants to merge 1 commit into
Stellopay:mainfrom
Emelie-Dev:fix/issue-821-rtl-smoke-test

Conversation

@Emelie-Dev

Copy link
Copy Markdown
Contributor

test: add RTL smoke test for dashboard shell

Adds a Playwright spec that renders the dashboard with dir="rtl" forced
on <html> and asserts the two failure modes that historically sink RTL
rollouts — horizontal overflow and silently clipped text — plus an
axe-core WCAG 2.1 AA pass and screenshot artifacts for PR review.

Why

No automated test currently renders any route with dir="rtl", so
regressions in RTL readiness (unintended horizontal scrollbars,
right-edge badges clipped into the sidebar, card labels truncated by
hard-coded widths tuned for English) would only be caught manually, if
at all, ahead of eventual Arabic / Hebrew / Persian locale support.

What

  • tests/rtl-dashboard-smoke.spec.ts — one test.describe per
    Tailwind breakpoint (sm/md/lg/xl) running the same 4 checks:

    1. dir="rtl" attribute survives hydration (sanity guard on the
      addInitScript injection)
    2. Horizontal overflow scan — every rendered element whose
      scrollWidth > clientWidth + 1px fails the test. Containers with
      overflow-x: auto | scroll are exempt (overflow is desired there).
    3. Clipped-text scan — any overflow: hidden ancestor with
      non-trivial text content that outgrows its box is flagged, unless
      the author explicitly opted in with text-overflow: ellipsis.
    4. axe-core (WCAG 2.1 A/AA + best-practice) using the same
      color-contrast allowlist as dashboard.spec.ts.
  • Screenshot artefacts per breakpoint:

    • On failure (overflow or clip) → full-page PNG attached so the
      exact offending render is in CI artefacts, no local repro needed.
    • On success → viewport PNG attached so PR reviewers get a visual
      RTL render side-by-side with the existing LTR dashboard snapshots.

Design decisions

  • Smoke test, not a visual regression baseline. This spec does
    not call toHaveScreenshot with a committed PNG baseline. That
    belongs in a dedicated RTL visual-regression pass once RTL copy is
    actually plugged in. Instead we codify the two structural failure
    modes that are language-agnostic and catch 80 % of the damage with
    zero ongoing baseline maintenance.
  • addInitScript, not a route.fulfill rewrite. Mirrors the
    pattern used by dark-mode-screenshots.spec.ts for localStorage
    theme injection — guaranteed to run before Next.js hydrates, so no
    LTR→RTL first-paint flash.
  • 1 px tolerance. Flex layouts on high-DPI canvases routinely
    produce fractional clientWidth values that round to a pixel-wide
    scroll overflow. Tolerance absorbs that without hiding real
    regressions (anything ≥ 2 px is always flagged).
  • Non-rendered tag allowlist + position: fixed aware visibility
    check.
    Naïve offsetParent === null guards incorrectly exclude
    fixed-position elements (which do paint and do cause overflow). We
    combine getBoundingClientRect() zero-box check with the offsetParent
    guard so fixed elements are scanned while truly-hidden nodes are
    skipped.
  • text-overflow: ellipsis exemption. If a container uses
    ellipsis, clipping is the intended behaviour — failing the test for
    it would force authors to either widen every box or drop ellipsis,
    neither of which is desirable.

Running

Artifacts

Failure screenshots land under the standard Playwright
test-results/ directory and are retained by the CI workflow as
artefacts on any red build.

closes #821

Forces dir="rtl" on <html> via addInitScript and exercises /dashboard
at four Tailwind breakpoints (sm/md/lg/xl). Catches the two regression
classes that historically sink RTL rollouts:

  - horizontal overflow: every element whose scrollWidth exceeds its
    clientWidth (minus a 1 px tolerance for sub-pixel rounding),
    excluding intentionally-scrollable containers.
  - clipped text: any overflow:hidden ancestor with textual content
    that does not fit the content box, unless text-overflow:ellipsis
    was explicitly opted in.

On failure each check attaches a full-page PNG as a Playwright
artifact so the exact RTL render is available for triage without
reproducing the viewport locally. On success a viewport PNG is still
attached to give PR reviewers a side-by-side RTL render.

axe-core runs against the same settled DOM (WCAG 2.1 A/AA +
best-practice) with the dashboard's existing triaged color-contrast
issue allowlisted, so RTL-specific a11y regressions surface here
instead of in a later manual pass.

Fixes Stellopay#821.
@vercel

vercel Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

@Emelie-Dev is attempting to deploy a commit to the Jagadeesh B's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

Add a dir="rtl" Playwright smoke test rendering the dashboard shell without clipped content

1 participant