-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(components): number of sequences over time: add story and visual…
… tests Refs: #318
- Loading branch information
1 parent
621f06e
commit 39f923d
Showing
12 changed files
with
3,653 additions
and
3 deletions.
There are no files selected for viewing
1,702 changes: 1,702 additions & 0 deletions
1,702
components/src/preact/numberSequencesOverTime/__mockData__/oneVariantEG.json
Large diffs are not rendered by default.
Oops, something went wrong.
642 changes: 642 additions & 0 deletions
642
components/src/preact/numberSequencesOverTime/__mockData__/twoVariantsEG.json
Large diffs are not rendered by default.
Oops, something went wrong.
1,070 changes: 1,070 additions & 0 deletions
1,070
components/src/preact/numberSequencesOverTime/__mockData__/twoVariantsJN1.json
Large diffs are not rendered by default.
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
168 changes: 168 additions & 0 deletions
168
components/src/web-components/visualization/gs-number-sequences-over-time.stories.ts
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,168 @@ | ||
import { expect, fireEvent, waitFor } from '@storybook/test'; | ||
import type { Meta, StoryObj } from '@storybook/web-components'; | ||
import { html } from 'lit'; | ||
|
||
import '../app'; | ||
import './gs-number-sequences-over-time'; | ||
import { withComponentDocs } from '../../../.storybook/ComponentDocsBlock'; | ||
import { AGGREGATED_ENDPOINT, LAPIS_URL } from '../../constants'; | ||
import oneVariantEG from '../../preact/numberSequencesOverTime/__mockData__/oneVariantEG.json'; | ||
import twoVariantsEG from '../../preact/numberSequencesOverTime/__mockData__/twoVariantsEG.json'; | ||
import twoVariantsJN1 from '../../preact/numberSequencesOverTime/__mockData__/twoVariantsJN1.json'; | ||
import type { NumberSequencesOverTimeProps } from '../../preact/numberSequencesOverTime/number-sequences-over-time'; | ||
import { withinShadowRoot } from '../withinShadowRoot.story'; | ||
|
||
const codeExample = String.raw` | ||
<gs-number-sequences-over-time | ||
lapisFilter='[{ "displayName": "EG", "lapisFilter": { "country": "USA", "pangoLineage": "EG*" }}, { "displayName": "JN.1", "lapisFilter": { "country": "USA", "pangoLineage": "JN.1*" }}]' | ||
lapisDateField="date" | ||
views='["bar", "line", "table"]' | ||
headline="Number of sequences of time" | ||
width="100%" | ||
height="700px" | ||
granularity="month" | ||
smoothingWindow="0" | ||
pageSize="10" | ||
></gs-number-sequences-over-time>`; | ||
|
||
const meta: Meta<NumberSequencesOverTimeProps> = { | ||
title: 'Visualization/Number sequences over time', | ||
component: 'gs-number-sequences-over-time', | ||
argTypes: { | ||
granularity: { | ||
options: ['day', 'week', 'month', 'year'], | ||
control: { type: 'radio' }, | ||
}, | ||
views: { | ||
options: ['bar', 'line', 'table'], | ||
control: { type: 'check' }, | ||
}, | ||
pageSize: { control: 'object' }, | ||
}, | ||
parameters: withComponentDocs({ | ||
componentDocs: { | ||
opensShadowDom: true, | ||
expectsChildren: false, | ||
codeExample, | ||
}, | ||
}), | ||
tags: ['autodocs'], | ||
}; | ||
|
||
export default meta; | ||
|
||
const Template: StoryObj<NumberSequencesOverTimeProps> = { | ||
render: (args) => html` | ||
<gs-app lapis="${LAPIS_URL}"> | ||
<gs-number-sequences-over-time | ||
.lapisFilter=${args.lapisFilter} | ||
.lapisDateField=${args.lapisDateField} | ||
.views=${args.views} | ||
.width=${args.width} | ||
.height=${args.height} | ||
.headline=${args.headline} | ||
.granularity=${args.granularity} | ||
.smoothingWindow=${args.smoothingWindow} | ||
.pageSize=${args.pageSize} | ||
></gs-number-sequences-over-time> | ||
</gs-app> | ||
`, | ||
args: { | ||
views: ['bar', 'line', 'table'], | ||
lapisFilter: [ | ||
{ displayName: 'EG', lapisFilter: { country: 'USA', pangoLineage: 'EG*', dateFrom: '2022-12-01' } }, | ||
], | ||
lapisDateField: 'date', | ||
width: '100%', | ||
height: '700px', | ||
headline: 'Number of sequences of time', | ||
smoothingWindow: 0, | ||
granularity: 'month', | ||
pageSize: 10, | ||
}, | ||
parameters: { | ||
fetchMock: { | ||
mocks: [ | ||
{ | ||
matcher: { | ||
name: 'aggregated', | ||
url: AGGREGATED_ENDPOINT, | ||
body: { | ||
country: 'USA', | ||
pangoLineage: 'EG*', | ||
dateFrom: '2022-12-01', | ||
fields: ['date'], | ||
}, | ||
}, | ||
response: { | ||
status: 200, | ||
body: oneVariantEG, | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
}; | ||
|
||
export const OneDatasetTable: StoryObj<NumberSequencesOverTimeProps> = { | ||
...Template, | ||
play: async ({ canvasElement }) => { | ||
const canvas = await withinShadowRoot(canvasElement, 'gs-number-sequences-over-time'); | ||
|
||
await waitFor(() => expect(canvas.getByRole('button', { name: 'Table' })).toBeInTheDocument()); | ||
|
||
await fireEvent.click(canvas.getByRole('button', { name: 'Table' })); | ||
}, | ||
}; | ||
|
||
export const TwoDatasets: StoryObj<NumberSequencesOverTimeProps> = { | ||
...Template, | ||
args: { | ||
...Template.args, | ||
lapisFilter: [ | ||
{ | ||
displayName: 'EG until 2023-06', | ||
lapisFilter: { country: 'USA', pangoLineage: 'EG*', dateTo: '2023-06-30' }, | ||
}, | ||
{ displayName: 'JN.1', lapisFilter: { country: 'USA', pangoLineage: 'JN.1*', dateFrom: '2023-01-01' } }, | ||
], | ||
}, | ||
parameters: { | ||
fetchMock: { | ||
mocks: [ | ||
{ | ||
matcher: { | ||
name: 'aggregatedEG', | ||
url: AGGREGATED_ENDPOINT, | ||
body: { | ||
country: 'USA', | ||
pangoLineage: 'EG*', | ||
dateTo: '2023-06-30', | ||
fields: ['date'], | ||
}, | ||
}, | ||
response: { | ||
status: 200, | ||
body: twoVariantsEG, | ||
}, | ||
}, | ||
{ | ||
matcher: { | ||
name: 'aggregatedJN.1', | ||
url: AGGREGATED_ENDPOINT, | ||
body: { | ||
country: 'USA', | ||
pangoLineage: 'JN.1*', | ||
dateFrom: '2023-01-01', | ||
fields: ['date'], | ||
}, | ||
}, | ||
response: { | ||
status: 200, | ||
body: twoVariantsJN1, | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
}; |
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
Binary file added
BIN
+31 KB
...izatio-d679d-me--one-dataset-table-should-match-screenshot-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+49 KB
...lizatio-d679d-me--one-dataset-table-should-match-screenshot-1-firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+13.6 KB
...izatio-ffd47-er-time--two-datasets-should-match-screenshot-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+28.4 KB
...lizatio-ffd47-er-time--two-datasets-should-match-screenshot-1-firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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