Skip to content

Commit 61ffede

Browse files
committed
fix(tests): scope migration probes and align remaining Project fixtures
1 parent 83bdee2 commit 61ffede

4 files changed

Lines changed: 757 additions & 2351 deletions

File tree

‎apps/sim/lib/mothership/tools/client/desktop-tool-authorization.integration.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ vi.mock('@/lib/auth', () => authMock)
2525

2626
import { db } from '@sim/db'
2727
import { copilotAsyncToolCalls, copilotChats, copilotRuns, user, workspace } from '@sim/db/schema'
28+
import { deleteWorkspaceFixture, insertWorkspaceFixture } from '@sim/db/testing/workspace-fixtures'
2829
import { generateId } from '@sim/utils/id'
2930
import { eq } from 'drizzle-orm'
3031
import { NextRequest } from 'next/server'
@@ -203,7 +204,7 @@ describe.runIf(Boolean(redisUrl))('desktop tool calls the server no longer admit
203204
createdAt: now,
204205
updatedAt: now,
205206
})
206-
await db.insert(workspace).values({
207+
await insertWorkspaceFixture(db, {
207208
id: workspaceId,
208209
name: 'Desktop authorization fixture',
209210
ownerId: userId,
@@ -224,7 +225,7 @@ describe.runIf(Boolean(redisUrl))('desktop tool calls the server no longer admit
224225

225226
afterAll(async () => {
226227
await db.delete(copilotChats).where(eq(copilotChats.id, chatId))
227-
await db.delete(workspace).where(eq(workspace.id, workspaceId))
228+
await deleteWorkspaceFixture(db, eq(workspace.id, workspaceId))
228229
await db.delete(user).where(eq(user.id, userId))
229230
})
230231

‎apps/sim/lib/table/row-changes.integration.ts‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
* moves it into the definition row without changing what a reader sees, under concurrent appends.
44
*/
55
import { db } from '@sim/db'
6-
import { userTableDefinitions } from '@sim/db/schema'
6+
import { userTableDefinitions, workspace } from '@sim/db/schema'
77
import { readTestDatabaseUrl } from '@sim/db/testing/test-infrastructure'
8+
import { deleteWorkspaceFixture, insertWorkspaceFixture } from '@sim/db/testing/workspace-fixtures'
89
import { generateId } from '@sim/utils/id'
10+
import { eq } from 'drizzle-orm'
911
import postgres from 'postgres'
1012
import { afterAll, beforeAll, describe, expect, it } from 'vitest'
1113
import {
@@ -63,12 +65,16 @@ describe('table row-change log against real PostgreSQL', () => {
6365
beforeAll(async () => {
6466
await control`INSERT INTO "user" (id, name, email, email_verified, created_at, updated_at)
6567
VALUES (${userId}, 'Row change fixture', ${`${userId}@example.test`}, true, now(), now())`
66-
await control`INSERT INTO workspace (id, name, owner_id, billed_account_user_id)
67-
VALUES (${workspaceId}, 'Row change fixtures', ${userId}, ${userId})`
68+
await insertWorkspaceFixture(db, {
69+
id: workspaceId,
70+
name: 'Row change fixtures',
71+
ownerId: userId,
72+
billedAccountUserId: userId,
73+
})
6874
})
6975

7076
afterAll(async () => {
71-
await control`DELETE FROM workspace WHERE id = ${workspaceId}`
77+
await deleteWorkspaceFixture(db, eq(workspace.id, workspaceId))
7278
await control`DELETE FROM "user" WHERE id = ${userId}`
7379
await control.end()
7480
})

0 commit comments

Comments
 (0)