-
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.
✅ [open-formulieren/open-forms#180] Test stop button
- Loading branch information
1 parent
dc4111f
commit 4794cb2
Showing
12 changed files
with
221 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export {BASE_URL} from './base'; | ||
export {buildForm, mockFormGet} from './forms'; | ||
export {buildSubmission} from './submissions'; | ||
export {buildSubmission, mockGetAnalyticsToolConfig} from './submissions'; |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import {ArgTypes, Canvas, Meta, Story} from '@storybook/blocks'; | ||
|
||
import * as AbortionButtonStories from './AbortionButton.stories'; | ||
|
||
<Meta of={AbortionButtonStories} /> | ||
|
||
# Abortion Button | ||
|
||
The abortion button can be used to abort a submission whether the user is authenticated or not. | ||
|
||
- If the user is authenticated, then the button will have the text 'Log out' to comply with Logius | ||
directives that whenever a user is logged in with DigiD a 'Log out' option must be available. | ||
- If the analytics tool 'GovMetric' is enabled, aborting the submission will open a new window where | ||
the user can give feedback about why they decided to not fill the form until the end. | ||
|
||
<Canvas> | ||
<Story of={AbortionButtonStories.Authenticated} /> | ||
<Story of={AbortionButtonStories.GovMetricEnabled} /> | ||
<Story of={AbortionButtonStories.AuthenticatedAndGovmetric} /> | ||
<Story of={AbortionButtonStories.NotAuthenticatedNoGovMetric} /> | ||
</Canvas> | ||
|
||
## Props | ||
|
||
<ArgTypes of={AbortionButtonStories} /> |
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 |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import {expect} from '@storybook/jest'; | ||
import {waitFor, within} from '@storybook/testing-library'; | ||
|
||
import {AnalyticsToolsDecorator} from 'story-utils/decorators'; | ||
|
||
import AbortionButton from './AbortionButton'; | ||
|
||
export default { | ||
title: 'Private API / Abortion button', | ||
component: AbortionButton, | ||
decorators: [AnalyticsToolsDecorator], | ||
}; | ||
|
||
export const Authenticated = { | ||
args: { | ||
isAuthenticated: true, | ||
}, | ||
play: async ({canvasElement}) => { | ||
const canvas = within(canvasElement); | ||
|
||
await waitFor(async () => { | ||
const abortButton = await canvas.queryByRole('button', {name: 'Uitloggen'}); | ||
await expect(abortButton).toBeVisible(); | ||
}); | ||
}, | ||
}; | ||
|
||
export const GovMetricEnabled = { | ||
args: { | ||
isAuthenticated: false, | ||
analyticsToolsParams: { | ||
govmetricSourceId: '1234', | ||
govmetricSecureGuid: '', | ||
enableGovmetricAnalytics: true, | ||
}, | ||
}, | ||
play: async ({canvasElement}) => { | ||
const canvas = within(canvasElement); | ||
|
||
await waitFor(async () => { | ||
const abortButton = await canvas.queryByRole('button', {name: 'Abort submission'}); | ||
await expect(abortButton).toBeVisible(); | ||
}); | ||
}, | ||
}; | ||
|
||
export const AuthenticatedAndGovmetric = { | ||
args: { | ||
isAuthenticated: true, | ||
analyticsToolsParams: { | ||
govmetricSourceId: '1234', | ||
govmetricSecureGuid: '', | ||
enableGovmetricAnalytics: true, | ||
}, | ||
}, | ||
play: async ({canvasElement}) => { | ||
const canvas = within(canvasElement); | ||
|
||
await waitFor(async () => { | ||
const abortButton = await canvas.queryByRole('button', {name: 'Uitloggen'}); | ||
await expect(abortButton).toBeVisible(); | ||
}); | ||
}, | ||
}; | ||
|
||
export const NotAuthenticatedNoGovMetric = { | ||
args: { | ||
isAuthenticated: false, | ||
}, | ||
play: async ({canvasElement}) => { | ||
const canvas = within(canvasElement); | ||
|
||
await waitFor(async () => { | ||
const abortButton = await canvas.queryByRole('button'); | ||
await expect(abortButton).toBeNull(); | ||
}); | ||
}, | ||
}; |
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
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import {buildGovMetricUrl} from './utils'; | ||
|
||
describe('Test analytics utils', () => { | ||
test('Test build URL without GUID', () => { | ||
const url = buildGovMetricUrl('1234', 'form-slug'); | ||
|
||
expect(url).toEqual('https://websurveys2.govmetric.com/theme/kf/1234?Q_Formid=form-slug'); | ||
}); | ||
|
||
test('Test build URL with GUID', () => { | ||
const url = buildGovMetricUrl('1234', 'form-slug', '4321'); | ||
|
||
expect(url).toEqual( | ||
'https://websurveys2.govmetric.com/theme/kf/1234?Q_Formid=form-slug&GUID=4321' | ||
); | ||
}); | ||
}); |
Oops, something went wrong.