test(tables): cover the views realtime signal - #6101
Conversation
- events.test.ts: signalTableViewsChanged appends a single 'views' event carrying the tableId (through the real memory buffer). - views/service.test.ts: create/update/delete emit signalTableViewsChanged on real success, and DON'T on a no-op (a PATCH/DELETE targeting a missing view changes nothing, so it must not signal). Mirrors delete-runner's signal-path coverage; drives the DB via the shared dbChainMock. - Add tableViews to the comprehensive @sim/db/schema test mock so the service tests can queue the in-transaction existence row.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryLow Risk Overview
Reviewed by Cursor Bugbot for commit 77b612d. Configure here. |
Greptile SummaryAdds focused tests for table-view realtime signaling.
Confidence Score: 5/5The PR appears safe to merge, with no actionable defects identified in the added test coverage or schema mock. The new tests use the intended in-memory event path and shared database mock correctly, reset state between cases, and model the tableViews schema consistently with the production definition.
|
| Filename | Overview |
|---|---|
| apps/sim/lib/table/events.test.ts | Adds deterministic memory-buffer coverage for signalTableViewsChanged; the append occurs synchronously before the immediate read. |
| apps/sim/lib/table/views/service.test.ts | Adds correctly isolated mutation tests covering signaling on successful writes and suppression on missing-view no-ops. |
| packages/testing/src/mocks/schema.mock.ts | Adds a tableViews mock whose fields match the real schema and support identity-based DB-row queue routing. |
Reviews (1): Last reviewed commit: "test(tables): cover the views realtime s..." | Re-trigger Greptile
Summary
events.test.ts:signalTableViewsChangedappends a singleviewsevent carrying the tableId, verified through the real in-memory event buffer.views/service.test.ts:createTableView/updateTableView/deleteTableViewemit the signal on real success, and do not on a no-op — a PATCH/DELETE targeting a missing view changes nothing, so it must not signal collaborators. Mirrorsdelete-runner.test.ts's signal-path coverage; drives the DB via the shareddbChainMock.tableViewsto the comprehensive@sim/db/schematest mock so the service tests can queue the in-transaction existence-check row (the mock is meant to be comprehensive; it was simply missing this table).Type of Change
Testing
tsc clean, lint clean, 618 table tests pass (36 files) including the 6 new cases. The client event-stream handler is intentionally not unit-tested — consistent with all 8 sibling event kinds (cell/dispatch/job/schema/metadata/definition/edit/usageLimitReached), which have no handler tests; it's a one-line type-checked invalidation.
Checklist