Skip to content

test: bootstrap frontend Jest and strengthen view-only org inventory spec#293

Open
GitAddRemote wants to merge 1 commit into
mainfrom
feature/ISSUE-167
Open

test: bootstrap frontend Jest and strengthen view-only org inventory spec#293
GitAddRemote wants to merge 1 commit into
mainfrom
feature/ISSUE-167

Conversation

@GitAddRemote
Copy link
Copy Markdown
Owner

Summary

  • Bootstrap Jest test infrastructure for the frontend (closes test: strengthen view-only org inventory test + fix Jest Babel config for import type #167): jest.config.ts, tsconfig.jest.json, jest.setup.ts, and an import.meta.env mock so ts-jest can run Vite-based source files in JSDOM
  • Fix Inventory.editor-mode.test.tsx: wrap module mock methods in arrow fns so jest.resetAllMocks() doesn't wipe implementations; add a distinct orgExclusiveItem to the view-only test; correct getOrgInventory call-signature assertion (orgId is the first positional argument, not a field inside the params object)

Test plan

  • pnpm --filter frontend test — all Jest tests pass
  • View-only org inventory test (hides the add button for view-only org users but still shows org inventory) passes
  • No regressions in other editor-mode tests

Closes #167

- Add jest.config.ts, tsconfig.jest.json, jest.setup.ts for frontend test
  infrastructure (ts-jest, jsdom, moduleNameMapper for import.meta.env)
- Add src/__mocks__/config/api.ts to stub Vite-only VITE_API_URL construct
- Add jest/ts-jest/jest-environment-jsdom devDependencies and test script
- Fix Inventory.editor-mode.test.tsx: use wrapper fns so jest.resetAllMocks()
  doesn't wipe module-mock implementations; add orgExclusiveItem to view-only
  test and correct getOrgInventory call signature assertion (orgId is first arg,
  not inside params object)
Copilot AI review requested due to automatic review settings June 2, 2026 20:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces Jest-based unit testing infrastructure for the frontend (ts-jest + JSDOM) and strengthens the “view-only org inventory” regression test to ensure org inventory is actually fetched/rendered and that getOrgInventory is called with the correct orgId.

Changes:

  • Add frontend Jest configuration (jest.config.ts, jest.setup.ts, tsconfig.jest.json) and wire up a pnpm --filter frontend test script.
  • Add a Jest mock for the API URL module and update module mocking patterns to survive jest.resetAllMocks().
  • Strengthen Inventory.editor-mode.test.tsx view-only org inventory test with a distinct org-only item and corrected getOrgInventory call assertion.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pnpm-lock.yaml Adds Jest-related dependencies; currently reflects mixed Jest v29/v30 resolution.
frontend/package.json Adds Jest/ts-jest and a test script for the frontend package.
frontend/jest.config.ts Introduces ts-jest + jsdom Jest config and module mapping for frontend tests.
frontend/jest.setup.ts Adds Testing Library setup and per-test cleanup hooks.
frontend/tsconfig.jest.json Adds a Jest-specific TS config for CommonJS transpilation.
frontend/src/mocks/config/api.ts Provides a test-time API URL export intended to avoid Vite import.meta.env usage.
frontend/src/pages/Inventory.editor-mode.test.tsx Fixes mock reset behavior and strengthens the view-only org inventory test assertions.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread frontend/jest.config.ts
Comment on lines +16 to +19
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/$1',
'config/api': '<rootDir>/__mocks__/config/api.ts',
},
Comment thread frontend/package.json
Comment on lines +40 to +42
"jest": "^29.7.0",
"jest-environment-jsdom": "^30.4.1",
"ts-jest": "^29.4.5",
Comment thread pnpm-lock.yaml
Comment on lines 225 to +227
ts-jest:
specifier: ^29.1.4
version: 29.4.5(@babel/core@7.28.5)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.28.5))(jest-util@29.7.0)(jest@29.7.0(@types/node@20.19.25)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.19.25)(typescript@5.9.3)))(typescript@5.9.3)
version: 29.4.5(@babel/core@7.28.5)(@jest/transform@29.7.0)(@jest/types@30.4.1)(babel-jest@29.7.0(@babel/core@7.28.5))(jest-util@30.4.1)(jest@29.7.0(@types/node@20.19.25)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.19.25)(typescript@5.9.3)))(typescript@5.9.3)
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.

test: strengthen view-only org inventory test + fix Jest Babel config for import type

2 participants