import { test, expect } from '@playwright/test'; test.describe('Check-in Scanner Navigation', () => { test('should be visible for users with high permission', async ({ page }) => { await page.route('**/user/info', async (route) => { await route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ status: 'success', code: 200, data: { user_id: 'test-user-id', username: 'testuser', nickname: 'Test User', permission_level: 21, avatar: 'https://example.com/avatar.png', }, }), }); }); await page.goto('/'); const sidebar = page.locator('[data-slot="sidebar"]'); await expect(sidebar).toBeVisible(); const scannerButton = page.getByRole('button', { name: '扫码签到' }); await expect(scannerButton).toBeVisible(); await scannerButton.click(); const dialog = page.getByRole('dialog'); await expect(dialog).toBeVisible(); await expect(page.getByText('扫描签到码')).toBeVisible(); }); test('should NOT be visible for users with low permission', async ({ page }) => { await page.route('**/user/info', async (route) => { await route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ status: 'success', code: 200, data: { user_id: 'test-user-id', username: 'testuser', nickname: 'Test User', permission_level: 10, avatar: 'https://example.com/avatar.png', }, }), }); }); await page.goto('/'); const sidebar = page.locator('[data-slot="sidebar"]'); await expect(sidebar).toBeVisible(); const scannerButton = page.getByRole('button', { name: '扫码签到' }); await expect(scannerButton).not.toBeVisible(); }); });