Skip to content

Commit aba9dc8

Browse files
authored
test: visual tests (#216)
1 parent 4f4de24 commit aba9dc8

File tree

89 files changed

+2393
-211
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+2393
-211
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ node_modules
33
/build
44
/storybook-static
55
/server
6+
7+
/playwright/playwright/.cache/

.github/workflows/playwright.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Playwright Tests
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
test:
8+
name: Test component
9+
runs-on: ubuntu-latest
10+
container:
11+
image: mcr.microsoft.com/playwright:v1.45.3-jammy
12+
steps:
13+
- uses: actions/checkout@v3
14+
- uses: actions/setup-node@v3
15+
with:
16+
node-version: 18
17+
- name: Install dependencies
18+
run: npm ci
19+
- name: Run Playwright tests
20+
run: npm run playwright
21+
env:
22+
CI: 'true'
23+
- name: Upload Playwright playwright report to GitHub Actions Artifacts
24+
if: always()
25+
uses: actions/upload-artifact@v3
26+
with:
27+
name: playwright-report
28+
path: ./playwright-report
29+
retention-days: 1
30+
- name: Save PR ID
31+
if: always()
32+
run: |
33+
pr="${{ github.event.pull_request.number }}"
34+
echo $pr > ./pr-id.txt
35+
shell: bash
36+
- name: Create PR Artifact
37+
if: always()
38+
uses: actions/upload-artifact@v3
39+
with:
40+
name: pr
41+
path: ./pr-id.txt
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: PR Playwright Report
2+
3+
on:
4+
workflow_run:
5+
workflows: ['Playwright Tests']
6+
types:
7+
- completed
8+
9+
jobs:
10+
comment:
11+
name: Upload Playwright report to s3
12+
if: github.event.workflow_run.event == 'pull_request'
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Download Artifacts
16+
uses: dawidd6/action-download-artifact@v2
17+
with:
18+
workflow: ${{ github.event.workflow_run.workflow_id }}
19+
run_id: ${{ github.event.workflow_run.id }}
20+
- name: Extract PR Number
21+
id: pr
22+
run: echo "::set-output name=id::$(<pr/pr-id.txt)"
23+
shell: bash
24+
- name: Upload
25+
env:
26+
AWS_ACCESS_KEY_ID: ${{ secrets.STORYBOOK_S3_KEY_ID }}
27+
AWS_SECRET_ACCESS_KEY: ${{ secrets.STORYBOOK_S3_SECRET_KEY }}
28+
AWS_DEFAULT_REGION: ru-central1
29+
AWS_EC2_METADATA_DISABLED: true
30+
run: aws s3 cp playwright-report s3://playwright-reports/blog-constructor/pulls/${{ steps.pr.outputs.id }}/ --endpoint-url=https://storage.yandexcloud.net --recursive
31+
shell: bash
32+
- name: Create Comment
33+
uses: marocchino/sticky-pull-request-comment@v2
34+
with:
35+
GITHUB_TOKEN: ${{ secrets.GRAVITY_UI_BOT_GITHUB_TOKEN }}
36+
number: ${{ steps.pr.outputs.id }}
37+
header: playwright test
38+
message: '[Playwright Test Component](https://storage.yandexcloud.net/playwright-reports/blog-constructor/pulls/${{ steps.pr.outputs.id }}/index.html) is ready.'

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,8 @@ node_modules
1515
.env
1616

1717
/styles/*css
18+
19+
/test-results/
20+
/playwright-report*
21+
/blob-report/
22+
.cache*

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ package.json
1515
# docs
1616
CHANGELOG.md
1717
CONTRIBUTING.md
18+
19+
/playwright/playwright/.cache/

.storybook/preview.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import {withMobile} from './decorators/withMobile';
1313
import {DocsDecorator} from './decorators/DocsDecorator/DocsDecorator';
1414
import {MobileProvider, ThemeProvider} from '@gravity-ui/uikit';
1515

16+
import {routerData} from '../src/demo/mocks';
17+
import {BlogConstructorProvider} from '../src/constructor/BlogConstructorProvider';
18+
1619
const withContextProvider: Decorator = (Story, context) => (
1720
<React.StrictMode>
1821
<ThemeProvider theme={context.globals.theme}>
@@ -23,8 +26,19 @@ const withContextProvider: Decorator = (Story, context) => (
2326
</React.StrictMode>
2427
);
2528

29+
const withBlogConstructorProvider: Decorator = (Story, context) => {
30+
return (
31+
<BlogConstructorProvider
32+
router={routerData}
33+
isMobile={context.globals.platform === 'mobile'}
34+
>
35+
<Story {...context} />
36+
</BlogConstructorProvider>
37+
);
38+
};
39+
2640
const preview: Preview = {
27-
decorators: [withTheme, withLang, withMobile, withContextProvider],
41+
decorators: [withTheme, withLang, withMobile, withContextProvider, withBlogConstructorProvider],
2842
parameters: {
2943
docs: {
3044
theme: themes.light,

jest.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,11 @@ module.exports = {
2222
'\\.(css|less|scss|sass)$': 'jest-transform-css',
2323
},
2424
testMatch: ['**/*.test.[jt]s?(x)'],
25+
testPathIgnorePatterns: [
26+
'<rootDir>/node_modules',
27+
'<rootDir>/build',
28+
'<rootDir>/server',
29+
'<rootDir>/.storybook',
30+
'.visual.',
31+
],
2532
};

0 commit comments

Comments
 (0)