Skip to content

test(web): add contribution editor coverage - #26

Merged
mcfarhat merged 1 commit into
developfrom
feat/web-test-infrastructure
Sep 2, 2026
Merged

mcfarhat merged 1 commit into
developfrom
feat/web-test-infrastructure

Conversation

@KareemN1936

Copy link
Copy Markdown
Collaborator

Summary

  • Replace the web workspace's placeholder Node test command with a Vitest + jsdom harness.
  • Add Testing Library setup for React component tests and convert the existing web env test to Vitest.
  • Add first contribution editor coverage for draft save payloads, token refresh during save, 403 preflight denial, and submit saving latest edits before proposal creation.

Trello

Verification

  • npm test --workspace=@hivelore/web
  • npm run lint --workspace=@hivelore/web
  • npm run typecheck --workspace=@hivelore/web
  • npm run build --workspace=@hivelore/web
  • npx prettier --check apps/web/package.json apps/web/vitest.config.ts apps/web/src/test/setup.ts apps/web/src/lib/env.test.ts apps/web/src/components/contributions/contribution-editor-form.test.tsx

@KareemN1936

Copy link
Copy Markdown
Collaborator Author

Implementation note for Trello card https://trello.com/c/IwdCoxpw:

This PR adds the first real web test harness and contribution editor coverage called out from the PR #20 review gap.

Covered cases:

  • draft save sends the current structured editor content;
  • a 401 during save refreshes the auth session and retries with the rotated token;
  • a 403 permission preflight hides the editor before the user writes a draft;
  • Submit Proposal saves the latest unsaved edits before creating the proposal.

Verified locally:

  • npm test --workspace=@hivelore/web
  • npm run lint --workspace=@hivelore/web
  • npm run typecheck --workspace=@hivelore/web
  • npm run build --workspace=@hivelore/web
  • focused Prettier check for touched web files

@github-actions

Copy link
Copy Markdown

Vercel preview is ready:

https://hivelore-68akx8x8i-kareemn1936s-projects.vercel.app

Commit: 2f8da59

@mcfarhat mcfarhat left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approving. This is the card I raised on 24 Aug when we agreed not to block your PR #20 over missing tests — good that you picked it up unprompted.

The harness is properly wired

Vitest + jsdom + Testing Library in apps/web, a test script, and root npm test --workspaces --if-present picks it up. I checked the thing that actually matters for a test-infrastructure PR — that it runs in CI, not just locally — by reading the real log from the Quality job on this head:

> vitest run
RUN  v4.1.11  /home/runner/work/hivelore/hivelore/apps/web
Test Files  2 passed (2)

So the suite is genuinely gated, not a script nobody invokes.

The tests have power

Coverage claims are worthless unless the tests fail when the behaviour breaks, so I mutated the component and re-ran:

mutation result
save path never retries on 401 (always rethrow) fails
retry reuses the stale token instead of the rotated one fails
403 permission preflight treated as allowed fails

That third one is the nice case — it proves the preflight test asserts on the editor actually being hidden, not just on a call count. And the token-rotation mutation is the one most test suites miss: plenty of tests would assert "retried twice" and pass even if the retry re-sent the expired token.

Nothing blocking. Merging.

@mcfarhat
mcfarhat merged commit d4bcfc1 into develop Sep 2, 2026
2 checks passed
@mcfarhat
mcfarhat deleted the feat/web-test-infrastructure branch September 2, 2026 12:45
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.

2 participants