Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

test(plugin): set up visual regression tests #423

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
restore-keys: |
${{ runner.os }}-yarn-
- name: Install
run: yarn install
run: yarn install --frozen-lockfile
- name: Lint
run: yarn run lint
- name: Test
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# github action to run playwright
name: e2e
on:
workflow_dispatch:
jobs:
e2e:
name: E2E tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn install --frozen-lockfile
working-directory: plugin
- name: Install playwright browsers
run: yarn run playwright install --with-deps
working-directory: plugin
- name: Run tests
run: yarn run e2e
working-directory: plugin
3 changes: 3 additions & 0 deletions plugin/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
root: true
extends:
- reearth
overrides:
- files: playwright.config.ts
extends: reearth/node
2 changes: 2 additions & 0 deletions plugin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*-snapshots/
test-results/
3 changes: 3 additions & 0 deletions plugin/e2e/utils/setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { FullConfig } from "@playwright/test";

export default async function globalSetup(_config: FullConfig) {}
11 changes: 11 additions & 0 deletions plugin/e2e/vrt/view.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { test, expect } from "@playwright/test";

test("vrt: top page", async ({ page }) => {
await page.goto("https://plateauview.mlit.go.jp/");
// close button
// await page.click("svg");
await page.waitForLoadState("networkidle");
// await page.waitForSelector("text=カタログから検索する");
const image = await page.screenshot();
expect(image).toMatchSnapshot();
});
6 changes: 4 additions & 2 deletions plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,19 @@
"coverage": "vitest run --coverage",
"lint": "eslint .",
"format": "eslint . --fix",
"type": "tsc"
"type": "tsc",
"e2e": "playwright test"
},
"devDependencies": {
"@playwright/test": "^1.33.0",
"@testing-library/jest-dom": "5.16.5",
"@testing-library/react": "13.4.0",
"@testing-library/react-hooks": "8.0.1",
"@testing-library/user-event": "14.4.3",
"@types/leaflet": "1.9.0",
"@types/lodash": "4.14.191",
"@types/lodash-es": "4.17.7",
"@types/node": "18.11.18",
"@types/node": "^20.1.1",
"@types/papaparse": "5.3.7",
"@types/react": "18.0.26",
"@types/react-dom": "18.0.10",
Expand Down
26 changes: 26 additions & 0 deletions plugin/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { devices, type PlaywrightTestConfig } from "@playwright/test";

const config: PlaywrightTestConfig = {
use: {
baseURL: "https://plateauview.mlit.go.jp",
screenshot: "only-on-failure",
video: "retain-on-failure",
},
testDir: "e2e",
globalSetup: "./e2e/utils/setup.ts",
reporter: process.env.CI ? "github" : "list",
projects: [
{
name: "chromium",
use: {
...devices["Desktop Chrome"],
headless: false,
launchOptions: {
args: ["--no-sandbox"],
},
},
},
],
};

export default config;
2 changes: 1 addition & 1 deletion plugin/tsconfig.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"module": "esnext",
"moduleResolution": "node"
},
"include": ["vite.config.ts"]
"include": ["vite.config.ts", "playwright.config.ts"]
}
24 changes: 22 additions & 2 deletions plugin/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,16 @@
resolved "https://registry.yarnpkg.com/@open-draft/until/-/until-1.0.3.tgz#db9cc719191a62e7d9200f6e7bab21c5b848adca"
integrity sha512-Aq58f5HiWdyDlFffbbSjAlv596h/cOnt2DO1w3DOC7OJ5EHs0hd/nycJfiu9RJbT6Yk6F1knnRRXNSpxoIVZ9Q==

"@playwright/test@^1.33.0":
version "1.33.0"
resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.33.0.tgz#669ef859efb81b143dfc624eef99d1dd92a81b67"
integrity sha512-YunBa2mE7Hq4CfPkGzQRK916a4tuZoVx/EpLjeWlTVOnD4S2+fdaQZE0LJkbfhN5FTSKNLdcl7MoT5XB37bTkg==
dependencies:
"@types/node" "*"
playwright-core "1.33.0"
optionalDependencies:
fsevents "2.3.2"

"@rc-component/portal@^1.0.0-6", "@rc-component/portal@^1.0.0-8", "@rc-component/portal@^1.0.2":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@rc-component/portal/-/portal-1.1.0.tgz#6b94450d2c2b00d50b141bd7a0be23bd96503dbe"
Expand Down Expand Up @@ -994,7 +1004,7 @@
resolved "https://registry.yarnpkg.com/@types/ms/-/ms-0.7.31.tgz#31b7ca6407128a3d2bbc27fe2d21b345397f6197"
integrity sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA==

"@types/node@*", "@types/node@18.11.18":
"@types/node@*":
version "18.11.18"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.11.18.tgz#8dfb97f0da23c2293e554c5a50d61ef134d7697f"
integrity sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA==
Expand All @@ -1004,6 +1014,11 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.24.tgz#c37ac69cb2948afb4cef95f424fa0037971a9a5c"
integrity sha512-yxDeaQIAJlMav7fH5AQqPH1u8YIuhYJXYBzxaQ4PifsU0GDO38MSdmEDeRlIxrKbC6NbEaaEHDanWb+y30U8SQ==

"@types/node@^20.1.1":
version "20.1.1"
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.1.1.tgz#afc492e8dbe7f672dd3a13674823522b467a45ad"
integrity sha512-uKBEevTNb+l6/aCQaKVnUModfEMjAl98lw2Si9P5y4hLu9tm6AlX2ZIoXZX6Wh9lJueYPrGPKk5WMCNHg/u6/A==

"@types/normalize-package-data@^2.4.0":
version "2.4.1"
resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz#d3357479a0fdfdd5907fe67e17e0a85c906e1301"
Expand Down Expand Up @@ -2820,7 +2835,7 @@ fs.realpath@^1.0.0:
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==

fsevents@~2.3.2:
fsevents@2.3.2, fsevents@~2.3.2:
version "2.3.2"
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a"
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==
Expand Down Expand Up @@ -4429,6 +4444,11 @@ pkg-types@^1.0.1:
mlly "^1.0.0"
pathe "^1.0.0"

playwright-core@1.33.0:
version "1.33.0"
resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.33.0.tgz#269efe29a927cd6d144d05f3c2d2f72bd72447a1"
integrity sha512-aizyPE1Cj62vAECdph1iaMILpT0WUDCq3E6rW6I+dleSbBoGbktvJtzS6VHkZ4DKNEOG9qJpiom/ZxO+S15LAw==

postcss-value-parser@^4.0.2:
version "4.2.0"
resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz#723c09920836ba6d3e5af019f92bc0971c02e514"
Expand Down