개선: 배포 검증과 관리자 UX 안정화
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
import { expect, test } from '@playwright/test';
|
||||
|
||||
const username = process.env.E2E_ADMIN_USERNAME ?? 'admin';
|
||||
const password = process.env.E2E_ADMIN_PASSWORD;
|
||||
const baseUrl = (process.env.E2E_BASE_URL ?? 'http://178.104.200.7/taxbaik').replace(/\/$/, '');
|
||||
|
||||
test.describe('admin smoke', () => {
|
||||
test('navigates the main admin menus without circuit errors', async ({ page }) => {
|
||||
test.skip(!password, 'E2E_ADMIN_PASSWORD is required.');
|
||||
|
||||
const consoleErrors: string[] = [];
|
||||
page.on('console', message => {
|
||||
if (message.type() === 'error') {
|
||||
consoleErrors.push(message.text());
|
||||
}
|
||||
});
|
||||
page.on('pageerror', error => {
|
||||
consoleErrors.push(error.message);
|
||||
});
|
||||
|
||||
const token = await page.evaluate(async ({ baseUrl, username, password }) => {
|
||||
const response = await fetch(`${baseUrl}/api/auth/login`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ username, password }),
|
||||
});
|
||||
if (!response.ok) {
|
||||
return null;
|
||||
}
|
||||
const body = await response.json();
|
||||
return body?.token ?? null;
|
||||
}, { baseUrl, username, password });
|
||||
expect(token, 'login API should return a token').toBeTruthy();
|
||||
|
||||
await page.addInitScript(value => localStorage.setItem('auth_token', value), token);
|
||||
|
||||
const menuChecks = [
|
||||
{ path: '/admin/dashboard', heading: /대시보드/ },
|
||||
{ path: '/admin/blog', heading: /블로그/ },
|
||||
{ path: '/admin/inquiries', heading: /문의/ },
|
||||
{ path: '/admin/settings', heading: /사이트 설정|설정/ },
|
||||
];
|
||||
|
||||
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 });
|
||||
}
|
||||
|
||||
expect(consoleErrors, 'browser console/page errors').toEqual([]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user