Skip to content

Commit 7937352

Browse files
authored
test(e2e): added playwright visual tests (#19)
* test: added playwright visual tests * ci: changed playwright action to trigger for develop as well * one linux image * e2e to artifacts * e2e to artifacts * test: added linux images * fixed screenshot
1 parent c2fcbda commit 7937352

File tree

48 files changed

+192
-3
lines changed

Some content is hidden

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

48 files changed

+192
-3
lines changed

.github/workflows/playwright.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Playwright Tests
2+
on:
3+
push:
4+
branches: [main, develop]
5+
pull_request:
6+
branches: [main, develop]
7+
jobs:
8+
test:
9+
timeout-minutes: 60
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-node@v4
14+
with:
15+
node-version: lts/*
16+
- name: Install dependencies
17+
run: npm install -g yarn && yarn
18+
- name: Install Playwright Browsers
19+
run: yarn playwright install --with-deps
20+
- name: Run Playwright tests
21+
run: yarn playwright test
22+
- uses: actions/upload-artifact@v4
23+
if: always()
24+
with:
25+
name: playwright-report
26+
path: |
27+
playwright-report/
28+
test-results/
29+
e2e/
30+
retention-days: 30

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,7 @@ dev-dist
2626

2727
# Local Netlify folder
2828
.netlify
29+
/test-results/
30+
/playwright-report/
31+
/blob-report/
32+
/playwright/.cache/

e2e/home.spec.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { test, expect } from "@playwright/test";
2+
3+
test("visual test", async ({ page }) => {
4+
await page.goto("/");
5+
// Wait for all network requests for images to complete
6+
await page.waitForLoadState("networkidle");
7+
8+
await expect(page).toHaveScreenshot();
9+
});

e2e/light-locators-generator.spec.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { test, expect } from "@playwright/test";
2+
3+
test("visual test", async ({ page }) => {
4+
await page.goto("/light-locators-generator");
5+
// Wait for all network requests for images to complete
6+
await page.waitForLoadState("networkidle");
7+
8+
await expect(page).toHaveScreenshot();
9+
});

e2e/other-tools.spec.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { test, expect } from "@playwright/test";
2+
3+
test("visual test", async ({ page }) => {
4+
await page.goto("/other-tools");
5+
// Wait for all network requests for images to complete
6+
await page.waitForLoadState("networkidle");
7+
8+
await expect(page).toHaveScreenshot();
9+
});

e2e/privacy.spec.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { test, expect } from "@playwright/test";
2+
3+
test("visual test", async ({ page }) => {
4+
await page.goto("/privacy");
5+
// Wait for all network requests for images to complete
6+
await page.waitForLoadState("networkidle");
7+
8+
await expect(page).toHaveScreenshot();
9+
});

e2e/traits-builder.spec.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { test, expect } from "@playwright/test";
2+
3+
test("visual test", async ({ page }) => {
4+
await page.goto("/traits-builder");
5+
// Wait for all network requests for images to complete
6+
await page.waitForLoadState("networkidle");
7+
8+
await expect(page).toHaveScreenshot();
9+
});

e2e/unused-dds-finder.spec.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { test, expect } from "@playwright/test";
2+
3+
test("visual test", async ({ page }) => {
4+
await page.goto("/unused-dds-finder");
5+
// Wait for all network requests for images to complete
6+
await page.waitForLoadState("networkidle");
7+
8+
await expect(page).toHaveScreenshot();
9+
});

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"postbuild": "rm public/assets/magick.js public/assets/magick.wasm",
1111
"preview": "vite preview",
1212
"release": "npx standard-version",
13-
"functions": "npx env-cmd -f ./.env.local netlify functions:serve"
13+
"functions": "npx env-cmd -f ./.env.local netlify functions:serve",
14+
"e2e": "playwright test"
1415
},
1516
"dependencies": {
1617
"@emotion/react": "^11.9.3",
@@ -33,6 +34,7 @@
3334
"use-image": "^1.1.0"
3435
},
3536
"devDependencies": {
37+
"@playwright/test": "^1.44.1",
3638
"@types/node": "^20.12.8",
3739
"@types/react": "^18.3.1",
3840
"@types/react-dom": "^18.3.0",

playwright.config.ts

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import { defineConfig, devices } from "@playwright/test";
2+
3+
/**
4+
* Read environment variables from file.
5+
* https://github.com/motdotla/dotenv
6+
*/
7+
// import dotenv from 'dotenv';
8+
// dotenv.config({ path: path.resolve(__dirname, '.env') });
9+
10+
/**
11+
* See https://playwright.dev/docs/test-configuration.
12+
*/
13+
export default defineConfig({
14+
testDir: "./e2e",
15+
/* Run tests in files in parallel */
16+
fullyParallel: true,
17+
/* Fail the build on CI if you accidentally left test.only in the source code. */
18+
forbidOnly: !!process.env.CI,
19+
/* Retry on CI only */
20+
retries: process.env.CI ? 2 : 1,
21+
/* Opt out of parallel tests on CI. */
22+
workers: process.env.CI ? 1 : undefined,
23+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
24+
reporter: [["html", { open: "none", outputDir: "playwright-report" }]],
25+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
26+
use: {
27+
/* Base URL to use in actions like `await page.goto('/')`. */
28+
baseURL: "http://localhost:5173/",
29+
30+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
31+
trace: "on-first-retry",
32+
},
33+
34+
/* Configure projects for major browsers */
35+
projects: [
36+
{
37+
name: "chromium",
38+
use: { ...devices["Desktop Chrome"] },
39+
},
40+
41+
{
42+
name: "firefox",
43+
use: { ...devices["Desktop Firefox"] },
44+
},
45+
46+
{
47+
name: "webkit",
48+
use: { ...devices["Desktop Safari"] },
49+
},
50+
51+
/* Test against mobile viewports. */
52+
// {
53+
// name: 'Mobile Chrome',
54+
// use: { ...devices['Pixel 5'] },
55+
// },
56+
// {
57+
// name: 'Mobile Safari',
58+
// use: { ...devices['iPhone 12'] },
59+
// },
60+
61+
/* Test against branded browsers. */
62+
// {
63+
// name: 'Microsoft Edge',
64+
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
65+
// },
66+
// {
67+
// name: 'Google Chrome',
68+
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
69+
// },
70+
],
71+
72+
/* Run your local dev server before starting the tests */
73+
webServer: {
74+
command: "yarn dev",
75+
url: "http://localhost:5173/",
76+
reuseExistingServer: !process.env.CI,
77+
},
78+
});

src/components/Header/Header.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export default function Header() {
6565
<Stack sx={{ maxWidth: 1500 }} mx="auto">
6666
<Group position="apart" px="sm">
6767
<Group>
68-
<Image src={rmgLogo} height={50} width={50} />
68+
<Image src={rmgLogo} height={50} width={50} alt="RMG logo" />
6969
<Text size="xl" weight={700}>
7070
RMG Utils for Stellaris
7171
</Text>

yarn.lock

+22-1
Original file line numberDiff line numberDiff line change
@@ -1491,6 +1491,13 @@
14911491
"@nodelib/fs.scandir" "2.1.5"
14921492
fastq "^1.6.0"
14931493

1494+
"@playwright/test@^1.44.1":
1495+
version "1.44.1"
1496+
resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.44.1.tgz#cc874ec31342479ad99838040e99b5f604299bcb"
1497+
integrity sha512-1hZ4TNvD5z9VuhNJ/walIjvMVvYkZKf71axoF/uiAqpntQJXpG64dlXhoDXE3OczPuTuvjf/M5KWFg5VAVUS3Q==
1498+
dependencies:
1499+
playwright "1.44.1"
1500+
14941501
"@radix-ui/[email protected]":
14951502
version "1.0.0"
14961503
resolved "https://registry.yarnpkg.com/@radix-ui/number/-/number-1.0.0.tgz#4c536161d0de750b3f5d55860fc3de46264f897b"
@@ -2436,7 +2443,7 @@ fs.realpath@^1.0.0:
24362443
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
24372444
integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==
24382445

2439-
fsevents@~2.3.2:
2446+
fsevents@2.3.2, fsevents@~2.3.2:
24402447
version "2.3.2"
24412448
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a"
24422449
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==
@@ -3022,6 +3029,20 @@ picomatch@^2.2.2, picomatch@^2.3.1:
30223029
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42"
30233030
integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==
30243031

3032+
3033+
version "1.44.1"
3034+
resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.44.1.tgz#53ec975503b763af6fc1a7aa995f34bc09ff447c"
3035+
integrity sha512-wh0JWtYTrhv1+OSsLPgFzGzt67Y7BE/ZS3jEqgGBlp2ppp1ZDj8c+9IARNW4dwf1poq5MgHreEM2KV/GuR4cFA==
3036+
3037+
3038+
version "1.44.1"
3039+
resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.44.1.tgz#5634369d777111c1eea9180430b7a184028e7892"
3040+
integrity sha512-qr/0UJ5CFAtloI3avF95Y0L1xQo6r3LQArLIg/z/PoGJ6xa+EwzrwO5lpNr/09STxdHuUoP2mvuELJS+hLdtgg==
3041+
dependencies:
3042+
playwright-core "1.44.1"
3043+
optionalDependencies:
3044+
fsevents "2.3.2"
3045+
30253046
postcss@^8.4.38:
30263047
version "8.4.38"
30273048
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.38.tgz#b387d533baf2054288e337066d81c6bee9db9e0e"

0 commit comments

Comments
 (0)