Skip to content

Add feature tests and Run Tests wiring - #4

Open
pradeep-problemsetters wants to merge 7 commits into
mainfrom
feat/feature-tests
Open

pradeep-problemsetters wants to merge 7 commits into
mainfrom
feat/feature-tests

Conversation

@pradeep-problemsetters

@pradeep-problemsetters pradeep-problemsetters commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Adds feature tests to the starter: 39 backend tests (pytest against a real MongoDB) and 23 frontend tests (Vitest + Testing Library). The Node and Spring Boot starters get the same scenarios in their own PRs, so the three stay in step.
  • Backend covers every API route and the rules behind it: sign-in and profiles (including a token that stops working once access is revoked), calendars, events and guests, repeats, invite answers, search, availability, daily insights and the input rules. Frontend covers sign-in, profile switch, week and month view, the mini calendar, the event editor and preview, the calendar sidebar, quick and advanced search, find a time, Meet with and the time insights drawer.
  • bun run test runs both suites and merges their reports into one output/junit.xml with junit-report-merger (pinned to 9.0.4). That's the only scored file. pytest (pytest.ini) and Vitest always write their report into .cache/junit/, so the script is the same short line on all three stacks. Adds pytest and pytest-timeout (pinned) to requirements.txt.
  • hackerrank.yml gets the scoring block, the test command, ports_settings and read-only paths for the tests and test config. hackerrank.yml itself is not read-only.
  • conftest.py points the tests at their own database, <db>_test, before Django starts. It's dropped at the start of each run and emptied before every test, so the seeded demo data is never touched.
  • The scoring command runs the tests even when seeding fails (setup.sh --seed; bun run test). Before, a broken seed stopped it and no report was written at all.
  • vite.config.js: host: true and allowedHosts: true, so the preview loads on HackerRank's public preview host.

Verification

  • Planted one bug at a time for 19 backend rules and 10 frontend flows. Each one failed its own test and nothing else.
  • bun run test on Linux: 39 + 23 passing, and output/ holds only junit.xml with all 62 testcases. Stable over repeated runs.
  • A planted backend bug exits 1 and shows up as a failing testcase in junit.xml. A leftover collection in the test database is gone after the next run.
  • Every one of the 22 API routes is hit by at least one backend test. Backend coverage per feature is 93-98% (auth, availability, calendars, events, insights, people), about 90% overall. Frontend is about 66% of statements: every main flow has a test, and what's left is mostly secondary UI such as the theme switch, the date and time pickers in the editor, and empty or error states.
  • Unpublished HRW draft (2872009), re-uploaded with the latest commit: validation passes with 62/62 read from output/junit.xml, and the zip HRW stores matches the local git archive file for file.
  • Ran the project checks from Add standalone Django and React project checks #3 on a fresh clone: the existing starter lint findings still fail (empty block in App.jsx:268, Ruff E402 in backend/scripts/seed.py), same as on main. Nothing in the new test files is flagged.

Notes

  • Kept the test setup simple on purpose, since candidates use this as a reference. Two things it doesn't handle: two test runs at the same time in one workspace share the test database, and a test that ends the process with os._exit(0) leaves the backend out of junit.xml while the run still exits 0 (HRW then scores those testcases as missing). Both can be hardened when a submission is converted to PBR.
  • The "no existing XML reports" check scans the working tree, so it fails as soon as someone runs the tests locally, because of the gitignored output/junit.xml and .cache/junit/. It should only look at tracked files (git ls-files).
  • If the Node and Django starters run against the same local MongoDB, they share calendar_db and the Django seed fails with an index name clash. Setting MONGODB_URI in backend/.env to its own database avoids it. It doesn't happen on HackerRank, where each workspace has its own MongoDB.

- Backend tests (pytest, 32): sign-in and profiles, calendars, events, invitation responses, search, availability, insights and repeating events
- Frontend tests (Vitest, 13): sign-in, week view, event editor and preview, calendars, search, find a time and insights
- scripts/run-tests.cjs from the base template: one Run Tests at a time, results written to output/backend.xml and output/frontend.xml
- Each test run uses its own database and drops it at the end, so the app's data is never touched
- hackerrank.yml: scoring, test command, ports_settings and read-only test paths
- vite.config.js: host and allowedHosts set to true, as the HackerRank config expects
A failed seed stopped the scoring command before bun run test, so neither report was written and the run scored nothing. The tests use their own database and do not need the seed, so the scoring command now runs them either way, like the Node base template does.
…lendar menu

Four features had no UI test: answering an invitation from the event preview, choosing a repeat in the event editor, switching profile from the header, and Display this only in a calendar menu. One test each, so every feature now has a frontend test as well as backend tests.
A coverage run showed the same gaps on every stack. Backend: editing an event's guests and repeat rule, search with places and dates, yearly and every-N repeats, bad guest ids, the input rules, past and partly overlapping availability, and tokens for an account that lost its profile or was switched off. Frontend: editing an existing event, month view, and booking through Meet with. One test each, so the suite is now 39 backend and 20 frontend tests.
… runner

Review changes: bun run test now runs the backend and frontend suites from package.json and merges their reports into a single output/junit.xml with junit-report-merger (pinned), which is the only scored file. scripts/run-tests.cjs and its scoring-run database mode are gone; every test run uses its own database. hackerrank.yml is no longer read-only. The run fails if either suite fails or ends without writing results.
conftest.py points the tests at one database, <app db>_test, dropped at the start of each run and emptied before every test, instead of a database per run with a sweep for runs that were killed. pytest.ini sets the report path. bun run test is now the same short script on every stack: it runs both suites and merges their reports into output/junit.xml. Each reporter always writes into .cache/junit, so no env vars are needed.
…ini calendar

Advanced search sends the place, excluded words and an inclusive date range, and blocks a range that ends before it starts. The insights drawer shows the breakdown by type and by calendar with the remaining time, and Schedule focus time opens a focus-time item. The mini calendar moves the week view to a date picked in another month. Each new test caught two planted app bugs and nothing else failed. The frontend suite is now 23 tests.
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.

1 participant