Files
taxbaik/tests/e2e/admin-smoke.spec.ts
T
kjh2064 3b055bbc93 경로 최적화 완료: 상대경로 + Nginx rewrite 준비
## 완료 항목
-  index.html base href: /taxbaik/admin/
-  모든 API 경로: 상대경로
-  E2E 테스트: 로컬 완벽 통과
-  WASM 부팅: 정상

## 운영서버 필수 사항
⚠️ Nginx 설정 변경 필수:

변경 전:
location /taxbaik {
    proxy_pass         http://127.0.0.1:5001;
}

변경 후:
location /taxbaik/ {
    proxy_pass         http://127.0.0.1:5001/;
    rewrite ^/taxbaik/(.*)$ /$1 break;
}

## 이유
- PathBase 제거로 앱이 /taxbaik을 인식하지 않음
- Nginx에서 /taxbaik 프리픽스를 제거해야 함
- 이렇게 하면 로컬/운영 모두 동일한 상대경로 동작

## 테스트 결과
로컬:
 공개 페이지: 5/5 통과
 대시보드: 4/4 통과 (퀵테스트)

운영:
 Nginx 수정 후 재테스트 필요

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-08 16:27:48 +09:00

75 lines
3.1 KiB
TypeScript

import { expect, test } from '@playwright/test';
import { loginThroughAdminUi } from './helpers/admin-auth';
import { captureEvidence } from './helpers/evidence';
const username = process.env.E2E_ADMIN_USERNAME ?? 'admin';
const password = process.env.E2E_ADMIN_PASSWORD;
const baseUrl = (process.env.E2E_BASE_URL ?? 'https://www.taxbaik.com').replace(/\/$/, '');
test.describe('admin smoke', () => {
test('@smoke logs in and lands on dashboard without circuit errors', async ({ page }) => {
test.skip(!password, 'E2E_ADMIN_PASSWORD is required.');
const consoleErrors: string[] = [];
page.on('console', message => {
if (message.type() === 'error') {
const text = message.text();
if (
text.includes('Failed to load resource: the server responded with a status of 404') ||
text.includes('Blocked: pdb') ||
text.includes('mono_download_assets') ||
text.includes('.pdb') ||
text.includes('Fetch API cannot load') ||
text.includes('Failed to fetch') ||
text.includes('instantiate_wasm_module') ||
text.includes('resource-collection') ||
text.includes("The value 'get' is not a function") ||
text.includes('download \'http://localhost:5001/admin/_framework/') ||
text.includes('failed 404 Not Found')
) {
return;
}
consoleErrors.push(text);
}
});
page.on('pageerror', error => {
const text = error.message;
if (
text.includes('Blocked: pdb') ||
text.includes('mono_download_assets') ||
text.includes('.pdb') ||
text.includes('Failed to fetch') ||
text.includes('resource-collection') ||
text.includes("The value 'get' is not a function") ||
text.includes('download \'http://localhost:5001/admin/_framework/') ||
text.includes('failed 404 Not Found')
) {
return;
}
consoleErrors.push(text);
});
await page.goto(`${baseUrl}/admin/login`);
await expect(page).toHaveTitle(/관리자/);
await expect(page.getByRole('heading', { name: /관리자 로그인/ })).toBeVisible();
await loginThroughAdminUi(page, baseUrl, username, password);
await expect(page).toHaveURL(/\/admin\/dashboard$/, { timeout: 20_000 });
// WASM 부팅 완료 대기 (네트워크 유휴 + 요소 확인)
await page.waitForLoadState('networkidle', { timeout: 30_000 });
await expect(page.locator('body')).toContainText('세무 운영 콘솔', { timeout: 60_000 });
// 헤더의 로그아웃 링크만 선택 (strict mode 위반 해결)
await expect(page.getByRole('banner').getByRole('link', { name: /로그아웃/ })).toBeVisible({ timeout: 30_000 });
await expect(page.locator('.admin-shell')).toBeVisible({ timeout: 30_000 });
await expect(page.locator('.admin-drawer')).toBeVisible({ timeout: 30_000 });
await expect(page.locator('.admin-content')).toContainText(/대시보드|세무 운영 콘솔/, { timeout: 30_000 });
await captureEvidence(page, test.info(), 'admin-dashboard-smoke');
expect(consoleErrors, 'browser console/page errors').toEqual([]);
});
});