Skip to content

chore: Playwright E2E 테스트 환경 구축#319

Open
kanghaeun wants to merge 11 commits into
devfrom
chore/318-playwright-e2e-setup
Open

chore: Playwright E2E 테스트 환경 구축#319
kanghaeun wants to merge 11 commits into
devfrom
chore/318-playwright-e2e-setup

Conversation

@kanghaeun

@kanghaeun kanghaeun commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

작업 요약

  • PR CI에서 주요 사용자 플로우를 자동 검증하는 E2E 테스트 환경 구축

작업 세부 내용

PR CI에서 주요 사용자 플로우를 자동 검증하는 E2E 테스트 환경을 구축했습니다

같은 코드면 항상 같은 결과가 나오도록 실서버 대신 모든 API를 목킹합니다.
추가 라이브러리는 @playwright/test 하나만 (MSW 도입 없음, 목킹은 Playwright 내장 기능 + node 내장 http 사용).

만약 실서버 기반으로 PR CI를 돌리면

  • 데이터 상태 불일치 — 예: 준비 페이지 테스트는 "PENDING 상태의 토너먼트"가 필요한데, 누가 QA 중에 그 토너먼트를 시작하면 코드와 무관하게 테스트가 깨짐.
  • 백엔드 가용성에 종속 — dev 서버 배포/장애 동안 모든 프론트 PR이 막힘
  • 데이터 오염 — CI가 돌 때마다 게스트 계정·테스트 토너먼트가 dev DB에 쌓임
  • 에러 케이스 테스트 불가 — 500/403 같은 응답을 실서버에서 마음대로 발생시킬 수 없음 (목킹은 api.error(...) 한 줄)

목킹 구조

요청 경로 목킹 방법 파일
① 인증 (미들웨어의 서버사이드 게스트 로그인) 가짜 JWT를 쿠키로 심어 로그인 자체를 우회 e2e/setup/auth.setup.ts
② 브라우저 발 API 요청 (clientApi) page.route() 인터셉트 e2e/fixtures/mockApiFixture.ts
③ 서버 발 API 요청 (SSR — serverApi, RSC 레이아웃) 로컬 목 스텁 서버 (127.0.0.1:4010) e2e/setup/mockApiServer.ts

① 인증: proxy.ts(미들웨어)는 access_token 쿠키가 없으면 서버사이드에서 게스트 로그인 API를 호출하는데, 이건 브라우저 밖에서 일어나 page.route()로 못 잡습니다. 대신 토큰 검증(isTokenValid)이 서명 없이 JWT의 exp만 확인하는 점을 이용해, global setup에서 만료가 미래인 가짜 JWT를 조립해 storageState(쿠키)로 저장합니다. 네트워크 0회로 인증 상태가 만들어지고 모든 테스트가 재사용합니다.

