Skip to content

test(tables): cover the views realtime signal - #6101

Merged
waleedlatif1 merged 1 commit into
realtime-roomsfrom
test/table-views-realtime-coverage
Jul 30, 2026
Merged

test(tables): cover the views realtime signal#6101
waleedlatif1 merged 1 commit into
realtime-roomsfrom
test/table-views-realtime-coverage

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Follow-up test coverage for the views-realtime wiring merged in feat(tables): propagate shared saved-view changes to collaborators live #6100 (was missing dedicated tests).
  • events.test.ts: signalTableViewsChanged appends a single views event carrying the tableId, verified through the real in-memory event buffer.
  • views/service.test.ts: createTableView/updateTableView/deleteTableView emit 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. Mirrors delete-runner.test.ts's signal-path coverage; drives the DB via the shared dbChainMock.
  • Adds tableViews to the comprehensive @sim/db/schema test 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

  • Test coverage

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

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

- 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.
@vercel

vercel Bot commented Jul 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jul 30, 2026 7:16pm

Request Review

@cursor

cursor Bot commented Jul 30, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Test-only changes and a shared schema mock entry; no production behavior modified.

Overview
Adds follow-up test coverage for table views realtime signaling (production wiring landed in #6100).

events.test.ts exercises signalTableViewsChanged against the real in-memory event buffer: one { kind: 'views', tableId } event is appended and readable via readTableEventsSince.

views/service.test.ts mocks signalTableViewsChanged and asserts create / update / delete call it with the table id only on successful writes, and do not when update targets a missing view or delete returns no row.

schema.mock.ts adds tableViews so service tests can queueTableRows for the in-transaction existence check.

Reviewed by Cursor Bugbot for commit 77b612d. Configure here.

@greptile-apps

greptile-apps Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds focused tests for table-view realtime signaling.

  • Verifies that a views event is appended to the in-memory event buffer.
  • Covers signaling after successful create, update, and delete operations, plus missing-view no-op behavior.
  • Extends the shared schema mock with the tableViews definition required by the service tests.

Confidence Score: 5/5

The 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.

Important Files Changed

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

@waleedlatif1
waleedlatif1 merged commit f717d60 into realtime-rooms Jul 30, 2026
5 checks passed
@waleedlatif1
waleedlatif1 deleted the test/table-views-realtime-coverage branch July 30, 2026 20:20
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