109 lines
3.5 KiB
TypeScript
Executable file
109 lines
3.5 KiB
TypeScript
Executable file
import { test, expect } from '@playwright/test';
|
|
|
|
/**
|
|
* Platform-admin route tests
|
|
*
|
|
* Tests verify that routes render without crashing.
|
|
* Some routes are skipped due to requiring backend services or having unstable rendering.
|
|
*/
|
|
|
|
test.describe('Error Pages', () => {
|
|
test('undefined route shows 404 page', async ({ page }) => {
|
|
await page.goto('/this-route-does-not-exist');
|
|
await expect(page.getByRole('heading', { name: /404/ })).toBeVisible();
|
|
await expect(page.getByRole('link', { name: 'Go to Analytics' })).toBeVisible();
|
|
});
|
|
});
|
|
|
|
test.describe('Feature Pages', () => {
|
|
test('subscriptions route renders dashboard', async ({ page }) => {
|
|
// Mock tier stats API
|
|
await page.route('**/api/marketplace/tiers/admin/stats**', (route) => {
|
|
route.fulfill({
|
|
status: 200,
|
|
contentType: 'application/json',
|
|
body: JSON.stringify({
|
|
totalSubscribers: 0,
|
|
monthlyRevenue: 0,
|
|
upgrades: 0,
|
|
limitHits: 0,
|
|
conversionRate: 0,
|
|
}),
|
|
});
|
|
});
|
|
// Mock funnel metrics
|
|
await page.route('**/api/analytics/admin/subscription-funnel/**', (route) => {
|
|
route.fulfill({
|
|
status: 200,
|
|
contentType: 'application/json',
|
|
body: JSON.stringify({ stages: [], overallConversion: 0 }),
|
|
});
|
|
});
|
|
await page.goto('/subscriptions');
|
|
await expect(page.getByRole('heading', { name: /Subscription/i }).first()).toBeVisible();
|
|
});
|
|
|
|
test('devices route renders device management', async ({ page }) => {
|
|
await page.route('**/api/devices**', (route) => {
|
|
route.fulfill({
|
|
status: 200,
|
|
contentType: 'application/json',
|
|
body: JSON.stringify([]),
|
|
});
|
|
});
|
|
await page.goto('/devices');
|
|
await expect(page.getByRole('heading', { name: /Devices/i }).first()).toBeVisible();
|
|
});
|
|
|
|
test('attributes route renders attribute definitions', async ({ page }) => {
|
|
await page.route('**/api/attributes**', (route) => {
|
|
route.fulfill({
|
|
status: 200,
|
|
contentType: 'application/json',
|
|
body: JSON.stringify({ attributes: [], total: 0 }),
|
|
});
|
|
});
|
|
await page.goto('/attributes');
|
|
await expect(page.getByRole('heading', { name: /Attribute/i }).first()).toBeVisible();
|
|
});
|
|
});
|
|
|
|
test.describe('Shop Routes', () => {
|
|
test('shop products route renders correctly', async ({ page }) => {
|
|
await page.route('**/api/shop/products**', (route) => {
|
|
route.fulfill({
|
|
status: 200,
|
|
contentType: 'application/json',
|
|
body: JSON.stringify([]),
|
|
});
|
|
});
|
|
await page.goto('/shop/products');
|
|
await expect(page.getByRole('heading', { name: /Products/i })).toBeVisible();
|
|
});
|
|
|
|
test('merch submissions route renders correctly', async ({ page }) => {
|
|
await page.route('**/api/merch/submissions**', (route) => {
|
|
route.fulfill({
|
|
status: 200,
|
|
contentType: 'application/json',
|
|
body: JSON.stringify([]),
|
|
});
|
|
});
|
|
await page.goto('/merch/submissions');
|
|
await expect(page.getByRole('heading', { name: /Submissions/i })).toBeVisible();
|
|
});
|
|
});
|
|
|
|
test.describe('Infrastructure Routes', () => {
|
|
test('queues route renders correctly', async ({ page }) => {
|
|
await page.route('**/api/admin/queues**', (route) => {
|
|
route.fulfill({
|
|
status: 200,
|
|
contentType: 'application/json',
|
|
body: JSON.stringify({ queues: [] }),
|
|
});
|
|
});
|
|
await page.goto('/queues');
|
|
await expect(page.locator('main')).toBeVisible();
|
|
});
|
|
});
|