test(canvas): cover canvas-actions restart-pending helpers (25% → 100%) (#1815) - #2149
Merged
Merged
Conversation
…%) (#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
requested a review
from hongmingwang-moleculeai
as a code owner
April 27, 2026 06:47
HongmingWang-Rabbit
enabled auto-merge
April 27, 2026 06:47
8 tasks
HongmingWang-Rabbit
pushed a commit
that referenced
this pull request
Jun 12, 2026
HongmingWang-Rabbit
pushed a commit
that referenced
this pull request
Jun 12, 2026
HongmingWang-Rabbit
pushed a commit
that referenced
this pull request
Jun 12, 2026
HongmingWang-Rabbit
pushed a commit
that referenced
this pull request
Jun 12, 2026
HongmingWang-Rabbit
pushed a commit
that referenced
this pull request
Jun 12, 2026
HongmingWang-Rabbit
pushed a commit
that referenced
this pull request
Jun 12, 2026
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[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
#1815 progress
🤖 Generated with Claude Code