② 브라우저 요청: api fixture가 **/api/v1/** 라우트를 선점하고 pathname+method로 매칭합니다. 팀 응답 규약 { status, data, detail, code }를 그대로 따르고, 목킹 안 된 요청은 500으로 실패시키고 테스트 끝에 단언이 터지게 해서 목 누락을 즉시 잡습니다.

③ SSR 요청: tournament/[id]/layout.tsx가 접근 권한 확인을 위해 RSC에서 getTournament를 직접 await하므로(실패 시 rethrow), 서버 발 요청은 반드시 성공해야 토너먼트 페이지에 진입할 수 있습니다. 그래서 NEXT_PUBLIC_API_URL127.0.0.1:4010으로 강제하고, globalSetup에서 node 내장 http로 목 스텁 서버를 띄워 응답합니다. 목 데이터 상수는 e2e/mocks/를 ②와 공유합니다(단일 소스)

파일 구조

apps/web/
├── playwright.config.ts        # 중심 설정 (모바일 뷰포트, webServer 로컬/CI 분리)
└── e2e/
    ├── home.spec.ts            # 샘플: 홈 진입 → 토너먼트 목록 렌더링
    ├── tournamentCreate.spec.ts # 샘플: 홈 → 카드 클릭 → 준비 페이지 진입 플로우
    ├── consts.ts               # 목 스텁 주소/포트
    ├── fixtures/mockApiFixture.ts  # page.route 목킹 fixture (api.get/post/error)
    ├── helpers/
    │   ├── apiResponse.ts      # 팀 응답 규약 래핑 (createApiSuccess/Error)
    │   └── fakeJwt.ts          # 가짜 JWT 조립
    ├── mocks/                  # 목 데이터 (실제 도메인 타입 기준)
    └── setup/
        ├── auth.setup.ts       # storageState 생성 (setup 프로젝트)
        ├── globalSetup.ts      # SSR 목 스텁 서버 기동/종료
        └── mockApiServer.ts    # node:http 목 스텁

실행 방법

# 기본 — dev 서버 있으면 재사용, 없으면 알아서 띄웠다 내림
pnpm test:e2e

# 디버깅 — GUI에서 단계별 화면/네트워크 타임라인 확인
pnpm --filter piki-web test:e2e:ui

# CI 완전 재현 — 프로덕션 빌드 기준 (CI에서만 깨질 때)
NEXT_PUBLIC_API_URL=http://127.0.0.1:4010 pnpm build:web && CI=1 pnpm test:e2e
  • 결과는 터미널에 3 passed처럼 출력되고, 실패 시 스크린샷 경로 + HTML 리포트가 자동으로 열립니다
  • 최초 실행은 수 분 걸릴 수 있습니다
  • UI 모드에서 테스트가 안 보이면 좌측 필터의 Projects에서 mobile-chromium을 체크해주세요

CI

  • 기존 ci 잡(lint/type/build)과 병렬로 도는 e2e 잡 추가 — 기존 필수 체크에 영향 없음
  • Playwright 브라우저 바이너리 캐싱 (~/.cache/ms-playwright, 버전 기반 키)
  • 실패 시 playwright-report + test-results(trace/스크린샷) 아티팩트 업로드

스크린샷

  • pnpm test:e2e 입력
image
  • pnpm --filter piki-web test:e2e:ui 입력
image

연관 이슈

closes #318

Summary by CodeRabbit

  • New Features
    • Playwright 기반 E2E 테스트 환경 및 실행 스크립트를 추가했습니다.
    • 홈/토너먼트 생성 흐름을 검증하는 신규 E2E 테스트를 추가했습니다.
  • Bug Fixes
    • 외부 리소스 접근을 차단하고, 목 응답 누락을 테스트에서 감지하도록 개선했습니다.
    • 실패 시 Playwright 리포트/테스트 결과를 아티팩트로 업로드하도록 구성했습니다.
  • Chores
    • CI Node 버전을 22로 상향하고, E2E 전용 작업/캐시 최적화를 적용했습니다.
    • Playwright 관련 산출물·인증 캐시 경로를 .gitignore에 추가했습니다.

@kanghaeun kanghaeun requested a review from iOdiO89 July 9, 2026 09:05
@vercel

vercel Bot commented Jul 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
depromeet Ready Ready Preview, Comment Jul 14, 2026 3:26pm

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

Discord 스레드 연동용 메타데이터입니다. discord-pr-bot 워크플로가 자동 생성하며, 수정·삭제하면 PR 과 Discord 알림 연동이 끊깁니다.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2298f87c-6a89-4681-a0c0-a8a942ecb2dc

📥 Commits

Reviewing files that changed from the base of the PR and between baa9f4a and a2c90d9.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/ci.yml

📝 Walkthrough

Walkthrough

Playwright 기반 E2E 테스트 환경이 추가되었습니다. 목 API 서버와 fixture, 게스트 인증 상태, 샘플 테스트, Playwright 설정, 실행 스크립트, CI E2E 잡 및 테스트 산출물 제외 규칙이 포함됩니다.

Changes

Playwright E2E 환경 구축

Layer / File(s) Summary
Playwright 설정과 실행 구성
apps/web/playwright.config.ts, apps/web/package.json, package.json, .gitignore, apps/web/e2e/consts.ts
테스트 프로젝트, webServer, E2E 스크립트와 Playwright 의존성, 목 API URL 및 산출물 제외 규칙이 추가되었습니다.
응답·인증 헬퍼와 목 데이터
apps/web/e2e/helpers/*, apps/web/e2e/mocks/*
표준 API 응답 생성기, 가짜 JWT 생성기, 게스트 사용자와 토너먼트 목 데이터가 추가되었습니다.
SSR 목 API 서버와 전역 설정
apps/web/e2e/setup/mockApiServer.ts, apps/web/e2e/setup/globalSetup.ts
SSR 요청을 처리하는 HTTP 목 서버를 시작하고 테스트 종료 시 서버를 닫는 globalSetup이 추가되었습니다.
클라이언트 API 목 fixture
apps/web/e2e/fixtures/mockApiFixture.ts
page.route로 API 및 SSE 요청을 처리하고 미등록 API 요청을 테스트 종료 시 검증하는 fixture가 추가되었습니다.
게스트 인증과 샘플 E2E 시나리오
apps/web/e2e/setup/auth.setup.ts, apps/web/e2e/*spec.ts
게스트 storageState 생성과 홈 화면 토너먼트 렌더링 및 토너먼트 준비 페이지 이동 테스트가 추가되었습니다.
CI E2E 실행 통합
.github/workflows/ci.yml
Node 22, Playwright 캐싱·설치, 웹 빌드, E2E 실행 및 실패 리포트 업로드를 수행하는 e2e 잡이 추가되었습니다.

Estimated code review effort: 3 (Moderate) | ~30 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CI
  participant globalSetup
  participant MockApiServer
  participant ApiFixture
  participant NextApp
  participant E2ETest

  CI->>globalSetup: 테스트 런 시작
  globalSetup->>MockApiServer: 목 서버 시작
  E2ETest->>ApiFixture: API 목 응답 등록
  E2ETest->>NextApp: 페이지 이동
  NextApp->>MockApiServer: SSR API 요청
  MockApiServer-->>NextApp: 목 응답 반환
  NextApp->>ApiFixture: 클라이언트 API 요청
  ApiFixture-->>NextApp: 목 응답 반환
  E2ETest->>NextApp: 화면과 URL 검증
  globalSetup->>MockApiServer: 서버 종료
Loading

Suggested reviewers: soyeong0115, iodio89

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목이 Playwright E2E 테스트 환경 구축이라는 핵심 변경사항을 정확하고 간결하게 요약합니다.
Linked Issues check ✅ Passed Playwright 설정, 목킹, 인증 상태, 샘플 E2E, CI 잡과 캐시/아티팩트 업로드까지 링크된 요구사항을 대부분 충족합니다.
Out of Scope Changes check ✅ Passed 변경 내용은 전반적으로 E2E 테스트 환경 구축 범위에 맞고, 명확한 무관 변경은 보이지 않습니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/318-playwright-e2e-setup

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
.github/workflows/ci.yml (2)

53-121: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

e2e 잡에 timeout-minutes 설정 권장

Playwright 브라우저 자동화는 네트워크/타이밍 이슈로 예기치 않게 멎을 수 있어, 다른 유사 워크플로 예시들도 대부분 잡 레벨에 timeout-minutes(보통 30~60분)를 명시해 러너가 기본 6시간까지 점유되는 것을 방지합니다. 현재 e2e 잡에는 이 설정이 없어, 테스트가 행(hang)될 경우 러너 자원이 오래 낭비될 수 있습니다.

⏱️ 제안
   e2e:
     name: E2E (Playwright)
     runs-on: ubuntu-latest
+    timeout-minutes: 30
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/ci.yml around lines 53 - 121, The e2e job is missing an
explicit timeout, so add a job-level timeout-minutes to the e2e workflow block
to prevent a hung Playwright run from occupying the runner too long. Update the
e2e job definition in the CI workflow (the job that runs Build web, Run E2E
tests, and Upload Playwright report) and choose a reasonable limit consistent
with other workflow jobs, such as 30–60 minutes.

53-55: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

ci 잡과의 의존 관계 부재로 인한 불필요한 실행 가능성

e2e 잡이 needs: ci를 지정하지 않아 lint/타입체크/빌드가 실패해도 e2e 잡은 독립적으로 실행됩니다. 브라우저 캐시 복원, pnpm build:web, 전체 테스트 스위트가 매번 도는 구조라, 기존 ci 잡이 먼저 실패할 게 뻔한 PR에서도 러너 시간이 소모됩니다. 의도적으로 병렬 실행해 피드백 속도를 우선한 것이라면 넘어가도 좋습니다.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/ci.yml around lines 53 - 55, The e2e job is currently
independent from the main ci job, so it can still run and consume runner time
even when lint/typecheck/build already failed. Update the workflow by adding a
dependency from the e2e job to the ci job in the GitHub Actions YAML, using the
e2e job definition as the place to reference needs: ci, unless parallel
execution is intentionally desired.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/web/e2e/setup/mockApiServer.ts`:
- Around line 29-54: `startMockApiServer`의 `server.listen()`에 에러 처리 경로가 없어 포트 충돌
시 프로세스가 종료될 수 있습니다. `http.Server`의 `'error'` 이벤트를 `startMockApiServer` 안에서 처리하고,
Promise를 성공 시 `resolve(server)`만 하지 말고 실패 시 `reject`하도록 바꿔 `EADDRINUSE` 같은
listen 오류가 `globalSetup`에서 명확히 전파되게 하세요. `startMockApiServer`, `server.listen`,
그리고 생성된 `server` 객체를 기준으로 수정하면 됩니다.

---

Nitpick comments:
In @.github/workflows/ci.yml:
- Around line 53-121: The e2e job is missing an explicit timeout, so add a
job-level timeout-minutes to the e2e workflow block to prevent a hung Playwright
run from occupying the runner too long. Update the e2e job definition in the CI
workflow (the job that runs Build web, Run E2E tests, and Upload Playwright
report) and choose a reasonable limit consistent with other workflow jobs, such
as 30–60 minutes.
- Around line 53-55: The e2e job is currently independent from the main ci job,
so it can still run and consume runner time even when lint/typecheck/build
already failed. Update the workflow by adding a dependency from the e2e job to
the ci job in the GitHub Actions YAML, using the e2e job definition as the place
to reference needs: ci, unless parallel execution is intentionally desired.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 47e78ea4-01a3-45b7-ba74-85af8cf61e48

📥 Commits

Reviewing files that changed from the base of the PR and between ef66bef and bec89ed.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (16)
  • .github/workflows/ci.yml
  • .gitignore
  • apps/web/e2e/consts.ts
  • apps/web/e2e/fixtures/mockApiFixture.ts
  • apps/web/e2e/helpers/apiResponse.ts
  • apps/web/e2e/helpers/fakeJwt.ts
  • apps/web/e2e/home.spec.ts
  • apps/web/e2e/mocks/me.ts
  • apps/web/e2e/mocks/tournament.ts
  • apps/web/e2e/setup/auth.setup.ts
  • apps/web/e2e/setup/globalSetup.ts
  • apps/web/e2e/setup/mockApiServer.ts
  • apps/web/e2e/tournamentCreate.spec.ts
  • apps/web/package.json
  • apps/web/playwright.config.ts
  • package.json

Comment on lines +29 to +54
export const startMockApiServer = (port: number) =>
new Promise<http.Server>(resolve => {
const server = http.createServer((req, res) => {
const pathname = new URL(req.url ?? '/', `http://127.0.0.1:${port}`).pathname;
const body = SSR_MOCK_ROUTES[`${req.method} ${pathname}`];

if (!body) {
res.writeHead(404, { 'content-type': 'application/json' });
res.end(
JSON.stringify(
createApiError({
status: 404,
code: 'E2E_SSR_UNMOCKED',
detail: `SSR 목 스텁에 등록되지 않은 요청: ${req.method} ${pathname}`,
})
)
);
return;
}

res.writeHead(200, { 'content-type': 'application/json' });
res.end(JSON.stringify(body));
});

server.listen(port, '127.0.0.1', () => resolve(server));
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

server.listen()에 에러 핸들러가 없어 포트 충돌 시 프로세스가 크래시할 수 있습니다.

http.ServerEventEmitter이므로 listen()EADDRINUSE 등으로 'error' 이벤트가 발생하면, 리스너가 없을 경우 처리되지 않은 예외로 Node 프로세스가 종료됩니다. 현재 Promise는 성공 콜백에서만 resolve되고 reject 경로가 없어, 이전 실행이 정상 종료되지 않아 포트가 남아있는 경우(예: CI 재시도, 로컬에서 강제 종료 후 재실행) globalSetup 단계에서 명확한 에러 메시지 없이 전체 E2E 실행이 죽어버릴 수 있습니다.

🔧 제안하는 수정
 export const startMockApiServer = (port: number) =>
-  new Promise<http.Server>(resolve => {
+  new Promise<http.Server>((resolve, reject) => {
     const server = http.createServer((req, res) => {
       ...
     });
 
+    server.on('error', reject);
     server.listen(port, '127.0.0.1', () => resolve(server));
   });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export const startMockApiServer = (port: number) =>
new Promise<http.Server>(resolve => {
const server = http.createServer((req, res) => {
const pathname = new URL(req.url ?? '/', `http://127.0.0.1:${port}`).pathname;
const body = SSR_MOCK_ROUTES[`${req.method} ${pathname}`];
if (!body) {
res.writeHead(404, { 'content-type': 'application/json' });
res.end(
JSON.stringify(
createApiError({
status: 404,
code: 'E2E_SSR_UNMOCKED',
detail: `SSR 목 스텁에 등록되지 않은 요청: ${req.method} ${pathname}`,
})
)
);
return;
}
res.writeHead(200, { 'content-type': 'application/json' });
res.end(JSON.stringify(body));
});
server.listen(port, '127.0.0.1', () => resolve(server));
});
export const startMockApiServer = (port: number) =>
new Promise<http.Server>((resolve, reject) => {
const server = http.createServer((req, res) => {
const pathname = new URL(req.url ?? '/', `http://127.0.0.1:${port}`).pathname;
const body = SSR_MOCK_ROUTES[`${req.method} ${pathname}`];
if (!body) {
res.writeHead(404, { 'content-type': 'application/json' });
res.end(
JSON.stringify(
createApiError({
status: 404,
code: 'E2E_SSR_UNMOCKED',
detail: `SSR 목 스텁에 등록되지 않은 요청: ${req.method} ${pathname}`,
})
)
);
return;
}
res.writeHead(200, { 'content-type': 'application/json' });
res.end(JSON.stringify(body));
});
server.on('error', reject);
server.listen(port, '127.0.0.1', () => resolve(server));
});
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/web/e2e/setup/mockApiServer.ts` around lines 29 - 54,
`startMockApiServer`의 `server.listen()`에 에러 처리 경로가 없어 포트 충돌 시 프로세스가 종료될 수 있습니다.
`http.Server`의 `'error'` 이벤트를 `startMockApiServer` 안에서 처리하고, Promise를 성공 시
`resolve(server)`만 하지 말고 실패 시 `reject`하도록 바꿔 `EADDRINUSE` 같은 listen 오류가
`globalSetup`에서 명확히 전파되게 하세요. `startMockApiServer`, `server.listen`, 그리고 생성된
`server` 객체를 기준으로 수정하면 됩니다.

@m-a-king

m-a-king commented Jul 9, 2026

Copy link
Copy Markdown

완전 최고다

kanghaeun and others added 2 commits July 12, 2026 23:37
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/web/e2e/setup/globalSetup.ts`:
- Around line 6-7: Update the server reuse logic around startMockApiServer so an
EADDRINUSE/null result is accepted only after a health check or identifying
response confirms the process is the expected mock API server; otherwise fail
setup instead of reusing the process. Preserve reuse for valid existing mock
servers and keep the normal newly-started server path unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3b95d009-1ddc-497a-80a7-4339fcd89b77

📥 Commits

Reviewing files that changed from the base of the PR and between bec89ed and baa9f4a.

📒 Files selected for processing (3)
  • apps/web/e2e/fixtures/mockApiFixture.ts
  • apps/web/e2e/setup/globalSetup.ts
  • apps/web/e2e/setup/mockApiServer.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/e2e/setup/mockApiServer.ts

Comment on lines +6 to +7
/** null 이면 다른 세션(UI 모드 등)이 띄운 기존 스텁을 재사용 — 내리지 않는다 */
const server = await startMockApiServer(MOCK_API_PORT);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== Files ==\n'
git ls-files 'apps/web/e2e/setup/*' 'apps/web/e2e/**/*mock*' 'apps/web/e2e/**/*setup*' | sort

