fix admin routing for browser e2e
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
<component type="typeof(HeadOutlet)" render-mode="InteractiveServer" />
|
||||
</head>
|
||||
<body>
|
||||
<Routes @rendermode="RenderMode.InteractiveServer" />
|
||||
<Routes @rendermode="new InteractiveServerRenderMode(prerender: false)" />
|
||||
<script src="_content/MudBlazor/MudBlazor.min.js"></script>
|
||||
<script src="_framework/blazor.web.js"></script>
|
||||
</body>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
<MudDrawer @bind-open="@drawerOpen" Elevation="1">
|
||||
<MudNavMenu>
|
||||
<MudNavLink Href="/taxbaik/admin/" Match="NavLinkMatch.All">📊 대시보드</MudNavLink>
|
||||
<MudNavLink Href="/taxbaik/admin/dashboard" Match="NavLinkMatch.All">📊 대시보드</MudNavLink>
|
||||
<MudNavLink Href="/taxbaik/admin/blog">📝 블로그 관리</MudNavLink>
|
||||
<MudNavLink Href="/taxbaik/admin/inquiries">💬 문의 관리</MudNavLink>
|
||||
<MudNavLink Href="/taxbaik/admin/settings">⚙️ 설정</MudNavLink>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
@page "/admin"
|
||||
@attribute [Authorize]
|
||||
@inject NavigationManager NavigationManager
|
||||
|
||||
@code {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
@page "/admin/blog"
|
||||
@attribute [Authorize]
|
||||
@inject IApiClient ApiClient
|
||||
@inject ISnackbar Snackbar
|
||||
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
@page "/admin/dashboard"
|
||||
@using TaxBaik.Application.Services
|
||||
@attribute [Authorize]
|
||||
@inject InquiryService InquiryService
|
||||
@inject BlogService BlogService
|
||||
|
||||
<PageTitle>대시보드</PageTitle>
|
||||
|
||||
<MudText Typo="Typo.h5" Class="mb-4">📊 대시보드</MudText>
|
||||
<h1 class="mb-4">대시보드</h1>
|
||||
|
||||
<MudGrid>
|
||||
<MudItem xs="12" sm="6" md="3">
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
@page "/admin/inquiries/{InquiryId:int}"
|
||||
@using TaxBaik.Application.Services
|
||||
@attribute [Authorize]
|
||||
@inject InquiryService InquiryService
|
||||
@inject NavigationManager Navigation
|
||||
@inject ISnackbar Snackbar
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
@page "/admin/inquiries"
|
||||
@using TaxBaik.Domain.Interfaces
|
||||
@attribute [Authorize]
|
||||
@inject IInquiryRepository InquiryRepository
|
||||
|
||||
<PageTitle>문의 관리</PageTitle>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
@page "/admin/settings"
|
||||
@using TaxBaik.Domain.Interfaces
|
||||
@attribute [Authorize]
|
||||
@inject ISnackbar Snackbar
|
||||
|
||||
<PageTitle>설정</PageTitle>
|
||||
|
||||
@@ -10,4 +10,3 @@
|
||||
@using TaxBaik.Web.Services
|
||||
@using TaxBaik.Domain.Entities
|
||||
@using TaxBaik.Application.Services
|
||||
@attribute [Authorize]
|
||||
|
||||
@@ -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([]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user