diff --git a/packages/worker/src/api/routes/global/tests/scim.spec.ts b/packages/worker/src/api/routes/global/tests/scim.spec.ts index 81dcc4b7c9..1b8039eac1 100644 --- a/packages/worker/src/api/routes/global/tests/scim.spec.ts +++ b/packages/worker/src/api/routes/global/tests/scim.spec.ts @@ -574,6 +574,38 @@ describe("scim", () => { expect(events.user.updated).toHaveBeenCalledTimes(1) }) + + it("an existing user's email can be updated", async () => { + const newEmail = structures.generator.email() + + const body: ScimUpdateRequest = { + schemas: ["urn:ietf:params:scim:api:messages:2.0:PatchOp"], + Operations: [ + { + op: "Replace", + path: 'emails[type eq "work"].value', + value: newEmail, + }, + ], + } + + const response = await patchScimUser({ id: user.id, body }) + + const expectedScimUser: ScimUserResponse = { + ...user, + emails: [ + { + value: newEmail, + type: "work", + primary: true, + }, + ], + } + expect(response).toEqual(expectedScimUser) + + const persistedUser = await config.api.scimUsersAPI.find(user.id) + expect(persistedUser).toEqual(expectedScimUser) + }) }) describe("DELETE /api/global/scim/v2/users/:id", () => {