Skip to content

test(onboarding): render-based ACCanvas tests for empty-state gating #111

@jacuzzicoding

Description

@jacuzzicoding

Context

PR #110 (closes #107) shipped a uiStore.test.ts test that verifies the canvas empty-state gate by evaluating the boolean expression directly — without ever mounting ACCanvas or asserting on the actual DOM. Copilot flagged this on review, and the concern is well-founded.

During testing on PR #110 a real bug shipped briefly: the conditional logic was accidentally inverted, causing the populated home view to render behind the TownManager drawer instead of being suppressed. A locally-evaluated boolean test has no way to catch that class of regression — it only checks whether the expression evaluates correctly, not whether the component renders correctly based on it.

What to add

A small render test suite for ACCanvas that:

  1. Mocks useAppStore, useUIStore, and useMuseumData (all have straightforward interfaces).
  2. Exercises the four meaningful permutations of (noTowns, townManagerOpen):
    • No towns + TownManager open → canvas renders nothing (null / empty subtree)
    • No towns + TownManager closed → empty-state UI
    • Towns present + TownManager open → FullView still renders (drawer is an overlay, not a suppressor)
    • Towns present + TownManager closed → FullView renders
  3. Asserts on the actual rendered DOM output (presence/absence of key elements) rather than on a re-evaluated boolean.

If the gating logic gets more complex over time, consider extracting it into a named helper (shouldSuppressCanvas or similar) so both the component and the test share the same source of truth and a logic change is impossible to miss.

Why this matters

The inverted-logic bug described above would have been caught by step 2 of the test above the moment the conditional changed. The current boolean-only test would have continued to pass. Render tests are the right tool here.

Target

Planned for v0.9.4-beta (hardening / test coverage pass).

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions