Skip to content

Commit 7e435bc

Browse files
authored
Playwright added (#321)
* Playwright added * cypress removed
1 parent 5c6b220 commit 7e435bc

Some content is hidden

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

67 files changed

+21063
-21892
lines changed

.eslintrc.cjs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ module.exports = {
66
"plugin:import/recommended",
77
"plugin:jsx-a11y/recommended",
88
"plugin:@typescript-eslint/recommended",
9-
"plugin:cypress/recommended",
109
// This disables the formatting rules in ESLint that Prettier is going to be responsible for handling.
1110
// Make sure it's always the last config, so it gets the chance to override other configs.
1211
"eslint-config-prettier",
@@ -18,14 +17,13 @@ module.exports = {
1817
},
1918
// Tells eslint how to resolve imports
2019
"import/resolver": {
21-
node: {
22-
paths: ["src"],
23-
extensions: [".js", ".jsx", ".ts", ".tsx"],
20+
typescript: {
21+
project: ["tsconfig.json", "integration_tests/tsconfig.json"],
2422
},
2523
},
2624
},
2725
rules: {
2826
// Add your own rules here to override ones from the extended configs.
29-
"@typescript-eslint/no-non-null-assertion": "warn"
27+
"@typescript-eslint/no-non-null-assertion": "warn",
3028
},
3129
};

.github/workflows/playwright.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Playwright Tests
2+
on:
3+
push:
4+
branches: [master]
5+
pull_request:
6+
branches: [master]
7+
8+
jobs:
9+
test:
10+
timeout-minutes: 5
11+
runs-on: ubuntu-latest
12+
container:
13+
image: mcr.microsoft.com/playwright:v1.36.2-focal
14+
steps:
15+
- uses: actions/checkout@v3
16+
17+
- uses: actions/setup-node@v3
18+
with:
19+
node-version: 18
20+
21+
- name: Install dependencies
22+
run: npm ci
23+
24+
- id: get-branch-name
25+
run: echo "::set-output name=branch_name::$(git symbolic-ref --short HEAD)"
26+
shell: bash
27+
28+
- name: Run Playwright tests
29+
run: npx playwright test
30+
env:
31+
VRT_APIURL: "https://visual-regression-tracker.com:4200"
32+
VRT_PROJECT: "VRT"
33+
VRT_ENABLESOFTASSERT: false
34+
VRT_APIKEY: ${{ secrets.VRT_API_KEY }}
35+
VRT_BRANCHNAME: ${{ github.head_ref || steps.get-branch-name.outputs.branch_name }}
36+
VRT_CIBUILDID: "Github run_id: ${{ github.run_id }}"
37+
38+
- uses: actions/upload-artifact@v3
39+
if: always()
40+
with:
41+
name: playwright-report
42+
path: playwright-report/
43+
retention-days: 30

.github/workflows/workflow.yml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,3 @@ jobs:
2323

2424
- name: Unit tests
2525
run: npm test -- --coverage
26-
27-
- id: get-branch-name
28-
run: echo "::set-output name=branch_name::$(git symbolic-ref --short HEAD)"
29-
shell: bash
30-
31-
# - name: Run Component tests 🧪
32-
# uses: cypress-io/github-action@v2
33-
# with:
34-
# command: npm run test:cy
35-
# env:
36-
# VRT_APIURL: "https://visual-regression-tracker.com:4200"
37-
# VRT_PROJECT: "VRT"
38-
# VRT_ENABLESOFTASSERT: false
39-
# VRT_APIKEY: ${{ secrets.VRT_API_KEY }}
40-
# VRT_BRANCHNAME: ${{ github.head_ref || steps.get-branch-name.outputs.branch_name }}
41-
# VRT_CIBUILDID: "Github run_id: ${{ github.run_id }}"
42-
# CHOKIDAR_USEPOLLING: 1

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@
99
vrt.json
1010
.nyc_output/
1111
/coverage
12-
/cypress/screenshots
1312

1413
# production
1514
/secrets
1615
/build
1716
env-config.js
18-
cypress.env.json
1917

2018
# misc
2119
.idea/
@@ -28,3 +26,6 @@ cypress.env.json
2826
npm-debug.log*
2927
yarn-debug.log*
3028
yarn-error.log*
29+
/test-results/
30+
/playwright-report/
31+
/playwright/.cache/

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
- Update `.env`
1010
- `npm run start`
1111

12-
The testing related `.spec.tsx` files are used with Cypress for browser tests, and the `.test.tsx` files with Jest for unit tests.
12+
The testing related `.spec.tsx` files are used with Playwright for browser tests, and the `.test.tsx` files with Jest for unit tests.
1313

1414
## Image download
15-
16-
- If you want to use image download feature in test runs, you have to have the files in backend imageUploads folder to a folder in this project under public/static/imageUploads. This can be achieved via manual copy, docker volume mapping to this project folder etc.
15+
16+
- If you want to use image download feature in test runs, you have to have the files in backend imageUploads folder to a folder in this project under public/static/imageUploads. This can be achieved via manual copy, docker volume mapping to this project folder etc.
1717

1818
## Local HTTPS config
1919

cypress.config.ts

Lines changed: 0 additions & 40 deletions
This file was deleted.

cypress/fixtures/example.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

cypress/support/component-index.html

Lines changed: 0 additions & 12 deletions
This file was deleted.

cypress/support/component.ts

Lines changed: 0 additions & 33 deletions
This file was deleted.
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import { test as base } from "@playwright/test";
2+
import { PlaywrightVisualRegressionTracker } from "@visual-regression-tracker/agent-playwright";
3+
import { LoginPage, ProfilePage, ProjectListPage, ProjectPage } from "pages";
4+
import { RegisterPage } from "pages/RegisterPage";
5+
import { TestVariationDetailsPage } from "pages/TestVariationDetailsPage";
6+
import { TestVariationListPage } from "pages/TestVariationListPage";
7+
import { UserListPage } from "pages/UserListPage";
8+
9+
type Fixtures = {
10+
vrt: PlaywrightVisualRegressionTracker;
11+
loginPage: LoginPage;
12+
registerPage: RegisterPage;
13+
openProjectPage: (id: string) => Promise<ProjectPage>;
14+
openTestVariationListPage: (
15+
projectId: string
16+
) => Promise<TestVariationListPage>;
17+
openTestVariationDetailsPage: (
18+
id: string
19+
) => Promise<TestVariationDetailsPage>;
20+
projectListPage: ProjectListPage;
21+
profilePage: ProfilePage;
22+
userListPage: UserListPage;
23+
authUser: void;
24+
};
25+
26+
export const test = base.extend<Fixtures>({
27+
vrt: async ({ browserName }, use) => {
28+
const vrt = new PlaywrightVisualRegressionTracker(browserName);
29+
30+
await vrt.start();
31+
await use(vrt);
32+
await vrt.stop();
33+
},
34+
loginPage: [
35+
async ({ page }, use) => {
36+
await page.goto("/");
37+
38+
await use(new LoginPage(page));
39+
},
40+
{ auto: true },
41+
],
42+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
43+
projectListPage: async ({ page, authUser }, use) => {
44+
await page.goto("/projects");
45+
46+
await use(new ProjectListPage(page));
47+
},
48+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
49+
profilePage: async ({ page, authUser }, use) => {
50+
await page.goto("/profile");
51+
52+
await use(new ProfilePage(page));
53+
},
54+
registerPage: async ({ page }, use) => {
55+
await page.goto("/register");
56+
57+
await use(new RegisterPage(page));
58+
},
59+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
60+
userListPage: async ({ page, authUser }, use) => {
61+
await page.goto("/users");
62+
63+
await use(new UserListPage(page));
64+
},
65+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
66+
openProjectPage: async ({ page, authUser }, use) => {
67+
await use(async (id) => {
68+
await page.goto(`${id}`);
69+
return new ProjectPage(page);
70+
});
71+
},
72+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
73+
openTestVariationListPage: async ({ page, authUser }, use) => {
74+
await use(async (projectId) => {
75+
await page.goto(`/variations/${projectId}`);
76+
return new TestVariationListPage(page);
77+
});
78+
},
79+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
80+
openTestVariationDetailsPage: async ({ page, authUser }, use) => {
81+
await use(async (id) => {
82+
await page.goto(`/variations/details/${id}`);
83+
return new TestVariationDetailsPage(page);
84+
});
85+
},
86+
authUser: async ({ page }, use) => {
87+
await page.evaluate(() =>
88+
window.localStorage.setItem(
89+
"user",
90+
JSON.stringify({
91+
id: "00b428bf-9b4d-487f-9883-0dc5ec9403d3",
92+
93+
firstName: "fname",
94+
lastName: "lname",
95+
apiKey: "ASJDHGAKJSDGASD",
96+
role: "admin",
97+
token: "eyJsgOE8Bw2bFwhZAugRRGm8U",
98+
})
99+
)
100+
);
101+
102+
await use();
103+
},
104+
});

0 commit comments

Comments
 (0)