Problem
src/components/AddressDisplay.tsx has three distinct testable behaviors with zero coverage: the address is truncated by default using truncateAddress() from src/lib/utils.ts, the copy button calls navigator.clipboard.writeText, and the button aria-label changes to "Copied!" after a successful copy.
The known bug where the copy operation silently fails in non-HTTPS contexts also has no regression test. Without a test that mocks a rejected clipboard promise, any fix to the fallback behavior can be reverted without detection. A third untested behavior: the 2-second reset timeout that changes the aria-label back from "Copied!" to the default — if the timeout is accidentally removed, the label stays "Copied!" forever.
Solution
Write React Testing Library + @testing-library/user-event tests for AddressDisplay. Mock navigator.clipboard using vi.stubGlobal. Test:
- Truncated address is displayed by default (not the full 56-char Stellar address)
- Clicking the copy button calls
navigator.clipboard.writeText with the full address
- The copy button
aria-label changes to "Copied!" immediately after click
- The
aria-label resets back after 2 seconds (use vi.useFakeTimers)
- When
clipboard.writeText rejects, the fallback document.execCommand is attempted
- No error is thrown when clipboard is unavailable
Acceptance Criteria
Note for Contributors: If you're assigned to this issue, write a clear and detailed description for your pull request. Explain what was changed, why it was needed, how it was implemented, and include any relevant testing or screenshots where applicable.
Problem
src/components/AddressDisplay.tsxhas three distinct testable behaviors with zero coverage: the address is truncated by default usingtruncateAddress()fromsrc/lib/utils.ts, the copy button callsnavigator.clipboard.writeText, and the buttonaria-labelchanges to "Copied!" after a successful copy.The known bug where the copy operation silently fails in non-HTTPS contexts also has no regression test. Without a test that mocks a rejected clipboard promise, any fix to the fallback behavior can be reverted without detection. A third untested behavior: the 2-second reset timeout that changes the aria-label back from "Copied!" to the default — if the timeout is accidentally removed, the label stays "Copied!" forever.
Solution
Write React Testing Library +
@testing-library/user-eventtests forAddressDisplay. Mocknavigator.clipboardusingvi.stubGlobal. Test:navigator.clipboard.writeTextwith the full addressaria-labelchanges to "Copied!" immediately after clickaria-labelresets back after 2 seconds (usevi.useFakeTimers)clipboard.writeTextrejects, the fallbackdocument.execCommandis attemptedAcceptance Criteria
aria-labelupdates to "Copied!" immediately after successful copyaria-labelresets after 2 seconds using fake timersexecCommandfallback pathnpm test