Files
tokens-reef/tests/e2e/navigation.spec.ts
Developer 8b19f56ba4 fix: update E2E test API paths and payloads to match backend
- user-apikey-lifecycle: /api/v1/keys -> /api/v1/api-keys (24 occurrences)
- admin-users: balance payload uses balance+operation+notes
- admin-groups: rate-multiplier already uses correct format
2026-04-02 22:35:48 +08:00

64 lines
2.2 KiB
TypeScript

import { test, expect } from '@playwright/test';
const TEST_EMAIL = process.env.TEST_EMAIL || 'lon22@qq.com';
const TEST_PASSWORD = process.env.TEST_PASSWORD || 'admin123';
/**
* Navigation Menu E2E Tests
*
* Tests the navigation menu items and their accessibility.
*/
test.describe('Navigation Menu', () => {
// Login before each test
test.beforeEach(async ({ page }) => {
await page.goto('/login');
await page.fill('input[type="email"], input[name="email"]', TEST_EMAIL);
await page.fill('input[type="password"]', TEST_PASSWORD);
await page.click('button[type="submit"]');
await page.waitForURL(/\/dashboard/, { timeout: 10000 });
});
test('all navigation menu items are accessible', async ({ page }) => {
// Check for common navigation menu items
const menuItems = [
{ name: 'Dashboard', path: '/dashboard' },
{ name: 'Users', path: '/admin/users' },
{ name: 'Accounts', path: '/admin/accounts' },
{ name: 'Groups', path: '/admin/groups' },
{ name: 'Redeem', path: '/admin/redeem' },
{ name: 'Settings', path: '/admin/settings' },
];
for (const item of menuItems) {
// Try to navigate to each page
const url = page.url();
if (!url.includes(item.path)) {
await page.goto(item.path);
await page.waitForTimeout(500);
}
// Page should load without error
expect(page.url()).toContain(item.path);
}
});
test('sidebar navigation exists', async ({ page }) => {
await page.goto('/dashboard');
// Look for common sidebar/nav elements
const sidebar = page.locator('nav, aside, [class*="sidebar"], [class*="nav"]').first();
await expect(sidebar).toBeVisible({ timeout: 5000 }).catch(() => {
// If no sidebar found, test passes if page loads
console.log('Sidebar not found, checking page load');
});
});
test('user menu is accessible', async ({ page }) => {
await page.goto('/dashboard');
// Look for user menu or profile elements
const userMenu = page.locator('[class*="user"], [class*="profile"], [class*="avatar"]').first();
await expect(userMenu).toBeVisible({ timeout: 5000 }).catch(() => {
console.log('User menu not found');
});
});
});