Files
star-erp/e2e/helpers/auth.ts
sky121113 197df3bec4
All checks were successful
ERP-Deploy-Demo / deploy-demo (push) Successful in 55s
[FIX] 修復所有 E2E 模組測試的標題定位器以及將測試帳號還原為 admin 權限
2026-03-09 16:53:06 +08:00

16 lines
612 B
TypeScript

import { Page, expect } from '@playwright/test';
/**
* 共用登入函式
* 使用測試帳號登入 Star ERP 系統
*/
export async function login(page: Page, username = 'admin', password = 'password') {
await page.goto('/');
await page.fill('#username', username);
await page.fill('#password', password);
await page.getByRole('button', { name: '登入系統' }).click();
// 等待儀表板載入完成 (改用更穩定的側邊欄文字或 URL)
await page.waitForURL('**/');
await expect(page.getByRole('link', { name: '儀表板' }).first()).toBeVisible({ timeout: 15000 });
}