Skip to content

Commit 0d5205a

Browse files
committed
chore: add screenshot tests
1 parent 02430bb commit 0d5205a

File tree

40 files changed

+148
-319
lines changed

40 files changed

+148
-319
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.cache-playwright*

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,5 @@ lib/
2929
/blob-report/
3030
/playwright/.cache/
3131
coverage/
32+
33+
.cache-playwright*

package-lock.json

Lines changed: 57 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
"jest": "^29.7.0",
7676
"lodash": "~4.17.13",
7777
"nano-staged": "^0.8.0",
78+
"playwright": "^1.52.0",
7879
"postcss": "^8.4.14",
7980
"prettier": "^2.8.8",
8081
"react": "^18.3.1",

playwright.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ export default defineConfig({
2626
trace: 'on-first-retry',
2727
headless: true,
2828
testIdAttribute: 'data-qa',
29-
ctCacheDir: __dirname + '/.cache-playwright',
29+
ctCacheDir: process.env.DOCKER_CI ? './.cache-playwright.docker' : './.cache-playwright',
30+
viewport: {width: 1280, height: 720},
3031
},
3132

3233
/* Configure projects for major browsers */

playwright/core/expectScreenshotFixture.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@ export const expectScreenshotFixture: PlaywrightFixture<ExpectScreenshotFixture>
1919
...pageScreenshotOptions
2020
} = defaultParams) => {
2121
const captureScreenshot = async () => {
22+
await page.waitForLoadState('networkidle');
2223
return (component || page.locator('.playwright-wrapper-test')).screenshot({
2324
animations: 'disabled',
2425
...pageScreenshotOptions,
2526
});
2627
};
2728

29+
await page.mouse.move(0, 0);
30+
2831
//console.log({nameScreenshot, nameSuffix, testInfo: testInfo});
2932

3033
// Wait for loading of all the images

playwright/docker-run.sh

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ else
1717
fi
1818

1919
IMAGE_NAME="mcr.microsoft.com/playwright"
20-
IMAGE_TAG="v"${VERSION}"-focal"
20+
IMAGE_TAG="v"${VERSION}"-noble"
2121
PW_VERSION=$(echo $IMAGE_TAG | awk -F "-" '{print $1}' | sed -e 's/^v//')
2222

2323
NAME=$(node -e 'console.log(require("./package.json").name)')
@@ -29,6 +29,15 @@ command_exists() {
2929
command -v "$1" >/dev/null 2>&1
3030
}
3131

32+
if command_exists docker; then
33+
CONTAINER_TOOL="docker"
34+
elif command_exists podman; then
35+
CONTAINER_TOOL="podman"
36+
else
37+
echo "Neither Docker nor Podman is installed on the system."
38+
exit 1
39+
fi
40+
3241
run_command() {
3342
toRun="$@"
3443

@@ -46,11 +55,14 @@ run_command() {
4655
echo Env file is found:
4756
echo " $useEnvFile"
4857
else
58+
useEnvFile=
4959
echo "Use the file to provide environment variables:"
5060
echo " $envFile"
5161
fi
5262

53-
$CONTAINER_TOOL run --rm --network host -it -w /work \
63+
$CONTAINER_TOOL run --rm --network host -it \
64+
-e DOCKER_CI=1 \
65+
-w /work \
5466
-v $(pwd):/work \
5567
-v "$NODE_MODULES_CACHE_DIR/node_modules:/work/node_modules" \
5668
-v "$NODE_MODULES_CACHE_DIR/.cache-playwright:/work/.cache-playwright" \
@@ -59,15 +71,6 @@ run_command() {
5971
/bin/bash -c "umask 0000; $toRun"
6072
}
6173

62-
if command_exists docker; then
63-
CONTAINER_TOOL="docker"
64-
elif command_exists podman; then
65-
CONTAINER_TOOL="podman"
66-
else
67-
echo "Neither Docker nor Podman is installed on the system."
68-
exit 1
69-
fi
70-
7174
action=${1:-test}
7275

7376
if [ "$action" = "clear-cache" ]; then

playwright/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {beforeMount} from '@playwright/experimental-ct-react/hooks';
44
import {MobileProvider, ThemeProvider, Toaster, ToasterProvider} from '@gravity-ui/uikit';
55

66
import '@gravity-ui/uikit/styles/styles.scss';
7+
import '@gravity-ui/unipika/styles/unipika.scss';
78

89
const toaster = new Toaster();
910

Loading
Loading

0 commit comments

Comments
 (0)