From 3e8cfc386c7039f214e4f5a6bd61a7964b79657b Mon Sep 17 00:00:00 2001 From: kjh2064 Date: Sat, 27 Jun 2026 15:09:41 +0900 Subject: [PATCH] fix admin routing for browser e2e --- TaxBaik.Web/Components/Admin/App.razor | 2 +- .../Components/Admin/Layout/MainLayout.razor | 2 +- .../Components/Admin/Pages/AdminIndex.razor | 1 - .../Admin/Pages/Blog/BlogCreate.razor | 1 - .../Admin/Pages/Blog/BlogList.razor | 1 - .../Components/Admin/Pages/Dashboard.razor | 3 +-- .../Admin/Pages/Inquiries/InquiryDetail.razor | 1 - .../Admin/Pages/Inquiries/InquiryList.razor | 1 - .../Admin/Pages/Settings/SiteSettings.razor | 1 - TaxBaik.Web/Components/Admin/_Imports.razor | 1 - tests/e2e/admin-login.spec.ts | 24 +++++++++++++++---- 11 files changed, 22 insertions(+), 16 deletions(-) diff --git a/TaxBaik.Web/Components/Admin/App.razor b/TaxBaik.Web/Components/Admin/App.razor index 014b97f..f811479 100644 --- a/TaxBaik.Web/Components/Admin/App.razor +++ b/TaxBaik.Web/Components/Admin/App.razor @@ -12,7 +12,7 @@ - + diff --git a/TaxBaik.Web/Components/Admin/Layout/MainLayout.razor b/TaxBaik.Web/Components/Admin/Layout/MainLayout.razor index b27bd30..f27eb82 100644 --- a/TaxBaik.Web/Components/Admin/Layout/MainLayout.razor +++ b/TaxBaik.Web/Components/Admin/Layout/MainLayout.razor @@ -17,7 +17,7 @@ - πŸ“Š λŒ€μ‹œλ³΄λ“œ + πŸ“Š λŒ€μ‹œλ³΄λ“œ πŸ“ λΈ”λ‘œκ·Έ 관리 πŸ’¬ 문의 관리 βš™οΈ μ„€μ • diff --git a/TaxBaik.Web/Components/Admin/Pages/AdminIndex.razor b/TaxBaik.Web/Components/Admin/Pages/AdminIndex.razor index fa9272c..c2d9169 100644 --- a/TaxBaik.Web/Components/Admin/Pages/AdminIndex.razor +++ b/TaxBaik.Web/Components/Admin/Pages/AdminIndex.razor @@ -1,5 +1,4 @@ @page "/admin" -@attribute [Authorize] @inject NavigationManager NavigationManager @code { diff --git a/TaxBaik.Web/Components/Admin/Pages/Blog/BlogCreate.razor b/TaxBaik.Web/Components/Admin/Pages/Blog/BlogCreate.razor index f839e34..059495c 100644 --- a/TaxBaik.Web/Components/Admin/Pages/Blog/BlogCreate.razor +++ b/TaxBaik.Web/Components/Admin/Pages/Blog/BlogCreate.razor @@ -2,7 +2,6 @@ @using TaxBaik.Application.DTOs @using TaxBaik.Application.Services @using TaxBaik.Domain.Interfaces -@attribute [Authorize] @inject BlogService BlogService @inject ICategoryRepository CategoryRepository @inject NavigationManager Navigation diff --git a/TaxBaik.Web/Components/Admin/Pages/Blog/BlogList.razor b/TaxBaik.Web/Components/Admin/Pages/Blog/BlogList.razor index 9ba4ac2..f014ebb 100644 --- a/TaxBaik.Web/Components/Admin/Pages/Blog/BlogList.razor +++ b/TaxBaik.Web/Components/Admin/Pages/Blog/BlogList.razor @@ -1,5 +1,4 @@ @page "/admin/blog" -@attribute [Authorize] @inject IApiClient ApiClient @inject ISnackbar Snackbar diff --git a/TaxBaik.Web/Components/Admin/Pages/Dashboard.razor b/TaxBaik.Web/Components/Admin/Pages/Dashboard.razor index dfe57a3..a17a576 100644 --- a/TaxBaik.Web/Components/Admin/Pages/Dashboard.razor +++ b/TaxBaik.Web/Components/Admin/Pages/Dashboard.razor @@ -1,12 +1,11 @@ @page "/admin/dashboard" @using TaxBaik.Application.Services -@attribute [Authorize] @inject InquiryService InquiryService @inject BlogService BlogService λŒ€μ‹œλ³΄λ“œ -πŸ“Š λŒ€μ‹œλ³΄λ“œ +

λŒ€μ‹œλ³΄λ“œ

diff --git a/TaxBaik.Web/Components/Admin/Pages/Inquiries/InquiryDetail.razor b/TaxBaik.Web/Components/Admin/Pages/Inquiries/InquiryDetail.razor index e269bbd..816b3f7 100644 --- a/TaxBaik.Web/Components/Admin/Pages/Inquiries/InquiryDetail.razor +++ b/TaxBaik.Web/Components/Admin/Pages/Inquiries/InquiryDetail.razor @@ -1,6 +1,5 @@ @page "/admin/inquiries/{InquiryId:int}" @using TaxBaik.Application.Services -@attribute [Authorize] @inject InquiryService InquiryService @inject NavigationManager Navigation @inject ISnackbar Snackbar diff --git a/TaxBaik.Web/Components/Admin/Pages/Inquiries/InquiryList.razor b/TaxBaik.Web/Components/Admin/Pages/Inquiries/InquiryList.razor index 640467f..99c91b0 100644 --- a/TaxBaik.Web/Components/Admin/Pages/Inquiries/InquiryList.razor +++ b/TaxBaik.Web/Components/Admin/Pages/Inquiries/InquiryList.razor @@ -1,6 +1,5 @@ @page "/admin/inquiries" @using TaxBaik.Domain.Interfaces -@attribute [Authorize] @inject IInquiryRepository InquiryRepository 문의 관리 diff --git a/TaxBaik.Web/Components/Admin/Pages/Settings/SiteSettings.razor b/TaxBaik.Web/Components/Admin/Pages/Settings/SiteSettings.razor index 46c42c9..7952f9f 100644 --- a/TaxBaik.Web/Components/Admin/Pages/Settings/SiteSettings.razor +++ b/TaxBaik.Web/Components/Admin/Pages/Settings/SiteSettings.razor @@ -1,6 +1,5 @@ @page "/admin/settings" @using TaxBaik.Domain.Interfaces -@attribute [Authorize] @inject ISnackbar Snackbar μ„€μ • diff --git a/TaxBaik.Web/Components/Admin/_Imports.razor b/TaxBaik.Web/Components/Admin/_Imports.razor index a91b67a..3bda42d 100644 --- a/TaxBaik.Web/Components/Admin/_Imports.razor +++ b/TaxBaik.Web/Components/Admin/_Imports.razor @@ -10,4 +10,3 @@ @using TaxBaik.Web.Services @using TaxBaik.Domain.Entities @using TaxBaik.Application.Services -@attribute [Authorize] diff --git a/tests/e2e/admin-login.spec.ts b/tests/e2e/admin-login.spec.ts index 75a045b..4ddaa0a 100644 --- a/tests/e2e/admin-login.spec.ts +++ b/tests/e2e/admin-login.spec.ts @@ -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([]); }); });