Files
taxbaik/tests/e2e/admin-login.spec.ts
T
kjh2064 6b5ea85733
TaxBaik CI/CD / build-and-deploy (push) Failing after 3h2m56s
test: add playwright deployment gate
2026-06-27 12:51:16 +09:00

37 lines
1.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('admin authentication', () => {
test('logs in through the real browser UI and reaches dashboard', 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);
});
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 page.getByRole('button', { name: '로그인' }).click();
await expect(page).toHaveURL(/\/taxbaik\/admin\/dashboard$/);
await expect(page.getByRole('heading', { name: /대시보드/ })).toBeVisible();
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([]);
});
});