-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'staging' into feat/table-for-lti-integration
- Loading branch information
Showing
45 changed files
with
628 additions
and
890 deletions.
There are no files selected for viewing
Binary file renamed
BIN
+25.4 KB
...cript-npm-4.0.7-ae4a7db3ec-d6717755d6.zip → ...cript-npm-4.0.9-2d615e0202-843081bc48.zip
Binary file not shown.
Binary file added
BIN
+143 KB
.yarn/cache/@graphql-codegen-visitor-plugin-common-npm-5.3.1-5a769a1d60-273f99a912.zip
Binary file not shown.
Binary file renamed
BIN
+239 KB
...r-sdk-npm-4.4.1-1dbedf48ea-3307e572f3.zip → ...r-sdk-npm-4.5.0-0df7aff729-b83efd4a83.zip
Binary file not shown.
Binary file renamed
BIN
+17.1 KB
...tion-npm-5.16.0-a008b15eff-3519fd0856.zip → ...tion-npm-5.16.1-a17d037152-b1e03dbf1f.zip
Binary file not shown.
Binary file renamed
BIN
+677 KB
...core-npm-8.13.0-d9dec4d67c-1841f57a46.zip → ...core-npm-8.15.0-bac8fa3dd7-72a98cb432.zip
Binary file not shown.
Binary file renamed
BIN
+587 KB
...node-npm-8.13.0-9362bc8c53-e6a2633ac6.zip → ...node-npm-8.15.0-7704a71f63-962c351315.zip
Binary file not shown.
Binary file removed
BIN
-158 KB
.yarn/cache/@sentry-opentelemetry-npm-8.13.0-db3da96871-2218152299.zip
Binary file not shown.
Binary file added
BIN
+158 KB
.yarn/cache/@sentry-opentelemetry-npm-8.15.0-0c124e7b6f-b836b10dcc.zip
Binary file not shown.
Binary file renamed
BIN
+137 KB
...ypes-npm-8.13.0-77e6eac1ae-571a15d24d.zip → ...ypes-npm-8.15.0-1fee4593d3-331575628a.zip
Binary file not shown.
Binary file renamed
BIN
+475 KB
...tils-npm-8.13.0-718dab5587-2fe28ce6d4.zip → ...tils-npm-8.15.0-0834d9288d-aecda8795e.zip
Binary file not shown.
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,140 +1,29 @@ | ||
import gql from 'graphql-tag' | ||
import { HttpResponse } from 'msw' | ||
import * as R from 'ramda' | ||
|
||
import { page, pageRevision, user as baseUser } from '../../../__fixtures__' | ||
import { given, Client, nextUuid } from '../../__utils__' | ||
import { Client } from '../../__utils__' | ||
|
||
const user = { ...baseUser, roles: ['de_static_pages_builder'] } | ||
const input = { | ||
content: 'new content', | ||
title: 'new title', | ||
pageId: 19767, | ||
} | ||
|
||
describe('PageAddRevisionMutation', () => { | ||
const input = { | ||
content: 'new content', | ||
title: 'new title', | ||
pageId: page.id, | ||
} | ||
|
||
const mutation = new Client({ userId: user.id }) | ||
.prepareQuery({ | ||
query: gql` | ||
mutation set($input: PageAddRevisionInput!) { | ||
page { | ||
addRevision(input: $input) { | ||
success | ||
} | ||
} | ||
const mutation = new Client().prepareQuery({ | ||
query: gql` | ||
mutation set($input: PageAddRevisionInput!) { | ||
page { | ||
addRevision(input: $input) { | ||
success | ||
} | ||
`, | ||
}) | ||
.withVariables({ input }) | ||
|
||
const newRevisionId = nextUuid(pageRevision.id) | ||
|
||
beforeEach(() => { | ||
given('UuidQuery').for(user, page, pageRevision) | ||
given('PageAddRevisionMutation').isDefinedBy(async ({ request }) => { | ||
const body = await request.json() | ||
// const { title, content } = req.body.payload | ||
const newRevision = { | ||
...pageRevision, | ||
...R.pick(['title', 'content'], body.payload), | ||
id: newRevisionId, | ||
} | ||
given('UuidQuery').for(newRevision) | ||
given('UuidQuery').for({ | ||
...page, | ||
revisionIds: [newRevision.id, ...page.revisionIds], | ||
currentRevisionId: newRevision.id, | ||
}) | ||
return HttpResponse.json({ success: true, revisionId: newRevision.id }) | ||
}) | ||
}) | ||
|
||
test('returns "{ success: true }" when mutation could be successfully executed', async () => { | ||
await mutation.shouldReturnData({ | ||
page: { addRevision: { success: true } }, | ||
}) | ||
}) | ||
|
||
test('updates the cache', async () => { | ||
const query = new Client({ userId: user.id }) | ||
.prepareQuery({ | ||
query: gql` | ||
query ($id: Int!) { | ||
uuid(id: $id) { | ||
... on Page { | ||
currentRevision { | ||
id | ||
content | ||
title | ||
} | ||
} | ||
} | ||
} | ||
`, | ||
}) | ||
.withVariables({ id: page.id }) | ||
|
||
await query.shouldReturnData({ | ||
uuid: { | ||
currentRevision: { | ||
id: pageRevision.id, | ||
content: pageRevision.content, | ||
title: pageRevision.title, | ||
}, | ||
}, | ||
}) | ||
|
||
await mutation.execute() | ||
|
||
await query.shouldReturnData({ | ||
uuid: { | ||
currentRevision: { | ||
id: newRevisionId, | ||
content: input.content, | ||
title: input.title, | ||
}, | ||
}, | ||
}) | ||
}) | ||
|
||
test('fails when user is not authenticated', async () => { | ||
await mutation | ||
.forUnauthenticatedUser() | ||
.shouldFailWithError('UNAUTHENTICATED') | ||
}) | ||
|
||
test('fails when user does not have role "static_pages_builder"', async () => { | ||
await mutation.forLoginUser().shouldFailWithError('FORBIDDEN') | ||
}) | ||
|
||
test('fails when `title` or `content` is empty', async () => { | ||
await mutation | ||
.withInput({ | ||
content: '', | ||
title: 'title', | ||
pageId: page.id, | ||
}) | ||
.shouldFailWithError('BAD_USER_INPUT') | ||
|
||
await mutation | ||
.withInput({ | ||
content: 'content', | ||
title: '', | ||
pageId: page.id, | ||
}) | ||
.shouldFailWithError('BAD_USER_INPUT') | ||
}) | ||
|
||
test('fails when database layer returns a 400er response', async () => { | ||
given('PageAddRevisionMutation').returnsBadRequest() | ||
|
||
await mutation.shouldFailWithError('BAD_USER_INPUT') | ||
}) | ||
|
||
test('fails when database layer has an internal error', async () => { | ||
given('PageAddRevisionMutation').hasInternalServerError() | ||
} | ||
`, | ||
variables: { input }, | ||
}) | ||
|
||
await mutation.shouldFailWithError('INTERNAL_SERVER_ERROR') | ||
test('returns "{ success: true }" when mutation could be successfully executed', async () => { | ||
const newMutation = await mutation.forUser('de_static_pages_builder') | ||
await newMutation.shouldReturnData({ | ||
page: { addRevision: { success: true } }, | ||
}) | ||
}) |
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
Oops, something went wrong.