Skip to content

Conversation

@Chiman2937
Copy link
Member

@Chiman2937 Chiman2937 commented Dec 11, 2025

📝 변경 사항

💡 MSW 동작 on/off를 환경변수로 제어하도록 수정

.env.local

# msw 사용 시
NEXT_PUBLIC_MSW_ENABLED=true
# msw 사용 안할 시
NEXT_PUBLIC_MSW_ENABLED=false

💡 E2E 테스트를 위한 패키지를 설치했습니다.

  • playwright
  • dotenv

playwright test를 위한 환경변수 설정이 필요합니다.
.env.test

NEXT_PUBLIC_MSW_ENABLED=true

💡 프로필 페이지 E2E 테스트 코드를 작성

  • 나의 프로필페이지로 접속했을 때 마이페이지로 리다이렉트 되는지 테스트
  • 존재하지 않는 프로필페이지 접속 시 not found 리다이렉트 되는지 테스트

🔗 관련 이슈

Closes #138


🧪 테스트 방법

  • 수동 테스트 검증(로컬 환경)
  • 유닛 테스트 검증
  • 통합 테스트 검증

📸 스크린샷 (선택)

image image

📋 체크리스트

  • 관련 문서를 업데이트했습니다 (필요한 경우)
  • 테스트를 추가/수정했습니다 (필요한 경우)
  • Breaking change가 있다면 명시했습니다

💬 추가 코멘트


CodeRabbit Review는 자동으로 실행되지 않습니다.

Review를 실행하려면 comment에 아래와 같이 작성해주세요

@coderabbitai review

Summary by CodeRabbit

  • Tests

    • Added end-to-end tests for profile routing behavior and error handling
    • Expanded test configuration to exclude test-related directories from coverage analysis
  • Chores

    • Integrated Playwright testing framework with configuration and new test scripts
    • Updated mock service configuration for improved environment-based initialization

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 11, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Playwright end-to-end testing infrastructure is introduced with configuration files, scripts, and profile page routing tests. The profile not-found page is instrumented with a test hook, Jest and gitignore ignore patterns are expanded, and MSW mock service worker configuration is simplified for environment-based enablement.

Changes

Cohort / File(s) Summary
Testing Framework Setup
playwright.config.ts, package.json, .gitignore, jest.config.js
Playwright configuration added with test runner setup for Chromium, Firefox, and WebKit browsers; test scripts (test:playwright, test:playwright:ui) and devDependencies (@playwright/test, dotenv) added to package.json; Jest ignore patterns expanded to exclude /e2e/ and /.next/; .gitignore updated with Playwright artifacts (/test-results/, /playwright-report/, /blob-report/, /playwright/.cache/, /playwright/.auth/)
End-to-End Tests
e2e/tests/profile.test.ts
New Playwright test suite for profile routing: validates redirect from /profile/1 to /mypage and 404 handling for user ID 4 via not-found-user test hook
Component Test Instrumentation
src/app/(user)/profile/not-found.tsx
Added data-testid="not-found-user" to root div to enable test targeting
Mock Service Worker Configuration
src/mock/index.ts
Simplified MSW initialization: removed environment-specific configuration object; centralized enablement to single NEXT_PUBLIC_MSW_ENABLED flag; fixed onUnhandledRequest to 'bypass' across server and client; implemented worker persistence via window.mswWorker to reuse instance across runs

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Configuration heterogeneity: Playwright, Jest, and package.json require separate validation of dependencies and config syntax
  • MSW logic simplification: Review the worker persistence pattern and environment-flag logic to ensure proper initialization and handler reuse
  • Test correctness: Verify test assertions, URL navigation waits, and test IDs match intended behavior

Suggested reviewers

  • wooktori

Poem

🐰 A profile page takes shape with care,
e2e tests scattered everywhere,
Playwright and Jest in harmony dance,
Not-found hooks get their chance,
MSW simplified, workflow refined,
Quality tests—oh, how aligned!

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately describes the main change—adding E2E test code for the profile page, which matches the primary focus of the changeset.
Description check ✅ Passed The PR description comprehensively covers all required template sections: changes, linked issues, testing methods, and checklist items are all properly filled out.
Linked Issues check ✅ Passed The PR implements the objective from issue #138 by adding E2E test code for the profile page, covering redirect to mypage and not-found scenarios.
Out of Scope Changes check ✅ Passed All code changes support the E2E testing objective: MSW configuration changes enable test environment setup, Jest/Playwright configs support test execution, and test file implements profile page scenarios.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions
Copy link

