Skip to content

Commit

Permalink
fixup! fixup! fixup! fixup! test: ci added
Browse files Browse the repository at this point in the history
  • Loading branch information
niktverd committed Sep 26, 2024
1 parent 4ad6aff commit 37bf5a8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pr-playwright-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ jobs:
AWS_SECRET_ACCESS_KEY: ${{ secrets.STORYBOOK_S3_SECRET_KEY }}
AWS_DEFAULT_REGION: ru-central1
AWS_EC2_METADATA_DISABLED: true
run: aws s3 cp playwright-report s3://playwright-reports/page-constructor/pulls/${{ steps.pr.outputs.id }}/ --endpoint-url=https://storage.yandexcloud.net --recursive
run: aws s3 cp playwright-report s3://playwright-reports/blog-constructor/pulls/${{ steps.pr.outputs.id }}/ --endpoint-url=https://storage.yandexcloud.net --recursive
shell: bash
- name: Create Comment
uses: marocchino/sticky-pull-request-comment@v2
with:
GITHUB_TOKEN: ${{ secrets.GRAVITY_UI_BOT_GITHUB_TOKEN }}
number: ${{ steps.pr.outputs.id }}
header: playwright test
message: '[Playwright Test Component](https://storage.yandexcloud.net/playwright-reports/page-constructor/pulls/${{ steps.pr.outputs.id }}/index.html) is ready.'
message: '[Playwright Test Component](https://storage.yandexcloud.net/playwright-reports/blog-constructor/pulls/${{ steps.pr.outputs.id }}/index.html) is ready.'
15 changes: 4 additions & 11 deletions playwright/core/expectScreenshotFixture.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import {expect} from '@playwright/experimental-ct-react';
import type {JSHandle, Locator, PageScreenshotOptions} from '@playwright/test';
import {isFunction} from 'lodash';
import type {Locator, PageScreenshotOptions} from '@playwright/test';

import {DEFAULT_MOUNT_TEST_DELAY} from './constants';
import type {PlaywrightFixture} from './types';

interface CaptureScreenshotParams extends PageScreenshotOptions {
screenshotName?: string;
component?: Locator;
waitingFunction?: JSHandle<boolean>;
skipTheme?: 'light' | 'dark';
}

Expand All @@ -24,11 +22,10 @@ export const expectScreenshotFixture: PlaywrightFixture<ExpectScreenshotFixture>
const expectScreenshot: ExpectScreenshotFixture = async ({
component,
screenshotName,
waitingFunction,
skipTheme,
...pageScreenshotOptions
} = {}) => {
const captureScreenshot = async (waitingFunctionLocal?: JSHandle<boolean>) => {
const captureScreenshot = async () => {
const locators = await page.locator('//img').all();
const promises = locators.map((locator) =>
locator.evaluate(
Expand All @@ -39,10 +36,6 @@ export const expectScreenshotFixture: PlaywrightFixture<ExpectScreenshotFixture>
);
await Promise.all(promises);

if (waitingFunctionLocal && isFunction(waitingFunctionLocal)) {
await waitingFunctionLocal();
}

return (component || page.locator('.playwright-wrapper-test')).screenshot({
animations: 'disabled',
...pageScreenshotOptions,
Expand All @@ -52,7 +45,7 @@ export const expectScreenshotFixture: PlaywrightFixture<ExpectScreenshotFixture>
const nameScreenshot = testInfo.titlePath.slice(1).join(' ');

if (skipTheme !== 'light') {
expect(await captureScreenshot(waitingFunction)).toMatchSnapshot({
expect(await captureScreenshot()).toMatchSnapshot({
name: `${screenshotName || nameScreenshot} light.png`,
});
}
Expand All @@ -62,7 +55,7 @@ export const expectScreenshotFixture: PlaywrightFixture<ExpectScreenshotFixture>

await page.waitForTimeout(DEFAULT_MOUNT_TEST_DELAY);

expect(await captureScreenshot(waitingFunction)).toMatchSnapshot({
expect(await captureScreenshot()).toMatchSnapshot({
name: `${screenshotName || nameScreenshot} dark.png`,
});
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/playwright-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -euo pipefail
IMAGE_NAME="mcr.microsoft.com/playwright"
IMAGE_TAG="v1.45.3-jammy" # This version have to be synchronized with playwright version from package.json

NODE_MODULES_CACHE_DIR="$HOME/.cache/page-constructor-playwright-docker-node-modules"
NODE_MODULES_CACHE_DIR="$HOME/.cache/blog-constructor-playwright-docker-node-modules"

command_exists() {
command -v "$1" >/dev/null 2>&1
Expand Down

0 comments on commit 37bf5a8

Please sign in to comment.