device-system.spec.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. const { test, expect } = require('@playwright/test');
  2. const BASE_URL = 'https://ajy.danclub.cn';
  3. const TEST_ADMIN = { username: 'admin', password: 'admin123' };
  4. test.describe('4.1 设备列表', () => {
  5. test.beforeEach(async ({ page }) => {
  6. await page.goto(BASE_URL);
  7. await page.waitForLoadState('networkidle');
  8. await page.getByPlaceholder('请输入用户名').fill(TEST_ADMIN.username);
  9. await page.getByPlaceholder('请输入密码').fill(TEST_ADMIN.password);
  10. await page.getByRole('button', { name: '登 录' }).click();
  11. await page.waitForURL(`${BASE_URL}/#/user/app`, { timeout: 10000 });
  12. });
  13. test('DM-001: 查看设备列表', async ({ page }) => {
  14. await page.goto(`${BASE_URL}/#/device`);
  15. await page.waitForLoadState('networkidle');
  16. await page.waitForTimeout(1000);
  17. });
  18. test('DM-002: 按设备编号搜索', async ({ page }) => {
  19. await page.goto(`${BASE_URL}/#/device`);
  20. await page.waitForLoadState('networkidle');
  21. const searchInput = page.getByPlaceholder('请输入设备编号');
  22. if (await searchInput.isVisible()) {
  23. await searchInput.fill('AJY001');
  24. await page.getByRole('button', { name: '查询' }).click();
  25. await page.waitForTimeout(1000);
  26. }
  27. });
  28. test('DM-003: 按设备名称搜索', async ({ page }) => {
  29. await page.goto(`${BASE_URL}/#/device`);
  30. await page.waitForLoadState('networkidle');
  31. });
  32. test('DM-004: 按绑定用户搜索', async ({ page }) => {
  33. await page.goto(`${BASE_URL}/#/device`);
  34. await page.waitForLoadState('networkidle');
  35. });
  36. test('DM-005: 按在线状态筛选', async ({ page }) => {
  37. await page.goto(`${BASE_URL}/#/device`);
  38. await page.waitForLoadState('networkidle');
  39. });
  40. });
  41. test.describe('4.2 新增设备', () => {
  42. test.beforeEach(async ({ page }) => {
  43. await page.goto(BASE_URL);
  44. await page.waitForLoadState('networkidle');
  45. await page.getByPlaceholder('请输入用户名').fill(TEST_ADMIN.username);
  46. await page.getByPlaceholder('请输入密码').fill(TEST_ADMIN.password);
  47. await page.getByRole('button', { name: '登 录' }).click();
  48. await page.waitForURL(`${BASE_URL}/#/user/app`, { timeout: 10000 });
  49. });
  50. test('DM-010: 成功新增设备', async ({ page }) => {
  51. await page.goto(`${BASE_URL}/#/device`);
  52. await page.waitForLoadState('networkidle');
  53. const addBtn = page.getByRole('button', { name: '新增' });
  54. if (await addBtn.isVisible()) {
  55. await addBtn.click();
  56. await page.waitForTimeout(500);
  57. }
  58. });
  59. test('DM-011: 设备编号必填验证', async ({ page }) => {
  60. await page.goto(`${BASE_URL}/#/device`);
  61. await page.waitForLoadState('networkidle');
  62. const addBtn = page.getByRole('button', { name: '新增' });
  63. if (await addBtn.isVisible()) {
  64. await addBtn.click();
  65. await page.waitForTimeout(500);
  66. await page.getByRole('button', { name: '确定' }).click();
  67. await page.waitForTimeout(500);
  68. }
  69. });
  70. test('DM-012: 设备编号唯一性验证', async ({ page }) => {
  71. await page.goto(`${BASE_URL}/#/device`);
  72. await page.waitForLoadState('networkidle');
  73. });
  74. });
  75. test.describe('4.3 设备用户管理', () => {
  76. test.beforeEach(async ({ page }) => {
  77. await page.goto(BASE_URL);
  78. await page.waitForLoadState('networkidle');
  79. await page.getByPlaceholder('请输入用户名').fill(TEST_ADMIN.username);
  80. await page.getByPlaceholder('请输入密码').fill(TEST_ADMIN.password);
  81. await page.getByRole('button', { name: '登 录' }).click();
  82. await page.waitForURL(`${BASE_URL}/#/user/app`, { timeout: 10000 });
  83. });
  84. test('DM-020: 查看设备绑定用户', async ({ page }) => {
  85. await page.goto(`${BASE_URL}/#/device`);
  86. await page.waitForLoadState('networkidle');
  87. });
  88. test('DM-021: 添加用户到设备', async ({ page }) => {
  89. await page.goto(`${BASE_URL}/#/device`);
  90. await page.waitForLoadState('networkidle');
  91. });
  92. test('DM-022: 设置主用户', async ({ page }) => {
  93. await page.goto(`${BASE_URL}/#/device`);
  94. await page.waitForLoadState('networkidle');
  95. });
  96. test('DM-023: 解绑用户', async ({ page }) => {
  97. await page.goto(`${BASE_URL}/#/device`);
  98. await page.waitForLoadState('networkidle');
  99. });
  100. });
  101. test.describe('5.1 管理员管理', () => {
  102. test.beforeEach(async ({ page }) => {
  103. await page.goto(BASE_URL);
  104. await page.waitForLoadState('networkidle');
  105. await page.getByPlaceholder('请输入用户名').fill(TEST_ADMIN.username);
  106. await page.getByPlaceholder('请输入密码').fill(TEST_ADMIN.password);
  107. await page.getByRole('button', { name: '登 录' }).click();
  108. await page.waitForURL(`${BASE_URL}/#/user/app`, { timeout: 10000 });
  109. });
  110. test('SY-001: 查看管理员列表', async ({ page }) => {
  111. await page.goto(`${BASE_URL}/#/system`);
  112. await page.waitForLoadState('networkidle');
  113. await page.waitForTimeout(1000);
  114. });
  115. test('SY-002: 新增管理员', async ({ page }) => {
  116. await page.goto(`${BASE_URL}/#/system`);
  117. await page.waitForLoadState('networkidle');
  118. const addBtn = page.getByRole('button', { name: '新增管理员' });
  119. if (await addBtn.isVisible()) {
  120. await addBtn.click();
  121. await page.waitForTimeout(500);
  122. }
  123. });
  124. test('SY-003: 用户名唯一性验证', async ({ page }) => {
  125. await page.goto(`${BASE_URL}/#/system`);
  126. await page.waitForLoadState('networkidle');
  127. });
  128. test('SY-004: 密码格式验证', async ({ page }) => {
  129. await page.goto(`${BASE_URL}/#/system`);
  130. await page.waitForLoadState('networkidle');
  131. });
  132. test('SY-005: 禁用管理员', async ({ page }) => {
  133. await page.goto(`${BASE_URL}/#/system`);
  134. await page.waitForLoadState('networkidle');
  135. });
  136. test('SY-006: 启用管理员', async ({ page }) => {
  137. await page.goto(`${BASE_URL}/#/system`);
  138. await page.waitForLoadState('networkidle');
  139. });
  140. });
  141. test.describe('5.2 操作日志', () => {
  142. test.beforeEach(async ({ page }) => {
  143. await page.goto(BASE_URL);
  144. await page.waitForLoadState('networkidle');
  145. await page.getByPlaceholder('请输入用户名').fill(TEST_ADMIN.username);
  146. await page.getByPlaceholder('请输入密码').fill(TEST_ADMIN.password);
  147. await page.getByRole('button', { name: '登 录' }).click();
  148. await page.waitForURL(`${BASE_URL}/#/user/app`, { timeout: 10000 });
  149. });
  150. test('SY-010: 查看操作日志', async ({ page }) => {
  151. await page.goto(`${BASE_URL}/#/system/log`);
  152. await page.waitForLoadState('networkidle');
  153. await page.waitForTimeout(1000);
  154. });
  155. test('SY-011: 按操作人筛选', async ({ page }) => {
  156. await page.goto(`${BASE_URL}/#/system/log`);
  157. await page.waitForLoadState('networkidle');
  158. });
  159. test('SY-012: 按操作类型筛选', async ({ page }) => {
  160. await page.goto(`${BASE_URL}/#/system/log`);
  161. await page.waitForLoadState('networkidle');
  162. });
  163. test('SY-013: 按时间范围筛选', async ({ page }) => {
  164. await page.goto(`${BASE_URL}/#/system/log`);
  165. await page.waitForLoadState('networkidle');
  166. });
  167. test('SY-014: 导出日志', async ({ page }) => {
  168. await page.goto(`${BASE_URL}/#/system/log`);
  169. await page.waitForLoadState('networkidle');
  170. });
  171. });