| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- const { test, expect } = require('@playwright/test');
- const BASE_URL = 'https://ajy.danclub.cn';
- const TEST_ADMIN = { username: 'admin', password: 'admin123' };
- test.describe('1.1 用户列表', () => {
- test.beforeEach(async ({ page }) => {
- await page.goto(BASE_URL);
- await page.waitForLoadState('networkidle');
- await page.getByPlaceholder('请输入用户名').fill(TEST_ADMIN.username);
- await page.getByPlaceholder('请输入密码').fill(TEST_ADMIN.password);
- await page.getByRole('button', { name: '登 录' }).click();
- await page.waitForURL(`${BASE_URL}/#/user/app`, { timeout: 10000 });
- });
- test('UM-001: 查看用户列表 - 显示完整列', async ({ page }) => {
- await page.goto(`${BASE_URL}/#/user/app`);
- await page.waitForLoadState('networkidle');
- await page.waitForTimeout(1000);
- const headers = await page.locator('.el-table__header th').allTextContents();
- expect(headers.some(h => h.includes('手机号') || h.includes('昵称'))).toBe(true);
- });
- test('UM-002: 按姓名模糊搜索', async ({ page }) => {
- await page.goto(`${BASE_URL}/#/user/app`);
- await page.waitForLoadState('networkidle');
- await page.getByPlaceholder('请输入手机号').fill('139');
- await page.getByRole('button', { name: '查询' }).click();
- await page.waitForTimeout(1000);
- });
- test('UM-003: 按手机号搜索', async ({ page }) => {
- await page.goto(`${BASE_URL}/#/user/app`);
- await page.waitForLoadState('networkidle');
- await page.getByPlaceholder('请输入手机号').fill('138');
- await page.getByRole('button', { name: '查询' }).click();
- await page.waitForTimeout(1000);
- });
- test('UM-004: 按设备编号搜索', async ({ page }) => {
- await page.goto(`${BASE_URL}/#/user/app`);
- await page.waitForLoadState('networkidle');
- const deviceInput = page.getByPlaceholder('请输入设备编号');
- if (await deviceInput.isVisible()) {
- await deviceInput.fill('AJY');
- await page.getByRole('button', { name: '查询' }).click();
- await page.waitForTimeout(1000);
- }
- });
- });
- test.describe('1.2 新增用户', () => {
- test.beforeEach(async ({ page }) => {
- await page.goto(BASE_URL);
- await page.waitForLoadState('networkidle');
- await page.getByPlaceholder('请输入用户名').fill(TEST_ADMIN.username);
- await page.getByPlaceholder('请输入密码').fill(TEST_ADMIN.password);
- await page.getByRole('button', { name: '登 录' }).click();
- await page.waitForURL(`${BASE_URL}/#/user/app`, { timeout: 10000 });
- });
- test('UM-010: 成功新增用户-打开弹窗', async ({ page }) => {
- await page.goto(`${BASE_URL}/#/user/app`);
- await page.waitForLoadState('networkidle');
- const addBtn = page.getByRole('button', { name: '新增' });
- if (await addBtn.isVisible()) {
- await addBtn.click();
- await page.waitForTimeout(500);
- }
- });
- test('UM-014: 手机号必填验证', async ({ page }) => {
- await page.goto(`${BASE_URL}/#/user/app`);
- await page.waitForLoadState('networkidle');
- const addBtn = page.getByRole('button', { name: '新增' });
- if (await addBtn.isVisible()) {
- await addBtn.click();
- await page.waitForTimeout(500);
- await page.getByRole('button', { name: '确定' }).click();
- await page.waitForTimeout(500);
- }
- });
- });
- test.describe('1.3 编辑用户', () => {
- test.beforeEach(async ({ page }) => {
- await page.goto(BASE_URL);
- await page.waitForLoadState('networkidle');
- await page.getByPlaceholder('请输入用户名').fill(TEST_ADMIN.username);
- await page.getByPlaceholder('请输入密码').fill(TEST_ADMIN.password);
- await page.getByRole('button', { name: '登 录' }).click();
- await page.waitForURL(`${BASE_URL}/#/user/app`, { timeout: 10000 });
- });
- test('UM-030: 编辑用户信息', async ({ page }) => {
- await page.goto(`${BASE_URL}/#/user/app`);
- await page.waitForLoadState('networkidle');
- const editBtn = page.locator('button:has-text("编辑")').first();
- if (await editBtn.isVisible()) {
- await editBtn.click();
- await page.waitForTimeout(500);
- }
- });
- test('UM-031: 编辑后重新生成坐标', async ({ page }) => {
- await page.goto(`${BASE_URL}/#/user/app`);
- await page.waitForLoadState('networkidle');
- const editBtn = page.locator('button:has-text("编辑")').first();
- if (await editBtn.isVisible()) {
- await editBtn.click();
- await page.waitForTimeout(500);
- }
- });
- test('UM-032: 查看用户详情', async ({ page }) => {
- await page.goto(`${BASE_URL}/#/user/app`);
- await page.waitForLoadState('networkidle');
- const viewBtn = page.locator('button:has-text("查看")').first();
- if (await viewBtn.isVisible()) {
- await viewBtn.click();
- await page.waitForTimeout(500);
- }
- });
- });
- test.describe('1.4 删除用户', () => {
- test.beforeEach(async ({ page }) => {
- await page.goto(BASE_URL);
- await page.waitForLoadState('networkidle');
- await page.getByPlaceholder('请输入用户名').fill(TEST_ADMIN.username);
- await page.getByPlaceholder('请输入密码').fill(TEST_ADMIN.password);
- await page.getByRole('button', { name: '登 录' }).click();
- await page.waitForURL(`${BASE_URL}/#/user/app`, { timeout: 10000 });
- });
- test('UM-040: 删除单个用户', async ({ page }) => {
- await page.goto(`${BASE_URL}/#/user/app`);
- await page.waitForLoadState('networkidle');
- const deleteBtn = page.locator('button:has-text("删除")').first();
- if (await deleteBtn.isVisible({ timeout: 2000 })) {
- await deleteBtn.click();
- await page.waitForTimeout(500);
- }
- });
- test('UM-041: 批量删除用户', async ({ page }) => {
- await page.goto(`${BASE_URL}/#/user/app`);
- await page.waitForLoadState('networkidle');
- });
- test('UM-042: 删除取消', async ({ page }) => {
- await page.goto(`${BASE_URL}/#/user/app`);
- await page.waitForLoadState('networkidle');
- const deleteBtn = page.locator('button:has-text("删除")').first();
- if (await deleteBtn.isVisible({ timeout: 2000 })) {
- await deleteBtn.click();
- await page.waitForTimeout(500);
- await page.getByRole('button', { name: '取消' }).click();
- await page.waitForTimeout(500);
- }
- });
- });
- test.describe('1.5 用户设备管理', () => {
- test.beforeEach(async ({ page }) => {
- await page.goto(BASE_URL);
- await page.waitForLoadState('networkidle');
- await page.getByPlaceholder('请输入用户名').fill(TEST_ADMIN.username);
- await page.getByPlaceholder('请输入密码').fill(TEST_ADMIN.password);
- await page.getByRole('button', { name: '登 录' }).click();
- await page.waitForURL(`${BASE_URL}/#/user/app`, { timeout: 10000 });
- });
- test('UM-050: 查看用户绑定设备', async ({ page }) => {
- await page.goto(`${BASE_URL}/#/user/app`);
- await page.waitForLoadState('networkidle');
- const deviceBtn = page.locator('button:has-text("设备管理")').first();
- if (await deviceBtn.isVisible()) {
- await deviceBtn.click();
- await page.waitForTimeout(500);
- }
- });
- test('UM-051: 添加设备到用户', async ({ page }) => {
- await page.goto(`${BASE_URL}/#/user/app`);
- await page.waitForLoadState('networkidle');
- });
- test('UM-052: 设置主设备', async ({ page }) => {
- await page.goto(`${BASE_URL}/#/user/app`);
- await page.waitForLoadState('networkidle');
- });
- test('UM-053: 解绑设备', async ({ page }) => {
- await page.goto(`${BASE_URL}/#/user/app`);
- await page.waitForLoadState('networkidle');
- });
- });
- test.describe('1.6 导入导出', () => {
- test.beforeEach(async ({ page }) => {
- await page.goto(BASE_URL);
- await page.waitForLoadState('networkidle');
- await page.getByPlaceholder('请输入用户名').fill(TEST_ADMIN.username);
- await page.getByPlaceholder('请输入密码').fill(TEST_ADMIN.password);
- await page.getByRole('button', { name: '登 录' }).click();
- await page.waitForURL(`${BASE_URL}/#/user/app`, { timeout: 10000 });
- });
- test('UM-060: 导出用户数据', async ({ page }) => {
- await page.goto(`${BASE_URL}/#/user/app`);
- await page.waitForLoadState('networkidle');
- const exportBtn = page.getByRole('button', { name: '导出' });
- if (await exportBtn.isVisible()) {
- await exportBtn.click();
- await page.waitForTimeout(1000);
- }
- });
- test('UM-061: 导入用户数据', async ({ page }) => {
- await page.goto(`${BASE_URL}/#/user/app`);
- await page.waitForLoadState('networkidle');
- });
- test('UM-062: 导入格式错误', async ({ page }) => {
- await page.goto(`${BASE_URL}/#/user/app`);
- await page.waitForLoadState('networkidle');
- });
- });
|