1
0
Fork 0
mirror of synced 2024-07-07 15:25:52 +12:00

Add tests for admins vs app users

This commit is contained in:
adrinr 2023-03-29 16:42:31 +01:00
parent b368c14308
commit 8783f0123d

View file

@ -5,7 +5,7 @@ import { rawUserMetadata, syncGlobalUsers } from "../utils"
describe("syncGlobalUsers", () => {
const config = new TestConfiguration()
beforeAll(async () => {
beforeEach(async () => {
await config.init()
})
@ -25,11 +25,10 @@ describe("syncGlobalUsers", () => {
})
})
it("app users are synced", async () => {
it("admin and builders users are synced", async () => {
const user1 = await config.createUser({ admin: true })
const user2 = await config.createUser({ admin: false, builder: true })
await config.doInContext(config.appId, async () => {
const user1 = await config.createUser()
const user2 = await config.createUser()
await syncGlobalUsers()
const metadata = await rawUserMetadata()
@ -46,4 +45,19 @@ describe("syncGlobalUsers", () => {
)
})
})
it("app users are not synced if not specified", async () => {
const user = await config.createUser({ admin: false, builder: false })
await config.doInContext(config.appId, async () => {
await syncGlobalUsers()
const metadata = await rawUserMetadata()
expect(metadata).toHaveLength(1)
expect(metadata).not.toContainEqual(
expect.objectContaining({
_id: db.generateUserMetadataID(user._id),
})
)
})
})
})