-
Notifications
You must be signed in to change notification settings - Fork 62
Add component tests for CopyButton clipboard states and analytics #262
Copy link
Copy link
Open
Labels
TypeScriptTypeScript codeTypeScript codeenhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomersgssoc:approvedApproved for GSSoC contributionApproved for GSSoC contributionlevel:beginnerSmall, well-scoped work suitable for newer contributors.Small, well-scoped work suitable for newer contributors.type:accessibilityAccessibility, keyboard, screen-reader, or inclusive UX work.Accessibility, keyboard, screen-reader, or inclusive UX work.type:testingTests, coverage, fixtures, or validation-only work.Tests, coverage, fixtures, or validation-only work.
Description
Metadata
Metadata
Assignees
Labels
TypeScriptTypeScript codeTypeScript codeenhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomersgssoc:approvedApproved for GSSoC contributionApproved for GSSoC contributionlevel:beginnerSmall, well-scoped work suitable for newer contributors.Small, well-scoped work suitable for newer contributors.type:accessibilityAccessibility, keyboard, screen-reader, or inclusive UX work.Accessibility, keyboard, screen-reader, or inclusive UX work.type:testingTests, coverage, fixtures, or validation-only work.Tests, coverage, fixtures, or validation-only work.
Summary
The shared copy button is used across the web UI for copyable values and code snippets. It handles clipboard access, temporary success feedback, optional analytics, accessible labels, repeated clicks, and cleanup on unmount, but it has no direct component tests.
Current behavior
On a successful clipboard write, the button changes from its normal label to a copied label for 1.6 seconds and optionally records an analytics event. Clipboard failures are intentionally silent. A pending reset timer is cleared on repeated clicks and when the component unmounts.
Desired behavior
Add focused component tests for the existing behavior using the web test DOM setup, a mocked clipboard, deterministic timers, and a mocked analytics sink. Do not change the visual design or runtime behavior.
Key interfaces
CopyButtonprops — value, visible labels, accessible label override, CSS class, analytics event, and analytics properties.writeText()— success and rejection paths.Acceptance criteria
cd web && bun run test:unit && bun run typecheckpasses.Out of scope
Blocked by
None — can start immediately.