scheme-management.spec.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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('3.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('SM-001: 查看方案列表', async ({ page }) => {
  14. await page.goto(`${BASE_URL}/#/plan`);
  15. await page.waitForLoadState('networkidle');
  16. await expect(page.locator('.el-table__body')).toBeVisible();
  17. });
  18. test('SM-002: 创作人显示-一键艾灸', async ({ page }) => {
  19. await page.goto(`${BASE_URL}/#/plan`);
  20. await page.waitForLoadState('networkidle');
  21. });
  22. test('SM-003: 创作人显示-专业模式', async ({ page }) => {
  23. await page.goto(`${BASE_URL}/#/plan`);
  24. await page.waitForLoadState('networkidle');
  25. });
  26. test('SM-004: 创作人显示-自定义模式', async ({ page }) => {
  27. await page.goto(`${BASE_URL}/#/plan`);
  28. await page.waitForLoadState('networkidle');
  29. });
  30. test('SM-005: 创作人显示-延年圣手', async ({ page }) => {
  31. await page.goto(`${BASE_URL}/#/plan`);
  32. await page.waitForLoadState('networkidle');
  33. });
  34. test('SM-006: 按方案名称搜索', async ({ page }) => {
  35. await page.goto(`${BASE_URL}/#/plan`);
  36. await page.waitForLoadState('networkidle');
  37. await page.getByPlaceholder('请输入方案名称').first().fill('艾灸');
  38. await page.getByRole('button', { name: '查询' }).click();
  39. await page.waitForTimeout(1000);
  40. });
  41. test('SM-007: 按模式类型筛选', async ({ page }) => {
  42. await page.goto(`${BASE_URL}/#/plan`);
  43. await page.waitForLoadState('networkidle');
  44. });
  45. test('SM-008: 按功效类型筛选', async ({ page }) => {
  46. await page.goto(`${BASE_URL}/#/plan`);
  47. await page.waitForLoadState('networkidle');
  48. });
  49. test('SM-009: 按创作人搜索', async ({ page }) => {
  50. await page.goto(`${BASE_URL}/#/plan`);
  51. await page.waitForLoadState('networkidle');
  52. });
  53. test('SM-010: 按状态筛选', async ({ page }) => {
  54. await page.goto(`${BASE_URL}/#/plan`);
  55. await page.waitForLoadState('networkidle');
  56. });
  57. });
  58. test.describe('3.2 方案详情查看', () => {
  59. test.beforeEach(async ({ page }) => {
  60. await page.goto(BASE_URL);
  61. await page.waitForLoadState('networkidle');
  62. await page.getByPlaceholder('请输入用户名').fill(TEST_ADMIN.username);
  63. await page.getByPlaceholder('请输入密码').fill(TEST_ADMIN.password);
  64. await page.getByRole('button', { name: '登 录' }).click();
  65. await page.waitForURL(`${BASE_URL}/#/user/app`, { timeout: 10000 });
  66. });
  67. test('SM-020: 查看方案详情', async ({ page }) => {
  68. await page.goto(`${BASE_URL}/#/plan`);
  69. await page.waitForLoadState('networkidle');
  70. const viewBtn = page.locator('button:has-text("查看")').first();
  71. if (await viewBtn.isVisible()) {
  72. await viewBtn.click();
  73. await page.waitForTimeout(500);
  74. }
  75. });
  76. });
  77. test.describe('3.3 新增方案', () => {
  78. test.beforeEach(async ({ page }) => {
  79. await page.goto(BASE_URL);
  80. await page.waitForLoadState('networkidle');
  81. await page.getByPlaceholder('请输入用户名').fill(TEST_ADMIN.username);
  82. await page.getByPlaceholder('请输入密码').fill(TEST_ADMIN.password);
  83. await page.getByRole('button', { name: '登 录' }).click();
  84. await page.waitForURL(`${BASE_URL}/#/user/app`, { timeout: 10000 });
  85. });
  86. test('SM-030: 新增一键艾灸方案', async ({ page }) => {
  87. await page.goto(`${BASE_URL}/#/plan`);
  88. await page.waitForLoadState('networkidle');
  89. await page.getByRole('button', { name: '新增' }).click();
  90. await page.waitForTimeout(500);
  91. });
  92. test('SM-031: 新增专业模式方案', async ({ page }) => {
  93. await page.goto(`${BASE_URL}/#/plan`);
  94. await page.waitForLoadState('networkidle');
  95. await page.getByRole('button', { name: '新增' }).click();
  96. await page.waitForTimeout(500);
  97. });
  98. test('SM-032: 新增自定义模式方案', async ({ page }) => {
  99. await page.goto(`${BASE_URL}/#/plan`);
  100. await page.waitForLoadState('networkidle');
  101. await page.getByRole('button', { name: '新增' }).click();
  102. await page.waitForTimeout(500);
  103. });
  104. test('SM-034: 方案名称必填验证', async ({ page }) => {
  105. await page.goto(`${BASE_URL}/#/plan`);
  106. await page.waitForLoadState('networkidle');
  107. await page.getByRole('button', { name: '新增' }).click();
  108. await page.waitForTimeout(500);
  109. await page.getByRole('button', { name: '确定' }).click();
  110. await page.waitForTimeout(500);
  111. });
  112. test('SM-035: 功效类型必填验证', async ({ page }) => {
  113. await page.goto(`${BASE_URL}/#/plan`);
  114. await page.waitForLoadState('networkidle');
  115. });
  116. test('SM-036: 适用症状必选验证', async ({ page }) => {
  117. await page.goto(`${BASE_URL}/#/plan`);
  118. await page.waitForLoadState('networkidle');
  119. });
  120. test('SM-041: 保存为草稿', async ({ page }) => {
  121. await page.goto(`${BASE_URL}/#/plan`);
  122. await page.waitForLoadState('networkidle');
  123. });
  124. test('SM-042: 发布方案', async ({ page }) => {
  125. await page.goto(`${BASE_URL}/#/plan`);
  126. await page.waitForLoadState('networkidle');
  127. });
  128. });
  129. test.describe('3.4 编辑方案', () => {
  130. test.beforeEach(async ({ page }) => {
  131. await page.goto(BASE_URL);
  132. await page.waitForLoadState('networkidle');
  133. await page.getByPlaceholder('请输入用户名').fill(TEST_ADMIN.username);
  134. await page.getByPlaceholder('请输入密码').fill(TEST_ADMIN.password);
  135. await page.getByRole('button', { name: '登 录' }).click();
  136. await page.waitForURL(`${BASE_URL}/#/user/app`, { timeout: 10000 });
  137. });
  138. test('SM-050: 编辑草稿方案', async ({ page }) => {
  139. await page.goto(`${BASE_URL}/#/plan`);
  140. await page.waitForLoadState('networkidle');
  141. });
  142. test('SM-051: 编辑已发布方案', async ({ page }) => {
  143. await page.goto(`${BASE_URL}/#/plan`);
  144. await page.waitForLoadState('networkidle');
  145. });
  146. test('SM-052: 添加治疗步骤', async ({ page }) => {
  147. await page.goto(`${BASE_URL}/#/plan`);
  148. await page.waitForLoadState('networkidle');
  149. });
  150. test('SM-053: 删除治疗步骤', async ({ page }) => {
  151. await page.goto(`${BASE_URL}/#/plan`);
  152. await page.waitForLoadState('networkidle');
  153. });
  154. test('SM-054: 至少保留1个步骤', async ({ page }) => {
  155. await page.goto(`${BASE_URL}/#/plan`);
  156. await page.waitForLoadState('networkidle');
  157. });
  158. });
  159. test.describe('3.5 方案状态操作', () => {
  160. test.beforeEach(async ({ page }) => {
  161. await page.goto(BASE_URL);
  162. await page.waitForLoadState('networkidle');
  163. await page.getByPlaceholder('请输入用户名').fill(TEST_ADMIN.username);
  164. await page.getByPlaceholder('请输入密码').fill(TEST_ADMIN.password);
  165. await page.getByRole('button', { name: '登 录' }).click();
  166. await page.waitForURL(`${BASE_URL}/#/user/app`, { timeout: 10000 });
  167. });
  168. test('SM-060: 下架方案', async ({ page }) => {
  169. await page.goto(`${BASE_URL}/#/plan`);
  170. await page.waitForLoadState('networkidle');
  171. const downBtn = page.locator('button:has-text("下架")').first();
  172. if (await downBtn.isVisible()) {
  173. await downBtn.click();
  174. await page.waitForTimeout(500);
  175. }
  176. });
  177. test('SM-061: 批量发布草稿', async ({ page }) => {
  178. await page.goto(`${BASE_URL}/#/plan`);
  179. await page.waitForLoadState('networkidle');
  180. });
  181. test('SM-062: 批量下架', async ({ page }) => {
  182. await page.goto(`${BASE_URL}/#/plan`);
  183. await page.waitForLoadState('networkidle');
  184. });
  185. test('SM-063: 批量删除草稿', async ({ page }) => {
  186. await page.goto(`${BASE_URL}/#/plan`);
  187. await page.waitForLoadState('networkidle');
  188. });
  189. });