website refactor

This commit is contained in:
2026-01-17 18:28:10 +01:00
parent 6d57f8b1ce
commit 64d9e7fd16
44 changed files with 1729 additions and 415 deletions

View File

@@ -0,0 +1,46 @@
import { expect, test } from '@playwright/test';
import { WebsiteAuthManager } from '../../shared/website/WebsiteAuthManager';
const WEBSITE_BASE_URL = process.env.PLAYWRIGHT_BASE_URL || 'http://localhost:3000';
test.describe('Role-based Access Sanity', () => {
test('admin can access admin dashboard', async ({ browser, request }) => {
const admin = await WebsiteAuthManager.createAuthContext(browser, request, 'admin');
try {
await admin.page.goto(`${WEBSITE_BASE_URL}/admin`);
expect(admin.page.url()).toContain('/admin');
await expect(admin.page.locator('body')).toBeVisible();
} finally {
await admin.context.close();
}
});
test('regular user is redirected from admin dashboard', async ({ browser, request }) => {
const auth = await WebsiteAuthManager.createAuthContext(browser, request, 'auth');
try {
await auth.page.goto(`${WEBSITE_BASE_URL}/admin`);
// Should be redirected to dashboard or home
expect(auth.page.url()).not.toContain('/admin');
expect(auth.page.url()).toContain('/dashboard');
} finally {
await auth.context.close();
}
});
test('sponsor can access sponsor dashboard', async ({ browser, request }) => {
const sponsor = await WebsiteAuthManager.createAuthContext(browser, request, 'sponsor');
try {
await sponsor.page.goto(`${WEBSITE_BASE_URL}/sponsor/dashboard`);
expect(sponsor.page.url()).toContain('/sponsor/dashboard');
await expect(sponsor.page.locator('body')).toBeVisible();
} finally {
await sponsor.context.close();
}
});
test('unauthenticated user is redirected to login', async ({ page }) => {
await page.goto(`${WEBSITE_BASE_URL}/dashboard`);
expect(page.url()).toContain('/auth/login');
});
});