Skip to content

Add tests for the new-pair page same-asset rejection and submit-error rendering #142

Description

@mikewheeleer

Add tests for the new-pair page same-asset rejection and submit-error rendering

Description

src/app/pairs/new/page.tsx guards against source === destination, posts to /api/v1/pairs, redirects to /pairs on success, and surfaces backend errors via role="alert" — but there is no test file for it. This issue adds focused coverage for that form.

Requirements and context

  • Repository scope: StableRoute-Org/Stableroute-frontend only.
  • Cover: the same-asset client guard blocks submit and shows the inline error without calling apiPost; a successful post calls router.push("/pairs"); a rejected post renders the backend message in the alert; the submit button shows its in-flight "Saving…" label while pending.
  • Mock apiPost from @/lib/apiClient and useRouter from next/navigation.

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b test/pairs-new-page-validation
  • Implement changes
    • Write comprehensive tests in: src/app/pairs/new/page.test.tsx — guard, success redirect, error alert, and pending label states.
    • Write code in: no production change expected; if a testability seam is required, keep it minimal and documented in src/app/pairs/new/page.tsx.
    • Add documentation: note the covered flow in README.md testing section.
    • Validate accessibility: assert the error is announced via role="alert".
  • Test and commit

Test and commit

  • Run npm run lint, npm test, and npm run build.

Example commit message

test: cover new-pair same-asset guard and submit-error rendering

Guidelines

  • Minimum 95 percent test coverage for impacted modules.
  • Clear, reviewer-focused documentation.
  • Timeframe: 96 hours.

Community & contribution rewards

  • 💬 Join the StableRoute community on Discord for questions, reviews, and faster merges: https://discord.gg/37aCpusvx
  • ⭐ This is a GrantFox OSS / Official Campaign task and may be rewarded. When your PR is merged you'll be prompted to rate the project — if this issue and the maintainers helped you ship, we'd be grateful for a 5-star rating. Clear questions in Discord and tidy, well-tested PRs are the fastest path to a merge and a reward.

Metadata

Metadata

Assignees

No one assigned

    Fields

    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions