From a58aa7efe0c15e08b1b44bd2a346c1e396d95d0d Mon Sep 17 00:00:00 2001 From: kjh2064 Date: Sat, 27 Jun 2026 21:29:31 +0900 Subject: [PATCH] =?UTF-8?q?test:=20=EA=B4=80=EB=A6=AC=EC=9E=90=20=ED=99=94?= =?UTF-8?q?=EB=A9=B4=20e2e=EB=A5=BC=20=EC=8B=A4=EC=A0=9C=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8=20=ED=9D=90=EB=A6=84=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EC=A0=84=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/e2e/admin-smoke.spec.ts | 7 +++---- tests/e2e/contact-submit.spec.ts | 4 ++-- tests/e2e/helpers/admin-auth.ts | 14 ++++++++++++++ tests/e2e/inquiry-detail.spec.ts | 4 ++-- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/tests/e2e/admin-smoke.spec.ts b/tests/e2e/admin-smoke.spec.ts index 16444dd..19bd039 100644 --- a/tests/e2e/admin-smoke.spec.ts +++ b/tests/e2e/admin-smoke.spec.ts @@ -1,12 +1,12 @@ 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 password = process.env.E2E_ADMIN_PASSWORD; const baseUrl = (process.env.E2E_BASE_URL ?? 'http://178.104.200.7/taxbaik').replace(/\/$/, ''); 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.'); const consoleErrors: string[] = []; @@ -19,8 +19,7 @@ test.describe('admin smoke', () => { consoleErrors.push(error.message); }); - const token = await getAdminToken(request, baseUrl, username, password); - await installAdminToken(page, token); + await loginThroughAdminUi(page, baseUrl, username, password); const menuChecks = [ { path: '/admin/dashboard', content: /이번달 문의/ }, diff --git a/tests/e2e/contact-submit.spec.ts b/tests/e2e/contact-submit.spec.ts index f1751e7..d98e577 100644 --- a/tests/e2e/contact-submit.spec.ts +++ b/tests/e2e/contact-submit.spec.ts @@ -1,5 +1,5 @@ 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 password = process.env.E2E_ADMIN_PASSWORD; @@ -48,7 +48,7 @@ test.describe('contact submit', () => { expect(inquiry.phone).toBe(phone); 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 expect(page.locator('.mud-main-content').getByText('문의 관리').first()).toBeVisible({ timeout: 20_000 }); }); diff --git a/tests/e2e/helpers/admin-auth.ts b/tests/e2e/helpers/admin-auth.ts index 5d7277f..9fb2a06 100644 --- a/tests/e2e/helpers/admin-auth.ts +++ b/tests/e2e/helpers/admin-auth.ts @@ -27,6 +27,20 @@ export async function installAdminToken(page: Page, token: string) { 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( request: APIRequestContext, baseUrl: string, diff --git a/tests/e2e/inquiry-detail.spec.ts b/tests/e2e/inquiry-detail.spec.ts index 7157be0..7bb9245 100644 --- a/tests/e2e/inquiry-detail.spec.ts +++ b/tests/e2e/inquiry-detail.spec.ts @@ -1,5 +1,5 @@ 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 password = process.env.E2E_ADMIN_PASSWORD; @@ -31,7 +31,7 @@ test.describe('inquiry detail', () => { const token = await getAdminToken(request, baseUrl, username, password); 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 expect(page).toHaveURL(/\/taxbaik\/admin\/inquiries\/\d+$/);