Skip to content

✅ 공지사항 테스트 추가 #416

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 2 commits 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
File renamed without changes.
29 changes: 24 additions & 5 deletions e2e/fixtures/pages.fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,43 @@
/* eslint-disable react-hooks/rules-of-hooks */

import { Page } from '@playwright/test';
import { test as base } from '@playwright/test';

import { NoticeCreatePage } from '../pages/community/notice/create.page';
import { NoticePage } from '../pages/community/notice/index.page';
import { test as base } from './role.fixture';
import { NoticeDetailPage } from '../pages/community/notice/detail.page';
import { NoticeEditPage } from '../pages/community/notice/edit.page';
import { NoticeListPage } from '../pages/community/notice/index.page';

type PagesFixtures = {
noticePage: NoticePage;
noticeListPage: NoticeListPage;
noticeCreatePage: NoticeCreatePage;
noticeEditPage: NoticeEditPage;
noticeDetailPage: NoticeDetailPage;
};

export const test = base.extend<PagesFixtures>({
noticePage: async ({ page }: { page: Page }, use: (page: NoticePage) => Promise<void>) => {
await use(new NoticePage(page));
noticeListPage: async (
{ page }: { page: Page },
use: (page: NoticeListPage) => Promise<void>,
) => {
await use(new NoticeListPage(page));
},
noticeCreatePage: async (
{ page }: { page: Page },
use: (page: NoticeCreatePage) => Promise<void>,
) => {
await use(new NoticeCreatePage(page));
},
noticeEditPage: async (
{ page }: { page: Page },
use: (page: NoticeEditPage) => Promise<void>,
) => {
await use(new NoticeEditPage(page));
},
noticeDetailPage: async (
{ page }: { page: Page },
use: (page: NoticeDetailPage) => Promise<void>,
) => {
await use(new NoticeDetailPage(page));
},
});
2 changes: 1 addition & 1 deletion e2e/fixtures/role.fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ type RoleFixtures = {
export const test = base.extend<RoleFixtures>({
loginAs: async ({ page }, use) => {
const login = async (role: Role) => {
await page.waitForLoadState('networkidle');
await page.getByRole('button', { name: role, exact: true }).click();
await page.waitForLoadState('networkidle');
};
await use(login);
},
Expand Down
39 changes: 39 additions & 0 deletions e2e/pages/community/notice/create.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,24 @@ export class NoticeCreatePage {
readonly page: Page;
readonly titleInput: Locator;
readonly contentEditor: Locator;
readonly tagInput: Locator;
readonly attachmentInput: Locator;
readonly importantToggle: Locator;
readonly privateToggle: Locator;
readonly pinnedToggle: Locator;
readonly mainDisplayToggle: Locator;
readonly submitButton: Locator;

constructor(page: Page) {
this.page = page;
this.titleInput = page.getByPlaceholder('제목을 입력하세요.');
this.contentEditor = page.locator('div.sun-editor-editable');
this.tagInput = page.locator('TODO_TAG_INPUT_SELECTOR'); // TODO: 실제 태그 입력 필드 selector 확인 필요
this.attachmentInput = page.locator('input[type="file"]');
this.importantToggle = page.locator('TODO_IMPORTANT_TOGGLE_SELECTOR'); // TODO: 중요 안내 토글 selector 확인 필요
this.privateToggle = page.locator('TODO_PRIVATE_TOGGLE_SELECTOR'); // TODO: 비공개 토글 selector 확인 필요
this.pinnedToggle = page.locator('TODO_PINNED_TOGGLE_SELECTOR'); // TODO: 상단고정 토글 selector 확인 필요
this.mainDisplayToggle = page.locator('TODO_MAIN_DISPLAY_TOGGLE_SELECTOR'); // TODO: 메인표시 토글 selector 확인 필요
this.submitButton = page.getByRole('button', { name: /게시/ });
}

Expand All @@ -22,7 +34,34 @@ export class NoticeCreatePage {
}

async fillContent(content: string) {
await this.page.waitForTimeout(1000); // suneditor 대기
await this.contentEditor.fill(content);
await this.page.waitForTimeout(1000); // suneditor 대기
}

async addTag(tag: string) {
await this.tagInput.fill(tag);
await this.page.keyboard.press('Enter');
}

async uploadAttachment(filePath: string) {
await this.attachmentInput.setInputFiles(filePath);
}

async toggleImportant() {
await this.importantToggle.click();
}

async togglePrivate() {
await this.privateToggle.click();
}

async togglePinned() {
await this.pinnedToggle.click();
}

async toggleMainDisplay() {
await this.mainDisplayToggle.click();
}

async clickSubmitButton() {
Expand Down
74 changes: 74 additions & 0 deletions e2e/pages/community/notice/detail.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { type Locator, type Page } from '@playwright/test';

export class NoticeDetailPage {
readonly page: Page;
readonly title: Locator;
readonly content: Locator;
readonly editButton: Locator;
readonly deleteButton: Locator;
readonly listButton: Locator;
readonly prevButton: Locator;
readonly nextButton: Locator;
readonly attachments: Locator;
readonly tags: Locator;

constructor(page: Page) {
this.page = page;
this.title = page.locator('TODO_NOTICE_TITLE_SELECTOR'); // TODO: 공지사항 제목 영역 selector 확인 필요
this.content = page.locator('TODO_NOTICE_CONTENT_SELECTOR'); // TODO: 공지사항 내용 영역 selector 확인 필요
this.editButton = page.getByRole('button', { name: '편집' });
this.deleteButton = page.getByRole('button', { name: '삭제' });
this.listButton = page.getByRole('button', { name: '목록' });
this.prevButton = page.locator('TODO_PREV_BUTTON_SELECTOR'); // TODO: 이전글 버튼 selector 확인 필요
this.nextButton = page.locator('TODO_NEXT_BUTTON_SELECTOR'); // TODO: 다음글 버튼 selector 확인 필요
this.attachments = page.locator('TODO_ATTACHMENTS_SECTION_SELECTOR'); // TODO: 첨부파일 영역 selector 확인 필요
this.tags = page.locator('TODO_TAGS_SECTION_SELECTOR'); // TODO: 태그 영역 selector 확인 필요
}

async goto(id: string) {
await this.page.goto(`/community/notice/${id}`);
}

async clickEditButton() {
await this.editButton.click();
}

async clickDeleteButton() {
await this.deleteButton.click();
}

async confirmDelete() {
// 삭제 확인 모달에서 확인 버튼 클릭
await this.page.getByRole('button', { name: '확인' }).click();
}

async clickListButton() {
await this.listButton.click();
}

async clickPrevButton() {
await this.prevButton.click();
}

async clickNextButton() {
await this.nextButton.click();
}

async getTitle(): Promise<string> {
return (await this.title.textContent()) || '';
}

async getContent(): Promise<string> {
return (await this.content.textContent()) || '';
}

async getTags(): Promise<string[]> {
const tagElements = await this.tags.locator('TODO_TAG_ITEM_SELECTOR').all(); // TODO: 개별 태그 item selector 확인 필요
const tags = [];
for (const tag of tagElements) {
const text = await tag.textContent();
if (text) tags.push(text);
}
return tags;
}
}
68 changes: 68 additions & 0 deletions e2e/pages/community/notice/edit.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { type Locator, type Page } from '@playwright/test';

export class NoticeEditPage {
readonly page: Page;
readonly titleInput: Locator;
readonly contentEditor: Locator;
readonly tagInput: Locator;
readonly attachmentInput: Locator;
readonly importantToggle: Locator;
readonly privateToggle: Locator;
readonly pinnedToggle: Locator;
readonly mainDisplayToggle: Locator;
readonly submitButton: Locator;

constructor(page: Page) {
this.page = page;
this.titleInput = page.getByPlaceholder('제목을 입력하세요.');
this.contentEditor = page.locator('div.sun-editor-editable');
this.tagInput = page.locator('TODO_TAG_INPUT_SELECTOR'); // TODO: 실제 태그 입력 필드 selector 확인 필요
this.attachmentInput = page.locator('input[type="file"]');
this.importantToggle = page.locator('TODO_IMPORTANT_TOGGLE_SELECTOR'); // TODO: 중요 안내 토글 selector 확인 필요
this.privateToggle = page.locator('TODO_PRIVATE_TOGGLE_SELECTOR'); // TODO: 비공개 토글 selector 확인 필요
this.pinnedToggle = page.locator('TODO_PINNED_TOGGLE_SELECTOR'); // TODO: 상단고정 토글 selector 확인 필요
this.mainDisplayToggle = page.locator('TODO_MAIN_DISPLAY_TOGGLE_SELECTOR'); // TODO: 메인표시 토글 selector 확인 필요
this.submitButton = page.getByRole('button', { name: /수정/ });
}

async goto(id: string) {
await this.page.goto(`/community/notice/${id}/edit`);
}

async fillTitle(title: string) {
await this.titleInput.fill(title);
}

async fillContent(content: string) {
await this.contentEditor.fill(content);
}

async addTag(tag: string) {
await this.tagInput.fill(tag);
await this.page.keyboard.press('Enter');
}

async uploadAttachment(filePath: string) {
await this.attachmentInput.setInputFiles(filePath);
}

async toggleImportant() {
await this.importantToggle.click();
}

async togglePrivate() {
await this.privateToggle.click();
}

async togglePinned() {
await this.pinnedToggle.click();
}

async toggleMainDisplay() {
await this.mainDisplayToggle.click();
}

async clickSubmitButton() {
await this.submitButton.click();
}
}
55 changes: 54 additions & 1 deletion e2e/pages/community/notice/index.page.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
import { type Locator, type Page } from '@playwright/test';

export class NoticePage {
export class NoticeListPage {
readonly page: Page;
readonly newPostButton: Locator;
readonly searchInput: Locator;
readonly searchButton: Locator;
readonly tagButtons: Locator;
readonly selectAllCheckbox: Locator;
readonly noticeCheckboxes: Locator;
readonly bulkDeleteButton: Locator;
readonly bulkUnpinButton: Locator;
readonly noticeItems: Locator;

constructor(page: Page) {
this.page = page;
this.newPostButton = page.getByRole('button', { name: '새 게시글' });
this.searchInput = page.locator('TODO_SEARCH_INPUT_SELECTOR'); // TODO: 검색 입력 필드 selector 확인 필요
this.searchButton = page.getByRole('button', { name: '검색' });
this.tagButtons = page.locator('TODO_TAG_FILTER_BUTTONS_SELECTOR'); // TODO: 태그 필터 버튼들 selector 확인 필요
this.selectAllCheckbox = page.locator('TODO_SELECT_ALL_CHECKBOX_SELECTOR'); // TODO: 전체 선택 체크박스 selector 확인 필요
this.noticeCheckboxes = page.locator('TODO_NOTICE_CHECKBOX_SELECTOR'); // TODO: 개별 공지사항 체크박스 selector 확인 필요
this.bulkDeleteButton = page.locator('TODO_BULK_DELETE_BUTTON_SELECTOR'); // TODO: 일괄 삭제 버튼 selector 확인 필요
this.bulkUnpinButton = page.locator('TODO_BULK_UNPIN_BUTTON_SELECTOR'); // TODO: 일괄 고정해제 버튼 selector 확인 필요
this.noticeItems = page.locator('TODO_NOTICE_ITEM_SELECTOR'); // TODO: 공지사항 목록 아이템 selector 확인 필요
}

async goto() {
Expand All @@ -16,4 +32,41 @@ export class NoticePage {
async clickNewPostButton() {
await this.newPostButton.click();
}

async searchByKeyword(keyword: string) {
await this.searchInput.fill(keyword);
await this.searchButton.click();
}

async filterByTag(tagName: string) {
await this.tagButtons.filter({ hasText: tagName }).click();
}

async selectAllNotices() {
await this.selectAllCheckbox.click();
}

async selectNotice(index: number) {
await this.noticeCheckboxes.nth(index).click();
}

async bulkDelete() {
await this.bulkDeleteButton.click();
// 확인 모달에서 확인 버튼 클릭
await this.page.getByRole('button', { name: '확인' }).click();
}

async bulkUnpin() {
await this.bulkUnpinButton.click();
// 확인 모달에서 확인 버튼 클릭
await this.page.getByRole('button', { name: '확인' }).click();
}

async getNoticeCount(): Promise<number> {
return await this.noticeItems.count();
}

async clickNoticeByTitle(title: string) {
await this.page.getByText(title).click();
}
}
30 changes: 0 additions & 30 deletions e2e/tests/community/notice.test.ts

This file was deleted.

Loading