From 06ec16c4920a5f868c1ff8d0f66466ae70df95fc Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 26 Sep 2024 02:08:42 +0000 Subject: [PATCH 1/3] Create draft PR for #723 From 65494fe9535769f1060c4d0b54bf430cc752f4d0 Mon Sep 17 00:00:00 2001 From: Kim Da Eun Date: Thu, 26 Sep 2024 23:32:08 +0900 Subject: [PATCH 2/3] =?UTF-8?q?test:=20=EA=B3=B5=EA=B3=A0=20=EB=A6=AC?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EB=A0=8C?= =?UTF-8?q?=EB=8D=94=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../recruitmentPostList.spec.ts | 55 +++++++++++++++++++ frontend/e2e/example.spec.ts | 18 ------ frontend/package-lock.json | 1 - frontend/src/mocks/handlers/authHandlers.ts | 2 +- frontend/src/pages/RecruitmentPost/index.tsx | 2 +- frontend/tsconfig.json | 2 +- 6 files changed, 58 insertions(+), 22 deletions(-) create mode 100644 frontend/e2e/createRecruitmentPost/recruitmentPostList.spec.ts delete mode 100644 frontend/e2e/example.spec.ts diff --git a/frontend/e2e/createRecruitmentPost/recruitmentPostList.spec.ts b/frontend/e2e/createRecruitmentPost/recruitmentPostList.spec.ts new file mode 100644 index 000000000..1e1f3551e --- /dev/null +++ b/frontend/e2e/createRecruitmentPost/recruitmentPostList.spec.ts @@ -0,0 +1,55 @@ +import { test, expect } from '@playwright/test'; +import { routes } from '@router/path'; + +test.describe('공고 목록 페이지', () => { + test.beforeEach(async ({ page }) => { + // 로그인 + await page.goto(routes.signIn()); + await page.fill('input[name="email"]', 'member@mail.com'); + await page.fill('input[name="password"]', 'qwer1234'); + await page.click('button[type="submit"]'); + + await page.waitForURL(routes.dashboard.list()); + }); + + test.describe('[Render] 공고 목록 페이지의 UI 요소가 올바르게 렌더링되는지 테스트한다.', () => { + test.skip('공고 목록 페이지의 타이틀이 올바르게 렌더링된다.', async ({ page }) => { + const title = await page.locator('h1'); + expect(await title.isVisible()).toBeTruthy(); + }); + + test('카드가 존재하는 경우 공고 제목, 모집 상태, 마감일, 지원자 현황(전체, 평가대상, 불합격, 합격)이 렌더링된다.', async ({ + page, + }) => { + await page.waitForSelector('article'); + + // 카드의 존재 여부 확인 + const card = await page.locator('article').nth(0); + + // 공고 제목 확인 + const recruitInfo = await card.locator('div').first(); + const title = await recruitInfo.locator('div').nth(0); + expect(await title.isVisible()).toBeTruthy(); + + // 모집 상태 확인 + const status = await recruitInfo.locator('div').nth(1); + expect(await status.isVisible()).toBeTruthy(); + + // 마감일 확인 + const deadline = await recruitInfo.locator('div').nth(2); + expect(await deadline.isVisible()).toBeTruthy(); + + // 지원자 현황 확인 + const total = await card.locator('div:has-text("전체")').locator('span').first(); + const evaluated = await card.locator('div:has-text("평가 대상")').locator('span').first(); + const failed = await card.locator('div:has-text("불합격")').locator('span').first(); + const passed = await card.locator('div:has-text("합격")').locator('span').first(); + + // 각각의 요소가 보이는지 확인 + expect(await total.isVisible()).toBeTruthy(); + expect(await evaluated.isVisible()).toBeTruthy(); + expect(await failed.isVisible()).toBeTruthy(); + expect(await passed.isVisible()).toBeTruthy(); + }); + }); +}); diff --git a/frontend/e2e/example.spec.ts b/frontend/e2e/example.spec.ts deleted file mode 100644 index 54a906a4e..000000000 --- a/frontend/e2e/example.spec.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { test, expect } from '@playwright/test'; - -test('has title', async ({ page }) => { - await page.goto('https://playwright.dev/'); - - // Expect a title "to contain" a substring. - await expect(page).toHaveTitle(/Playwright/); -}); - -test('get started link', async ({ page }) => { - await page.goto('https://playwright.dev/'); - - // Click the get started link. - await page.getByRole('link', { name: 'Get started' }).click(); - - // Expects page to have a heading with the name of Installation. - await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible(); -}); diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 1fbc750d2..48e914f10 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -50,7 +50,6 @@ "@typescript-eslint/parser": "^7.16.0", "chromatic": "^11.5.6", "copy-webpack-plugin": "^12.0.2", - "copy-webpack-plugin": "^12.0.2", "css-loader": "^7.1.2", "dotenv": "^16.4.5", "dotenv-webpack": "^8.1.0", diff --git a/frontend/src/mocks/handlers/authHandlers.ts b/frontend/src/mocks/handlers/authHandlers.ts index 825803d7f..0ec6f5fc5 100644 --- a/frontend/src/mocks/handlers/authHandlers.ts +++ b/frontend/src/mocks/handlers/authHandlers.ts @@ -14,7 +14,7 @@ const authHandlers = [ await new Promise((resolve) => setTimeout(resolve, 2000)); - if (!body.email || !body.password || body.email !== 'admin@gmail.com' || body.password !== 'admin') { + if (!body.email || !body.password || body.email !== 'member@mail.com' || body.password !== 'qwer1234') { return new Response(JSON.stringify({ detail: '로그인 정보가 일치하지 않습니다.' }), { status: 401, }); diff --git a/frontend/src/pages/RecruitmentPost/index.tsx b/frontend/src/pages/RecruitmentPost/index.tsx index ca958c87a..e5d742a4a 100644 --- a/frontend/src/pages/RecruitmentPost/index.tsx +++ b/frontend/src/pages/RecruitmentPost/index.tsx @@ -19,7 +19,7 @@ export default function RecruitmentPost() { - {recruitmentPost?.title} + {recruitmentPost?.title ?? ''} {Object.values(recruitmentPeriod).join(' ~ ')} diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json index 1a8f7ceef..61ca51de5 100644 --- a/frontend/tsconfig.json +++ b/frontend/tsconfig.json @@ -44,5 +44,5 @@ "@router/*": ["src/router/*"] } }, - "include": ["src/**/*", "setupTests.ts", ".storybook/*", "src/types/images.d.ts"] + "include": ["src/**/*", "setupTests.ts", ".storybook/*", "src/types/images.d.ts", "e2e/**/*"] } From 3ad1fe7794611ca4e32c1cb9ff5c19b97dce4817 Mon Sep 17 00:00:00 2001 From: Kim Da Eun Date: Fri, 27 Sep 2024 00:25:15 +0900 Subject: [PATCH 3/3] =?UTF-8?q?test:=20=EA=B3=B5=EA=B3=A0=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=95=A1=EC=85=98=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../recruitmentPostList.spec.ts | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/frontend/e2e/createRecruitmentPost/recruitmentPostList.spec.ts b/frontend/e2e/createRecruitmentPost/recruitmentPostList.spec.ts index 1e1f3551e..8e56643f6 100644 --- a/frontend/e2e/createRecruitmentPost/recruitmentPostList.spec.ts +++ b/frontend/e2e/createRecruitmentPost/recruitmentPostList.spec.ts @@ -52,4 +52,26 @@ test.describe('공고 목록 페이지', () => { expect(await passed.isVisible()).toBeTruthy(); }); }); + + test.describe('[Action] 공고 목록 페이지의 기능이 올바르게 동작하는지 테스트한다.', () => { + test('공고 카드를 클릭하면 공고 대시보드 페이지로 이동한다.', async ({ page }) => { + await page.waitForSelector('article'); + + const card = await page.locator('article').nth(0); + await card.click(); + + const currentPath = new URL(page.url()).pathname; + const dashboardPathPattern = /^\/dashboard\/\d+\/\d+$/; + expect(currentPath).toMatch(dashboardPathPattern); + }); + + test('새 공고 추가 버튼을 클릭하면 공고 생성 페이지로 이동한다.', async ({ page }) => { + const createButton = await page.getByText('새 공고 추가'); + await createButton.click(); + + const currentPath = new URL(page.url()).pathname; + const createPathPattern = /^\/dashboard\/create$/; + expect(currentPath).toMatch(createPathPattern); + }); + }); });