Skip to content

test: cover public problem page behavior - #55

Merged
AlwaysAcing123 merged 2 commits into
codearena-oss:mainfrom
adityamukesh:test/problem-page-14
Oct 30, 2026
Merged

AlwaysAcing123 merged 2 commits into
codearena-oss:mainfrom
adityamukesh:test/problem-page-14

Conversation

@adityamukesh

@adityamukesh adityamukesh commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds 17 Jest/React Testing Library tests for frontend/pages/problems/[slug].js, exercising the real page and ProblemDescription:

  • Public details, examples, constraints, navigation and empty/missing optional sections.
  • Accepted-solution loading/display, missing or empty solutions, non-OK responses, success: false, and rejected fetches.
  • Sign-out clearing and deferred responses after logout or a problem change.
  • Direct getStaticProps coverage: 404 without retries, three failed attempts, recovery after a 5xx, revalidation values, and exclusion of testCases/starterCode for both response formats.

Uses mocked authentication/API boundaries, deferred promises and fake timers. Only the test file changes; no production code, setup, dependency or configuration changes.

Contributes to #14 without closing it. This follows the confirmed summary-page scope and requested follow-up. Run/Submit, testcase tabs, execution feedback and explicit timeout UI belong to the separate practice surface and are outside this PR.

Validation

Run locally with Node 22.23.3:

  • cd frontend && npm test -- --runInBand: 25 suites, 183 tests passed.
  • cd frontend && npm run lint: 0 errors, 4 existing warnings, all in unchanged files.
  • cd frontend && NEXT_PUBLIC_BACKEND_URL=http://127.0.0.1:3001 npm run build: passed (workspace-root and Edge Runtime deprecation warnings).
  • cd backend && npm test -- --runInBand --silent: 92 suites, 1,509 tests passed, with the CI test environment and local-port access.
  • cd backend && npm run validate:problems: 45/45 valid.
  • node scripts/check-boundary.js and git diff --check: passed.
  • After restoring all mutations, the focused suite passed again: 17/17.

Regression evidence

Each of these 15 temporary changes caused relevant tests to fail; each was restored and none is committed:

  • Remove the description; break the practice destination; show an empty Examples heading.
  • Hide accepted solutions; show a panel for empty code; accept unsuccessful payloads; ignore HTTP failure; leave request rejection unhandled.
  • Stop clearing on logout; remove the stale-response guard (both logout and problem-change tests fail).
  • Retry 404s; shorten the retry budget; stop recovery after a transient error; return execution-only fields in public props; change successful revalidation.

Limits and assistance

GitHub CI and Vercel deployment authorization are separate from these local results. Browser E2E/manual application testing was not performed locally; this PR changes no UI or production behavior. Implemented and validated with OpenAI Codex assistance; no human review is claimed.

@vercel

vercel Bot commented Oct 13, 2026

Copy link
Copy Markdown

@adityamukesh is attempting to deploy a commit to the Sennai's projects Team on Vercel.

A member of the Team first needs to authorize it.

@AlwaysAcing123

Copy link
Copy Markdown
Collaborator

Thanks @adityamukesh! This is a very useful first draft, and your scope clarification is correct.

Scope confirmed: problems/[slug].js is the public summary page. The editor, Run/Submit controls, and execution results live in components/practice/ArenaPractice.js. Please keep this PR focused on the summary page; it contributes to #14 without closing the broader issue.

The tests exercise the real page and ProblemDescription, check what players see, and use a deferred promise to verify loading behavior without arbitrary sleeps.

I checked 329ad79:

  • All 3 new tests pass.
  • The full frontend suite passes: 25 suites, 169 tests.
  • Lint passes with 0 errors and 4 existing warnings.
  • The publication-boundary check passes.

I also temporarily broke 12 behaviors and restored each change afterward. Your tests caught the incorrect solution-request URL, missing example explanation, missing Constraints heading, and missing solution language. They didn’t catch the error, race, or static-props regressions, which matches the remaining work you’ve already noted.

For the next push, please add:

  1. Solution-request failures: non-OK HTTP responses, success: false, and rejected fetches. The public problem should remain readable, no accepted solution should appear, and rejected requests should be handled.

  2. Stale responses: start a deferred request, rerender after logout or a problem change, then resolve the old request. Verify that the old solution doesn’t appear. A check after unmount alone won’t reliably detect removal of the stale-response guard.

  3. getStaticProps coverage: import and call it directly with mocked fetch.

    • A 404 returns { notFound: true } without retries.
    • Repeated 5xx responses exhaust the retries and return { notFound: true, revalidate: 30 }.
    • A 5xx followed by success retries and returns the problem with revalidate: 3600.
    • Returned problem props exclude testCases and starterCode.

    Use fake timers for retry delays so these tests stay deterministic.

Before marking the PR ready for review, please add your own temporary-break-and-restore evidence and the complete results of cd frontend && npm test && npm run lint to the description.

Keep it up! Thanks for being a valued contributor of Codearena. Please let me know if you'd like any guidance/assistance.

@adityamukesh

adityamukesh commented Oct 14, 2026 via email

Copy link
Copy Markdown
Contributor Author

@adityamukesh
adityamukesh marked this pull request as ready for review October 14, 2026 03:51
@adityamukesh

adityamukesh commented Oct 14, 2026 via email

Copy link
Copy Markdown
Contributor Author

@AlwaysAcing123

Copy link
Copy Markdown
Collaborator

Thanks for adding these tests, and for your patience while this was waiting on review. The checks are passing. Approved!

@AlwaysAcing123
AlwaysAcing123 merged commit cd28980 into codearena-oss:main Oct 30, 2026
4 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

Development

Successfully merging this pull request may close these issues.

2 participants