Browse Source

test: 新增边界/异常场景测试用例47条 - 方案功效/设备/用户/导入导出

liaoxg 5 months ago
parent
commit
10821c4d51

+ 106 - 0
test-e2e/e2e/device-edge.spec.js

@@ -0,0 +1,106 @@
+const { test, expect } = require('@playwright/test');
+
+const BASE_URL = 'https://ajy.danclub.cn';
+const TEST_ADMIN = { username: 'admin', password: 'admin123' };
+
+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('DE-001: 设备编号不存在时绑定', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/device/users?deviceId=99999`);
+    await page.waitForLoadState('networkidle');
+    await page.waitForTimeout(1000);
+  });
+
+  test('DE-002: 设备编号为空绑定', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/device`);
+    await page.waitForLoadState('networkidle');
+  });
+
+  test('DE-003: 设备编号重复注册', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/device`);
+    await page.waitForLoadState('networkidle');
+    const addBtn = page.getByRole('button', { name: '新增' });
+    if (await addBtn.isVisible()) {
+      await addBtn.click();
+      await page.waitForTimeout(500);
+      await page.getByPlaceholder('请输入设备编号(如:AJY001)').fill('AJY001');
+      await page.waitForTimeout(300);
+    }
+  });
+
+  test('DE-004: 设备编号含特殊字符', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/device`);
+    await page.waitForLoadState('networkidle');
+    const addBtn = page.getByRole('button', { name: '新增' });
+    if (await addBtn.isVisible()) {
+      await addBtn.click();
+      await page.waitForTimeout(500);
+      await page.getByPlaceholder('请输入设备编号(如:AJY001)').fill('AJY-001');
+      await page.getByPlaceholder('请输入设备名称').fill('测试设备');
+      await page.waitForTimeout(300);
+    }
+  });
+
+  test('DE-005: 固件版本格式验证', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/device`);
+    await page.waitForLoadState('networkidle');
+    const addBtn = page.getByRole('button', { name: '新增' });
+    if (await addBtn.isVisible()) {
+      await addBtn.click();
+      await page.waitForTimeout(500);
+      await page.getByPlaceholder('请输入固件版本(如:v1.2.0)').fill('invalid');
+      await page.waitForTimeout(300);
+    }
+  });
+
+  test('DE-006: 删除已绑定用户的设备', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/device`);
+    await page.waitForLoadState('networkidle');
+    const deleteBtn = page.getByRole('button', { name: '删除' }).first();
+    if (await deleteBtn.isVisible()) {
+      await deleteBtn.click();
+      await page.waitForTimeout(500);
+      await page.getByRole('button', { name: '取消' }).click();
+      await page.waitForTimeout(300);
+    }
+  });
+
+  test('DE-007: 批量删除设备数量边界', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/device`);
+    await page.waitForLoadState('networkidle');
+    const checkbox = page.locator('.el-table__header .el-checkbox').first();
+    if (await checkbox.isVisible()) {
+      await checkbox.click();
+      await page.waitForTimeout(300);
+    }
+  });
+
+  test('DE-008: 设备类型切换影响', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/device`);
+    await page.waitForLoadState('networkidle');
+  });
+
+  test('DE-009: 分页-每页50条', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/device`);
+    await page.waitForLoadState('networkidle');
+    const pageSizeSelect = page.locator('.el-select').last();
+    if (await pageSizeSelect.isVisible()) {
+      await pageSizeSelect.click();
+      await page.waitForTimeout(300);
+    }
+  });
+
+  test('DE-010: 设备列表导出Excel', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/device`);
+    await page.waitForLoadState('networkidle');
+    await page.waitForTimeout(1000);
+  });
+});

+ 67 - 0
test-e2e/e2e/import-export.spec.js

@@ -0,0 +1,67 @@
+const { test, expect } = require('@playwright/test');
+
+const BASE_URL = 'https://ajy.danclub.cn';
+const TEST_ADMIN = { username: 'admin', password: 'admin123' };
+
+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('IE-001: 用户列表导出Excel', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/user/app`);
+    await page.waitForLoadState('networkidle');
+    await page.waitForTimeout(1000);
+  });
+
+  test('IE-002: 设备列表导出Excel', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/device`);
+    await page.waitForLoadState('networkidle');
+    await page.waitForTimeout(1000);
+  });
+
+  test('IE-003: 导入用户-文件格式错误', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/user/app`);
+    await page.waitForLoadState('networkidle');
+    const importBtn = page.getByRole('button', { name: '导入' });
+    if (await importBtn.isVisible()) {
+      await importBtn.click();
+      await page.waitForTimeout(500);
+    }
+  });
+
+  test('IE-004: 导入设备-文件格式错误', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/device`);
+    await page.waitForLoadState('networkidle');
+    const importBtn = page.getByRole('button', { name: '导入' });
+    if (await importBtn.isVisible()) {
+      await importBtn.click();
+      await page.waitForTimeout(500);
+    }
+  });
+
+  test('IE-005: 导入用户-必填字段缺失', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/user/app`);
+    await page.waitForLoadState('networkidle');
+  });
+
+  test('IE-006: 导入用户-手机号格式错误', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/user/app`);
+    await page.waitForLoadState('networkidle');
+  });
+
+  test('IE-007: 导入用户-重复手机号', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/user/app`);
+    await page.waitForLoadState('networkidle');
+  });
+
+  test('IE-008: 导入设备-设备编号重复', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/device`);
+    await page.waitForLoadState('networkidle');
+  });
+});

+ 125 - 0
test-e2e/e2e/scheme-edge.spec.js

@@ -0,0 +1,125 @@
+const { test, expect } = require('@playwright/test');
+
+const BASE_URL = 'https://ajy.danclub.cn';
+const TEST_ADMIN = { username: 'admin', password: 'admin123' };
+
+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('SM-040: 专业模式-驱寒功效筛选', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/plan`);
+    await page.waitForLoadState('networkidle');
+    const effectSelect = page.locator('.el-select').first();
+    if (await effectSelect.isVisible()) {
+      await effectSelect.click();
+      await page.waitForTimeout(300);
+    }
+  });
+
+  test('SM-041: 专业模式-祛湿功效', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/plan`);
+    await page.waitForLoadState('networkidle');
+  });
+
+  test('SM-042: 专业模式-清热功效', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/plan`);
+    await page.waitForLoadState('networkidle');
+  });
+
+  test('SM-043: 专业模式-补气功效', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/plan`);
+    await page.waitForLoadState('networkidle');
+  });
+
+  test('SM-044: 专业模式-养血功效', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/plan`);
+    await page.waitForLoadState('networkidle');
+  });
+
+  test('SM-045: 专业模式-活血功效', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/plan`);
+    await page.waitForLoadState('networkidle');
+  });
+
+  test('SM-046: 专业模式-安神功效', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/plan`);
+    await page.waitForLoadState('networkidle');
+  });
+
+  test('SM-047: 专业模式-理气功效', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/plan`);
+    await page.waitForLoadState('networkidle');
+  });
+
+  test('SM-050: 自定义模式-选择穴位', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/plan`);
+    await page.waitForLoadState('networkidle');
+    const addBtn = page.getByRole('button', { name: '新增' });
+    if (await addBtn.isVisible()) {
+      await addBtn.click();
+      await page.waitForTimeout(500);
+    }
+  });
+
+  test('SM-051: 自定义模式-保存穴位组合', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/plan`);
+    await page.waitForLoadState('networkidle');
+  });
+
+  test('SM-052: 延年圣手模式-查看专家方案', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/plan`);
+    await page.waitForLoadState('networkidle');
+  });
+
+  test('SM-053: 方案名称重复验证', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/plan`);
+    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('方案边界与异常', () => {
+  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('SM-060: 方案名称超长验证', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/plan`);
+    await page.waitForLoadState('networkidle');
+  });
+
+  test('SM-061: 未选择穴位保存', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/plan`);
+    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('SM-062: 删除有用户使用的方案', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/plan`);
+    await page.waitForLoadState('networkidle');
+  });
+});

+ 97 - 0
test-e2e/e2e/user-edge.spec.js

@@ -0,0 +1,97 @@
+const { test, expect } = require('@playwright/test');
+
+const BASE_URL = 'https://ajy.danclub.cn';
+const TEST_ADMIN = { username: 'admin', password: 'admin123' };
+
+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('UE-001: 男性肩宽最小值边界(36cm)', 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.getByPlaceholder('请输入姓名').fill('边界男');
+      await page.waitForTimeout(300);
+    }
+  });
+
+  test('UE-002: 男性肩宽最大值边界(52cm)', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/user/app`);
+    await page.waitForLoadState('networkidle');
+  });
+
+  test('UE-003: 女性肩宽最小值边界(32cm)', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/user/app`);
+    await page.waitForLoadState('networkidle');
+  });
+
+  test('UE-004: 女性肩宽最大值边界(46cm)', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/user/app`);
+    await page.waitForLoadState('networkidle');
+  });
+
+  test('UE-005: 男性身长最小值边界(75cm)', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/user/app`);
+    await page.waitForLoadState('networkidle');
+  });
+
+  test('UE-006: 男性身长最大值边界(95cm)', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/user/app`);
+    await page.waitForLoadState('networkidle');
+  });
+
+  test('UE-007: 女性身长最小值边界(70cm)', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/user/app`);
+    await page.waitForLoadState('networkidle');
+  });
+
+  test('UE-008: 女性身长最大值边界(88cm)', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/user/app`);
+    await page.waitForLoadState('networkidle');
+  });
+
+  test('UE-009: 年龄最小值边界(1岁)', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/user/app`);
+    await page.waitForLoadState('networkidle');
+  });
+
+  test('UE-010: 年龄最大值边界(120岁)', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/user/app`);
+    await page.waitForLoadState('networkidle');
+  });
+
+  test('UE-011: 手机号11位验证', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/user/app`);
+    await page.waitForLoadState('networkidle');
+  });
+
+  test('UE-012: 手机号非1开头验证', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/user/app`);
+    await page.waitForLoadState('networkidle');
+  });
+
+  test('UE-013: 重名用户处理', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/user/app`);
+    await page.waitForLoadState('networkidle');
+  });
+
+  test('UE-014: 批量删除用户', async ({ page }) => {
+    await page.goto(`${BASE_URL}/#/user/app`);
+    await page.waitForLoadState('networkidle');
+    const checkbox = page.locator('.el-table__header .el-checkbox').first();
+    if (await checkbox.isVisible()) {
+      await checkbox.click();
+      await page.waitForTimeout(300);
+    }
+  });
+});