test: 관리자 화면 e2e를 실제 로그인 흐름으로 전환
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
import { expect, test } from '@playwright/test';
|
import { expect, test } from '@playwright/test';
|
||||||
import { getAdminToken, installAdminToken } from './helpers/admin-auth';
|
import { loginThroughAdminUi } from './helpers/admin-auth';
|
||||||
|
|
||||||
const username = process.env.E2E_ADMIN_USERNAME ?? 'admin';
|
const username = process.env.E2E_ADMIN_USERNAME ?? 'admin';
|
||||||
const password = process.env.E2E_ADMIN_PASSWORD;
|
const password = process.env.E2E_ADMIN_PASSWORD;
|
||||||
const baseUrl = (process.env.E2E_BASE_URL ?? 'http://178.104.200.7/taxbaik').replace(/\/$/, '');
|
const baseUrl = (process.env.E2E_BASE_URL ?? 'http://178.104.200.7/taxbaik').replace(/\/$/, '');
|
||||||
|
|
||||||
test.describe('admin smoke', () => {
|
test.describe('admin smoke', () => {
|
||||||
test('navigates the main admin menus without circuit errors', async ({ page, request }) => {
|
test('navigates the main admin menus without circuit errors', async ({ page }) => {
|
||||||
test.skip(!password, 'E2E_ADMIN_PASSWORD is required.');
|
test.skip(!password, 'E2E_ADMIN_PASSWORD is required.');
|
||||||
|
|
||||||
const consoleErrors: string[] = [];
|
const consoleErrors: string[] = [];
|
||||||
@@ -19,8 +19,7 @@ test.describe('admin smoke', () => {
|
|||||||
consoleErrors.push(error.message);
|
consoleErrors.push(error.message);
|
||||||
});
|
});
|
||||||
|
|
||||||
const token = await getAdminToken(request, baseUrl, username, password);
|
await loginThroughAdminUi(page, baseUrl, username, password);
|
||||||
await installAdminToken(page, token);
|
|
||||||
|
|
||||||
const menuChecks = [
|
const menuChecks = [
|
||||||
{ path: '/admin/dashboard', content: /이번달 문의/ },
|
{ path: '/admin/dashboard', content: /이번달 문의/ },
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { expect, test } from '@playwright/test';
|
import { expect, test } from '@playwright/test';
|
||||||
import { findInquiryByName, getAdminToken, installAdminToken } from './helpers/admin-auth';
|
import { findInquiryByName, getAdminToken, loginThroughAdminUi } from './helpers/admin-auth';
|
||||||
|
|
||||||
const username = process.env.E2E_ADMIN_USERNAME ?? 'admin';
|
const username = process.env.E2E_ADMIN_USERNAME ?? 'admin';
|
||||||
const password = process.env.E2E_ADMIN_PASSWORD;
|
const password = process.env.E2E_ADMIN_PASSWORD;
|
||||||
@@ -48,7 +48,7 @@ test.describe('contact submit', () => {
|
|||||||
expect(inquiry.phone).toBe(phone);
|
expect(inquiry.phone).toBe(phone);
|
||||||
expect(inquiry.message).toContain(message.slice(0, 20));
|
expect(inquiry.message).toContain(message.slice(0, 20));
|
||||||
|
|
||||||
await installAdminToken(page, token);
|
await loginThroughAdminUi(page, baseUrl, username, password);
|
||||||
await page.goto(`${baseUrl}/admin/inquiries`);
|
await page.goto(`${baseUrl}/admin/inquiries`);
|
||||||
await expect(page.locator('.mud-main-content').getByText('문의 관리').first()).toBeVisible({ timeout: 20_000 });
|
await expect(page.locator('.mud-main-content').getByText('문의 관리').first()).toBeVisible({ timeout: 20_000 });
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -27,6 +27,20 @@ export async function installAdminToken(page: Page, token: string) {
|
|||||||
await page.addInitScript(value => localStorage.setItem('auth_token', value), token);
|
await page.addInitScript(value => localStorage.setItem('auth_token', value), token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function loginThroughAdminUi(
|
||||||
|
page: Page,
|
||||||
|
baseUrl: string,
|
||||||
|
username: string,
|
||||||
|
password: string,
|
||||||
|
) {
|
||||||
|
await page.goto(`${baseUrl}/admin/login`);
|
||||||
|
await page.locator('input[placeholder="사용자명"]').fill(username);
|
||||||
|
await page.locator('input[placeholder="비밀번호"]').fill(password);
|
||||||
|
await page.getByRole('button', { name: '로그인' }).click();
|
||||||
|
await expect(page).toHaveURL(/\/taxbaik\/admin\/dashboard$/);
|
||||||
|
await expect(page.getByRole('heading', { name: '대시보드' })).toBeVisible({ timeout: 20_000 });
|
||||||
|
}
|
||||||
|
|
||||||
export async function findInquiryByName(
|
export async function findInquiryByName(
|
||||||
request: APIRequestContext,
|
request: APIRequestContext,
|
||||||
baseUrl: string,
|
baseUrl: string,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { expect, test } from '@playwright/test';
|
import { expect, test } from '@playwright/test';
|
||||||
import { findInquiryByName, getAdminToken, installAdminToken } from './helpers/admin-auth';
|
import { findInquiryByName, getAdminToken, loginThroughAdminUi } from './helpers/admin-auth';
|
||||||
|
|
||||||
const username = process.env.E2E_ADMIN_USERNAME ?? 'admin';
|
const username = process.env.E2E_ADMIN_USERNAME ?? 'admin';
|
||||||
const password = process.env.E2E_ADMIN_PASSWORD;
|
const password = process.env.E2E_ADMIN_PASSWORD;
|
||||||
@@ -31,7 +31,7 @@ test.describe('inquiry detail', () => {
|
|||||||
const token = await getAdminToken(request, baseUrl, username, password);
|
const token = await getAdminToken(request, baseUrl, username, password);
|
||||||
const inquiry = await findInquiryByName(request, baseUrl, token, name);
|
const inquiry = await findInquiryByName(request, baseUrl, token, name);
|
||||||
|
|
||||||
await installAdminToken(page, token);
|
await loginThroughAdminUi(page, baseUrl, username, password);
|
||||||
await page.goto(`${baseUrl}/admin/inquiries/${inquiry.id}`);
|
await page.goto(`${baseUrl}/admin/inquiries/${inquiry.id}`);
|
||||||
|
|
||||||
await expect(page).toHaveURL(/\/taxbaik\/admin\/inquiries\/\d+$/);
|
await expect(page).toHaveURL(/\/taxbaik\/admin\/inquiries\/\d+$/);
|
||||||
|
|||||||
Reference in New Issue
Block a user