Skip to content

πŸ§ͺ μ„Έλ―Έλ‚˜ μž‘μ„± 흐름을 검증 Playwright ν…ŒμŠ€νŠΈ μΆ”κ°€ #417

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
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions e2e/fixtures/pages.fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<PagesFixtures>({
Expand All @@ -22,4 +26,14 @@ export const test = base.extend<PagesFixtures>({
) => {
await use(new NoticeCreatePage(page));
},

seminarPage: async ({ page }: { page: Page }, use: (page: SeminarPage) => Promise<void>) => {
await use(new SeminarPage(page));
},
seminarCreatePage: async (
{ page }: { page: Page },
use: (page: SeminarCreatePage) => Promise<void>,
) => {
await use(new SeminarCreatePage(page));
},
});
52 changes: 52 additions & 0 deletions e2e/pages/community/seminar/create.page.ts
Original file line number Diff line number Diff line change
@@ -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();
}
}
19 changes: 19 additions & 0 deletions e2e/pages/community/seminar/index.page.ts
Original file line number Diff line number Diff line change
@@ -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();
}
}
32 changes: 32 additions & 0 deletions e2e/tests/community/seminar.test.ts
Original file line number Diff line number Diff line change
@@ -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();
});
});