-
Notifications
You must be signed in to change notification settings - Fork 0
/
components.test.js
59 lines (52 loc) · 1.92 KB
/
components.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { test, expect } from '@playwright/test';
import * as utils from '../helpers/utils';
import * as constants from '../helpers/constants';
test.describe.configure({ mode: 'parallel' });
constants.TEST_PARAMS.forEach(testParams => {
const COMPONENT_NAME = testParams.component_name;
const PAGE_URL = testParams.page_url;
const CHECKBOX_LABELS = testParams.checkbox_labels;
const HAS_MESSAGE_FIELD = testParams.has_message_field;
test.describe(`${COMPONENT_NAME}: `, () => {
test.beforeEach(async ({ page }) => {
await page.goto(PAGE_URL);
page.context.storyBookRoot = await utils.waitForStorybookRootToLoad(page);
});
// Test all data sets/checkbox combinations
constants.DATA_SET_VALUES.forEach(dataset => {
CHECKBOX_LABELS.forEach(checkboxLabel => {
const testTagDetails = {
tag: [
`@component-${COMPONENT_NAME.toLowerCase().replace(/ /g, '-')}`,
`@dataset-${dataset.toLowerCase().replace(/ /g, '-')}`,
`@checkbox-${checkboxLabel.toLowerCase().replace(/ /g, '-')}`,
],
};
test(
`Data Set: ${dataset} | Checkbox: ${checkboxLabel}`,
testTagDetails,
async ({ page }) => {
await utils.selectDataSet(page.context.storyBookRoot, dataset);
if (checkboxLabel === 'NO_CHECKBOX_CHANGE') {
await utils.verifyStorybookPreview(page);
return;
}
await utils.setCheckBox(
page.context.storyBookRoot,
checkboxLabel,
true,
);
await utils.verifyStorybookPreview(page);
},
);
});
});
// Test the message functionality
if (HAS_MESSAGE_FIELD) {
test('Message', async ({ page }) => {
await utils.setMessageBox(page.context.storyBookRoot, 'Test Message');
await utils.verifyStorybookPreview(page);
});
}
});
});