Skip to content

test(functionalities): fix copy-page button test hydration race#471

Open
g-despot wants to merge 1 commit into
mainfrom
docs/fix-copy-page-clipboard-test
Open

test(functionalities): fix copy-page button test hydration race#471
g-despot wants to merge 1 commit into
mainfrom
docs/fix-copy-page-clipboard-test

Conversation

@g-despot

Copy link
Copy Markdown
Contributor

The nightly Docs Functionalities Tests suite has been red (both test_copy_page_button_writes_markdown params: /weaviate/quickstart, /weaviate/search/bm25) since at least Jul 5 — the "Copy page" button never showed "Copied!" within the timeout.

Root cause: a hydration race in the test — not a feature bug, not clipboard

The button is server-rendered, so Playwright reports it "visible" before React hydrates and attaches its onClick. A click landing in that gap is silently dropped, so the label stays on "Copy page" and never reports success. The fixture already grants clipboard-read/clipboard-write, and a direct Clipboard API round-trip works in the test context — clipboard was a red herring. It fails deterministically (not flaky) because heavier pages and slower headless CI runners lose the race every time. The copy-page feature itself (from #460) is deployed and works.

Fix (test-only)

After the button is visible, wait for the page JS to finish loading (wait_for_load_state("networkidle"), non-fatal so a chatty live page can't hang the test), then retry the click a few times until the aria-live span reports "Copied!". No site source changed.

Verification

uv run pytest -m functionalities against live docs.weaviate.io:

  • test_copy_page_button_writes_markdown[/weaviate/quickstart] — PASSED
  • test_copy_page_button_writes_markdown[/weaviate/search/bm25] — PASSED

Stable across repeated runs (verified independently). All downstream assertions (markdown length, Source: prefix, fenced code block, no page chrome) still pass.

The copy-page button is server-rendered, so Playwright clicked it before React hydrated and attached onClick — the click was dropped and the label never reached 'Copied!', failing the nightly suite deterministically on slower CI. Clipboard permissions were already granted (not the cause). Wait for networkidle (hydration) then retry the click. Test-only; the feature works.

@orca-security-eu orca-security-eu Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Infrastructure as Code high 0   medium 0   low 0   info 0 View in Orca
Passed Passed SAST high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Vulnerabilities high 0   medium 0   low 0   info 0 View in Orca

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.

1 participant