-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #647 from woowacourse-teams/feat/636-e2e-init
핵심기능 E2E 테스트 - 템플릿, 인증/인가
- Loading branch information
Showing
14 changed files
with
384 additions
and
144 deletions.
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.