github-actions bot commented Dec 11, 2025

🎨 Storybook Report

변경 사항이 없습니다

모든 Story가 이전 빌드와 동일합니다.

Status Storybook Build Log Updated (UTC)
✅ Unchanged View Storybook View Build 2025-12-11 04:08:09

@github-actions
Copy link

github-actions bot commented Dec 11, 2025

📊 Coverage Report

Status Build Log Updated (UTC)
✅ Ready View Build 2025-12-11 04:06:46

📈 #144main에 병합하면 coverage가 0.06% 증가합니다.

Coverage 요약

@@             Coverage Diff             @@
##             main     #144       +/-   ##
===========================================
+ Coverage   40.67%   40.73%    +0.06%     
===========================================
  Files         125      125         0     
  Lines        5010     5003        -7     
  Branches      214      214         0     
===========================================
  Hits         2038     2038         0     
- Misses       2972     2965        -7     

영향받은 파일

이 PR로 영향받은 파일이 없습니다

수정된 모든 파일이 현재 coverage를 유지했습니다.

@github-actions
Copy link

github-actions bot commented Dec 11, 2025

🚀 PR Preview Report

Build가 성공적으로 완료되었습니다.

Preview에서 변경사항을 확인하세요.

Status Preview Build Log Updated (UTC)
✅ Ready Visit Preview View Logs 2025-12-11 04:08:05

@Chiman2937 Chiman2937 added the Ready For Review! 리뷰 받을 준비가 되었습니다. label Dec 11, 2025
@Chiman2937
Copy link
Member Author

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 11, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
.gitignore (1)

45-52: Playwright artifacts ignore looks good; consider dropping duplicate node_modules/

The new Playwright block correctly ignores test-results, reports, and Playwright cache/auth directories. The extra node_modules/ is redundant with the earlier /node_modules entry, so you could remove it to avoid confusion, but it’s harmless as-is.

