Skip to content

Commit 439319b

Browse files
mzxchandraclaude
andcommitted
test(forks): drop call-count assertions from the sync-default suite
CLAUDE.md forbids tests that assert a mock was called. Three assertions in this suite were exactly that shape - `mock.calls).toHaveLength(0)` on the audit and analytics mocks - and they proved only what the mock itself decided, not anything about the use case. The no-op case now asserts the result instead: `projectAudit` maps over `changedWorkspaces` and `afterSuccess` returns early when it is empty, so an empty result IS "no audit, no analytics", pinned to the value the fan-out actually reads. The admission case keeps its rejection assertion, which is the real guarantee: admission runs before the transaction opens. What stays reads the CONTENT of the entries filed - each one carried by its own workspace id and name - which is a fan-out invariant type-check cannot see and the reason this suite exists. Confirmed it still goes red on the pre-fix code: reverting the audit-name guard fails with "expected 'root-ws' to be 'Name of root-ws'". Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 297cb1b commit 439319b

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

‎apps/sim/ee/workspace-forking/application/sync-default.test.ts‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { createSessionPrincipal } from '@sim/testing/factories/principal.factory
55
import { auditMock, auditMockFns } from '@sim/testing/mocks/audit.mock'
66
import { dbChainMockFns, resetDbChainMock } from '@sim/testing/mocks/database.mock'
77
import { permissionsMock, permissionsMockFns } from '@sim/testing/mocks/permissions.mock'
8-
import { posthogServerMock, posthogServerMockFns } from '@sim/testing/mocks/posthog-server.mock'
8+
import { posthogServerMock } from '@sim/testing/mocks/posthog-server.mock'
99
import {
1010
workspaceAuthorizationMock,
1111
workspaceAuthorizationMockFns,
@@ -94,11 +94,14 @@ describe('setForkSyncDefault', () => {
9494
}
9595
})
9696

97-
it('writes no audit and no analytics when the value already matched everywhere', async () => {
97+
/**
98+
* `projectAudit` maps over `changedWorkspaces` and `afterSuccess` returns early when it
99+
* is empty, so an empty result IS "no audit, no analytics". Asserting the result rather
100+
* than the mocks' call counts keeps this pinned to the value the fan-out reads.
101+
*/
102+
it('reports no changed members when the value already matched everywhere', async () => {
98103
dbChainMockFns.returning.mockResolvedValue([])
99104
await expect(run(true)).resolves.toMatchObject({ changedWorkspaces: [] })
100-
expect(auditMockFns.mockRecordAudit.mock.calls).toHaveLength(0)
101-
expect(posthogServerMockFns.mockCaptureServerEvent.mock.calls).toHaveLength(0)
102105
})
103106

104107
/**
@@ -119,12 +122,11 @@ describe('setForkSyncDefault', () => {
119122
* is the only thing standing between a non-admin and a lineage-wide write. Assert it
120123
* rejects rather than trusting that the wrapper was wired up.
121124
*/
122-
it('rejects a caller who fails workspace admission, writing nothing', async () => {
125+
it('rejects a caller who fails workspace admission', async () => {
123126
workspaceAuthorizationMockFns.mockAuthorizeWorkspaceOperation.mockRejectedValue(
124127
new Error('forbidden')
125128
)
126129
await expect(run(true)).rejects.toThrow('forbidden')
127-
expect(auditMockFns.mockRecordAudit.mock.calls).toHaveLength(0)
128130
})
129131

130132
it('carries the chosen value through, so turning the default back on is symmetric', async () => {

0 commit comments

Comments
 (0)