-
Notifications
You must be signed in to change notification settings - Fork 1
Sends user confirmation email #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
95a89ec
Sends user confirmation email
jbarnsley10 779fbe8
Extra coverage
jbarnsley10 226f718
FInal email body changes
jbarnsley10 b401260
Changed to use custom property in meta
jbarnsley10 0a6d86b
Reverted
jbarnsley10 a261cd9
Upversioned engine plugin
jbarnsley10 c1ee5b9
Resolved date in tests being shifted by BST
jbarnsley10 d8a02ab
Extra coverage
jbarnsley10 8ab93b7
Removed coercing
jbarnsley10 d5244c5
Uses ISO string
jbarnsley10 33e341f
Added BST test
jbarnsley10 859f45f
CHanged managerUrl config
jbarnsley10 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,111 +1,149 @@ | ||
| import { FormStatus } from '@defra/forms-model' | ||
| import { buildDefinition } from '@defra/forms-model/stubs' | ||
| import { buildDefinition, buildMetaData } from '@defra/forms-model/stubs' | ||
|
|
||
| import { getJson } from '~/src/lib/fetch.js' | ||
| import { getFormDefinition } from '~/src/lib/manager.js' | ||
| import { getFormDefinition, getFormMetadata } from '~/src/lib/manager.js' | ||
| jest.mock('~/src/lib/fetch.js') | ||
| jest.mock('~/src/config/index.js', () => ({ | ||
| config: { | ||
| get: jest.fn().mockReturnValueOnce('http://forms-manager') | ||
| } | ||
| })) | ||
|
|
||
| describe('getDefinition', () => { | ||
| it('should get the current definition if draft', async () => { | ||
| const expectedDefinition = buildDefinition() | ||
| const formId = '68a890909ab460290c289409' | ||
| jest | ||
| .mocked(getJson) | ||
| .mockResolvedValueOnce({ response: {}, body: expectedDefinition }) | ||
| const definition = await getFormDefinition( | ||
| formId, | ||
| FormStatus.Draft, | ||
| undefined | ||
| ) | ||
| expect(getJson).toHaveBeenCalledWith( | ||
| expect.objectContaining({ | ||
| href: 'http://forms-manager/forms/68a890909ab460290c289409/definition/draft' | ||
| }) | ||
| ) | ||
| expect(definition).toEqual(expectedDefinition) | ||
| }) | ||
| describe('Manager', () => { | ||
| describe('getDefinition', () => { | ||
| it('should get the current definition if draft', async () => { | ||
| const expectedDefinition = buildDefinition() | ||
| const formId = '68a890909ab460290c289409' | ||
| jest | ||
| .mocked(getJson) | ||
| .mockResolvedValueOnce({ response: {}, body: expectedDefinition }) | ||
| const definition = await getFormDefinition( | ||
| formId, | ||
| FormStatus.Draft, | ||
| undefined | ||
| ) | ||
| expect(getJson).toHaveBeenCalledWith( | ||
| expect.objectContaining({ | ||
| href: 'http://forms-manager/forms/68a890909ab460290c289409/definition/draft' | ||
| }) | ||
| ) | ||
| expect(definition).toEqual(expectedDefinition) | ||
| }) | ||
|
|
||
| it('should get the current definition if live', async () => { | ||
| const expectedDefinition = buildDefinition() | ||
| const formId = '68a890909ab460290c289409' | ||
| jest | ||
| .mocked(getJson) | ||
| .mockResolvedValueOnce({ response: {}, body: expectedDefinition }) | ||
| const definition = await getFormDefinition( | ||
| formId, | ||
| FormStatus.Live, | ||
| undefined | ||
| ) | ||
| expect(getJson).toHaveBeenCalledWith( | ||
| expect.objectContaining({ | ||
| href: 'http://forms-manager/forms/68a890909ab460290c289409/definition/' | ||
| }) | ||
| ) | ||
| expect(definition).toEqual(expectedDefinition) | ||
| }) | ||
| it('should get the current definition if live', async () => { | ||
| const expectedDefinition = buildDefinition() | ||
| const formId = '68a890909ab460290c289409' | ||
| jest | ||
| .mocked(getJson) | ||
| .mockResolvedValueOnce({ response: {}, body: expectedDefinition }) | ||
| const definition = await getFormDefinition( | ||
| formId, | ||
| FormStatus.Live, | ||
| undefined | ||
| ) | ||
| expect(getJson).toHaveBeenCalledWith( | ||
| expect.objectContaining({ | ||
| href: 'http://forms-manager/forms/68a890909ab460290c289409/definition/' | ||
| }) | ||
| ) | ||
| expect(definition).toEqual(expectedDefinition) | ||
| }) | ||
|
|
||
| it('should get a specific version if version number is provided', async () => { | ||
| const expectedDefinition = buildDefinition() | ||
| const formId = '68a890909ab460290c289409' | ||
| const versionNumber = 3 | ||
| jest | ||
| .mocked(getJson) | ||
| .mockResolvedValueOnce({ response: {}, body: expectedDefinition }) | ||
| const definition = await getFormDefinition( | ||
| formId, | ||
| FormStatus.Live, | ||
| versionNumber | ||
| ) | ||
| expect(getJson).toHaveBeenCalledWith( | ||
| expect.objectContaining({ | ||
| href: 'http://forms-manager/forms/68a890909ab460290c289409/versions/3/definition' | ||
| }) | ||
| ) | ||
| expect(definition).toEqual(expectedDefinition) | ||
| }) | ||
| it('should get a specific version if version number is provided', async () => { | ||
| const expectedDefinition = buildDefinition() | ||
| const formId = '68a890909ab460290c289409' | ||
| const versionNumber = 3 | ||
| jest | ||
| .mocked(getJson) | ||
| .mockResolvedValueOnce({ response: {}, body: expectedDefinition }) | ||
| const definition = await getFormDefinition( | ||
| formId, | ||
| FormStatus.Live, | ||
| versionNumber | ||
| ) | ||
| expect(getJson).toHaveBeenCalledWith( | ||
| expect.objectContaining({ | ||
| href: 'http://forms-manager/forms/68a890909ab460290c289409/versions/3/definition' | ||
| }) | ||
| ) | ||
| expect(definition).toEqual(expectedDefinition) | ||
| }) | ||
|
|
||
| it('should get a specific version with draft status if version number is provided', async () => { | ||
| const expectedDefinition = buildDefinition() | ||
| const formId = '68a890909ab460290c289409' | ||
| const versionNumber = 1 | ||
| jest | ||
| .mocked(getJson) | ||
| .mockResolvedValueOnce({ response: {}, body: expectedDefinition }) | ||
| const definition = await getFormDefinition( | ||
| formId, | ||
| FormStatus.Draft, | ||
| versionNumber | ||
| ) | ||
| expect(getJson).toHaveBeenCalledWith( | ||
| expect.objectContaining({ | ||
| href: 'http://forms-manager/forms/68a890909ab460290c289409/versions/1/definition' | ||
| }) | ||
| ) | ||
| expect(definition).toEqual(expectedDefinition) | ||
| }) | ||
|
|
||
| it('should handle version number 0 correctly', async () => { | ||
| const expectedDefinition = buildDefinition() | ||
| const formId = '68a890909ab460290c289409' | ||
| const versionNumber = 0 | ||
| jest | ||
| .mocked(getJson) | ||
| .mockResolvedValueOnce({ response: {}, body: expectedDefinition }) | ||
| const definition = await getFormDefinition( | ||
| formId, | ||
| FormStatus.Live, | ||
| versionNumber | ||
| ) | ||
| expect(getJson).toHaveBeenCalledWith( | ||
| expect.objectContaining({ | ||
| href: 'http://forms-manager/forms/68a890909ab460290c289409/versions/0/definition' | ||
| }) | ||
| ) | ||
| expect(definition).toEqual(expectedDefinition) | ||
| }) | ||
|
|
||
| it('should get a specific version with draft status if version number is provided', async () => { | ||
| const expectedDefinition = buildDefinition() | ||
| const formId = '68a890909ab460290c289409' | ||
| const versionNumber = 1 | ||
| jest | ||
| .mocked(getJson) | ||
| .mockResolvedValueOnce({ response: {}, body: expectedDefinition }) | ||
| const definition = await getFormDefinition( | ||
| formId, | ||
| FormStatus.Draft, | ||
| versionNumber | ||
| ) | ||
| expect(getJson).toHaveBeenCalledWith( | ||
| expect.objectContaining({ | ||
| href: 'http://forms-manager/forms/68a890909ab460290c289409/versions/1/definition' | ||
| }) | ||
| ) | ||
| expect(definition).toEqual(expectedDefinition) | ||
| it('should throw if no manager url set', async () => { | ||
| const expectedDefinition = buildDefinition() | ||
| const formId = '68a890909ab460290c289409' | ||
| jest | ||
| .mocked(getJson) | ||
| .mockResolvedValueOnce({ response: {}, body: expectedDefinition }) | ||
| const definition = await getFormDefinition( | ||
| formId, | ||
| FormStatus.Draft, | ||
| undefined | ||
| ) | ||
| expect(getJson).toHaveBeenCalledWith( | ||
| expect.objectContaining({ | ||
| href: 'http://forms-manager/forms/68a890909ab460290c289409/definition/draft' | ||
| }) | ||
| ) | ||
| expect(definition).toEqual(expectedDefinition) | ||
| }) | ||
| }) | ||
|
|
||
| it('should handle version number 0 correctly', async () => { | ||
| const expectedDefinition = buildDefinition() | ||
| const formId = '68a890909ab460290c289409' | ||
| const versionNumber = 0 | ||
| jest | ||
| .mocked(getJson) | ||
| .mockResolvedValueOnce({ response: {}, body: expectedDefinition }) | ||
| const definition = await getFormDefinition( | ||
| formId, | ||
| FormStatus.Live, | ||
| versionNumber | ||
| ) | ||
| expect(getJson).toHaveBeenCalledWith( | ||
| expect.objectContaining({ | ||
| href: 'http://forms-manager/forms/68a890909ab460290c289409/versions/0/definition' | ||
| }) | ||
| ) | ||
| expect(definition).toEqual(expectedDefinition) | ||
| describe('getMetadata', () => { | ||
| it('should get the metadata', async () => { | ||
| const expectedMetadata = buildMetaData() | ||
| const formId = '68a890909ab460290c289409' | ||
| jest | ||
| .mocked(getJson) | ||
| .mockResolvedValueOnce({ response: {}, body: expectedMetadata }) | ||
| const metadata = await getFormMetadata(formId) | ||
| expect(getJson).toHaveBeenCalledWith( | ||
| expect.objectContaining({ | ||
| href: 'http://forms-manager/forms/68a890909ab460290c289409' | ||
| }) | ||
| ) | ||
| expect(metadata).toEqual(expectedMetadata) | ||
| }) | ||
| }) | ||
| }) |
This file contains hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this
eslint-disable-next-lineneeded? Shouldn't config.get('managerUrl') bestring | undefined?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copied from previous method. Unfortunately the types from config.get() aren't correct (for all config items) so coerced the assignment. Let me know if you're happy with that or if you want me to do something more drastic with the config.get stuff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for sorting that Jez 🎉