Skip to content

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

@GitAddRemote

Description

@GitAddRemote

User Story

As a developer maintaining the inventory permission tests,
I want the test runner to correctly parse TypeScript `import type` syntax and have meaningful assertions for the view-only org inventory path,
So that CI catches regressions in the org inventory permission gating.

Definition of Done

  • All acceptance criteria met and verified
  • `Inventory.editor-mode.test.tsx` runs without Babel parse errors
  • View-only org inventory test asserts `getOrgInventory` was called and a distinct org inventory item is rendered

Acceptance Criteria

  • Jest/Babel config supports `import type` syntax
  • The `hides the add button for view-only org users but still shows org inventory` test uses a distinct mocked org inventory item and asserts `mockGetOrgInventory` was called with the correct `orgId`
  • No unrelated tests broken by config change

Technical Elaboration

Two issues surfaced during ISSUE-163 / PR #166 review:

1. Babel config: The frontend Jest suite uses Babel but does not handle `import type`. Adding `import type { LocationRecord }` to the test file caused a parse error: `Unexpected token, expected "from"`. Fix by adding the appropriate Babel plugin or switching this suite to ts-jest.

2. Weak assertion: The test for view-only users (`can_view_org_inventory` only) currently asserts `screen.getByText('Test Org')` after selecting the org — but that text was already in the dropdown before selection, so it doesn't prove `getOrgInventory` ran. The test should:

  • Mock `getOrgInventory` to return a distinct item (e.g. `'Org Exclusive Item'`)
  • Assert that item appears after org selection
  • Assert `mockGetOrgInventory` was called with `orgId: 42`

Design Elaboration

Low-priority follow-up to ISSUE-163. No UX or security impact — purely test infrastructure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfrontendFrontend app and dashboardinventoryInventory system features

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions