const { test, expect } = require('@playwright/test'); const BASE_URL = 'https://ajy.danclub.cn'; const TEST_ADMIN = { username: 'admin', password: 'admin123' }; test.describe('登录模块', () => { test('TC-001: 正常登录', 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('TC-002: 用户名为空验证', async ({ page }) => { await page.goto(BASE_URL); await page.getByPlaceholder('请输入密码').fill(TEST_ADMIN.password); await page.getByRole('button', { name: '登 录' }).click(); await expect(page.getByText('请输入用户名')).toBeVisible(); }); test('TC-003: 密码为空验证', async ({ page }) => { await page.goto(BASE_URL); await page.getByPlaceholder('请输入用户名').fill(TEST_ADMIN.username); await page.getByRole('button', { name: '登 录' }).click(); await expect(page.getByText('请输入密码')).toBeVisible(); }); test('TC-004: 错误账号登录', async ({ page }) => { await page.goto(BASE_URL); await page.getByPlaceholder('请输入用户名').fill('wronguser'); await page.getByPlaceholder('请输入密码').fill('wrongpass'); await page.getByRole('button', { name: '登 录' }).click(); await page.waitForTimeout(2000); await expect(page.getByRole('button', { name: '登 录' })).toBeVisible(); }); }); test.describe('账号管理模块', () => { 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('TC-010: 查看账号管理页面', async ({ page }) => { await expect(page.locator('.el-table__body')).toBeVisible(); }); test('TC-011: 账号列表搜索-手机号', async ({ page }) => { await page.getByPlaceholder('请输入手机号').fill('138'); await page.getByRole('button', { name: '搜索' }).click(); await page.waitForTimeout(1000); }); test('TC-012: 账号列表搜索-昵称', async ({ page }) => { await page.getByPlaceholder('请输入昵称').fill('管理员'); await page.getByRole('button', { name: '搜索' }).click(); await page.waitForTimeout(1000); }); test('TC-013: 新增用户按钮存在', async ({ page }) => { await expect(page.getByRole('button', { name: '新增用户' })).toBeVisible(); }); test('TC-014: 编辑功能', async ({ page }) => { const editBtn = page.locator('button:has-text("编辑")').first(); if (await editBtn.isVisible()) { await editBtn.click(); await page.waitForTimeout(500); } }); test('TC-015: 禁用功能', async ({ page }) => { const disableBtn = page.locator('button:has-text("禁用")').first(); if (await disableBtn.isVisible()) { await disableBtn.click(); await page.waitForTimeout(500); } }); test('TC-017: 取消删除', async ({ page }) => { const deleteBtn = page.locator('button:has-text("删除")').first(); if (await deleteBtn.isVisible()) { await deleteBtn.click(); await page.waitForTimeout(500); const cancelBtn = page.getByRole('button', { name: '取消' }); if (await cancelBtn.isVisible()) { await cancelBtn.click(); } } }); test('TC-017: 重置搜索条件', async ({ page }) => { await page.getByPlaceholder('请输入手机号').fill('测试'); await page.getByRole('button', { name: '重置' }).click(); await page.waitForTimeout(500); }); }); test.describe('穴位管理模块', () => { 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('TC-040: 查看穴位列表', async ({ page }) => { await expect(page.locator('.el-table__body')).toBeVisible(); }); test('TC-041: 穴位列表搜索-穴位名称', async ({ page }) => { await page.goto(`${BASE_URL}/#/acupoint`); await page.waitForLoadState('networkidle'); await page.getByPlaceholder('请输入穴位名称').first().fill('大椎'); await page.getByRole('button', { name: '查询' }).click(); await page.waitForTimeout(1000); }); test('TC-042: 新增按钮存在', async ({ page }) => { await page.getByRole('button', { name: '新增' }).click(); await page.waitForTimeout(500); }); test('TC-043: 查看穴位详情', async ({ page }) => { const viewBtn = page.locator('button:has-text("查看")').first(); if (await viewBtn.isVisible()) { await viewBtn.click(); await page.waitForTimeout(500); } }); test('TC-044: 编辑穴位', async ({ page }) => { const editBtn = page.locator('button:has-text("编辑")').first(); if (await editBtn.isVisible()) { await editBtn.click(); await page.waitForTimeout(500); } }); test('TC-045: 删除穴位', async ({ page }) => { const deleteBtn = page.locator('button:has-text("删除")').first(); if (await deleteBtn.isVisible()) { await deleteBtn.click(); await page.waitForTimeout(500); } }); test('TC-046: 分页功能', async ({ page }) => { const nextBtn = page.getByRole('button', { name: '下一页' }); if (await nextBtn.isEnabled()) { await nextBtn.click(); await page.waitForTimeout(500); } }); }); test.describe('方案管理模块', () => { 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('TC-060: 查看方案列表', async ({ page }) => { await page.goto(`${BASE_URL}/#/plan`); await page.waitForLoadState('networkidle'); await expect(page.locator('.el-table__body')).toBeVisible(); }); test('TC-061: 方案列表搜索-方案名称', async ({ page }) => { await page.goto(`${BASE_URL}/#/plan`); await page.waitForLoadState('networkidle'); await page.getByPlaceholder('请输入方案名称').first().fill('艾灸'); await page.getByRole('button', { name: '查询' }).click(); await page.waitForTimeout(1000); }); test('TC-062: 新增按钮存在', async ({ page }) => { await page.getByRole('button', { name: '新增' }).click(); await page.waitForTimeout(500); }); test('TC-063: 查看方案详情', async ({ page }) => { const viewBtn = page.locator('button:has-text("查看")').first(); if (await viewBtn.isVisible()) { await viewBtn.click(); await page.waitForTimeout(500); } }); test('TC-064: 编辑方案', async ({ page }) => { const editBtn = page.locator('button:has-text("编辑")').first(); if (await editBtn.isVisible()) { await editBtn.click(); await page.waitForTimeout(500); } }); test('TC-065: 下架功能', async ({ page }) => { const downBtn = page.locator('button:has-text("下架")').first(); if (await downBtn.isVisible()) { await downBtn.click(); await page.waitForTimeout(500); } }); test('TC-066: 分页功能', async ({ page }) => { const nextBtn = page.getByRole('button', { name: '下一页' }); if (await nextBtn.isEnabled()) { await nextBtn.click(); await page.waitForTimeout(500); } }); }); test.describe('设备管理模块', () => { 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('TC-080: 查看设备列表', async ({ page }) => { await page.goto(`${BASE_URL}/#/device`); await page.waitForLoadState('networkidle'); await page.waitForTimeout(1000); }); test('TC-081: 新增设备', async ({ page }) => { await page.goto(`${BASE_URL}/#/device`); await page.waitForLoadState('networkidle'); const addBtn = page.getByRole('button', { name: '新增' }); if (await addBtn.isVisible({ timeout: 5000 })) { await addBtn.click(); await page.waitForTimeout(500); } }); }); test.describe('系统管理模块', () => { test.beforeEach(async ({ page }) => { await page.goto(`${BASE_URL}/#/system`); await page.waitForLoadState('networkidle'); await page.waitForTimeout(1000); }); test('TC-090: 查看系统管理页面', async ({ page }) => { await page.waitForTimeout(500); }); test('TC-091: 新增管理员', async ({ page }) => { const addBtn = page.getByRole('button', { name: '新增管理员' }); if (await addBtn.isVisible()) { await addBtn.click(); await page.waitForTimeout(500); } }); }); test.describe('艾灸手法管理模块', () => { test.beforeEach(async ({ page }) => { await page.goto(`${BASE_URL}/#/technique`); await page.waitForLoadState('networkidle'); await page.waitForTimeout(1000); }); test('TC-100: 查看艾灸手法管理页面', async ({ page }) => { await page.waitForTimeout(500); }); }); test.describe('方案模拟测试模块', () => { test.beforeEach(async ({ page }) => { await page.goto(`${BASE_URL}/#/simulation`); await page.waitForLoadState('networkidle'); await page.waitForTimeout(1000); }); test('TC-110: 查看方案模拟测试页面', async ({ page }) => { await page.waitForTimeout(500); }); });