Skip to content

Commit

Permalink
add tests for list site
Browse files Browse the repository at this point in the history
  • Loading branch information
harishv7 committed Jan 15, 2025
1 parent 05cb6ac commit b2b72bc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
26 changes: 26 additions & 0 deletions apps/studio/src/server/modules/site/__tests__/site.router.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,32 @@ describe("site.router", async () => {
},
])
})

it("should only return sites if the permissions are not deleted for the site", async () => {
const { site: site1 } = await setupSite()
const { site: site2 } = await setupSite()
await setupAdminPermissions({
userId: session.userId,
siteId: site1.id,
isDeleted: true,
})
await setupAdminPermissions({
userId: session.userId,
siteId: site2.id,
})

// Act
const result = await caller.list()

// Assert
expect(result).toEqual([
{
id: site2.id,
name: site2.name,
config: site2.config,
},
])
})
})

describe("getSiteName", () => {
Expand Down
3 changes: 3 additions & 0 deletions apps/studio/tests/integration/helpers/seed/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import { nanoid } from "nanoid"
export const setupAdminPermissions = async ({
userId,
siteId,
isDeleted = false,
}: {
userId?: string
siteId: number
isDeleted?: boolean
}) => {
if (!userId) throw new Error("userId is a required field")

Expand All @@ -22,6 +24,7 @@ export const setupAdminPermissions = async ({
siteId,
role: RoleType.Admin,
resourceId: null,
deletedAt: isDeleted ? new Date() : null,
})
.execute()
}
Expand Down

0 comments on commit b2b72bc

Please sign in to comment.