-
Notifications
You must be signed in to change notification settings - Fork 3
[test] 지원하기 e2e 테스트 #1132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
seongwon030
wants to merge
20
commits into
develop-fe
Choose a base branch
from
feature/#1131-apply-e2e-test-MOA-591
base: develop-fe
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[test] 지원하기 e2e 테스트 #1132
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
51bc908
refactor: prop앞에 $추가
seongwon030 4dcf2b8
fix: styled-components 커스텀 prop에 $ 접두사 적용 (DOM 경고 방지)
seongwon030 39657ad
chore: e2e 테스트 스크립트/Playwright 추가 및 MSW 설정
seongwon030 916687b
chore: playwright 설정 추가 및 e2e 실행 옵션 정리
seongwon030 8108572
chore: package-lock json 추가
seongwon030 c2920e9
fix: MSW 비활성화 시 서비스워커 자동 해제
seongwon030 ad67a1b
fix: MSW 서비스워커 스크립트 최신화
seongwon030 9b26475
feat: e2e mock 데이터 추가
seongwon030 580ae33
test: 지원하기 플로우 e2e 테스트 추가
seongwon030 c080912
chore: gitingore 업데이트
seongwon030 22e91e9
fix: TS 설정 보완
seongwon030 d2b044e
feat: 프론트엔드 테스트 ci 추가
seongwon030 b06ef5d
fix: 단위테스트 시 e2e 파일 제외
seongwon030 1b0f8f8
fix: Playwright에서 서비스워커 차단 및 MSW 시작 실패 처리
seongwon030 2e229dd
feat: Mixpanel 비활성화 시 mock 함수 적용
seongwon030 943f3c5
feat: e2e 서버 실행 시 Mixpanel 비활성화 환경변수 추가
seongwon030 728d5dc
chore: 환경변수 주입
seongwon030 f7dfc6b
refactor: 주석제거
seongwon030 7ff6b66
chore: 개발서버 주소 직접 지정
seongwon030 112da33
chore: ci 파일에 서버주소 제거
seongwon030 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| name: Frontend CI | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [main, develop-fe] | ||
| paths: | ||
| - "frontend/**" | ||
| push: | ||
| branches: [main, develop-fe] | ||
| paths: | ||
| - "frontend/**" | ||
|
|
||
| defaults: | ||
| run: | ||
| working-directory: frontend | ||
|
|
||
| jobs: | ||
| lint: | ||
| name: Lint | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version-file: "frontend/.nvmrc" | ||
| cache: "npm" | ||
| cache-dependency-path: "frontend/package-lock.json" | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Run ESLint | ||
| run: npm run lint | ||
|
|
||
| test: | ||
| name: Unit Tests | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version-file: "frontend/.nvmrc" | ||
| cache: "npm" | ||
| cache-dependency-path: "frontend/package-lock.json" | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Run tests | ||
| run: npm run test -- --coverage | ||
|
|
||
| - name: Upload coverage | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: coverage-report | ||
| path: frontend/coverage/ | ||
| retention-days: 7 | ||
|
|
||
| e2e: | ||
| name: E2E Tests | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version-file: "frontend/.nvmrc" | ||
| cache: "npm" | ||
| cache-dependency-path: "frontend/package-lock.json" | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Install Playwright browsers | ||
| run: npx playwright install --with-deps chromium | ||
|
|
||
| - name: Run E2E tests | ||
| run: npm run test:e2e -- --project=chromium | ||
| env: | ||
| CI: true | ||
|
|
||
| - name: Upload Playwright report | ||
| uses: actions/upload-artifact@v4 | ||
| if: always() | ||
| with: | ||
| name: playwright-report | ||
| path: frontend/playwright-report/ | ||
| retention-days: 7 | ||
|
|
||
| - name: Upload test results | ||
| uses: actions/upload-artifact@v4 | ||
| if: failure() | ||
| with: | ||
| name: test-results | ||
| path: frontend/test-results/ | ||
| retention-days: 7 | ||
|
|
||
| build: | ||
| name: Build | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version-file: "frontend/.nvmrc" | ||
| cache: "npm" | ||
| cache-dependency-path: "frontend/package-lock.json" | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Build | ||
| run: npm run build:prod |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,157 @@ | ||
| import { expect, test } from '@playwright/test'; | ||
| import { | ||
| MOCK_CLUB_ID, | ||
| MOCK_FORM_ID, | ||
| mockApplicationFormResponse, | ||
| mockApplicationOptionsResponse, | ||
| mockClubDetailResponse, | ||
| mockClubSearchResponse, | ||
| } from './fixture/mock-data'; | ||
|
|
||
| // 팝업 닫기 헬퍼 함수 | ||
| async function closePopupIfExists(page: import('@playwright/test').Page) { | ||
| const popup = page.locator('[aria-modal="true"]'); | ||
| const isPopupVisible = await popup.isVisible().catch(() => false); | ||
|
|
||
| if (isPopupVisible) { | ||
| await page.keyboard.press('Escape'); | ||
| await page.waitForTimeout(300); | ||
|
|
||
| if (await popup.isVisible().catch(() => false)) { | ||
| const closeButton = popup.locator('button').first(); | ||
| if (await closeButton.isVisible().catch(() => false)) { | ||
| await closeButton.click({ force: true }); | ||
| await page.waitForTimeout(300); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| test.describe('지원하기 플로우', () => { | ||
| test.beforeEach(async ({ context }) => { | ||
| // context.route는 서비스 워커를 통과하는 요청도 가로챌 수 있음 | ||
|
|
||
| // 모든 API 요청을 하나의 핸들러에서 URL 기반으로 분기 처리 | ||
| await context.route( | ||
| (url) => url.href.includes('/api/club'), | ||
| async (route) => { | ||
| const url = route.request().url(); | ||
| const method = route.request().method(); | ||
| console.log(`[MOCK] ${method} ${url}`); | ||
|
|
||
| // 지원서 폼 데이터 (GET) + 지원 제출 (POST) | ||
| if (url.includes(`/api/club/${MOCK_CLUB_ID}/apply/${MOCK_FORM_ID}`)) { | ||
| if (method === 'POST') { | ||
| await route.fulfill({ status: 200, body: '' }); | ||
| } else { | ||
| await route.fulfill({ json: mockApplicationFormResponse }); | ||
| } | ||
| return; | ||
| } | ||
|
|
||
| // 지원서 옵션 목록 (GET /api/club/{clubId}/apply) | ||
| if ( | ||
| url.includes(`/api/club/${MOCK_CLUB_ID}/apply`) && | ||
| !url.includes(`/apply/`) | ||
| ) { | ||
| await route.fulfill({ json: mockApplicationOptionsResponse }); | ||
| return; | ||
| } | ||
|
|
||
| // 동아리 검색 (GET /api/club/search/) | ||
| if (url.includes('/api/club/search')) { | ||
| await route.fulfill({ json: mockClubSearchResponse }); | ||
| return; | ||
| } | ||
|
|
||
| // 동아리 상세 (GET /api/club/{clubId}) — 위에서 매칭되지 않은 나머지 | ||
| if ( | ||
| url.includes(`/api/club/${MOCK_CLUB_ID}`) && | ||
| !url.includes('/apply') && | ||
| !url.includes('/search') | ||
| ) { | ||
| await route.fulfill({ json: mockClubDetailResponse }); | ||
| return; | ||
| } | ||
|
|
||
| // 매칭되지 않는 API 요청은 통과 | ||
| await route.continue(); | ||
| }, | ||
| ); | ||
| }); | ||
|
|
||
| test('메인페이지 → 동아리 카드 클릭 → 상세 → 지원하기 → 폼 작성 → 제출', async ({ | ||
| page, | ||
| }) => { | ||
| // 브라우저 콘솔 에러 로깅 | ||
| page.on('console', (msg) => { | ||
| if (msg.type() === 'error') { | ||
| console.log(`[BROWSER ERROR] ${msg.text()}`); | ||
| } | ||
| }); | ||
| page.on('pageerror', (err) => { | ||
| console.log(`[PAGE ERROR] ${err.message}`); | ||
| }); | ||
|
|
||
| // Step 1: 메인페이지 진입 | ||
| await page.goto('/'); | ||
| await page.waitForLoadState('networkidle'); | ||
| await closePopupIfExists(page); | ||
|
|
||
| await expect(page.getByText(/전체 \d+개의 동아리/)).toBeVisible({ | ||
| timeout: 10000, | ||
| }); | ||
|
|
||
seongwon030 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // Step 2: 동아리 카드 클릭 → 상세페이지 이동 | ||
| await page.getByText('테스트 동아리').first().click(); | ||
|
|
||
| await expect(page).toHaveURL(new RegExp(`/clubDetail/${MOCK_CLUB_ID}`), { | ||
| timeout: 10000, | ||
| }); | ||
|
|
||
| // Step 3: 상세페이지에서 동아리명 확인 및 지원하기 버튼 확인 | ||
| await expect(page.getByText('테스트 동아리').first()).toBeVisible({ | ||
| timeout: 10000, | ||
| }); | ||
|
|
||
| const applyButton = page.getByText('지원하기'); | ||
| await expect(applyButton).toBeVisible({ timeout: 10000 }); | ||
|
|
||
| // Step 4: 지원하기 버튼 클릭 → 지원서 폼 페이지 이동 | ||
| await applyButton.click(); | ||
|
|
||
| await expect(page).toHaveURL( | ||
| new RegExp(`/application/${MOCK_CLUB_ID}/${MOCK_FORM_ID}`), | ||
| { timeout: 10000 }, | ||
| ); | ||
|
|
||
| // Step 5: 지원서 폼 확인 및 답변 입력 | ||
| await expect( | ||
| page.getByText('2026년 1학기 신입부원 모집').first(), | ||
| ).toBeVisible({ timeout: 10000 }); | ||
|
|
||
| // NAME 질문: 이름 입력 | ||
| const nameInput = page.getByPlaceholder('답변입력란(최대 100자)').first(); | ||
| await nameInput.fill('홍길동'); | ||
|
|
||
| // SHORT_TEXT 질문: 지원 동기 입력 | ||
| const motivationInput = page | ||
| .getByPlaceholder('답변입력란(최대 100자)') | ||
| .nth(1); | ||
| await motivationInput.fill('동아리 활동에 관심이 많습니다.'); | ||
|
|
||
| // CHOICE 질문: 선택지 클릭 | ||
| await page.getByText('프로그래밍').click(); | ||
|
|
||
| // Step 6: 제출하기 클릭 → alert 확인 → 상세페이지 복귀 | ||
| page.on('dialog', async (dialog) => { | ||
| await dialog.accept(); | ||
| }); | ||
|
|
||
| await page.getByText('제출하기').click(); | ||
|
|
||
| await expect(page).toHaveURL(new RegExp(`/clubDetail/${MOCK_CLUB_ID}`), { | ||
| timeout: 10000, | ||
| }); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.