Skip to content

Commit dae2fa0

Browse files
ci: add website ja/en integration test workflow with playwright
Agent-Logs-Url: https://github.com/sensuikan1973/pedax/sessions/b671752b-d862-42eb-991d-dd43c6931560 Co-authored-by: sensuikan1973 <23427957+sensuikan1973@users.noreply.github.com>
1 parent d408d59 commit dae2fa0

1 file changed

Lines changed: 84 additions & 0 deletions

File tree

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
name: Website Integration Test
3+
4+
on:
5+
pull_request:
6+
paths:
7+
- '.github/workflows/website_integration_test.yaml'
8+
- 'website/**'
9+
push:
10+
branches: [main]
11+
paths:
12+
- '.github/workflows/website_integration_test.yaml'
13+
- 'website/**'
14+
workflow_dispatch:
15+
16+
jobs:
17+
website_integration_test:
18+
runs-on: ubuntu-latest
19+
timeout-minutes: 15
20+
defaults:
21+
run:
22+
working-directory: website
23+
24+
steps:
25+
- uses: actions/checkout@v6
26+
27+
# https://github.com/actions/setup-node/issues/206#issuecomment-774538395
28+
- uses: nodenv/actions/node-version@main
29+
id: nodenv
30+
- uses: actions/setup-node@v6
31+
with:
32+
node-version: '${{ steps.nodenv.outputs.node-version }}'
33+
34+
- run: yarn install --frozen-lockfile
35+
- run: yarn build
36+
37+
- name: Verify JA/EN website pages with Playwright
38+
run: |
39+
yarn serve --port 3000 --host 127.0.0.1 >"$RUNNER_TEMP/docusaurus-serve.log" 2>&1 &
40+
41+
started=false
42+
for i in {1..60}; do
43+
if curl -fsS "http://127.0.0.1:3000/pedax/" >/dev/null && \
44+
curl -fsS "http://127.0.0.1:3000/pedax/en/" >/dev/null; then
45+
started=true
46+
break
47+
fi
48+
sleep 1
49+
done
50+
51+
if [ "$started" != "true" ]; then
52+
cat "$RUNNER_TEMP/docusaurus-serve.log"
53+
echo "Docusaurus server failed to start"
54+
exit 1
55+
fi
56+
57+
mkdir -p "$RUNNER_TEMP/playwright"
58+
cat <<'EOF' >"$RUNNER_TEMP/playwright/package.json"
59+
{
60+
"name": "website-integration-test",
61+
"private": true
62+
}
63+
EOF
64+
65+
cat <<'EOF' >"$RUNNER_TEMP/playwright/website.integration.spec.js"
66+
const { test, expect } = require('@playwright/test')
67+
68+
test('ja locale page is displayed', async ({ page }) => {
69+
const response = await page.goto('http://127.0.0.1:3000/pedax/')
70+
expect(response.ok()).toBeTruthy()
71+
await expect(page.getByText('edax 用のリバーシ盤')).toBeVisible()
72+
})
73+
74+
test('en locale page is displayed', async ({ page }) => {
75+
const response = await page.goto('http://127.0.0.1:3000/pedax/en/')
76+
expect(response.ok()).toBeTruthy()
77+
await expect(page.getByText('Reversi Board with edax')).toBeVisible()
78+
})
79+
EOF
80+
81+
cd "$RUNNER_TEMP/playwright"
82+
npm install --no-fund --no-audit @playwright/test
83+
npx playwright install chromium
84+
npx playwright test website.integration.spec.js --reporter=line

0 commit comments

Comments
 (0)