Skip to content

Conversation

ludvigz
Copy link
Member

@ludvigz ludvigz commented Nov 13, 2026

Purpose

Core functionality (compatibility checks, build persistence, GraphQL resolvers and build publishing) had little or no automated test coverage, which made regressions hard to catch. This PR adds tests for the most important parts, prioritising compatibility checks and backend validation.

Changes

  • Add checkCompatability.test.ts: compatible and incompatible combinations for CPU/motherboard, RAM, case, GPU, PSU, cooler and storage, plus missing, negative and non-numeric data staying "unknown", an empty build, and several parts in one category.
  • Add BuildProvider.test.tsx: loading saved builds, handling of invalid or corrupted localStorage data (broken JSON, empty values, null, non-object JSON, the browser refusing to read or save), and adding, replacing, removing and clearing parts.
  • Fix a bug found by those tests: BuildProvider accepted valid JSON that was not an object (for example a string or array) as the saved build. It now only accepts a plain object.
  • Add publishBuild.test.ts: valid publishing (trimming, length limits, parts stored in the right columns, user input kept out of the SQL) and ten kinds of invalid requests, each verified to save nothing.
  • Add catalogResolvers.test.ts: the parts resolver (pagination cursors, page-size limits, filters, sorting, attribute filters), part, manufacturers, builds, and the Part/Build field resolvers.
  • The backend tests mock the database and config.js (the config loads dotenv and needs DATABASE_URL, which tests do not have).
  • Document the backend test command (npm test in backend/server) in the README.

Related issues

Closes #92

Verification

Automated checks:

  • backend/server: npm test passes all 76 tests (46 new in this PR).
  • frontend: npm test passes all 81 tests (50 new).

Screenshots

Not applicable

Checklist

  • I have reviewed my own changes.
  • The changes meet the linked issue's acceptance criteria, where applicable.
  • I have verified the changes and recorded the results above.
  • I have added or updated tests where needed.
  • I have updated documentation where needed.
  • I have included screenshots for visual changes, or marked them not applicable.

@ludvigz ludvigz self-assigned this Nov 13, 2026
@ludvigz ludvigz requested a review from a team as a code owner November 13, 2026 18:24
@ludvigz ludvigz linked an issue Nov 13, 2026 that may be closed by this pull request
6 tasks
Copy link
Member

@oscarog oscarog left a comment

Choose a reason for hiding this comment

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

Nice work!

@oscarog oscarog merged commit c052cf0 into dev Nov 13, 2026
@oscarog oscarog deleted the 92-add-automated-tests-for-critical-functionality branch November 13, 2026 22:10
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add automated tests for critical functionality
2 participants