From 3d2d6655f193432d536de472b5d7cd5487c8972a Mon Sep 17 00:00:00 2001 From: Jan Date: Wed, 25 Jan 2023 15:50:35 +0100 Subject: [PATCH] Start fixing tests --- .../tests/unit/views/Users.spec.ts | 64 ++++++------------- 1 file changed, 19 insertions(+), 45 deletions(-) diff --git a/packages/web-app-admin-settings/tests/unit/views/Users.spec.ts b/packages/web-app-admin-settings/tests/unit/views/Users.spec.ts index f2e04699f29..2c32b3096af 100644 --- a/packages/web-app-admin-settings/tests/unit/views/Users.spec.ts +++ b/packages/web-app-admin-settings/tests/unit/views/Users.spec.ts @@ -21,7 +21,9 @@ const getDefaultUser = () => { memberOf: [], mail: 'admin@example.org', drive: { - name: 'any' + id: '1', + name: 'admin', + quota: { remaining: 5000000000, state: 'normal', total: 5000000000, used: 0 } }, appRoleAssignments: [ { @@ -141,28 +143,18 @@ describe('Users view', () => { appRoleAssignments: [ { appRoleId: '2', - id: '1', - principalId: '1', - principalType: 'User', - resourceDisplayName: 'ownCloud Infinite Scale', - resourceId: 'some-graph-app-id' + resourceId: 'some-graph-app-id', + principalId: '1' } ], displayName: 'administrator', - givenName: 'Admin', id: '1', mail: 'administrator@example.org', - memberOf: [], - onPremisesSamAccountName: 'admin', - surname: 'Admin', drive: { id: '1', - name: 'Admin', + name: 'admin', quota: { - remaining: 5000000000, - state: 'normal', - total: 5000000000, - used: 0 + total: 1000000000 } }, passwordProfile: { @@ -176,13 +168,8 @@ describe('Users view', () => { graph.drives.updateDrive.mockImplementation(() => mockAxiosResolve({ id: '1', - name: 'Admin', - quota: { - remaining: 5000000000, - state: 'normal', - total: 5000000000, - used: 0 - } + name: 'admin', + quota: { remaining: 1000000000, state: 'normal', total: 1000000000, used: 0 } }) ) graph.users.getUser.mockImplementation(() => @@ -200,15 +187,9 @@ describe('Users view', () => { displayName: 'administrator', drive: { id: '1', - name: 'Admin', - quota: { - remaining: 5000000000, - state: 'normal', - total: 5000000000, - used: 0 - } + name: 'admin', + quota: { remaining: 1000000000, state: 'normal', total: 1000000000, used: 0 } }, - givenName: 'Admin', id: '1', mail: 'administrator@example.org', memberOf: [], @@ -224,9 +205,9 @@ describe('Users view', () => { { ...getDefaultUser(), quota: { - remaining: 100000000, + remaining: 1000000000, state: 'normal', - total: 100000000, + total: 1000000000, used: 0 } } @@ -245,20 +226,13 @@ describe('Users view', () => { await wrapper.vm.editUser({ user: wrapper.vm.selectedUsers[0], editUser }) await wrapper.vm.$nextTick() - console.log(wrapper.vm.users) - console.log('USER IS THERE') - console.log(wrapper.vm.users.find((user) => user.id === editUser.id)) - const a = wrapper.vm.users.find((user) => user.id === editUser.id) - console.log(a) - console.log('USER IS THERE') - - console.log(JSON.stringify({ ...a })) + const updatedUser = wrapper.vm.users.find((user) => user.id === editUser.id) - expect(a).toEqual(3) - expect(busStub).toHaveBeenCalledWith([ - 'sidebar.entity.saved', - 'app.admin-settings.users.user.updated ' - ]) + expect(updatedUser.displayName).toEqual('administrator') + expect(updatedUser.mail).toEqual('administrator@example.org') + expect(updatedUser.appRoleAssignments[0].appRoleId).toEqual('2') + expect(updatedUser.drive.quota.total).toEqual(1000000000) + expect(busStub).toHaveBeenCalledTimes(2) expect(graphUpdateDriveStub).toHaveBeenCalled() expect(updateSpaceFieldStub).toHaveBeenCalled() expect(graphUpdateCreateUserAppRoleAssignmentStub).toHaveBeenCalled()