fix admin routing for browser e2e
TaxBaik Browser E2E / browser-e2e (push) Successful in 1m23s
TaxBaik CI/CD / build-and-deploy (push) Successful in 1m26s

This commit is contained in:
2026-06-27 15:09:41 +09:00
parent 640b2079b0
commit 3e8cfc386c
11 changed files with 22 additions and 16 deletions
+19 -5
View File
@@ -23,14 +23,28 @@ test.describe('admin authentication', () => {
await expect(page.getByRole('heading', { name: '관리자 로그인' })).toBeVisible();
await page.getByRole('textbox', { name: '사용자명' }).fill(username);
await page.getByRole('textbox', { name: '비밀번호' }).fill(password);
await page.getByRole('button', { name: '로그인' }).click();
await expect(page.getByRole('button', { name: '로그인' })).toBeEnabled();
await page.getByRole('button', { name: '로그인' }).click({ force: true });
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/dashboard`);
await expect(page).toHaveURL(/\/taxbaik\/admin\/dashboard$/);
await expect(page.getByRole('heading', { name: /대시보드/ })).toBeVisible();
await expect(page.getByRole('heading', { name: /대시보드/ })).toBeVisible({ timeout: 20_000 });
await expect(page.getByRole('link', { name: /로그아웃/ })).toBeVisible();
const token = await page.evaluate(() => localStorage.getItem('auth_token'));
expect(token, 'auth_token should be stored after login').toBeTruthy();
expect(consoleErrors, 'browser console/page errors').toEqual([]);
});
});