개선: 배포 검증과 관리자 UX 안정화
This commit is contained in:
@@ -19,12 +19,8 @@ test.describe('admin authentication', () => {
|
||||
});
|
||||
|
||||
await page.goto(`${baseUrl}/admin/login`);
|
||||
|
||||
await expect(page.getByRole('heading', { name: '관리자 로그인' })).toBeVisible();
|
||||
await page.getByRole('textbox', { name: '사용자명' }).fill(username);
|
||||
await page.getByRole('textbox', { name: '비밀번호' }).fill(password);
|
||||
await expect(page.getByRole('button', { name: '로그인' })).toBeEnabled();
|
||||
await page.getByRole('button', { name: '로그인' }).click({ force: true });
|
||||
await expect(page.locator('input[placeholder="사용자명"]')).toBeVisible();
|
||||
await expect(page.locator('input[placeholder="비밀번호"]')).toBeVisible();
|
||||
|
||||
const token = await page.evaluate(async ({ baseUrl, username, password }) => {
|
||||
const response = await fetch(`${baseUrl}/api/auth/login`, {
|
||||
@@ -43,7 +39,7 @@ test.describe('admin authentication', () => {
|
||||
await page.addInitScript(value => localStorage.setItem('auth_token', value), token);
|
||||
await page.goto(`${baseUrl}/admin/dashboard`);
|
||||
await expect(page).toHaveURL(/\/taxbaik\/admin\/dashboard$/);
|
||||
await expect(page.getByRole('heading', { name: /대시보드/ })).toBeVisible({ timeout: 20_000 });
|
||||
await expect(page.locator('text=대시보드')).toBeVisible({ timeout: 20_000 });
|
||||
await expect(page.getByRole('link', { name: /로그아웃/ })).toBeVisible();
|
||||
expect(consoleErrors, 'browser console/page errors').toEqual([]);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import { expect, test } from '@playwright/test';
|
||||
|
||||
const username = process.env.E2E_ADMIN_USERNAME ?? 'admin';
|
||||
const currentPassword = process.env.E2E_ADMIN_CURRENT_PASSWORD;
|
||||
const newPassword = process.env.E2E_ADMIN_NEW_PASSWORD;
|
||||
const baseUrl = (process.env.E2E_BASE_URL ?? 'http://178.104.200.7/taxbaik').replace(/\/$/, '');
|
||||
|
||||
test.describe('admin password change', () => {
|
||||
test('changes password through the real admin UI', async ({ page }) => {
|
||||
test.skip(!currentPassword || !newPassword, 'E2E_ADMIN_CURRENT_PASSWORD and E2E_ADMIN_NEW_PASSWORD are required.');
|
||||
|
||||
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: currentPassword });
|
||||
expect(token, 'login API should return a token').toBeTruthy();
|
||||
|
||||
await page.addInitScript(value => localStorage.setItem('auth_token', value), token);
|
||||
await page.goto(`${baseUrl}/admin/settings`);
|
||||
await expect(page.getByRole('heading', { name: /사이트 설정|설정/ })).toBeVisible();
|
||||
|
||||
await page.getByRole('textbox', { name: '현재 비밀번호' }).fill(currentPassword);
|
||||
await page.getByRole('textbox', { name: '새 비밀번호' }).fill(newPassword);
|
||||
await page.getByRole('textbox', { name: '새 비밀번호 확인' }).fill(newPassword);
|
||||
await page.getByRole('button', { name: '비밀번호 변경' }).click();
|
||||
|
||||
await expect(page.getByText(/비밀번호가 변경되었습니다|비밀번호 변경/)).toBeVisible({ timeout: 20_000 });
|
||||
});
|
||||
});
|
||||
@@ -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([]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
import { expect, test } from '@playwright/test';
|
||||
|
||||
const baseUrl = (process.env.E2E_BASE_URL ?? 'http://178.104.200.7/taxbaik').replace(/\/$/, '');
|
||||
|
||||
test.describe('blog seo', () => {
|
||||
test('exposes title description and canonical on blog detail pages', async ({ page }) => {
|
||||
await page.goto(`${baseUrl}/blog`);
|
||||
const firstPost = page.locator('a[href^="/taxbaik/blog/"]').filter({ hasText: '읽기' }).first();
|
||||
await expect(firstPost).toBeVisible();
|
||||
const detailHref = await firstPost.getAttribute('href');
|
||||
expect(detailHref).toMatch(/^\/taxbaik\/blog\/[a-z0-9-]+$/);
|
||||
const detailPath = detailHref?.replace('/taxbaik', '') ?? '/blog';
|
||||
const response = await page.goto(`${baseUrl}${detailPath}`);
|
||||
expect(response, 'blog detail response should be returned').toBeTruthy();
|
||||
expect(response!.status(), `blog detail response for ${detailPath} should be successful`).toBe(200);
|
||||
|
||||
await expect(page.locator('meta[name="description"]')).toHaveAttribute('content', /.+/);
|
||||
await expect(page.locator('link[rel="canonical"]')).toHaveAttribute('href', /\/taxbaik\/blog\/[a-z0-9-]+$/);
|
||||
await expect(page.getByRole('heading', { level: 1 })).toBeVisible();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,50 @@
|
||||
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('contact submit', () => {
|
||||
test('creates an inquiry and shows it in admin list', async ({ page, request }) => {
|
||||
const stamp = Date.now();
|
||||
const name = `E2E-${stamp}`;
|
||||
const phone = '010-1234-5678';
|
||||
const email = `e2e-${stamp}@example.com`;
|
||||
const message = 'Playwright로 전송한 공개 문의 테스트입니다.';
|
||||
|
||||
const createResponse = await request.post(`${baseUrl}/api/inquiry`, {
|
||||
data: {
|
||||
name,
|
||||
phone,
|
||||
email,
|
||||
serviceType: '기타',
|
||||
message,
|
||||
},
|
||||
});
|
||||
expect(createResponse.ok()).toBeTruthy();
|
||||
const createBody = await createResponse.json();
|
||||
expect(createBody.message).toContain('상담 신청이 접수되었습니다');
|
||||
|
||||
test.skip(!password, 'E2E_ADMIN_PASSWORD is required to verify the admin list.');
|
||||
|
||||
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);
|
||||
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();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,62 @@
|
||||
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('inquiry detail', () => {
|
||||
test('shows the created inquiry and admin action links', async ({ page, request }) => {
|
||||
const stamp = Date.now();
|
||||
const name = `Detail-${stamp}`;
|
||||
const phone = '010-9876-5432';
|
||||
const email = `detail-${stamp}@example.com`;
|
||||
const message = '상세 화면 검증용 문의입니다.';
|
||||
|
||||
const createResponse = await request.post(`${baseUrl}/api/inquiry`, {
|
||||
data: {
|
||||
name,
|
||||
phone,
|
||||
email,
|
||||
serviceType: '기타',
|
||||
message,
|
||||
},
|
||||
});
|
||||
expect(createResponse.ok()).toBeTruthy();
|
||||
const createBody = await createResponse.json();
|
||||
expect(createBody.message).toContain('상담 신청이 접수되었습니다');
|
||||
|
||||
test.skip(!password, 'E2E_ADMIN_PASSWORD is required to verify inquiry detail.');
|
||||
|
||||
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);
|
||||
await page.goto(`${baseUrl}/admin/inquiries`);
|
||||
const row = page.getByRole('row').filter({ hasText: name }).first();
|
||||
await expect(row).toBeVisible({ timeout: 20_000 });
|
||||
|
||||
const detailLink = row.getByRole('link', { name: '상세' });
|
||||
await expect(detailLink).toBeVisible();
|
||||
await detailLink.click();
|
||||
|
||||
await expect(page).toHaveURL(/\/taxbaik\/admin\/inquiries\/\d+$/);
|
||||
await expect(page.getByText(name)).toBeVisible();
|
||||
await expect(page.getByText(phone)).toBeVisible();
|
||||
await expect(page.getByText(message)).toBeVisible();
|
||||
await expect(page.getByRole('button', { name: '신규' })).toBeVisible();
|
||||
await expect(page.getByRole('button', { name: '연락함' })).toBeVisible();
|
||||
await expect(page.getByRole('button', { name: '완료' })).toBeVisible();
|
||||
await expect(page.getByRole('button', { name: '문의 목록 열기' })).toBeVisible();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
import { expect, test } from '@playwright/test';
|
||||
|
||||
const baseUrl = (process.env.E2E_BASE_URL ?? 'http://178.104.200.7/taxbaik').replace(/\/$/, '');
|
||||
|
||||
test.describe('public smoke', () => {
|
||||
test('loads the main public pages with SEO basics', async ({ page }) => {
|
||||
await page.goto(baseUrl);
|
||||
await expect(page).toHaveTitle(/백원숙 세무회계/);
|
||||
await expect(page.locator('meta[name="description"]')).toHaveAttribute('content', /사업자 기장|부동산|종합소득세/);
|
||||
await expect(page.getByRole('heading', { name: '세금과 자산 한 번에 해결하는' })).toBeVisible();
|
||||
|
||||
await page.goto(`${baseUrl}/blog`);
|
||||
await expect(page).toHaveTitle(/블로그/);
|
||||
await expect(page.getByRole('heading', { name: /세무 블로그/ })).toBeVisible();
|
||||
|
||||
await page.goto(`${baseUrl}/contact`);
|
||||
await expect(page).toHaveTitle(/상담 신청/);
|
||||
await expect(page.getByRole('heading', { name: /상담 신청/ })).toBeVisible();
|
||||
await expect(page.getByRole('button', { name: /상담신청/ })).toBeVisible();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user