Skip to content

Commit 372ca00

Browse files
committed
test(forks): derive the reverse fan-out expectation independently of its result
1 parent 1d79426 commit 372ca00

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

‎apps/sim/lib/workspaces/__integration__/fork-sync.integration.ts‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -893,21 +893,22 @@ describe('authorized fork and sync against PostgreSQL', () => {
893893

894894
await db.update(workspace).set({ archivedAt: new Date() }).where(eq(workspace.id, childId))
895895
const fromGrandchild = await setDefault(grandchildId, false)
896-
expect(await policyOf(sourceWorkspaceId)).toBe(false)
897-
expect(await policyOf(grandchildId)).toBe(false)
898-
expect(await policyOf(childId)).toBe(true)
899-
// The archived member was neither written nor audited.
900-
const expectedFromGrandchild = fromGrandchild.changedWorkspaces.map((member) => member.id)
901-
expect(expectedFromGrandchild).toEqual(
902-
expect.arrayContaining([sourceWorkspaceId, grandchildId])
896+
// Every live member flips back - the ones the first change covered and the two forks
897+
// created since - while the archived child is neither written nor audited.
898+
const expectedFromGrandchild = [
899+
...[...changed.keys()].filter((id) => id !== childId),
900+
newForkId,
901+
grandchildId,
902+
].sort()
903+
expect(fromGrandchild.changedWorkspaces.map((member) => member.id).sort()).toEqual(
904+
expectedFromGrandchild
903905
)
904-
expect(expectedFromGrandchild).not.toContain(childId)
906+
for (const id of expectedFromGrandchild) expect(await policyOf(id)).toBe(false)
907+
expect(await policyOf(childId)).toBe(true)
905908
await vi.waitFor(
906909
async () => {
907910
const entries = await auditedFrom(grandchildId)
908-
expect(entries.map((entry) => entry.resourceId).sort()).toEqual(
909-
[...expectedFromGrandchild].sort()
910-
)
911+
expect(entries.map((entry) => entry.resourceId).sort()).toEqual(expectedFromGrandchild)
911912
},
912913
{ timeout: 5000 }
913914
)

0 commit comments

Comments
 (0)