middleware fix wip
This commit is contained in:
@@ -32,6 +32,13 @@ test.describe('Website Pages - TypeORM Integration', () => {
|
||||
for (const route of publicRoutes) {
|
||||
const path = routeManager.resolvePathTemplate(route.pathTemplate, route.params);
|
||||
const response = await page.goto(`${WEBSITE_BASE_URL}${path}`);
|
||||
const status = response?.status();
|
||||
const finalUrl = page.url();
|
||||
|
||||
console.log(`[TEST DEBUG] Public route - Path: ${path}, Status: ${status}, Final URL: ${finalUrl}`);
|
||||
if (status === 500) {
|
||||
console.log(`[TEST DEBUG] 500 error on ${path} - Page title: ${await page.title()}`);
|
||||
}
|
||||
|
||||
// Should load successfully or show 404 page
|
||||
expect(response?.ok() || response?.status() === 404).toBeTruthy();
|
||||
@@ -59,11 +66,16 @@ test.describe('Website Pages - TypeORM Integration', () => {
|
||||
for (const route of adminRoutes) {
|
||||
const path = routeManager.resolvePathTemplate(route.pathTemplate, route.params);
|
||||
|
||||
// Regular auth user should be blocked
|
||||
// Regular auth user should be redirected to their home page (dashboard)
|
||||
{
|
||||
const auth = await WebsiteAuthManager.createAuthContext(browser, request, 'auth');
|
||||
await auth.page.goto(`${WEBSITE_BASE_URL}${path}`);
|
||||
expect(auth.page.url().includes('login')).toBeTruthy();
|
||||
const response = await auth.page.goto(`${WEBSITE_BASE_URL}${path}`);
|
||||
const finalUrl = auth.page.url();
|
||||
console.log(`[TEST DEBUG] Admin route test - Path: ${path}`);
|
||||
console.log(`[TEST DEBUG] Response status: ${response?.status()}`);
|
||||
console.log(`[TEST DEBUG] Final URL: ${finalUrl}`);
|
||||
console.log(`[TEST DEBUG] Page title: ${await auth.page.title()}`);
|
||||
expect(auth.page.url().includes('dashboard')).toBeTruthy();
|
||||
await auth.context.close();
|
||||
}
|
||||
|
||||
@@ -84,14 +96,14 @@ test.describe('Website Pages - TypeORM Integration', () => {
|
||||
for (const route of sponsorRoutes) {
|
||||
const path = routeManager.resolvePathTemplate(route.pathTemplate, route.params);
|
||||
|
||||
// Regular auth user should be blocked
|
||||
// Regular auth user should be redirected to their home page (dashboard)
|
||||
{
|
||||
const auth = await WebsiteAuthManager.createAuthContext(browser, request, 'auth');
|
||||
await auth.page.goto(`${WEBSITE_BASE_URL}${path}`);
|
||||
const finalUrl = auth.page.url();
|
||||
console.log(`[DEBUG] Final URL: ${finalUrl}`);
|
||||
console.log(`[DEBUG] Includes 'login': ${finalUrl.includes('login')}`);
|
||||
expect(finalUrl.includes('login')).toBeTruthy();
|
||||
console.log(`[DEBUG] Includes 'dashboard': ${finalUrl.includes('dashboard')}`);
|
||||
expect(finalUrl.includes('dashboard')).toBeTruthy();
|
||||
await auth.context.close();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user