Files
taxbaik/tests/e2e/inquiry-detail.spec.ts
T
kjh2064 f29f2c3cff
TaxBaik Browser E2E / browser-e2e (push) Failing after 1m3s
TaxBaik CI/CD / build-and-deploy (push) Failing after 2m46s
개선: 배포 검증과 관리자 UX 안정화
2026-06-27 20:57:09 +09:00

63 lines
2.5 KiB
TypeScript

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();
});
});