📜 Review details

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 27a4995 and bdcdb4a.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (7)
  • .gitignore (1 hunks)
  • e2e/tests/profile.test.ts (1 hunks)
  • jest.config.js (1 hunks)
  • package.json (3 hunks)
  • playwright.config.ts (1 hunks)
  • src/app/(user)/profile/not-found.tsx (1 hunks)
  • src/mock/index.ts (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/mock/index.ts (1)
src/mock/server.ts (1)
  • server (5-5)
🔇 Additional comments (4)
src/app/(user)/profile/not-found.tsx (1)

5-5: Test hook is minimal and well-scoped

Adding data-testid='not-found-user' on the wrapper div is a clean way to support E2E checks without affecting UI behavior.

jest.config.js (1)

15-16: Good separation of Jest unit tests from Playwright E2E tests

Ignoring /e2e/ in both coverage and test path patterns is a clean way to avoid Jest picking up Playwright tests or skewing coverage. The configuration correctly isolates the e2e directory.

package.json (1)

16-17: Playwright scripts and devDependencies are consistent with the new E2E setup

test:playwright / test:playwright:ui scripts align with @playwright/test and dotenv devDependencies. The playwright.config.ts correctly imports and uses dotenv to load environment variables from .env.test, and the configuration properly uses @playwright/test APIs with appropriate CI-aware settings. No blocking issues.

playwright.config.ts (1)

1-78: Address missing .env.test file and clarify environment variable setup

The Playwright config structure follows best practices, but the environment variable loading setup has issues:

  • .env.test does not exist in the repository (it's gitignored via .env* pattern), so dotenv.config({ path: path.resolve(__dirname, '.env.test') }) will silently fail and load no variables.
  • The config assumes NEXT_PUBLIC_MSW_ENABLED and other test env vars will be available, but without a committed .env.test file or clear documentation, developers won't know how to set up these variables locally.
  • Either commit a .env.test.example with required variables, document the setup process in README, or load env vars from the CI environment directly without relying on a missing file.

The rest of the configuration (testDir, baseURL, multi-browser projects, and webServer with reuseExistingServer) is sound.

Comment on lines 1 to 17
import { expect, test } from '@playwright/test';

test('나의 프로필 페이지로 접속 시 마이페이지로 리다이렉트 되는 지 테스트', async ({ page }) => {
// 나의 프로필 페이지 방문
await page.goto('/profile/1');

// redirect 대기
await expect(page).toHaveURL('/mypage');
});

test('존재하지 않는 프로필 페이지로 접속 시 404 리다이렉트 되는 지 테스트', async ({ page }) => {
// 나의 프로필 페이지 방문
await page.goto('/profile/4');

// redirect 대기
await expect(page.getByTestId('not-found-user')).toBeVisible();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, check if the file exists and read its content
cat -n e2e/tests/profile.test.ts

Repository: WeGo-Together/WeGo_FrontEnd

Length of output: 637


🏁 Script executed:

# Look for Playwright configuration
find . -type f -name "playwright.config.*" | head -5

Repository: WeGo-Together/WeGo_FrontEnd

Length of output: 93


🏁 Script executed:

# Check for any baseURL configuration
git ls-files | grep -E "playwright|test" | head -20

Repository: WeGo-Together/WeGo_FrontEnd

Length of output: 658


🏁 Script executed:

# Read the Playwright configuration to verify baseURL and browsers
cat -n playwright.config.ts

Repository: WeGo-Together/WeGo_FrontEnd

Length of output: 2769


Profile E2E tests are straightforward and align with routing behavior

  • Using page.goto('/profile/1') with expect(page).toHaveURL('/mypage') aligns with the baseURL configuration (http://localhost:3000).
  • The not-found case via getByTestId('not-found-user') matches the component change and should be robust.

The comment on line 12 needs updating: it says "나의 프로필 페이지 방문" (visiting my profile page) but should reflect that it's testing a non-existent profile (e.g., "존재하지 않는 프로필 페이지 방문").

🤖 Prompt for AI Agents
In e2e/tests/profile.test.ts around lines 1 to 17, the inline comment on line 12
incorrectly reads "나의 프로필 페이지 방문" but this test visits a non-existent profile;
update that comment to "존재하지 않는 프로필 페이지 방문" so it accurately describes the test
case and leave the rest of the test unchanged.

// MSW 활성화 여부 확인
const isDev = process.env.NODE_ENV === 'development';
const shouldEnable = isDev ? config.enabledInDevelopment : config.enabledInProduction;
const shouldEnable = process.env.NEXT_PUBLIC_MSW_ENABLED === 'true';
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

fd -t f "browser|index" src/mock

Repository: WeGo-Together/WeGo_FrontEnd

Length of output: 108


🏁 Script executed:

cat -n src/mock/index.ts

Repository: WeGo-Together/WeGo_FrontEnd

Length of output: 1525


🏁 Script executed:

cat -n src/mock/browser.ts

Repository: WeGo-Together/WeGo_FrontEnd

Length of output: 661


MSW init flow looks correct; one small type import polish

  • The env gate (NEXT_PUBLIC_MSW_ENABLED === 'true') cleanly centralizes MSW control for both server and client.
  • Caching window.mswWorker avoids duplicate workers across HMR, which is good.
  • Handler wiring is correct: worker is created without handlers in ./browser, then handlers are injected via worker.use() on first init and reset via worker.resetHandlers() on HMR—no duplication.

One improvement:

Mark SetupWorker as a type-only import (line 3) to clarify it's used only for the type annotation on line 10:

-import { SetupWorker } from 'msw/browser';
+import type { SetupWorker } from 'msw/browser';

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
src/mock/index.ts around line 16: the SetupWorker symbol is used only for a type
annotation (on line 10) but is imported as a regular value import; change the
import to a type-only import (e.g., import type { SetupWorker } from 'msw') so
TypeScript drops it from emitted JS and clarifies intent, leaving the rest of
the file unchanged.

@Chiman2937 Chiman2937 merged commit bd02e9f into main Dec 11, 2025
6 checks passed
@Chiman2937 Chiman2937 deleted the chiyoung-feat/profile-e2e-test branch December 11, 2025 04:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready For Review! 리뷰 받을 준비가 되었습니다.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[프로필 페이지] 테스트 코드 작성

3 participants