Skip to content

test(canvas): cover canvas-actions restart-pending helpers (25% → 100%) (#1815) - #2149

Merged
HongmingWang-Rabbit merged 1 commit into
stagingfrom
test/canvas-actions-1815
Apr 27, 2026
Merged

test(canvas): cover canvas-actions restart-pending helpers (25% → 100%) (#1815)#2149
HongmingWang-Rabbit merged 1 commit into
stagingfrom
test/canvas-actions-1815

Conversation

@HongmingWang-Rabbit

Copy link
Copy Markdown
Contributor

[Molecule-Platform-Evolvement-Manager]

Continues the #1815 coverage rollup. `canvas-actions.ts` was at 25% in the baseline from #2147.

Coverage — 5 cases

markAllWorkspacesNeedRestart (3): calls `updateNodeData` on every node with `{needsRestart: true}`; no-op on empty canvas; preserves call ordering (matters because the toolbar pill observes per-node data changes incrementally — a refactor that shuffled iteration order would silently change which workspaces flash first).

markWorkspaceNeedsRestart (2): targeted call fires exactly once on the named id; defensive cardinality check — regardless of how many other workspaces exist in the store, only the target gets updated. Pre-this-test, a refactor that accidentally wired this through the per-node iteration path of `markAll` would silently mark every workspace.

Test plan

  • All 5 cases pass locally (~132ms)
  • No SUT changes — pure additive coverage
  • CI green

#1815 progress

🤖 Generated with Claude Code

…%) (#1815)

[Molecule-Platform-Evolvement-Manager]

Continues the #1815 coverage rollup. canvas-actions.ts was at 25%
in the baseline run from #2147; this PR brings the file's two
helpers to full coverage.

5 cases:

**markAllWorkspacesNeedRestart (3):**
- calls updateNodeData on every node with `{needsRestart: true}`
- no-op when the canvas has zero workspaces
- preserves call ordering — matters because the toolbar's
  Restart Pending pill observes per-node data changes
  incrementally; a refactor that shuffled iteration order would
  silently change which workspaces flash first

**markWorkspaceNeedsRestart (2):**
- targeted call: updateNodeData fires exactly once on the named id
- defensive: regardless of how many other workspaces exist in the
  store, only the target workspace gets updated. Pre-this-test, a
  refactor that accidentally wired this function through the
  per-node iteration path of markAll would silently mark every
  workspace — pinning the cardinality here catches that.

## Mock strategy

Standard pattern for canvas store: mock useCanvasStore as both the
selector function AND a getState()-bearing object. updateNodeData
is a vi.fn() spy so the test asserts on calls + args directly.

## Test plan

- [x] All 5 cases pass locally (~132ms)
- [x] No SUT changes — pure additive coverage
- [ ] CI green

## #1815 progress

- [x] Step 1+2: instrumentation + script (#2147)
- [x] utils.ts + runtime-names.ts (#2148)
- [x] canvas-actions.ts (this PR)
- [ ] Remaining low-coverage targets: store/classNames.ts (17%),
      store/canvas.ts (73% — largest absolute gap by lines)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@HongmingWang-Rabbit
HongmingWang-Rabbit added this pull request to the merge queue Apr 27, 2026
Merged via the queue into staging with commit a682dcb Apr 27, 2026
14 checks passed
@molecule-ai
molecule-ai Bot deleted the test/canvas-actions-1815 branch May 20, 2026 06:22
HongmingWang-Rabbit pushed a commit that referenced this pull request Jun 12, 2026
…n firing loop (#2149)' (#2154) from regression/2149-scheduler-real-pg into main
HongmingWang-Rabbit pushed a commit that referenced this pull request Jun 12, 2026
… redis online-status key/TTL coverage (#2150)

Refile of the WIP at origin/regression/2150-migration-replay-from-scratch-real-pg
(stalled 2026-06-03, never advanced past DRAFT, base on a 200-commit-stale main
that would have undone my PR #2449's guard widening + the mc#1982 mask removal
+ the #2149 scheduler trigger if merged directly).

This is the #2150 implementation (close-supersedes the WIP PR #2155):

  - workspace-server/internal/db/postgres_replay_integration_test.go (286 lines)
      Real-PG integration tests for db.RunMigrations (forward chain replay-from-
      scratch via the production entrypoint, hard-fail; double-apply for the
      045 crash-loop class) and db.InitPostgres (ping + bad-DSN).
  - workspace-server/internal/db/redis_test.go (291 lines)
      Unit tests for redis.go (was untested fleet-wide): SetOnline / IsOnline /
      RefreshTTL on ws:<id>, CacheURL / GetCachedURL on ws:<id>:url, internal
      namespace pin, LivenessTTL >= 5x heartbeat, real TTL expiry via miniredis.
  - .gitea/workflows/handlers-postgres-integration.yml (+27)
      New 'Migration replay-from-scratch gate (#2150)' step, runs the integration
      suite against a SEPARATE 'molecule_replay' database on the same sibling
      Postgres (so the destructive DROP SCHEMA never touches the handlers
      molecule DB). Inserted AFTER the scheduler (#2149) step; does NOT undo
      any of: the mc#1982 mask removal, the preflight INTEGRATION_DB_URL
      check, or the table-presence guard widening (PR #2449).
  - .gitea/scripts/detect-changes.py (+5)
      'handlers-postgres' profile now also matches internal/db/ (additive,
      preserves the scheduler trigger from #2149) so a change to redis.go or
      postgres.go runs the gate.

Refs #2150. Supersedes the WIP PR #2155 (DRAFT, 6 days stalled, branched from
a 200-commit-stale main).
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