39 lines
1.5 KiB
TypeScript
39 lines
1.5 KiB
TypeScript
import { expect, test } from '@playwright/test';
|
|
import { getAdminToken, installAdminToken } from './helpers/admin-auth';
|
|
|
|
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 getAdminToken(request, baseUrl, username, password);
|
|
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();
|
|
});
|
|
});
|