-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): Add
updateActiveAdministrator
mutation
- Loading branch information
1 parent
0df7c71
commit 73ab736
Showing
11 changed files
with
162 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,7 +57,7 @@ Object { | |
"lastName": "new last", | ||
"user": Object { | ||
"id": "T_3", | ||
"identifier": "[email protected]", | ||
"identifier": "new-email", | ||
"lastLogin": null, | ||
"roles": Array [ | ||
Object { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ import { | |
DeletionResult, | ||
GetAdministrator, | ||
GetAdministrators, | ||
UpdateActiveAdministrator, | ||
UpdateAdministrator, | ||
} from './graphql/generated-e2e-admin-types'; | ||
import { CREATE_ADMINISTRATOR } from './graphql/shared-definitions'; | ||
|
@@ -73,22 +74,6 @@ describe('Administrator resolver', () => { | |
expect(result.administrator).toEqual(createdAdmin); | ||
}); | ||
|
||
it('activeAdministrator', async () => { | ||
await adminClient.asAnonymousUser(); | ||
|
||
const { activeAdministrator: result1 } = await adminClient.query<ActiveAdministrator.Query>( | ||
GET_ACTIVE_ADMINISTRATOR, | ||
); | ||
expect(result1).toBeNull(); | ||
|
||
await adminClient.asSuperAdmin(); | ||
|
||
const { activeAdministrator: result2 } = await adminClient.query<ActiveAdministrator.Query>( | ||
GET_ACTIVE_ADMINISTRATOR, | ||
); | ||
expect(result2?.emailAddress).toBe(SUPER_ADMIN_USER_IDENTIFIER); | ||
}); | ||
|
||
it('updateAdministrator', async () => { | ||
const result = await adminClient.query<UpdateAdministrator.Mutation, UpdateAdministrator.Variables>( | ||
UPDATE_ADMINISTRATOR, | ||
|
@@ -175,6 +160,45 @@ describe('Administrator resolver', () => { | |
|
||
expect(administrator).toBeNull(); | ||
}); | ||
|
||
it('activeAdministrator', async () => { | ||
await adminClient.asAnonymousUser(); | ||
|
||
const { activeAdministrator: result1 } = await adminClient.query<ActiveAdministrator.Query>( | ||
GET_ACTIVE_ADMINISTRATOR, | ||
); | ||
expect(result1).toBeNull(); | ||
|
||
await adminClient.asSuperAdmin(); | ||
|
||
const { activeAdministrator: result2 } = await adminClient.query<ActiveAdministrator.Query>( | ||
GET_ACTIVE_ADMINISTRATOR, | ||
); | ||
expect(result2?.emailAddress).toBe(SUPER_ADMIN_USER_IDENTIFIER); | ||
}); | ||
|
||
it('updateActiveAdministrator', async () => { | ||
const { updateActiveAdministrator } = await adminClient.query< | ||
UpdateActiveAdministrator.Mutation, | ||
UpdateActiveAdministrator.Variables | ||
>(UPDATE_ACTIVE_ADMINISTRATOR, { | ||
input: { | ||
firstName: 'Thomas', | ||
lastName: 'Anderson', | ||
emailAddress: '[email protected]', | ||
}, | ||
}); | ||
|
||
expect(updateActiveAdministrator.firstName).toBe('Thomas'); | ||
expect(updateActiveAdministrator.lastName).toBe('Anderson'); | ||
|
||
const { activeAdministrator } = await adminClient.query<ActiveAdministrator.Query>( | ||
GET_ACTIVE_ADMINISTRATOR, | ||
); | ||
|
||
expect(activeAdministrator?.firstName).toBe('Thomas'); | ||
expect(activeAdministrator?.user.identifier).toBe('[email protected]'); | ||
}); | ||
}); | ||
|
||
export const GET_ADMINISTRATORS = gql` | ||
|
@@ -207,6 +231,15 @@ export const GET_ACTIVE_ADMINISTRATOR = gql` | |
${ADMINISTRATOR_FRAGMENT} | ||
`; | ||
|
||
export const UPDATE_ACTIVE_ADMINISTRATOR = gql` | ||
mutation UpdateActiveAdministrator($input: UpdateActiveAdministratorInput!) { | ||
updateActiveAdministrator(input: $input) { | ||
...Administrator | ||
} | ||
} | ||
${ADMINISTRATOR_FRAGMENT} | ||
`; | ||
|
||
export const UPDATE_ADMINISTRATOR = gql` | ||
mutation UpdateAdministrator($input: UpdateAdministratorInput!) { | ||
updateAdministrator(input: $input) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.