printf '\n== Outline: globalSetup ==\n'
ast-grep outline apps/web/e2e/setup/globalSetup.ts --view expanded

printf '\n== Outline: mockApiServer ==\n'
ast-grep outline apps/web/e2e/setup/mockApiServer.ts --view expanded

printf '\n== Relevant excerpts ==\n'
sed -n '1,220p' apps/web/e2e/setup/globalSetup.ts | cat -n
printf '\n--- mockApiServer.ts ---\n'
sed -n '1,260p' apps/web/e2e/setup/mockApiServer.ts | cat -n

Repository: TeamPiKi/PiKi-Client

Length of output: 3846


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== MOCK_API_PORT references ==\n'
rg -n --hidden --glob '!**/node_modules/**' --glob '!**/.next/**' 'MOCK_API_PORT|startMockApiServer\(' apps/web

printf '\n== consts file ==\n'
sed -n '1,220p' apps/web/e2e/consts.ts | cat -n

printf '\n== e2e setup files ==\n'
sed -n '1,220p' apps/web/e2e/setup/auth.setup.ts | cat -n
printf '\n--- fixture ---\n'
sed -n '1,240p' apps/web/e2e/fixtures/mockApiFixture.ts | cat -n

printf '\n== package scripts mentioning e2e or ui mode ==\n'
sed -n '1,240p' package.json | cat -n

