Skip to content

Commit 5f462da

Browse files
committed
test(platform): delete a seeded person's projects before their personal organization
A first page load now gives the new account a personal workspace with a project, and project restricts deleting its organization and its owner. The cleanup removed the organization first and failed every first-load check in its finally.
1 parent 6161104 commit 5f462da

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

‎apps/sim/platform/checks/live/support/database.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,18 @@ export async function seedPerson(
6262
*/
6363
async function removePerson(person: SeededPerson) {
6464
await withLiveDatabase(async (sql) => {
65-
await sql`delete from organization where kind = 'personal' and id in (
66-
select organization_id from member where user_id = ${person.id})`
67-
const owned = await sql<{ id: string; projectId: string | null }[]>`
68-
select id, project_id as "projectId" from workspace where owner_id = ${person.id}`
65+
const owned = await sql<{ id: string }[]>`
66+
select id from workspace where owner_id = ${person.id}`
6967
if (owned.length > 0) {
7068
const workspaceIds = owned.map(({ id }) => id)
7169
await sql`delete from permissions
7270
where entity_type = 'workspace' and entity_id in ${sql(workspaceIds)}`
7371
await sql`delete from workspace where id in ${sql(workspaceIds)}`
74-
const projects = owned.flatMap(({ projectId }) => (projectId ? [projectId] : []))
75-
if (projects.length > 0) await sql`delete from project where id in ${sql(projects)}`
7672
}
73+
// A project restricts deleting its organization and its owner, so it goes before both.
74+
await sql`delete from project where owner_id = ${person.id}`
75+
await sql`delete from organization where kind = 'personal' and id in (
76+
select organization_id from member where user_id = ${person.id})`
7777
await sql`delete from "user" where id = ${person.id}`
7878
})
7979
}

0 commit comments

Comments
 (0)