-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(react-components): add snapshot tests
- Loading branch information
1 parent
e512db5
commit 49504a6
Showing
47 changed files
with
439 additions
and
585 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
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,11 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
const TEST_PAGE = '/iframe.html?id=widgets-base-chart--default-base-chart'; | ||
|
||
test('line chart default settings', async ({ page }) => { | ||
await page.goto(TEST_PAGE); | ||
const LineChart = page.getByTestId('base-chart-container'); | ||
|
||
// screenshot comparison with everything showing | ||
await expect(LineChart).toHaveScreenshot('line-chart-default-settings.png'); | ||
}); |
Binary file added
BIN
+21.5 KB
...s/chart/chart.spec.ts-snapshots/line-chart-default-settings-chromium-darwin.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
+21.5 KB
...ts/chart/chart.spec.ts-snapshots/line-chart-default-settings-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.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,28 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
const TEST_IFRAME = '#storybook-preview-iframe'; | ||
const TEST_PAGE = '/?path=/story/widgets-gauge-gauge-base--main'; | ||
const TEST_DATA_ID = 'gauge-base-component'; | ||
const TEST_PAGE = '/iframe.html?id=widgets-gauge--default-gauge'; | ||
const TEST_PAGE_HIDDEN_SETTINGS = | ||
'/iframe.html?id=widgets-gauge--hidden-settings-gauge'; | ||
const THRESHOLD_TEST_PAGE = '/iframe.html?id=widgets-gauge--threshold-gauge'; | ||
|
||
test('guage', async ({ page }) => { | ||
test('default guage', async ({ page }) => { | ||
await page.goto(TEST_PAGE); | ||
await page.evaluate(() => document.fonts.ready); | ||
const frame = page.frameLocator(TEST_IFRAME); // Need to go into frame otherwise the `locator` won't locate the selection. | ||
const GaugeComponent = frame.getByTestId('gauge-base-component'); | ||
const GaugeError = frame.getByTestId('gauge-base-component-error'); | ||
|
||
// Gauge component should be visible | ||
await expect(GaugeComponent).toBeVisible(); | ||
|
||
// Gauge should displays 'Uncertain Quality' for 'UNCERTAIN' quality | ||
await page.goto(`${TEST_PAGE}&args=propertyPoint.quality:UNCERTAIN`); | ||
await expect(GaugeComponent).toContainText('Uncertain Quality'); | ||
|
||
// Gauge should displays 'Bad Quality' for 'BAD' quality | ||
await page.goto(`${TEST_PAGE}&args=propertyPoint.quality:BAD`); | ||
await expect(GaugeComponent).toContainText('Bad Quality'); | ||
|
||
// Gauge should display error text when error is provided | ||
const errorMsg = 'No Network'; | ||
await page.goto(`${TEST_PAGE}&args=error:${errorMsg}`); | ||
await expect(GaugeError).toContainText(errorMsg); | ||
|
||
// Gauge default settings | ||
const gaugeValueElement = GaugeComponent.getByText('82'); | ||
const gaugeUnitElement = GaugeComponent.getByText('%'); | ||
const gaugeOutsideArcLabelelement = GaugeComponent.getByText('100'); | ||
await page.goto(`${TEST_PAGE}`); | ||
await expect(GaugeComponent).not.toContainText('Windmill'); | ||
await expect(GaugeComponent).toContainText('%'); | ||
await expect(gaugeValueElement).toHaveCSS('font-size', '40px'); | ||
await expect(gaugeUnitElement).toHaveCSS('font-size', '16px'); | ||
await expect(gaugeOutsideArcLabelelement).toHaveCSS('font-size', '12px'); | ||
await expect(GaugeComponent).toContainText('0'); | ||
await expect(GaugeComponent).toContainText('100'); | ||
|
||
// Gauge settings should display name when showName is true | ||
await page.goto(`${TEST_PAGE}&args=settings.showName:true`); | ||
await expect(GaugeComponent).toContainText('Windmill'); | ||
|
||
// Gauge settings should not display unit when showUnit is false | ||
await page.goto(`${TEST_PAGE}&args=settings.showUnit:false`); | ||
await expect(GaugeComponent).not.toContainText('%'); | ||
|
||
// Gauge settings should disaplay the font size of 50 for value text | ||
await page.goto(`${TEST_PAGE}&args=settings.fontSize:50`); | ||
await expect(gaugeValueElement).toHaveCSS('font-size', '50px'); | ||
|
||
// Gauge settings should disaplay the unit size of 20 for unit text | ||
await page.goto(`${TEST_PAGE}&args=settings.unitFontSize:20`); | ||
await expect(gaugeUnitElement).toHaveCSS('font-size', '20px'); | ||
|
||
// Gauge settings should disaplay the labelFontSize size of 16 for label text | ||
await page.goto(`${TEST_PAGE}&args=settings.labelFontSize:16`); | ||
await expect(gaugeOutsideArcLabelelement).toHaveCSS('font-size', '16px'); | ||
const chart = page.getByTestId(TEST_DATA_ID); | ||
// screenshot comparison | ||
await expect(chart).toHaveScreenshot('gauge-default-settings.png'); | ||
}); | ||
|
||
// Gauge settings should change the yMin value to 15 | ||
await page.goto(`${TEST_PAGE}&args=settings.yMin:15`); | ||
await expect(GaugeComponent).toContainText('15'); | ||
test('hidden guage settings', async ({ page }) => { | ||
await page.goto(TEST_PAGE_HIDDEN_SETTINGS); | ||
const chart = page.getByTestId(TEST_DATA_ID); | ||
// screenshot comparison | ||
await expect(chart).toHaveScreenshot('gauge-hidden-settings.png'); | ||
}); | ||
|
||
// Gauge settings should change the yMax value to 200 | ||
await page.goto(`${TEST_PAGE}&args=settings.yMax:200`); | ||
await expect(GaugeComponent).toContainText('200'); | ||
test('guage with threshold', async ({ page }) => { | ||
await page.goto(THRESHOLD_TEST_PAGE); | ||
const chart = page.getByTestId(TEST_DATA_ID); | ||
// screenshot comparison | ||
await expect(chart).toHaveScreenshot('gauge-with-thresholds.png'); | ||
}); |
Binary file added
BIN
+17.7 KB
.../tests/gauge/gauge.spec.ts-snapshots/gauge-default-settings-chromium-darwin.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
+17.7 KB
...e/tests/gauge/gauge.spec.ts-snapshots/gauge-default-settings-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
+15.7 KB
...e/tests/gauge/gauge.spec.ts-snapshots/gauge-hidden-settings-chromium-darwin.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
+15.7 KB
...2e/tests/gauge/gauge.spec.ts-snapshots/gauge-hidden-settings-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
+30.9 KB
...e/tests/gauge/gauge.spec.ts-snapshots/gauge-with-thresholds-chromium-darwin.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
+30.9 KB
...2e/tests/gauge/gauge.spec.ts-snapshots/gauge-with-thresholds-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.
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,38 +1,30 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
const TEST_PAGE = '/?path=/story/widgets-kpi-kpi-base--main'; | ||
const TEST_IFRAME = '#storybook-preview-iframe'; | ||
const TEST_PAGE = '/iframe.html?id=widgets-kpi--default-kpi'; | ||
const TEST_PAGE_HIDDEN_SETTINGS = | ||
'/iframe.html?id=widgets-kpi--kpi-hidden-settings'; | ||
const TEST_PAGE_THRESHOLD = '/iframe.html?id=widgets-kpi--kpi-thresholds'; | ||
|
||
test('kpi', async ({ page }) => { | ||
await page.goto(TEST_PAGE); | ||
await page.evaluate(() => document.fonts.ready); | ||
const frame = page.frameLocator(TEST_IFRAME); // Need to go into frame otherwise the `locator` won't locate the selection. | ||
const KPIComponent = frame.getByTestId('kpi-base-component'); | ||
const KPIError = frame.getByTestId('kpi-error-component'); | ||
const KPIComponent = page.getByTestId('kpi-base-component'); | ||
|
||
// KPI will always show value | ||
await expect(KPIComponent).toContainText('100'); | ||
|
||
// unit will display | ||
const unit = 'mph'; | ||
await page.goto(`${TEST_PAGE}&args=unit:${unit}`); | ||
await expect(KPIComponent).toContainText(unit); | ||
// screenshot comparison with everything showing | ||
await expect(KPIComponent).toHaveScreenshot('kpi-default-settings.png'); | ||
}); | ||
|
||
// name will display | ||
const name = 'windmill-name'; | ||
await page.goto(`${TEST_PAGE}&args=name:${name}`); | ||
await expect(KPIComponent).toContainText(name); | ||
test('kpi hidden settings', async ({ page }) => { | ||
await page.goto(TEST_PAGE_HIDDEN_SETTINGS); | ||
const KPIComponent = page.getByTestId('kpi-base-component'); | ||
|
||
// displays as loading | ||
await page.goto(`${TEST_PAGE}&args=isLoading:true`); | ||
await expect(KPIComponent).toContainText('-'); | ||
// screenshot comparison with everything hidden | ||
await expect(KPIComponent).toHaveScreenshot('kpi-hidden-settings.png'); | ||
}); | ||
|
||
// error will display | ||
const errorMsg = 'my-custom-error-msg'; | ||
await page.goto(`${TEST_PAGE}&args=error:${errorMsg}`); | ||
await expect(KPIError).toContainText(errorMsg); | ||
test('kpi with thresholds', async ({ page }) => { | ||
await page.goto(TEST_PAGE_THRESHOLD); | ||
const AllKPIs = page.getByTestId('mock-data-kpi-story'); | ||
|
||
// displays empty state | ||
await page.goto(`${TEST_PAGE}&args=propertyPoint:!null`); | ||
await expect(KPIComponent).toContainText('-'); | ||
// screenshot comparison | ||
await expect(AllKPIs).toHaveScreenshot('kpi-with-thresholds.png'); | ||
}); |
Binary file added
BIN
+5.58 KB
...ts/e2e/tests/kpi/kpi.spec.ts-snapshots/kpi-default-settings-chromium-darwin.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
+5.58 KB
...nts/e2e/tests/kpi/kpi.spec.ts-snapshots/kpi-default-settings-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
+1.95 KB
...nts/e2e/tests/kpi/kpi.spec.ts-snapshots/kpi-hidden-settings-chromium-darwin.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
+1.95 KB
...ents/e2e/tests/kpi/kpi.spec.ts-snapshots/kpi-hidden-settings-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
+19.5 KB
...nts/e2e/tests/kpi/kpi.spec.ts-snapshots/kpi-with-thresholds-chromium-darwin.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
+19.5 KB
...ents/e2e/tests/kpi/kpi.spec.ts-snapshots/kpi-with-thresholds-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.
39 changes: 39 additions & 0 deletions
39
packages/react-components/e2e/tests/webgl-charts/webgl-charts.spec.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,39 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
const COMPONENT_SELECTOR = '#story-container'; | ||
const TEST_PAGE_LINE_CHART = | ||
'/iframe.html?id=widgets-webgl-charts--line-chart-example'; | ||
const TEST_PAGE_BAR_CHART = | ||
'/iframe.html?id=widgets-webgl-charts--bar-chart-example'; | ||
const TEST_PAGE_SCATTER_CHART = | ||
'/iframe.html?id=widgets-webgl-charts--scatter-chart-example'; | ||
const TEST_PAGE_STATUS_TIMELINE = | ||
'/iframe.html?id=widgets-webgl-charts--status-timeline-example'; | ||
|
||
test('webgl-line-chart', async ({ page }) => { | ||
await page.goto(TEST_PAGE_LINE_CHART); | ||
const chart = page.locator(COMPONENT_SELECTOR); | ||
await expect(chart).toContainText('2000'); | ||
await expect(chart).toHaveScreenshot('line-chart.png'); | ||
}); | ||
|
||
test('webgl-bar-chart', async ({ page }) => { | ||
await page.goto(TEST_PAGE_BAR_CHART); | ||
const chart = page.locator(COMPONENT_SELECTOR); | ||
await expect(chart).toContainText('2000'); | ||
await expect(chart).toHaveScreenshot('bar-chart.png'); | ||
}); | ||
|
||
test('webgl-scatter-chart', async ({ page }) => { | ||
await page.goto(TEST_PAGE_SCATTER_CHART); | ||
const chart = page.locator(COMPONENT_SELECTOR); | ||
await expect(chart).toContainText('2000'); | ||
await expect(chart).toHaveScreenshot('scatter-chart.png'); | ||
}); | ||
|
||
test('webgl-status-timeline', async ({ page }) => { | ||
await page.goto(TEST_PAGE_STATUS_TIMELINE); | ||
const chart = page.locator(COMPONENT_SELECTOR); | ||
await expect(chart).toContainText('2000'); | ||
await expect(chart).toHaveScreenshot('status-timeline.png'); | ||
}); |
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
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
89 changes: 0 additions & 89 deletions
89
packages/react-components/stories/allChartsWithDefaultSettings/defaultCharts.stories.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.