Files
my-mom-system/erp-frontend-vue/tests/utils/erpTestUtils.ts

34 lines
1.0 KiB
TypeScript
Raw Normal View History

import { expect, Page } from '@playwright/test'
export const USERNAME = process.env.ERP_USER || 'admin'
export const PASSWORD = process.env.ERP_PASS || 'admin123'
export async function login(page: Page) {
await page.goto('/login')
await page.getByPlaceholder(/用户名|账号/).fill(USERNAME)
await page.getByPlaceholder(/密码/).fill(PASSWORD)
const codeInput = page.getByPlaceholder(/验证码/).first()
if (await codeInput.isVisible().catch(() => false)) {
await codeInput.fill('0000')
}
await page.getByRole('button', { name: /登录|登 录/ }).click()
await expect(page).toHaveURL(/dashboard/)
}
export async function clickSubMenu(page: Page, title: string) {
await page.click(`.el-sub-menu__title:has-text("${title}")`)
}
export async function clickMenuItem(page: Page, path: string) {
await page.click(`.el-menu-item[index="${path}"]`)
}
export async function expectBasicList(page: Page) {
await expect(page.locator('.el-form').first()).toBeVisible()
await expect(page.locator('.el-table').first()).toBeVisible()
}