diff --git a/e2e/fixtures/pages.fixture.ts b/e2e/fixtures/pages.fixture.ts index 7cdf3c19..e9be9290 100644 --- a/e2e/fixtures/pages.fixture.ts +++ b/e2e/fixtures/pages.fixture.ts @@ -5,11 +5,15 @@ import { Page } from '@playwright/test'; import { NoticeCreatePage } from '../pages/community/notice/create.page'; import { NoticePage } from '../pages/community/notice/index.page'; +import { SeminarCreatePage } from '../pages/community/seminar/create.page'; +import { SeminarPage } from '../pages/community/seminar/index.page'; import { test as base } from './role.fixture'; type PagesFixtures = { noticePage: NoticePage; noticeCreatePage: NoticeCreatePage; + seminarPage: SeminarPage; + seminarCreatePage: SeminarCreatePage; }; export const test = base.extend({ @@ -22,4 +26,14 @@ export const test = base.extend({ ) => { await use(new NoticeCreatePage(page)); }, + + seminarPage: async ({ page }: { page: Page }, use: (page: SeminarPage) => Promise) => { + await use(new SeminarPage(page)); + }, + seminarCreatePage: async ( + { page }: { page: Page }, + use: (page: SeminarCreatePage) => Promise, + ) => { + await use(new SeminarCreatePage(page)); + }, }); diff --git a/e2e/pages/community/seminar/create.page.ts b/e2e/pages/community/seminar/create.page.ts new file mode 100644 index 00000000..ce3f02b4 --- /dev/null +++ b/e2e/pages/community/seminar/create.page.ts @@ -0,0 +1,52 @@ +import type { Locator, Page } from '@playwright/test'; + +export class SeminarCreatePage { + readonly page: Page; + readonly titleInput: Locator; + readonly locationInput: Locator; + readonly nameInput: Locator; + readonly affiliationInput: Locator; + readonly startDateInput: Locator; + readonly submitButton: Locator; + + constructor(page: Page) { + this.page = page; + this.titleInput = page.getByPlaceholder('제목을 입력하세요.'); + this.locationInput = page.getByPlaceholder('장소를 입력하세요.'); + this.nameInput = page.getByLabel('이름'); + this.affiliationInput = page.getByLabel('소속'); + this.startDateInput = page.getByText(/^\d{4}년 \d{1,2}월 \d{1,2}일/); // "2025년 8월 20일 수요일" + this.submitButton = page.getByRole('button', { name: '저장하기' }); + } + + async goto() { + await this.page.goto('/community/seminar/create'); + } + + async fillTitle(title: string) { + await this.titleInput.fill(title); + } + + async fillLocation(location: string) { + await this.locationInput.fill(location); + } + + async fillName(name: string) { + await this.nameInput.fill(name); + } + + async fillAffiliation(affiliation: string) { + await this.affiliationInput.fill(affiliation); + } + + async selectStartDate(day: string, hour: string, minute: string) { + await this.startDateInput.click(); // 날짜 선택 모달 열기 + await this.page.getByRole('button', { name: day }).click(); // 예: '20' + await this.page.getByText(`${hour}시`).click(); // 예: '14시' + await this.page.getByText(`${minute}분`).click(); // 예: '30분' + } + + async clickSubmitButton() { + await this.submitButton.click(); + } +} diff --git a/e2e/pages/community/seminar/index.page.ts b/e2e/pages/community/seminar/index.page.ts new file mode 100644 index 00000000..7a67d58c --- /dev/null +++ b/e2e/pages/community/seminar/index.page.ts @@ -0,0 +1,19 @@ +import type { Locator, Page } from '@playwright/test'; + +export class SeminarPage { + readonly page: Page; + readonly newPostButton: Locator; + + constructor(page: Page) { + this.page = page; + this.newPostButton = page.getByRole('button', { name: '새 게시글' }); + } + + async goto() { + await this.page.goto('/community/seminar/'); + } + + async clickNewPostButton() { + await this.newPostButton.click(); + } +} \ No newline at end of file diff --git a/e2e/tests/community/seminar.test.ts b/e2e/tests/community/seminar.test.ts new file mode 100644 index 00000000..b2e5795c --- /dev/null +++ b/e2e/tests/community/seminar.test.ts @@ -0,0 +1,32 @@ +import { expect } from '@playwright/test'; +import { test } from '../../fixtures'; + +test.describe('Seminar', () => { + test('should allow STAFF to create a seminar post with required fields', async ({ + page, + loginAs, + seminarPage, + seminarCreatePage, + }) => { + // 로그인 + await loginAs('STAFF'); + + // 세미나 페이지 이동 → 새 게시글 클릭 + await seminarPage.goto(); + await seminarPage.clickNewPostButton(); + + // 데이터 입력 + const title = `[E2E] 테스트 세미나 ${Date.now()}`; + await seminarCreatePage.fillTitle(title); + await seminarCreatePage.fillLocation('서울대학교 301동'); + await seminarCreatePage.fillName('홍길동'); + await seminarCreatePage.fillAffiliation('서울대학교 컴퓨터공학부'); + await seminarCreatePage.selectStartDate('20', '14', '30'); // 20일 14시 30분 + + // 제출 + await seminarCreatePage.clickSubmitButton(); + + // 결과 확인 + await expect(page.getByText(title)).toBeVisible(); + }); +});