Skip to content

Commit c415bf8

Browse files
committed
fix
1 parent 1e565d7 commit c415bf8

File tree

2 files changed

+37
-5
lines changed

2 files changed

+37
-5
lines changed

.github/workflows/playwright.yml

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ jobs:
4444
CONVEX_PREVIEW_NAME: pr-${{ github.event.pull_request.number }}
4545
E2E_CLERK_USER: ${{ vars.E2E_CLERK_USER }}
4646
E2E_CLERK_PASSWORD: ${{ vars.E2E_CLERK_PASSWORD }}
47-
E2E_CLERK_USER_B: ${{ vars.E2E_CLERK_USER_B }}
48-
E2E_CLERK_PASSWORD_B: ${{ vars.E2E_CLERK_PASSWORD_B }}
4947
CLERK_SECRET_KEY: ${{ secrets.CLERK_SECRET_KEY }}
5048
VITE_CLERK_PUBLISHABLE_KEY: ${{ secrets.VITE_CLERK_PUBLISHABLE_KEY }}
5149
CONVEX_DEPLOY_KEY: ${{ secrets.CONVEX_DEPLOY_KEY }}
@@ -73,13 +71,47 @@ jobs:
7371
uses: actions/github-script@v8
7472
with:
7573
script: |
76-
const reportUrl = `https://yn1323.github.io/hosting-pages/$REPORT_DIR/${{ github.event.pull_request.number }}/`;
74+
const fs = require('fs');
75+
const reportUrl = `https://yn1323.github.io/hosting-pages/${{ env.REPORT_DIR }}/${{ github.event.pull_request.number }}/`;
7776
const testResult = '${{ steps.playwright.outcome }}';
7877
const statusEmoji = testResult === 'success' ? '✅' : '❌';
7978
const statusText = testResult === 'success' ? '成功' : '失敗';
79+
80+
let summary = '';
81+
try {
82+
const json = JSON.parse(fs.readFileSync('test-results.json', 'utf8'));
83+
const suites = json.suites || [];
84+
let passed = 0, failed = 0, skipped = 0;
85+
const rows = [];
86+
87+
function collectTests(suites) {
88+
for (const suite of suites) {
89+
for (const spec of (suite.specs || [])) {
90+
for (const test of (spec.tests || [])) {
91+
const status = test.status;
92+
if (status === 'expected') passed++;
93+
else if (status === 'unexpected') failed++;
94+
else if (status === 'skipped') skipped++;
95+
const icon = status === 'expected' ? '✅' : status === 'unexpected' ? '❌' : '⏭';
96+
rows.push(`| ${icon} | ${spec.title} |`);
97+
}
98+
}
99+
if (suite.suites) collectTests(suite.suites);
100+
}
101+
}
102+
collectTests(suites);
103+
104+
summary = `\n\n**${passed} passed** / **${failed} failed** / **${skipped} skipped**\n\n`;
105+
if (rows.length > 0) {
106+
summary += `<details><summary>テスト詳細</summary>\n\n| Status | Test |\n|--------|------|\n${rows.join('\n')}\n\n</details>`;
107+
}
108+
} catch (e) {
109+
summary = '\n\n⚠️ テスト結果JSONの読み込みに失敗しました';
110+
}
111+
80112
await github.rest.issues.createComment({
81113
owner: context.repo.owner,
82114
repo: context.repo.repo,
83115
issue_number: context.issue.number,
84-
body: `## 📊 Playwright Test Report\n\n${statusEmoji} **テスト結果: ${statusText}**\n\n[View Report](${reportUrl})`
116+
body: `## 📊 Playwright Test Report\n\n${statusEmoji} **テスト結果: ${statusText}**${summary}\n\n[View Report](${reportUrl})\n\nデプロイ先: https://github.com/yn1323/hosting-pages`
85117
});

playwright.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default defineConfig({
3434
/* Opt out of parallel tests on CI. */
3535
workers: 1,
3636
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
37-
reporter: [["list"], ["html"]],
37+
reporter: [["list"], ["html"], ["json", { outputFile: "test-results.json" }]],
3838
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
3939
use: {
4040
/* Base URL to use in actions like `await page.goto('/')`. */

0 commit comments

Comments
 (0)