-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! Feat(web): Introduce Drawer component #DS-1580
- Loading branch information
Showing
10 changed files
with
90 additions
and
2 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,88 @@ | ||
/* eslint-disable no-console -- we want to log when test fails */ | ||
import { isTesting as isTestingEnvironment } from '@lmc-eu/spirit-common/constants/environments'; | ||
import { test, Page } from '@playwright/test'; | ||
import { formatPackageName, getServerUrl, hideFromVisualTests, waitForPageLoad, takeScreenshot } from '../../helpers'; | ||
|
||
type TestConfig = { | ||
componentsDir: string; | ||
packageName: string; | ||
componentName: string; | ||
}; | ||
|
||
const runComponentCompareTests = ({ componentsDir, packageName, componentName }: TestConfig): void => { | ||
if (!packageName) return; | ||
|
||
const formattedPackageName = formatPackageName(packageName); | ||
|
||
test.describe(`Test opened Drawer`, () => { | ||
test(`Test ${componentName} component in ${formattedPackageName} package`, async ({ page }: { page: Page }) => { | ||
try { | ||
const url = getServerUrl(packageName); | ||
await page.goto(`${url}${componentsDir}/${componentName}/`); | ||
await waitForPageLoad(page); | ||
await hideFromVisualTests(page); | ||
await runDrawerTests(page, componentName); | ||
} catch (error) { | ||
console.error(`Test for demo ${formattedPackageName} component ${componentName} failed. ${error}`); | ||
throw error; | ||
} | ||
}); | ||
}); | ||
}; | ||
|
||
const runDrawerTests = async (page: Page, componentName: string): Promise<void> => { | ||
// open drawer on the right side, close with backdrop click | ||
await page.click('[data-test-id="drawer-open-button"]'); | ||
await takeScreenshot(page, `${componentName}-right-backdrop-click-`); | ||
await page.locator('body').click({ position: { x: 0, y: 0 } }); | ||
|
||
// open drawer on the left side, close with backdrop click | ||
await page.click('[id="drawer-alignment-left"]'); | ||
await page.click('[data-test-id="drawer-open-button"]'); | ||
await takeScreenshot(page, `${componentName}-left-backdrop-click`); | ||
await page.locator('body').click({ position: { x: 300, y: 0 } }); | ||
|
||
// open drawer on the right side, close with close button | ||
await page.click('[id="drawer-alignment-right"]'); | ||
await page.click('[data-test-id="drawer-open-button"]'); | ||
await takeScreenshot(page, `${componentName}-right-close-button`); | ||
await page.click('dialog[open] button'); | ||
|
||
// open drawer on the left side, close with close button | ||
await page.click('[id="drawer-alignment-left"]'); | ||
await page.click('[data-test-id="drawer-open-button"]'); | ||
await takeScreenshot(page, `${componentName}-left-close-button`); | ||
await page.click('dialog[open] button'); | ||
|
||
// open drawer on the right side, close with escape keys | ||
await page.click('[id="drawer-alignment-right"]'); | ||
await page.click('[data-test-id="drawer-open-button"]'); | ||
await takeScreenshot(page, `${componentName}-right-escape-key`); | ||
await page.keyboard.press('Escape'); | ||
|
||
// open drawer on the left side, close with escape keys | ||
await page.click('[id="drawer-alignment-left"]'); | ||
await page.click('[data-test-id="drawer-open-button"]'); | ||
await takeScreenshot(page, `${componentName}-left-escape-key`); | ||
await page.keyboard.press('Escape'); | ||
|
||
// screenshot of closed drawer | ||
await takeScreenshot(page, `${componentName}-closed-drawer`, { fullPage: true }); | ||
}; | ||
|
||
const componentName = 'Drawer'; | ||
|
||
const testConfigs: TestConfig[] = [ | ||
{ | ||
componentName, | ||
componentsDir: '/src/scss/components', | ||
packageName: 'web', | ||
}, | ||
{ | ||
componentName, | ||
componentsDir: '/src/components', | ||
packageName: 'web-react', | ||
}, | ||
]; | ||
|
||
testConfigs.forEach(runComponentCompareTests); |
Binary file added
BIN
+26.3 KB
...s/demo-drawer-compare.spec.ts-snapshots/drawer-closed-drawer-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
+9.29 KB
...-drawer-compare.spec.ts-snapshots/drawer-left-backdrop-click-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
+9.29 KB
...mo-drawer-compare.spec.ts-snapshots/drawer-left-close-button-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
+9.29 KB
...demo-drawer-compare.spec.ts-snapshots/drawer-left-escape-key-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
+29.1 KB
...rawer-compare.spec.ts-snapshots/drawer-right-backdrop-click--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
+29.1 KB
...o-drawer-compare.spec.ts-snapshots/drawer-right-close-button-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
+29.1 KB
...emo-drawer-compare.spec.ts-snapshots/drawer-right-escape-key-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 modified
BIN
+12.3 KB
(190%)
tests/e2e/demo-components-compare.spec.ts-snapshots/drawer-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.