diff --git a/packages/server/src/api/routes/tests/user.spec.js b/packages/server/src/api/routes/tests/user.spec.js index 56f1923cb0..8f4f44d4c5 100644 --- a/packages/server/src/api/routes/tests/user.spec.js +++ b/packages/server/src/api/routes/tests/user.spec.js @@ -171,9 +171,28 @@ describe("/users", () => { .expect("Content-Type", /json/) expect(res.body.message).toEqual('User synced.') }) + + + it("should sync the user when a previous user is specified", async () => { + const app1 = await config.createApp('App 1') + const app2 = await config.createApp('App 2') + + let user = await config.createUser( + undefined, + undefined, + undefined, + undefined, + false, + true, + { [app1.appId]: 'ADMIN' }) + let res = await request + .post(`/api/users/metadata/sync/${user._id}`) + .set(config.defaultHeaders()) + .send({ previousUser: { ...user, roles: { ...user.roles, [app2.appId]: 'BASIC' } } }) + .expect(200) + .expect("Content-Type", /json/) + + expect(res.body.message).toEqual('User synced.') + }) }) - - - - })