Repository: TeamPiKi/PiKi-Client

Length of output: 8127


기존 서버 재사용 전에 신원을 확인하세요
EADDRINUSE를 그대로 null로 처리하면 4010을 점유한 stale/unrelated 프로세스도 목 서버로 간주됩니다. 헬스체크나 식별 응답이 맞을 때만 재사용하고, 그렇지 않으면 실패시키는 편이 안전합니다.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/web/e2e/setup/globalSetup.ts` around lines 6 - 7, Update the server
reuse logic around startMockApiServer so an EADDRINUSE/null result is accepted
only after a health check or identifying response confirms the process is the
expected mock API server; otherwise fail setup instead of reusing the process.
Preserve reuse for valid existing mock servers and keep the normal newly-started
server path unchanged.

@iOdiO89 iOdiO89 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

어렵당 나도 playwright는 제대로 써본적이 없어서 가볍게 리뷰남겼어!

이거 관련 md 파일을 하나 추가하면 어떨까 폴더 구조나 어떻게 사용해야한다는 지침서가 있으면 좋을 것 같아

Comment thread .github/workflows/ci.yml
Comment on lines +112 to +120
- name: Upload Playwright report
if: failure()
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: |
apps/web/playwright-report/
apps/web/test-results/
retention-days: 7

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

failure 발생하면 디스코드로 알림 보내주면 어떨까??
이거는 근데 discord-pr-bot 쪽 워크플로우를 건드려야하는 거긴 해

Comment on lines +99 to +103
await provide({
get: (path, data) =>
entries.push({ method: 'GET', path, status: 200, body: createApiSuccess(data) }),
post: (path, data) =>
entries.push({ method: 'POST', path, status: 200, body: createApiSuccess(data) }),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

patch, delete가 없는데 이건 e2e 테스트 생성하면서 추가하면 될까? error는 get, post, delete, patch까지 다 대응되어 있는 것 같아서!

Comment thread apps/web/e2e/mocks/me.ts
Comment on lines +6 to +7
/** 외부 이미지 URL 금지 — next/image 가 서버사이드에서 fetch 해 목킹이 불가능하다 */
profileImage: '',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이게 좀 고민이 된다 ~.. 빈 문자열로 처리한 이유는 합당한 거 같은데, Next/Image에서는 src가 빈 문자열이면 에러가 발생해서 테스트하다가 ui 상에 오류가 날 수도 있겠다는 생각!

BaseImage 컴포넌트 썼으면 미리 에러 핸들링 해두어서 문제 없을텐데, 내 기억에는 Next/Image 자체를 쓴 경우도 많았어서 문제가 될까봐 마음에 좀 걸리넹

Image

이런 느낌으로 실제 image url을 사용해보면 어때?!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아님 이런건 e2e 테스트 실제로 생성하면서 작업하는 게 나을까!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore: Playwright E2E 테스트 환경 구축

3 participants