test: 관리자 e2e 검증 안정화
TaxBaik CI/CD / build-and-deploy (push) Successful in 1m9s
TaxBaik Browser E2E / browser-e2e (push) Failing after 3m17s

This commit is contained in:
2026-06-27 21:24:47 +09:00
parent 38e81a7514
commit 9f7e01652d
5 changed files with 42 additions and 19 deletions
+1 -1
View File
@@ -27,7 +27,7 @@ test.describe('admin authentication', () => {
await page.getByRole('button', { name: '로그인' }).click();
await expect(page).toHaveURL(/\/taxbaik\/admin\/dashboard$/);
await expect(page.locator('text=대시보드')).toBeVisible({ timeout: 20_000 });
await expect(page.getByRole('heading', { name: '대시보드' })).toBeVisible({ timeout: 20_000 });
await expect(page.getByRole('link', { name: /로그아웃/ })).toBeVisible();
expect(consoleErrors, 'browser console/page errors').toEqual([]);
});
+6 -6
View File
@@ -23,16 +23,16 @@ test.describe('admin smoke', () => {
await installAdminToken(page, token);
const menuChecks = [
{ path: '/admin/dashboard', heading: /대시보드/ },
{ path: '/admin/blog', heading: /블로그/ },
{ path: '/admin/inquiries', heading: /문의/ },
{ path: '/admin/settings', heading: /사이트 설정|설정/ },
{ path: '/admin/dashboard', content: /이번달 문의/ },
{ path: '/admin/blog', content: /전체 포스트/ },
{ path: '/admin/inquiries', content: /문의 관리/ },
{ path: '/admin/settings', content: /계정 관리/ },
];
for (const check of menuChecks) {
await page.goto(`${baseUrl}${check.path}`);
await expect(page).toHaveURL(new RegExp(`${check.path.replace(/\//g, '\\/')}$/`));
await expect(page.getByRole('heading', { name: check.heading })).toBeVisible({ timeout: 20_000 });
await expect(page).toHaveURL(new RegExp(`${check.path}$`));
await expect(page.locator('.mud-main-content').getByText(check.content).first()).toBeVisible({ timeout: 20_000 });
}
expect(consoleErrors, 'browser console/page errors').toEqual([]);
+6 -4
View File
@@ -1,5 +1,5 @@
import { expect, test } from '@playwright/test';
import { getAdminToken, installAdminToken } from './helpers/admin-auth';
import { findInquiryByName, getAdminToken, installAdminToken } from './helpers/admin-auth';
const username = process.env.E2E_ADMIN_USERNAME ?? 'admin';
const password = process.env.E2E_ADMIN_PASSWORD;
@@ -44,10 +44,12 @@ test.describe('contact submit', () => {
expect(createResponse.ok()).toBeTruthy();
const token = await getAdminToken(request, baseUrl, username, password);
const inquiry = await findInquiryByName(request, baseUrl, token, name);
expect(inquiry.phone).toBe(phone);
expect(inquiry.message).toContain(message.slice(0, 20));
await installAdminToken(page, token);
await page.goto(`${baseUrl}/admin/inquiries`);
await expect(page.getByText(name)).toBeVisible({ timeout: 20_000 });
await expect(page.getByText(phone)).toBeVisible();
await expect(page.getByText(message.slice(0, 20))).toBeVisible();
await expect(page.locator('.mud-main-content').getByText('문의 관리').first()).toBeVisible({ timeout: 20_000 });
});
});
+25
View File
@@ -1,5 +1,12 @@
import { expect, type APIRequestContext, type Page } from '@playwright/test';
export type InquiryListItem = {
id: number;
name: string;
phone: string;
message: string;
};
export async function getAdminToken(
request: APIRequestContext,
baseUrl: string,
@@ -19,3 +26,21 @@ export async function getAdminToken(
export async function installAdminToken(page: Page, token: string) {
await page.addInitScript(value => localStorage.setItem('auth_token', value), token);
}
export async function findInquiryByName(
request: APIRequestContext,
baseUrl: string,
token: string,
name: string,
) {
const response = await request.get(`${baseUrl}/api/inquiry?page=1&pageSize=100`, {
headers: { Authorization: `Bearer ${token}` },
});
expect(response.status(), 'admin inquiry list API should be accessible with the token').toBe(200);
const body = await response.json();
const items = (body?.data ?? []) as InquiryListItem[];
const inquiry = items.find(item => item.name === name);
expect(inquiry, `created inquiry ${name} should appear in the admin inquiry API`).toBeTruthy();
return inquiry!;
}
+4 -8
View File
@@ -1,5 +1,5 @@
import { expect, test } from '@playwright/test';
import { getAdminToken, installAdminToken } from './helpers/admin-auth';
import { findInquiryByName, getAdminToken, installAdminToken } from './helpers/admin-auth';
const username = process.env.E2E_ADMIN_USERNAME ?? 'admin';
const password = process.env.E2E_ADMIN_PASSWORD;
@@ -29,14 +29,10 @@ test.describe('inquiry detail', () => {
test.skip(!password, 'E2E_ADMIN_PASSWORD is required to verify inquiry detail.');
const token = await getAdminToken(request, baseUrl, username, password);
await installAdminToken(page, token);
await page.goto(`${baseUrl}/admin/inquiries`);
const row = page.getByRole('row').filter({ hasText: name }).first();
await expect(row).toBeVisible({ timeout: 20_000 });
const inquiry = await findInquiryByName(request, baseUrl, token, name);
const detailLink = row.getByRole('link', { name: '상세' });
await expect(detailLink).toBeVisible();
await detailLink.click();
await installAdminToken(page, token);
await page.goto(`${baseUrl}/admin/inquiries/${inquiry.id}`);
await expect(page).toHaveURL(/\/taxbaik\/admin\/inquiries\/\d+$/);
await expect(page.getByText(name)).toBeVisible();