-
Notifications
You must be signed in to change notification settings - Fork 7
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
핵심기능 E2E 테스트 - 템플릿, 인증/인가 #647
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
09c5619
feat(e2eTests): 템플릿 관련 핵심기능 E2E 테스트 작성
Jaymyong66 195b782
chore: jest.config - testIgnorePattern에 e2eTests 폴더만 명시적으로 적용
Jaymyong66 641304e
refactor(e2eTests): waitForSuccess 유틸함수를 활용, 파일명 오타 수정(공백제거_
Jaymyong66 bbd8417
refactor(e2eTests): templates 관련 공통 로직을 actions 파일로 분리
Jaymyong66 c7c2d8d
refactor(e2eTests): templates - Locator를 의미있는 네이밍을 가진 변수에 할당
Jaymyong66 dc9f86e
refactor(e2eTests): templates - 템플릿 업로드 action에서 요청 success, redirect…
Jaymyong66 ffa04e8
refactor(e2eTests): utill - waitForSuccess에 201 status 추가, login 요청 s…
Jaymyong66 691f355
refactor(e2eTests): templates - 수정을 위한 템플릿 생성 케이스 제거, 테스트 변수명 변경
Jaymyong66 8f57161
refactor(e2eTests): 테스트에 불필요한 click 이벤트 제거
Jaymyong66 ee0c2f5
Merge branch 'dev/fe' of https://github.com/woowacourse-teams/2024-co…
Jaymyong66 33e4190
refactor(e2eTests): templates - waitForSuccess의 인자 변수명을 apiUrl로 변경
Jaymyong66 2108363
refactor(e2eTests): 테스트 아이디 환경변수 적용
Jaymyong66 4d6a1f1
refactor(e2eTests): templates - 템플릿 업로드 전 카테고리 목록 요청 응답을 기다리도록 변경
Jaymyong66 288f483
feat(playwright): 테스트 전 로그인을 authentication page context로 저장
Jaymyong66 1e0b106
refactor(playwright): e2eTests -> playwright로 폴더 변경, 로그인 beforeEach 제거
Jaymyong66 f417b61
refactor(tests): authentication - 로그인 테스트 제거
Jaymyong66 77b1a5b
feat(tests): category, search - 테스트 전, page 이동
Jaymyong66 3ff4404
chore: package.json - e2e 관련 스크립트 추가
Jaymyong66 6b4f993
chore: jest.config - CI에서 playwright 제외
Jaymyong66 5eefd65
refactor(tests): templates.actions - categories waitForSuccess 오류를 wa…
Jaymyong66 262d293
refactor(tests): search 테스트에서 검색 테스트의 키워드 '테스트'=>'검색테스트'로 변경
Hain-tain 2a6c8b1
refactor(tests): templates - 테스트로 만들어진 템플릿 삭제 처리
Jaymyong66 8a3c479
refactor(tests): templates - 생성하는 템플릿 정보에 테스트 브라우저 환경 추가
Jaymyong66 ad02ef6
Merge branch 'feat/636-e2e-init' of https://github.com/woowacourse-te…
Jaymyong66 a14702f
refactor(playwright): templates - 테스트 중 에러 발생 시, 생성한 템플릿 제거를 finally로 처리
Jaymyong66 d968b6e
refactor(playwright): category - 테스트 중 에러 발생 시, 생성한 템플릿 제거를 finally로 처리
Jaymyong66 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 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 |
---|---|---|
|
@@ -10,6 +10,9 @@ | |
### Environment Variable ### | ||
.env | ||
|
||
### playwright authentication context | ||
.auth | ||
|
||
*.crt | ||
*.csr | ||
*.key | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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 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 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 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,20 @@ | ||
import { test as setup } from '@playwright/test'; | ||
import path from 'path'; | ||
|
||
const authFile = path.join(__dirname, '../.auth/user.json'); | ||
|
||
setup('authenticate', async ({ page }) => { | ||
const username = process.env.PLAYWRIGHT_TEST_USERNAME || ''; | ||
const password = process.env.PLAYWRIGHT_TEST_PASSWORD || ''; | ||
|
||
await page.goto('/'); | ||
await page.getByRole('button', { name: '로그인', exact: true }).click(); | ||
await page.locator('input[type="text"]').fill(username); | ||
await page.locator('input[type="text"]').press('Tab'); | ||
await page.locator('input[type="password"]').fill(password); | ||
await page.locator('form').getByRole('button', { name: '로그인' }).click(); | ||
|
||
await page.waitForURL('/my-templates'); | ||
|
||
await page.context().storageState({ path: authFile }); | ||
}); |
File renamed without changes.
This file contains 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,109 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
import { createCategory, deleteCategory, getCategoryButton } from './category.actions'; | ||
import { waitForSuccess } from './utils'; | ||
|
||
test('카테고리 편집 모달에서 새 카테고리를 추가 및 삭제할 수 있다.', async ({ page, browserName }) => { | ||
await page.goto('/my-templates'); | ||
|
||
const newCategoryName = `생성테스트-${browserName}`; | ||
|
||
try { | ||
await createCategory({ page, categoryName: newCategoryName }); | ||
|
||
await waitForSuccess({ page, apiUrl: '/categories' }); | ||
|
||
const newCategoryButton = getCategoryButton({ page, categoryName: newCategoryName }); | ||
|
||
await expect(newCategoryButton).toBeVisible(); | ||
} catch (error) { | ||
throw Error(error); | ||
} finally { | ||
await deleteCategory({ page, categoryName: newCategoryName }); | ||
|
||
await waitForSuccess({ page, apiUrl: '/categories' }); | ||
|
||
const newCategoryButton = getCategoryButton({ page, categoryName: newCategoryName }); | ||
|
||
await expect(newCategoryButton).not.toBeVisible(); | ||
} | ||
}); | ||
|
||
test('카테고리 편집 모달에서 카테고리명을 수정 및 삭제할 수 있다.', async ({ page, browserName }) => { | ||
await page.goto('/my-templates'); | ||
|
||
const newCategoryName = `수정테스트-${browserName}`; | ||
const editedCategoryName = `수정완료-${browserName}`; | ||
|
||
try { | ||
// 수정할 카테고리 생성 | ||
await createCategory({ page, categoryName: newCategoryName }); | ||
|
||
await waitForSuccess({ page, apiUrl: '/categories' }); | ||
|
||
const newCategoryButton = getCategoryButton({ page, categoryName: newCategoryName }); | ||
|
||
await expect(newCategoryButton).toBeVisible(); | ||
|
||
// 카테고리 수정 | ||
await page.getByRole('button', { name: '카테고리 편집' }).click(); | ||
|
||
const newCategoryInEditModal = page.getByText(newCategoryName).nth(1); | ||
|
||
await newCategoryInEditModal.hover(); | ||
await page.getByRole('button', { name: '카테고리 이름 변경' }).click(); | ||
await page.getByPlaceholder('카테고리 입력').click(); | ||
await page.getByPlaceholder('카테고리 입력').fill(editedCategoryName); | ||
await page.getByRole('button', { name: '저장' }).click(); | ||
|
||
const editedCategoryButton = getCategoryButton({ page, categoryName: editedCategoryName }); | ||
|
||
await expect(editedCategoryButton).toBeVisible(); | ||
} catch (error) { | ||
throw Error(error); | ||
} finally { | ||
// 다음 테스트를 위해 테스트용 카테고리 삭제 | ||
await deleteCategory({ page, categoryName: editedCategoryName }); | ||
|
||
const editedCategoryButton = getCategoryButton({ page, categoryName: editedCategoryName }); | ||
|
||
await waitForSuccess({ page, apiUrl: '/categories' }); | ||
await expect(editedCategoryButton).not.toBeVisible(); | ||
} | ||
}); | ||
|
||
test('카테고리는 최대 15글자까지만 입력할 수 있다.', async ({ page, browserName }) => { | ||
await page.goto('/my-templates'); | ||
const rawCategoryName = `최대글자수테스트-${browserName}`; | ||
const expectedCategoryName = rawCategoryName.slice(0, 15); | ||
|
||
try { | ||
await page.getByRole('button', { name: '카테고리 편집' }).click(); | ||
await page.getByRole('button', { name: '+ 카테고리 추가' }).click(); | ||
const categoryInput = page.getByPlaceholder('카테고리 입력'); | ||
|
||
await categoryInput.click(); | ||
|
||
for (const char of rawCategoryName) { | ||
await page.keyboard.type(char); | ||
} | ||
|
||
await page.getByRole('button', { name: '저장' }).click(); | ||
|
||
await waitForSuccess({ page, apiUrl: '/categories' }); | ||
|
||
const newCategoryButton = getCategoryButton({ page, categoryName: expectedCategoryName }); | ||
|
||
await expect(newCategoryButton).toBeVisible(); | ||
} catch (error) { | ||
throw Error(error); | ||
} finally { | ||
// 다음 테스트를 위해 테스트용 카테고리 삭제 | ||
await deleteCategory({ page, categoryName: expectedCategoryName }); | ||
|
||
const newCategoryButton = getCategoryButton({ page, categoryName: expectedCategoryName }); | ||
|
||
await waitForSuccess({ page, apiUrl: '/categories' }); | ||
await expect(newCategoryButton).not.toBeVisible(); | ||
} | ||
}); |
File renamed without changes.
22 changes: 10 additions & 12 deletions
22
frontend/e2eTests/search.spec.ts → frontend/playwright/tests/search.spec.ts
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
굿굿! 스크립트 추가하니까 훨씬 편하고 좋네요! 👍