개선: 배포 검증과 관리자 UX 안정화
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { expect, test } from '@playwright/test';
|
||||
|
||||
const username = process.env.E2E_ADMIN_USERNAME ?? 'admin';
|
||||
const currentPassword = process.env.E2E_ADMIN_CURRENT_PASSWORD;
|
||||
const newPassword = process.env.E2E_ADMIN_NEW_PASSWORD;
|
||||
const baseUrl = (process.env.E2E_BASE_URL ?? 'http://178.104.200.7/taxbaik').replace(/\/$/, '');
|
||||
|
||||
test.describe('admin password change', () => {
|
||||
test('changes password through the real admin UI', async ({ page }) => {
|
||||
test.skip(!currentPassword || !newPassword, 'E2E_ADMIN_CURRENT_PASSWORD and E2E_ADMIN_NEW_PASSWORD are required.');
|
||||
|
||||
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: currentPassword });
|
||||
expect(token, 'login API should return a token').toBeTruthy();
|
||||
|
||||
await page.addInitScript(value => localStorage.setItem('auth_token', value), token);
|
||||
await page.goto(`${baseUrl}/admin/settings`);
|
||||
await expect(page.getByRole('heading', { name: /사이트 설정|설정/ })).toBeVisible();
|
||||
|
||||
await page.getByRole('textbox', { name: '현재 비밀번호' }).fill(currentPassword);
|
||||
await page.getByRole('textbox', { name: '새 비밀번호' }).fill(newPassword);
|
||||
await page.getByRole('textbox', { name: '새 비밀번호 확인' }).fill(newPassword);
|
||||
await page.getByRole('button', { name: '비밀번호 변경' }).click();
|
||||
|
||||
await expect(page.getByText(/비밀번호가 변경되었습니다|비밀번호 변경/)).toBeVisible({ timeout: 20_000 });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user