diff --git a/packages/server/src/sdk/users/tests/utils.spec.ts b/packages/server/src/sdk/users/tests/utils.spec.ts index 3178978c46..8eba6db5b6 100644 --- a/packages/server/src/sdk/users/tests/utils.spec.ts +++ b/packages/server/src/sdk/users/tests/utils.spec.ts @@ -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), + }) + ) + }) + }) })