Skip to content

test: cover the shared CopyButton and its gate-code use on My tickets (#242 already implemented) - #347

Merged
presidojay1 merged 2 commits into
StellarTickets:mainfrom
floraispretty:test/242-copy-button
Oct 16, 2026
Merged

presidojay1 merged 2 commits into
StellarTickets:mainfrom
floraispretty:test/242-copy-button

Conversation

@floraispretty

@floraispretty floraispretty commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

| New src/components/copy-button.tsx | ✅ exists |
| Copies text with one click | ✅ copyToClipboard() (Clipboard API, with a textarea + execCommand fallback in src/lib/clipboard.ts) |
| Announces "Copied" through a live region | ✅ <span aria-live="polite" role="status"> shows Copied / Copy failed, cleared after 2s |
| Done when: used on My tickets for the gate code | ✅ src/app/my-tickets/page.tsx:52: <CopyButton value={secret} label="Copy gate code" /> (also used for the wallet address in wallet-connect-button.tsx) |

What was missing: no tests at all for CopyButton, so none of that behaviour (including the live-region announcement that's the point of the issue) was protected against regressions. This PR adds that coverage, so the issue can be closed with evidence instead of by inspection.

No production code changes. I also checked keyboard focus visibility. The icon button has no custom focus style, but Tailwind v4's base styles keep the browser's default focus ring and there's no global outline: none, so it already shows a ring on keyboard focus. I left that alone.

What changed

Commit 1: test(copy-button), new src/components/copy-button.test.tsx

Renders the real component (React createRoot + act in jsdom; copyToClipboard mocked, fake timers):

  • It's a type="button" with the given accessible name (aria-label="Copy gate code"), and the role="status" / aria-live="polite" region is empty at rest, so nothing is announced on page load.
  • One click calls copyToClipboard with the exact value and the live region reads Copied.
  • When the clipboard is unavailable (copyToClipboard → false) it reads Copy failed.
  • The announcement clears after 2 seconds.

Commit 2: test(my-tickets), new src/app/my-tickets/gate-code-copy.test.ts

Pins the issue's "done when": My tickets imports CopyButton and renders <CopyButton value={secret} label="Copy gate code" /> for the gate code, so a refactor can't silently drop the copy control.

Testing

npx vitest run src/components/copy-button.test.tsx src/app/my-tickets/gate-code-copy.test.ts
 Test Files  2 passed (2)
      Tests  5 passed (5)
  • npx eslint on both test files: clean.
  • npx tsc --noEmit: no errors in the new files. The only errors are the 4 TS18046 errors in src/lib/api-timeout.test.ts, which this PR doesn't touch.

Closes #242
Closes #243
Closes #244
Closes #245

CopyButton (added in 16b8bcf) had no tests. Cover the labelled
type=button, the empty polite live region at rest, copying the value
and announcing 'Copied', 'Copy failed' when the clipboard is unavailable,
and clearing the announcement after 2s.

Refs StellarTickets#242
Pins the StellarTickets#242 'done when' condition so a refactor of My tickets can't
silently drop the copy control.

Closes StellarTickets#242
@drips-wave

drips-wave Bot commented Oct 16, 2026

Copy link
Copy Markdown

@floraispretty Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@netlify

netlify Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

❌ Deploy Preview for stellartickets failed.

Name Link
🔨 Latest commit deb4f79
🔍 Latest deploy log https://app.netlify.com/projects/stellartickets/deploys/6ad2b01afa8a0c61a971be70

@presidojay1
presidojay1 merged commit c103801 into StellarTickets:main Oct 16, 2026
0 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants