lss.spec.ts 62 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801
  1. import { test, expect, type Page } from '@playwright/test'
  2. // 测试账号配置
  3. const TEST_USERNAME = process.env.TEST_USERNAME || 'admin'
  4. const TEST_PASSWORD = process.env.TEST_PASSWORD || '123456'
  5. // 日本相关测试数据
  6. const TEST_DATA = {
  7. name: '東京テスト環境',
  8. address: '東京都渋谷区神宮前1-2-3',
  9. // 用于恢复的原始数据
  10. originalName: '初台測試環境',
  11. originalAddress: ''
  12. }
  13. test.describe('LSS管理 CRUD 测试', () => {
  14. // 登录辅助函数
  15. async function login(page: Page) {
  16. await page.goto('/login')
  17. await page.evaluate(() => {
  18. localStorage.clear()
  19. document.cookie.split(';').forEach((c) => {
  20. document.cookie = c.replace(/^ +/, '').replace(/=.*/, `=;expires=${new Date().toUTCString()};path=/`)
  21. })
  22. })
  23. await page.reload()
  24. await page.getByPlaceholder('用户名').fill(TEST_USERNAME)
  25. await page.getByPlaceholder('密码').fill(TEST_PASSWORD)
  26. await page.getByRole('button', { name: '登录' }).click()
  27. await expect(page).not.toHaveURL(/\/login/, { timeout: 15000 })
  28. }
  29. test('LSS管理页面正确显示', async ({ page }) => {
  30. await login(page)
  31. await page.goto('/lss-manage/list')
  32. // 验证页面标题 (Bug #4537: 页面标题从 "LSS 管理" 改为 "LSS 列表")
  33. // 使用 .first() 避免匹配多个元素(侧边栏和面包屑都有)
  34. await expect(page.locator('text=LSS 列表').first()).toBeVisible()
  35. // 验证搜索表单元素
  36. await expect(page.getByPlaceholder('LSS ID')).toBeVisible()
  37. await expect(page.getByPlaceholder('名称')).toBeVisible()
  38. await expect(page.getByRole('button', { name: '查询' })).toBeVisible()
  39. await expect(page.getByRole('button', { name: '重置' })).toBeVisible()
  40. // 验证表头
  41. await expect(page.locator('th:has-text("LSS ID")')).toBeVisible()
  42. await expect(page.locator('th:has-text("名称")')).toBeVisible()
  43. await expect(page.locator('th:has-text("地址")')).toBeVisible()
  44. await expect(page.locator('th:has-text("IP")')).toBeVisible()
  45. await expect(page.locator('th:has-text("操作")')).toBeVisible()
  46. })
  47. test('编辑LSS节点 - 修改Name和Address', async ({ page }) => {
  48. await login(page)
  49. await page.goto('/lss-manage/list')
  50. // 等待表格加载
  51. await page.waitForTimeout(1000)
  52. // 找到数据行中的编辑按钮(Actions列第一个按钮)
  53. const editButton = page.locator('tbody tr').first().locator('button').nth(1)
  54. await expect(editButton).toBeVisible({ timeout: 10000 })
  55. await editButton.click()
  56. // 验证编辑对话框打开
  57. const dialog = page.locator('.el-drawer, .el-dialog').filter({ hasText: 'LSS详情' })
  58. await expect(dialog).toBeVisible({ timeout: 5000 })
  59. // 修改 Name 字段
  60. const nameInput = dialog
  61. .locator('input')
  62. .filter({ hasText: /名称|Name/ })
  63. .or(dialog.locator('label:has-text("Name")').locator('..').locator('input'))
  64. .first()
  65. // 使用更通用的方式定位 Name 输入框
  66. const nameField = dialog.getByPlaceholder('请输入名称')
  67. await nameField.clear()
  68. await nameField.fill(TEST_DATA.name)
  69. // 修改 Address 字段
  70. const addressField = dialog.getByPlaceholder('请输入地址')
  71. await addressField.clear()
  72. await addressField.fill(TEST_DATA.address)
  73. // 点击 更新 按钮保存
  74. await dialog.getByRole('button', { name: '更新' }).click()
  75. // 等待对话框关闭
  76. await expect(dialog).not.toBeVisible({ timeout: 10000 })
  77. // 验证列表中数据已更新
  78. await page.waitForTimeout(500)
  79. const firstRow = page.locator('tbody tr').first()
  80. await expect(firstRow).toContainText(TEST_DATA.name)
  81. await expect(firstRow).toContainText(TEST_DATA.address)
  82. })
  83. test('查询LSS节点', async ({ page }) => {
  84. await login(page)
  85. await page.goto('/lss-manage/list')
  86. // 等待表格加载
  87. await page.waitForTimeout(1000)
  88. // 在名称搜索框输入关键词
  89. await page.getByPlaceholder('名称').fill('東京')
  90. // 点击搜索
  91. await page.getByRole('button', { name: '查询' }).click()
  92. await page.waitForTimeout(500)
  93. // 验证搜索结果
  94. const tableRows = page.locator('tbody tr')
  95. const rowCount = await tableRows.count()
  96. if (rowCount > 0) {
  97. // 验证每行都包含搜索关键词
  98. for (let i = 0; i < rowCount; i++) {
  99. const row = tableRows.nth(i)
  100. const rowText = await row.textContent()
  101. expect(rowText).toContain('東京')
  102. }
  103. }
  104. })
  105. test('重置搜索条件', async ({ page }) => {
  106. await login(page)
  107. await page.goto('/lss-manage/list')
  108. // 填入搜索条件
  109. await page.getByPlaceholder('LSS ID').fill('test-id')
  110. await page.getByPlaceholder('名称').fill('test-name')
  111. // 点击重置
  112. await page.getByRole('button', { name: '重置' }).click()
  113. await page.waitForTimeout(300)
  114. // 验证搜索条件已清空
  115. await expect(page.getByPlaceholder('LSS ID')).toHaveValue('')
  116. await expect(page.getByPlaceholder('名称')).toHaveValue('')
  117. })
  118. // TODO: 此测试因 UI 可见性问题暂时跳过
  119. // 设备列表抽屉元素存在但 CSS visibility 为 hidden,需要检查组件实现
  120. test.skip('查看LSS节点设备列表', async ({ page }) => {
  121. await login(page)
  122. await page.goto('/lss-manage/list')
  123. // 等待表格加载
  124. await page.waitForTimeout(1000)
  125. // 找到有 LSS ID 的行的设备列表按钮(跳过空行)
  126. const rows = page.locator('tbody tr')
  127. let deviceListButton = null
  128. for (let i = 0; i < (await rows.count()); i++) {
  129. const row = rows.nth(i)
  130. const lssIdCell = await row.locator('td').first().textContent()
  131. if (lssIdCell && lssIdCell.trim()) {
  132. deviceListButton = row.locator('button').first()
  133. break
  134. }
  135. }
  136. if (!deviceListButton) {
  137. test.skip()
  138. return
  139. }
  140. await expect(deviceListButton).toBeVisible({ timeout: 10000 })
  141. await deviceListButton.click()
  142. // 等待抽屉动画完成
  143. await page.waitForTimeout(500)
  144. // 验证设备列表面板打开
  145. const devicePanel = page.locator('.device-drawer.el-drawer')
  146. await expect(devicePanel).toBeVisible({ timeout: 10000 })
  147. // 验证设备列表表头
  148. await expect(devicePanel.locator('th:has-text("设备ID")')).toBeVisible()
  149. await expect(devicePanel.locator('th:has-text("名称")')).toBeVisible()
  150. // 关闭面板
  151. await devicePanel.locator('button[aria-label*="Close"], .el-drawer__close-btn, .el-dialog__close').first().click()
  152. await expect(devicePanel).not.toBeVisible({ timeout: 5000 })
  153. })
  154. test('从侧边栏导航到LSS管理', async ({ page }) => {
  155. await login(page)
  156. // 等待侧边栏加载
  157. await page.waitForTimeout(500)
  158. // 点击展开 LSS 管理 父菜单
  159. await page.getByText('LSS 管理').first().click()
  160. await page.waitForTimeout(300)
  161. // 点击侧边栏 LSS 列表菜单项 (Bug #4537: 菜单标题从 "LSS 管理" 改为 "LSS 列表")
  162. await page.getByText('LSS 列表').first().click()
  163. // 验证跳转到 LSS 管理页面
  164. await expect(page).toHaveURL(/\/lss-manage\/list/)
  165. // 使用 .first() 避免匹配多个元素(侧边栏和面包屑都有)
  166. await expect(page.locator('text=LSS 列表').first()).toBeVisible()
  167. })
  168. })
  169. test.describe('LSS管理 - CodeEditor 组件测试 (JSON模式)', () => {
  170. // 登录辅助函数
  171. async function login(page: Page) {
  172. await page.goto('/login')
  173. await page.evaluate(() => {
  174. localStorage.clear()
  175. document.cookie.split(';').forEach((c) => {
  176. document.cookie = c.replace(/^ +/, '').replace(/=.*/, `=;expires=${new Date().toUTCString()};path=/`)
  177. })
  178. })
  179. await page.reload()
  180. await page.getByPlaceholder('用户名').fill(TEST_USERNAME)
  181. await page.getByPlaceholder('密码').fill(TEST_PASSWORD)
  182. await page.getByRole('button', { name: '登录' }).click()
  183. await expect(page).not.toHaveURL(/\/login/, { timeout: 15000 })
  184. }
  185. /**
  186. * 测试 CodeEditor JSON 模式 - 头部显示
  187. */
  188. test('CodeEditor JSON模式 - 验证头部显示JSON标签和按钮', async ({ page }) => {
  189. await login(page)
  190. await page.goto('/lss-manage/list')
  191. // 等待表格加载
  192. await page.waitForTimeout(1000)
  193. // 点击 Device List 按钮打开设备列表
  194. const deviceListButton = page.locator('tbody tr').first().locator('button').first()
  195. await expect(deviceListButton).toBeVisible({ timeout: 10000 })
  196. await deviceListButton.click()
  197. // 等待设备列表面板打开
  198. const devicePanel = page.locator('.el-drawer, .el-dialog').filter({ hasText: '摄像头列表' })
  199. await expect(devicePanel).toBeVisible({ timeout: 5000 })
  200. // 点击 Parameter Configuration 的 View 按钮
  201. const viewButton = devicePanel.locator('tbody tr').first().locator('button:has-text("查看")').first()
  202. await expect(viewButton).toBeVisible({ timeout: 5000 })
  203. await viewButton.click()
  204. // 等待参数配置抽屉打开
  205. const paramsDrawer = page.locator('.params-drawer')
  206. await expect(paramsDrawer).toBeVisible({ timeout: 5000 })
  207. // 验证 CodeEditor 头部显示 JSON 标签
  208. const codeEditor = paramsDrawer.locator('.code-editor')
  209. await expect(codeEditor).toBeVisible()
  210. await expect(codeEditor.locator('.editor-header')).toBeVisible()
  211. await expect(codeEditor.locator('.file-type')).toContainText('JSON')
  212. // 验证 Copy 按钮存在
  213. await expect(codeEditor.locator('button:has-text("复制"), button:has-text("Copy")')).toBeVisible()
  214. // 验证 格式化 按钮存在 (JSON模式特有)
  215. await expect(codeEditor.locator('button:has-text("格式化")')).toBeVisible()
  216. })
  217. /**
  218. * 测试 CodeEditor JSON 模式 - 复制功能
  219. */
  220. test('CodeEditor JSON模式 - 复制按钮功能', async ({ page }) => {
  221. await login(page)
  222. await page.goto('/lss-manage/list')
  223. // 等待表格加载
  224. await page.waitForTimeout(1000)
  225. // 点击 Device List 按钮
  226. const deviceListButton = page.locator('tbody tr').first().locator('button').first()
  227. await deviceListButton.click()
  228. // 等待设备列表面板打开
  229. const devicePanel = page.locator('.el-drawer, .el-dialog').filter({ hasText: '摄像头列表' })
  230. await expect(devicePanel).toBeVisible({ timeout: 5000 })
  231. // 点击 Parameter Configuration 的 View 按钮
  232. const viewButton = devicePanel.locator('tbody tr').first().locator('button:has-text("查看")').first()
  233. await viewButton.click()
  234. // 等待参数配置抽屉打开
  235. const paramsDrawer = page.locator('.params-drawer')
  236. await expect(paramsDrawer).toBeVisible({ timeout: 5000 })
  237. // 点击复制按钮
  238. const copyButton = paramsDrawer.locator(
  239. '.code-editor button:has-text("复制"), .code-editor button:has-text("Copy")'
  240. )
  241. await expect(copyButton).toBeVisible()
  242. await copyButton.click()
  243. // 验证复制按钮点击后没有报错(复制成功提示在无头浏览器中可能不显示)
  244. await page.waitForTimeout(500)
  245. await expect(paramsDrawer).toBeVisible()
  246. })
  247. /**
  248. * 测试 CodeEditor JSON 模式 - 格式化功能
  249. */
  250. test('CodeEditor JSON模式 - 格式化按钮功能', async ({ page }) => {
  251. await login(page)
  252. await page.goto('/lss-manage/list')
  253. // 等待表格加载
  254. await page.waitForTimeout(1000)
  255. // 点击 Device List 按钮
  256. const deviceListButton = page.locator('tbody tr').first().locator('button').first()
  257. await deviceListButton.click()
  258. // 等待设备列表面板打开
  259. const devicePanel = page.locator('.el-drawer, .el-dialog').filter({ hasText: '摄像头列表' })
  260. await expect(devicePanel).toBeVisible({ timeout: 5000 })
  261. // 点击 Parameter Configuration 的 View 按钮
  262. const viewButton = devicePanel.locator('tbody tr').first().locator('button:has-text("查看")').first()
  263. await viewButton.click()
  264. // 等待参数配置抽屉打开
  265. const paramsDrawer = page.locator('.params-drawer')
  266. await expect(paramsDrawer).toBeVisible({ timeout: 5000 })
  267. // 验证格式化按钮可用(如果内容是有效JSON)
  268. const formatButton = paramsDrawer.locator('.code-editor button:has-text("格式化")')
  269. await expect(formatButton).toBeVisible()
  270. // 点击格式化按钮(如果按钮未禁用)
  271. const isDisabled = await formatButton.isDisabled()
  272. if (!isDisabled) {
  273. await formatButton.click()
  274. // 格式化后内容应该保持有效
  275. await page.waitForTimeout(300)
  276. }
  277. })
  278. /**
  279. * 测试 CodeEditor JSON 模式 - 无效JSON显示错误提示
  280. */
  281. test('CodeEditor JSON模式 - 无效JSON显示错误提示', async ({ page }) => {
  282. await login(page)
  283. await page.goto('/lss-manage/list')
  284. // 等待表格加载
  285. await page.waitForTimeout(1000)
  286. // 点击 Device List 按钮
  287. const deviceListButton = page.locator('tbody tr').first().locator('button').first()
  288. await deviceListButton.click()
  289. // 等待设备列表面板打开
  290. const devicePanel = page.locator('.el-drawer, .el-dialog').filter({ hasText: '摄像头列表' })
  291. await expect(devicePanel).toBeVisible({ timeout: 5000 })
  292. // 点击 Parameter Configuration 的 View 按钮
  293. const viewButton = devicePanel.locator('tbody tr').first().locator('button:has-text("查看")').first()
  294. await viewButton.click()
  295. // 等待参数配置抽屉打开
  296. const paramsDrawer = page.locator('.params-drawer')
  297. await expect(paramsDrawer).toBeVisible({ timeout: 5000 })
  298. // 获取编辑器并输入无效JSON
  299. const codeEditor = paramsDrawer.locator('.code-editor')
  300. const editorContent = codeEditor.locator('.cm-content')
  301. // 清空并输入无效JSON
  302. await editorContent.click()
  303. await page.keyboard.press('Meta+a')
  304. await page.keyboard.type('{ invalid json }')
  305. // 验证错误提示显示
  306. await expect(codeEditor.locator('.validation-error')).toBeVisible({ timeout: 3000 })
  307. await expect(codeEditor.locator('.validation-error')).toContainText('JSON 格式错误')
  308. // 验证格式化按钮被禁用
  309. const formatButton = codeEditor.locator('button:has-text("格式化")')
  310. await expect(formatButton).toBeDisabled()
  311. })
  312. /**
  313. * 测试 CodeEditor JSON 模式 - 更新内容并验证保存成功
  314. * 注:此测试依赖于后端实际保存数据,在某些环境中可能不稳定
  315. */
  316. // TODO: 待后端 API 稳定后重新启用
  317. test.skip('CodeEditor JSON模式 - 更新参数配置并验证保存成功', async ({ page }) => {
  318. await login(page)
  319. await page.goto('/lss-manage/list')
  320. // 等待表格加载
  321. await page.waitForTimeout(1000)
  322. // 点击 Device List 按钮
  323. const deviceListButton = page.locator('tbody tr').first().locator('button').first()
  324. await deviceListButton.click()
  325. // 等待设备列表面板打开
  326. const devicePanel = page.locator('.el-drawer, .el-dialog').filter({ hasText: '摄像头列表' })
  327. await expect(devicePanel).toBeVisible({ timeout: 5000 })
  328. // 点击 Parameter Configuration 的 View 按钮
  329. const viewButton = devicePanel.locator('tbody tr').first().locator('button:has-text("查看")').first()
  330. await viewButton.click()
  331. // 等待参数配置抽屉打开
  332. const paramsDrawer = page.locator('.params-drawer')
  333. await expect(paramsDrawer).toBeVisible({ timeout: 5000 })
  334. // 获取当前编辑器内容
  335. const codeEditor = paramsDrawer.locator('.code-editor')
  336. const editorContent = codeEditor.locator('.cm-content')
  337. // 生成唯一标识用于验证更新
  338. const timestamp = Date.now()
  339. const testValue = `"testUpdate": "${timestamp}"`
  340. // 修改JSON内容 - 在现有JSON中添加测试字段
  341. await editorContent.click()
  342. await page.keyboard.press('Meta+a')
  343. // 输入新的有效JSON内容
  344. await page.keyboard.type(`{\n ${testValue},\n "ip": "192.168.0.64"\n}`)
  345. // 点击更新按钮
  346. const updateButton = paramsDrawer.locator('button:has-text("更新"), button:has-text("Update")')
  347. await updateButton.click()
  348. // 等待更新成功提示
  349. await expect(page.locator('.el-message--success')).toBeVisible({ timeout: 5000 })
  350. // 等待抽屉关闭
  351. await expect(paramsDrawer).not.toBeVisible({ timeout: 5000 })
  352. // 重新打开参数配置抽屉验证内容已保存
  353. await page.waitForTimeout(500)
  354. await viewButton.click()
  355. // 等待抽屉重新打开
  356. const paramsDrawerReopened = page.locator('.params-drawer')
  357. await expect(paramsDrawerReopened).toBeVisible({ timeout: 5000 })
  358. // 验证内容包含我们添加的测试字段
  359. const editorContentReopened = paramsDrawerReopened.locator('.cm-content')
  360. await expect(editorContentReopened).toContainText(timestamp.toString())
  361. })
  362. /**
  363. * 测试 CodeEditor JSON 模式 - 运行参数更新并验证保存成功
  364. * 注:此测试依赖于后端实际保存数据,在某些环境中可能不稳定
  365. */
  366. // TODO: 待后端 API 稳定后重新启用
  367. test.skip('CodeEditor JSON模式 - 更新运行参数并验证保存成功', async ({ page }) => {
  368. await login(page)
  369. await page.goto('/lss-manage/list')
  370. // 等待表格加载
  371. await page.waitForTimeout(1000)
  372. // 点击 Device List 按钮
  373. const deviceListButton = page.locator('tbody tr').first().locator('button').first()
  374. await deviceListButton.click()
  375. // 等待设备列表面板打开
  376. const devicePanel = page.locator('.el-drawer, .el-dialog').filter({ hasText: '摄像头列表' })
  377. await expect(devicePanel).toBeVisible({ timeout: 5000 })
  378. // 点击 Run Parameters 的 View 按钮(第二个 View 按钮)
  379. const viewButtons = devicePanel.locator('tbody tr').first().locator('button:has-text("查看")')
  380. const runParamsViewButton = viewButtons.nth(1)
  381. await expect(runParamsViewButton).toBeVisible({ timeout: 5000 })
  382. await runParamsViewButton.click()
  383. // 等待运行参数抽屉打开
  384. const paramsDrawer = page.locator('.el-drawer').filter({ hasText: '运行参数' })
  385. await expect(paramsDrawer).toBeVisible({ timeout: 5000 })
  386. // 获取编辑器
  387. const codeEditor = paramsDrawer.locator('.code-editor')
  388. const editorContent = codeEditor.locator('.cm-content')
  389. // 生成唯一标识用于验证更新
  390. const timestamp = Date.now()
  391. const testValue = `"runtimeTest": "${timestamp}"`
  392. // 修改JSON内容
  393. await editorContent.click()
  394. await page.keyboard.press('Meta+a')
  395. await page.keyboard.type(`{\n ${testValue}\n}`)
  396. // 点击更新按钮
  397. const updateButton = paramsDrawer.locator('button:has-text("更新"), button:has-text("Update")')
  398. await updateButton.click()
  399. // 等待更新成功提示
  400. await expect(page.locator('.el-message--success')).toBeVisible({ timeout: 5000 })
  401. // 等待抽屉关闭
  402. await expect(paramsDrawer).not.toBeVisible({ timeout: 5000 })
  403. // 重新打开运行参数抽屉验证内容已保存
  404. await page.waitForTimeout(500)
  405. await runParamsViewButton.click()
  406. // 等待抽屉重新打开
  407. const paramsDrawerReopened = page.locator('.el-drawer').filter({ hasText: '运行参数' })
  408. await expect(paramsDrawerReopened).toBeVisible({ timeout: 5000 })
  409. // 验证内容包含我们添加的测试字段
  410. const editorContentReopened = paramsDrawerReopened.locator('.cm-content')
  411. await expect(editorContentReopened).toContainText(timestamp.toString())
  412. })
  413. })
  414. test.describe('LSS管理 - 摄像头列表搜索测试', () => {
  415. // 登录辅助函数
  416. async function login(page: Page) {
  417. await page.goto('/login')
  418. await page.evaluate(() => {
  419. localStorage.clear()
  420. document.cookie.split(';').forEach((c) => {
  421. document.cookie = c.replace(/^ +/, '').replace(/=.*/, `=;expires=${new Date().toUTCString()};path=/`)
  422. })
  423. })
  424. await page.reload()
  425. await page.getByPlaceholder('用户名').fill(TEST_USERNAME)
  426. await page.getByPlaceholder('密码').fill(TEST_PASSWORD)
  427. await page.getByRole('button', { name: '登录' }).click()
  428. await expect(page).not.toHaveURL(/\/login/, { timeout: 15000 })
  429. }
  430. // 打开摄像头列表辅助函数
  431. async function openCameraList(page: Page) {
  432. await page.goto('/lss-manage/list')
  433. await page.waitForTimeout(1000)
  434. // 点击 Device List 按钮打开设备列表 - 点击编辑按钮进入 LSS 编辑抽屉
  435. const editButton = page.locator('tbody tr').first().locator('button').nth(1)
  436. await expect(editButton).toBeVisible({ timeout: 10000 })
  437. await editButton.click()
  438. // 等待 LSS 编辑抽屉打开
  439. const drawer = page.locator('.el-drawer').filter({ hasText: 'LSS详情' })
  440. await expect(drawer).toBeVisible({ timeout: 5000 })
  441. // 点击"摄像头列表" Tab
  442. await drawer.locator('.el-tabs__item').filter({ hasText: '摄像头列表' }).click()
  443. await page.waitForTimeout(500)
  444. return drawer
  445. }
  446. /**
  447. * 测试摄像头搜索表单元素显示
  448. */
  449. test('摄像头列表 - 验证搜索表单元素显示', async ({ page }) => {
  450. await login(page)
  451. const drawer = await openCameraList(page)
  452. const toolbar = drawer.locator('.camera-toolbar')
  453. // 验证 Device ID 搜索框存在
  454. await expect(toolbar.getByPlaceholder('设备ID')).toBeVisible()
  455. // 验证 Name 搜索框存在
  456. await expect(toolbar.getByPlaceholder('名称')).toBeVisible()
  457. // 验证 Status 下拉框存在
  458. await expect(toolbar.locator('.el-select').first()).toBeVisible()
  459. // 验证查询按钮存在
  460. await expect(toolbar.getByRole('button', { name: /查询|Search/ })).toBeVisible()
  461. // 验证重置按钮存在
  462. await expect(toolbar.getByRole('button', { name: /重置|Reset/ })).toBeVisible()
  463. // 验证新增按钮存在
  464. await expect(toolbar.getByRole('button', { name: /新增|Add/ })).toBeVisible()
  465. })
  466. /**
  467. * 测试按设备ID搜索
  468. */
  469. test('摄像头列表 - 按设备ID搜索', async ({ page }) => {
  470. await login(page)
  471. const drawer = await openCameraList(page)
  472. const toolbar = drawer.locator('.camera-toolbar')
  473. // 等待表格数据加载
  474. await page.waitForTimeout(500)
  475. // 获取搜索前的数据数量
  476. const initialRowCount = await drawer.locator('.tab-content-wrapper tbody tr').count()
  477. // 使用固定的设备ID搜索
  478. const searchId = 'CT-IP100'
  479. // 输入设备ID搜索
  480. await toolbar.getByPlaceholder('设备ID').fill(searchId)
  481. // 点击搜索
  482. await toolbar.getByRole('button', { name: /查询|Search/ }).click()
  483. await page.waitForTimeout(500)
  484. // 验证搜索条件已应用
  485. await expect(toolbar.getByPlaceholder('设备ID')).toHaveValue(searchId)
  486. // 验证搜索结果
  487. const tableRows = drawer.locator('.tab-content-wrapper tbody tr')
  488. const rowCount = await tableRows.count()
  489. // 搜索结果应该有数据
  490. expect(rowCount).toBeGreaterThan(0)
  491. // 如果初始数据大于搜索结果,说明搜索生效了
  492. if (initialRowCount > 1) {
  493. expect(rowCount).toBeLessThanOrEqual(initialRowCount)
  494. }
  495. // 验证搜索结果中包含搜索关键词
  496. const firstRowDeviceId = await tableRows.first().locator('td').first().textContent()
  497. expect(firstRowDeviceId?.toUpperCase()).toContain('CT')
  498. })
  499. /**
  500. * 测试按名称搜索
  501. */
  502. test('摄像头列表 - 按名称搜索', async ({ page }) => {
  503. await login(page)
  504. const drawer = await openCameraList(page)
  505. const toolbar = drawer.locator('.camera-toolbar')
  506. // 等待表格数据加载
  507. await page.waitForTimeout(500)
  508. // 获取搜索前的数据数量
  509. const initialRowCount = await drawer.locator('.tab-content-wrapper tbody tr').count()
  510. // 使用固定的名称搜索
  511. const searchName = '初台64'
  512. // 输入名称搜索
  513. await toolbar.getByPlaceholder('名称').fill(searchName)
  514. // 点击搜索
  515. await toolbar.getByRole('button', { name: /查询|Search/ }).click()
  516. await page.waitForTimeout(500)
  517. // 验证搜索条件已应用
  518. await expect(toolbar.getByPlaceholder('名称')).toHaveValue(searchName)
  519. // 验证搜索结果
  520. const tableRows = drawer.locator('.tab-content-wrapper tbody tr')
  521. const rowCount = await tableRows.count()
  522. // 搜索结果应该有数据
  523. expect(rowCount).toBeGreaterThan(0)
  524. // 如果初始数据大于搜索结果,说明搜索生效了
  525. if (initialRowCount > 1) {
  526. expect(rowCount).toBeLessThanOrEqual(initialRowCount)
  527. }
  528. // 验证搜索结果中包含搜索关键词
  529. const firstRowName = await tableRows.first().locator('td').nth(1).textContent()
  530. expect(firstRowName).toContain('初台')
  531. })
  532. /**
  533. * 测试组合搜索 - 设备ID + 名称
  534. */
  535. test('摄像头列表 - 组合搜索设备ID和名称', async ({ page }) => {
  536. await login(page)
  537. const drawer = await openCameraList(page)
  538. const toolbar = drawer.locator('.camera-toolbar')
  539. // 等待表格数据加载
  540. await page.waitForTimeout(500)
  541. // 输入设备ID
  542. await toolbar.getByPlaceholder('设备ID').fill('CT')
  543. // 输入名称
  544. await toolbar.getByPlaceholder('名称').fill('初台')
  545. // 点击搜索
  546. await toolbar.getByRole('button', { name: /查询|Search/ }).click()
  547. await page.waitForTimeout(500)
  548. // 验证搜索条件已应用(输入框保留值)
  549. await expect(toolbar.getByPlaceholder('设备ID')).toHaveValue('CT')
  550. await expect(toolbar.getByPlaceholder('名称')).toHaveValue('初台')
  551. })
  552. /**
  553. * 测试重置搜索条件
  554. */
  555. test('摄像头列表 - 重置搜索条件', async ({ page }) => {
  556. await login(page)
  557. const drawer = await openCameraList(page)
  558. const toolbar = drawer.locator('.camera-toolbar')
  559. // 填入搜索条件
  560. await toolbar.getByPlaceholder('设备ID').fill('test-device-id')
  561. await toolbar.getByPlaceholder('名称').fill('test-camera-name')
  562. // 验证输入值
  563. await expect(toolbar.getByPlaceholder('设备ID')).toHaveValue('test-device-id')
  564. await expect(toolbar.getByPlaceholder('名称')).toHaveValue('test-camera-name')
  565. // 点击重置
  566. await toolbar.getByRole('button', { name: /重置|Reset/ }).click()
  567. await page.waitForTimeout(300)
  568. // 验证搜索条件已清空
  569. await expect(toolbar.getByPlaceholder('设备ID')).toHaveValue('')
  570. await expect(toolbar.getByPlaceholder('名称')).toHaveValue('')
  571. })
  572. /**
  573. * 测试搜索无结果情况
  574. */
  575. test('摄像头列表 - 搜索无结果显示空状态', async ({ page }) => {
  576. await login(page)
  577. const drawer = await openCameraList(page)
  578. const toolbar = drawer.locator('.camera-toolbar')
  579. // 输入一个不存在的设备ID
  580. await toolbar.getByPlaceholder('设备ID').fill('non-existent-device-id-xyz123')
  581. // 点击搜索
  582. await toolbar.getByRole('button', { name: /查询|Search/ }).click()
  583. await page.waitForTimeout(500)
  584. // 验证显示空状态或表格无数据
  585. const tableRows = drawer.locator('.tab-content-wrapper tbody tr')
  586. const rowCount = await tableRows.count()
  587. if (rowCount === 0) {
  588. // 验证显示空状态组件
  589. await expect(drawer.locator('.el-empty')).toBeVisible()
  590. }
  591. })
  592. /**
  593. * 测试按Enter键搜索
  594. */
  595. test('摄像头列表 - 按Enter键触发搜索', async ({ page }) => {
  596. await login(page)
  597. const drawer = await openCameraList(page)
  598. const toolbar = drawer.locator('.camera-toolbar')
  599. // 等待表格数据加载
  600. await page.waitForTimeout(500)
  601. // 在设备ID输入框输入并按Enter
  602. const deviceIdInput = toolbar.getByPlaceholder('设备ID')
  603. await deviceIdInput.fill('CT-IP100')
  604. await deviceIdInput.press('Enter')
  605. await page.waitForTimeout(500)
  606. // 验证搜索已执行(检查输入值保留)
  607. await expect(deviceIdInput).toHaveValue('CT-IP100')
  608. // 验证搜索结果有数据
  609. const tableRows = drawer.locator('.tab-content-wrapper tbody tr')
  610. const rowCount = await tableRows.count()
  611. expect(rowCount).toBeGreaterThan(0)
  612. })
  613. /**
  614. * 测试名称输入框按Enter键搜索
  615. */
  616. test('摄像头列表 - 名称输入框按Enter键触发搜索', async ({ page }) => {
  617. await login(page)
  618. const drawer = await openCameraList(page)
  619. const toolbar = drawer.locator('.camera-toolbar')
  620. // 等待表格数据加载
  621. await page.waitForTimeout(500)
  622. // 在名称输入框输入并按Enter
  623. const nameInput = toolbar.getByPlaceholder('名称')
  624. await nameInput.fill('初台64')
  625. await nameInput.press('Enter')
  626. await page.waitForTimeout(500)
  627. // 验证搜索已执行(检查输入值保留)
  628. await expect(nameInput).toHaveValue('初台64')
  629. // 验证搜索结果有数据
  630. const tableRows = drawer.locator('.tab-content-wrapper tbody tr')
  631. const rowCount = await tableRows.count()
  632. expect(rowCount).toBeGreaterThan(0)
  633. })
  634. /**
  635. * 测试表格列显示正确
  636. */
  637. test('摄像头列表 - 验证表格列显示', async ({ page }) => {
  638. await login(page)
  639. const drawer = await openCameraList(page)
  640. // 验证表头列(中英文)
  641. await expect(drawer.locator('th:has-text("设备ID"), th:has-text("Device ID")')).toBeVisible()
  642. await expect(drawer.locator('th:has-text("名称"), th:has-text("Name")')).toBeVisible()
  643. await expect(drawer.locator('th:has-text("状态"), th:has-text("Status")')).toBeVisible()
  644. await expect(drawer.locator('th:has-text("厂商"), th:has-text("Vendor")')).toBeVisible()
  645. await expect(drawer.locator('th:has-text("型号"), th:has-text("Model")')).toBeVisible()
  646. })
  647. /**
  648. * 测试设备总数显示
  649. */
  650. test('摄像头列表 - 验证设备总数显示', async ({ page }) => {
  651. await login(page)
  652. const drawer = await openCameraList(page)
  653. // 等待表格数据加载
  654. await page.waitForTimeout(500)
  655. // 获取表格行数
  656. const tableRows = drawer.locator('.tab-content-wrapper tbody tr')
  657. const rowCount = await tableRows.count()
  658. if (rowCount > 0) {
  659. // 验证总数显示(例如 "共 2 个设备" 或 "Total 2 Device")
  660. await expect(drawer.locator('.camera-count')).toBeVisible()
  661. }
  662. })
  663. })
  664. test.describe('LSS管理 - 摄像头未创建 Live Stream 对话框测试', () => {
  665. // 登录辅助函数
  666. async function login(page: Page) {
  667. await page.goto('/login')
  668. await page.evaluate(() => {
  669. localStorage.clear()
  670. document.cookie.split(';').forEach((c) => {
  671. document.cookie = c.replace(/^ +/, '').replace(/=.*/, `=;expires=${new Date().toUTCString()};path=/`)
  672. })
  673. })
  674. await page.reload()
  675. await page.getByPlaceholder('用户名').fill(TEST_USERNAME)
  676. await page.getByPlaceholder('密码').fill(TEST_PASSWORD)
  677. await page.getByRole('button', { name: '登录' }).click()
  678. await expect(page).not.toHaveURL(/\/login/, { timeout: 15000 })
  679. }
  680. // 打开摄像头列表辅助函数
  681. async function openCameraList(page: Page) {
  682. await page.goto('/lss-manage/list')
  683. await page.waitForTimeout(1000)
  684. // 点击编辑按钮进入 LSS 编辑抽屉
  685. const editButton = page.locator('tbody tr').first().locator('button').nth(1)
  686. await expect(editButton).toBeVisible({ timeout: 10000 })
  687. await editButton.click()
  688. // 等待 LSS 编辑抽屉打开
  689. const drawer = page.locator('.el-drawer').filter({ hasText: 'LSS详情' })
  690. await expect(drawer).toBeVisible({ timeout: 5000 })
  691. // 点击"摄像头列表" Tab
  692. await drawer.locator('.el-tabs__item').filter({ hasText: '摄像头列表' }).click()
  693. await page.waitForTimeout(500)
  694. return drawer
  695. }
  696. /**
  697. * 测试点击无 streamSn 的摄像头时显示对话框
  698. */
  699. test('点击无 streamSn 的摄像头时显示"尚未建立 Live Stream"对话框', async ({ page }) => {
  700. await login(page)
  701. // Mock 摄像头列表 API 返回无 streamSn 的数据
  702. await page.route('**/admin/camera/list*', async (route) => {
  703. await route.fulfill({
  704. status: 200,
  705. contentType: 'application/json',
  706. body: JSON.stringify({
  707. success: true,
  708. errCode: 0,
  709. data: {
  710. list: [
  711. {
  712. id: 1,
  713. cameraId: 'CAM_NO_STREAM',
  714. cameraName: '无推流摄像头',
  715. lssId: 'LSS_001',
  716. status: 'active',
  717. streamSn: null // 没有 streamSn
  718. }
  719. ],
  720. total: 1
  721. }
  722. })
  723. })
  724. })
  725. const drawer = await openCameraList(page)
  726. // 等待表格数据加载
  727. await page.waitForTimeout(500)
  728. // 点击摄像头控制按钮(crosshairs-btn)
  729. const crosshairsBtn = drawer.locator('.crosshairs-btn').first()
  730. await expect(crosshairsBtn).toBeVisible({ timeout: 5000 })
  731. await crosshairsBtn.click()
  732. // 验证对话框显示
  733. const messageBox = page.locator('.el-message-box')
  734. await expect(messageBox).toBeVisible({ timeout: 5000 })
  735. // 验证对话框标题
  736. await expect(messageBox.locator('.el-message-box__title')).toContainText('尚未建立 Live Stream')
  737. // 验证对话框内容
  738. await expect(messageBox.locator('.el-message-box__message')).toContainText('请先新增 Live Stream')
  739. // 验证按钮存在
  740. await expect(messageBox.locator('button:has-text("新增 Live Stream")')).toBeVisible()
  741. await expect(messageBox.locator('button:has-text("取消")')).toBeVisible()
  742. })
  743. /**
  744. * 测试点击"取消"按钮关闭对话框
  745. */
  746. test('点击"取消"按钮关闭对话框', async ({ page }) => {
  747. await login(page)
  748. // Mock 摄像头列表 API 返回无 streamSn 的数据
  749. await page.route('**/admin/camera/list*', async (route) => {
  750. await route.fulfill({
  751. status: 200,
  752. contentType: 'application/json',
  753. body: JSON.stringify({
  754. success: true,
  755. errCode: 0,
  756. data: {
  757. list: [
  758. {
  759. id: 1,
  760. cameraId: 'CAM_NO_STREAM',
  761. cameraName: '无推流摄像头',
  762. lssId: 'LSS_001',
  763. status: 'active',
  764. streamSn: null
  765. }
  766. ],
  767. total: 1
  768. }
  769. })
  770. })
  771. })
  772. const drawer = await openCameraList(page)
  773. await page.waitForTimeout(500)
  774. // 点击摄像头控制按钮
  775. const crosshairsBtn = drawer.locator('.crosshairs-btn').first()
  776. await crosshairsBtn.click()
  777. // 等待对话框显示
  778. const messageBox = page.locator('.el-message-box')
  779. await expect(messageBox).toBeVisible({ timeout: 5000 })
  780. // 点击取消按钮
  781. await messageBox.locator('button:has-text("取消")').click()
  782. // 验证对话框关闭
  783. await expect(messageBox).not.toBeVisible({ timeout: 3000 })
  784. // 验证仍在 LSS 页面
  785. await expect(page).toHaveURL(/\/lss-manage\/list/)
  786. })
  787. /**
  788. * 测试点击"新增 Live Stream"按钮跳转到创建页面
  789. */
  790. test('点击"新增 Live Stream"按钮跳转到 live-stream 创建页面', async ({ page }) => {
  791. await login(page)
  792. const drawer = await openCameraList(page)
  793. await page.waitForTimeout(500)
  794. // 找到没有 streamSn 的摄像头(crosshairs-btn 没有 active 类的)
  795. const inactiveCrosshairsBtn = drawer.locator('.crosshairs-btn:not(.active)').first()
  796. // 如果存在无 streamSn 的摄像头
  797. if ((await inactiveCrosshairsBtn.count()) > 0) {
  798. await inactiveCrosshairsBtn.click()
  799. // 等待对话框显示
  800. const messageBox = page.locator('.el-message-box')
  801. await expect(messageBox).toBeVisible({ timeout: 5000 })
  802. // 点击"新增 Live Stream"按钮
  803. await messageBox.locator('button:has-text("新增 Live Stream")').click()
  804. // 验证跳转到 live-stream 页面并带有 action=create 参数
  805. await expect(page).toHaveURL(/\/live-stream\?cameraId=.*&action=create/, { timeout: 5000 })
  806. // 验证新增抽屉自动打开
  807. const liveStreamDrawer = page.locator('.el-drawer').filter({ hasText: '新增 Live Stream' })
  808. await expect(liveStreamDrawer).toBeVisible({ timeout: 5000 })
  809. } else {
  810. // 如果没有无 streamSn 的摄像头,跳过测试
  811. test.skip()
  812. }
  813. })
  814. /**
  815. * 测试有 streamSn 的摄像头直接跳转(不显示对话框)
  816. */
  817. test('有 streamSn 的摄像头直接跳转到 live-stream 页面', async ({ page }) => {
  818. await login(page)
  819. const drawer = await openCameraList(page)
  820. await page.waitForTimeout(500)
  821. // 找到有 streamSn 的摄像头(crosshairs-btn 有 active 类的)
  822. const activeCrosshairsBtn = drawer.locator('.crosshairs-btn.active').first()
  823. // 如果存在有 streamSn 的摄像头
  824. if ((await activeCrosshairsBtn.count()) > 0) {
  825. await activeCrosshairsBtn.click()
  826. // 等待一小段时间检查是否有对话框
  827. await page.waitForTimeout(500)
  828. // 验证没有显示对话框,直接跳转
  829. const messageBox = page.locator('.el-message-box')
  830. // 验证跳转到 live-stream 页面(不带 action=create)
  831. await expect(page).toHaveURL(/\/live-stream\?cameraId=/, { timeout: 5000 })
  832. await expect(page).not.toHaveURL(/action=create/)
  833. } else {
  834. // 如果没有有 streamSn 的摄像头,跳过测试
  835. test.skip()
  836. }
  837. })
  838. })
  839. test.describe('LSS管理 - Bug修复验证测试', () => {
  840. // 登录辅助函数
  841. async function login(page: Page) {
  842. await page.goto('/login')
  843. await page.evaluate(() => {
  844. localStorage.clear()
  845. document.cookie.split(';').forEach((c) => {
  846. document.cookie = c.replace(/^ +/, '').replace(/=.*/, `=;expires=${new Date().toUTCString()};path=/`)
  847. })
  848. })
  849. await page.reload()
  850. await page.getByPlaceholder('用户名').fill(TEST_USERNAME)
  851. await page.getByPlaceholder('密码').fill(TEST_PASSWORD)
  852. await page.getByRole('button', { name: '登录' }).click()
  853. await expect(page).not.toHaveURL(/\/login/, { timeout: 15000 })
  854. }
  855. /**
  856. * Bug #4535: 重置按钮需要清除所有搜索条件(包括排序状态)
  857. */
  858. test('Bug #4535 - 重置按钮清除所有搜索条件包括排序状态', async ({ page }) => {
  859. await login(page)
  860. await page.goto('/lss-manage/list')
  861. // 等待表格加载
  862. await page.waitForTimeout(1000)
  863. // 填入搜索条件
  864. await page.getByPlaceholder('LSS ID').fill('test-id')
  865. await page.getByPlaceholder('名称').fill('test-name')
  866. // 点击表头进行排序
  867. const lssIdHeader = page.locator('th:has-text("LSS ID")')
  868. await lssIdHeader.click()
  869. await page.waitForTimeout(300)
  870. // 验证排序图标出现(使用 .first() 避免 strict mode 错误)
  871. await expect(lssIdHeader.locator('.caret-wrapper').first()).toBeVisible()
  872. // 点击重置
  873. await page.getByRole('button', { name: '重置' }).click()
  874. await page.waitForTimeout(300)
  875. // 验证搜索条件已清空
  876. await expect(page.getByPlaceholder('LSS ID')).toHaveValue('')
  877. await expect(page.getByPlaceholder('名称')).toHaveValue('')
  878. // TODO: 验证排序状态已重置(表头不再显示排序方向)
  879. // Bug #4535 尚未完全修复 - 重置按钮目前只清空搜索条件,不清空排序状态
  880. // 当 Bug #4535 修复后,取消下面的注释以启用排序状态验证
  881. // const headerClasses = await lssIdHeader.getAttribute('class') || ''
  882. // expect(headerClasses).not.toMatch(/\bascending\b/)
  883. // expect(headerClasses).not.toMatch(/\bdescending\b/)
  884. })
  885. /**
  886. * Bug #4536: 心跳状态显示为英文(active/hold/dead)而非中文
  887. */
  888. test('Bug #4536 - 心跳状态显示为英文格式', async ({ page }) => {
  889. await login(page)
  890. await page.goto('/lss-manage/list')
  891. // 等待表格加载
  892. await page.waitForTimeout(1000)
  893. // 获取心跳列的内容
  894. const heartbeatColumn = page.locator('tbody tr').first().locator('td').nth(4)
  895. const heartbeatText = await heartbeatColumn.textContent()
  896. // 验证心跳状态是英文格式(active/hold/dead),而非中文(活跃/待机/离线)
  897. // 心跳列格式: "status | time" 例如 "active | 2024-01-26 10:00:00"
  898. expect(heartbeatText).toMatch(/active|hold|dead/i)
  899. // 不应该包含中文状态
  900. expect(heartbeatText).not.toMatch(/活跃|待机|离线/)
  901. })
  902. /**
  903. * Bug #4537: 页面标题从"LSS 管理"改为"LSS 列表"
  904. */
  905. test('Bug #4537 - 页面标题显示为"LSS 列表"', async ({ page }) => {
  906. await login(page)
  907. await page.goto('/lss-manage/list')
  908. // 等待页面加载
  909. await page.waitForTimeout(500)
  910. // 验证侧边栏菜单显示"LSS 列表"
  911. await expect(page.locator('.el-menu-item.is-active, .el-sub-menu.is-active').first()).toContainText('LSS 列表')
  912. // 验证页面内容区域标题(如果有面包屑或页面标题)
  913. // 注意:根据实际UI调整选择器
  914. const pageTitle = page.locator('text=LSS 列表').first()
  915. await expect(pageTitle).toBeVisible()
  916. })
  917. /**
  918. * Bug #4538: 分页默认显示15条/页
  919. */
  920. test('Bug #4538 - 分页默认显示15条/页', async ({ page }) => {
  921. await login(page)
  922. await page.goto('/lss-manage/list')
  923. // 等待表格加载
  924. await page.waitForTimeout(1000)
  925. // 验证分页选择器的默认值是15
  926. const pageSizeSelector = page.locator(
  927. '.el-pagination .el-select .el-input__inner, .el-pagination .el-select-v2__placeholder'
  928. )
  929. const pageSizeText = (await pageSizeSelector.first().textContent()) || (await pageSizeSelector.first().inputValue())
  930. // 验证默认每页显示15条
  931. expect(pageSizeText).toContain('15')
  932. })
  933. /**
  934. * Bug #4538: 分页选项包含15
  935. */
  936. test('Bug #4538 - 分页选项包含15条/页选项', async ({ page }) => {
  937. await login(page)
  938. await page.goto('/lss-manage/list')
  939. // 等待表格加载
  940. await page.waitForTimeout(1000)
  941. // 点击分页选择器打开下拉菜单
  942. const pageSizeSelector = page.locator('.el-pagination .el-select')
  943. await pageSizeSelector.click()
  944. await page.waitForTimeout(300)
  945. // 验证下拉菜单中包含15选项
  946. const dropdown = page.locator('.el-select-dropdown, .el-popper')
  947. await expect(dropdown.locator('text=15')).toBeVisible()
  948. // 验证选项顺序正确: 10, 15, 20, 50, 100
  949. const options = dropdown.locator('.el-select-dropdown__item')
  950. const optionsText = await options.allTextContents()
  951. // 验证包含所有期望的选项
  952. expect(optionsText.some((t) => t.includes('10'))).toBeTruthy()
  953. expect(optionsText.some((t) => t.includes('15'))).toBeTruthy()
  954. expect(optionsText.some((t) => t.includes('20'))).toBeTruthy()
  955. expect(optionsText.some((t) => t.includes('50'))).toBeTruthy()
  956. expect(optionsText.some((t) => t.includes('100'))).toBeTruthy()
  957. })
  958. /**
  959. * Bug #4540: 查询按钮使用蓝底(409EFF)白字
  960. */
  961. test('Bug #4540 - 查询按钮使用蓝底白字', async ({ page }) => {
  962. await login(page)
  963. await page.goto('/lss-manage/list')
  964. // 等待页面加载
  965. await page.waitForTimeout(500)
  966. // 获取查询按钮
  967. const searchButton = page.locator('[data-id="btn-search"]')
  968. await expect(searchButton).toBeVisible()
  969. // 验证按钮有 el-button--primary 类(蓝色按钮)
  970. await expect(searchButton).toHaveClass(/el-button--primary/)
  971. // 验证按钮背景色接近 #409EFF
  972. const bgColor = await searchButton.evaluate((el) => {
  973. return window.getComputedStyle(el).backgroundColor
  974. })
  975. // #409EFF 的 RGB 值为 rgb(64, 158, 255)
  976. expect(bgColor).toMatch(/rgb\(64,\s*158,\s*255\)|rgba\(64,\s*158,\s*255/)
  977. })
  978. /**
  979. * Bug #4541: 重置按钮使用灰底(909399)白字
  980. */
  981. test('Bug #4541 - 重置按钮使用灰底白字', async ({ page }) => {
  982. await login(page)
  983. await page.goto('/lss-manage/list')
  984. // 等待页面加载
  985. await page.waitForTimeout(500)
  986. // 获取重置按钮
  987. const resetButton = page.locator('[data-id="btn-reset"]')
  988. await expect(resetButton).toBeVisible()
  989. // 验证按钮有 el-button--info 类(灰色按钮)
  990. await expect(resetButton).toHaveClass(/el-button--info/)
  991. // 验证按钮背景色接近 #909399
  992. const bgColor = await resetButton.evaluate((el) => {
  993. return window.getComputedStyle(el).backgroundColor
  994. })
  995. // #909399 的 RGB 值为 rgb(144, 147, 153)
  996. expect(bgColor).toMatch(/rgb\(144,\s*147,\s*153\)|rgba\(144,\s*147,\s*153/)
  997. })
  998. /**
  999. * Bug #4542: 分页当前页背景色使用蓝底(409EFF)白字
  1000. */
  1001. test('Bug #4542 - 分页当前页使用蓝底白字', async ({ page }) => {
  1002. await login(page)
  1003. await page.goto('/lss-manage/list')
  1004. // 等待表格加载
  1005. await page.waitForTimeout(1000)
  1006. // 获取分页组件中当前激活的页码按钮
  1007. const activePager = page.locator('.el-pagination .el-pager .is-active, .el-pagination .el-pager .active')
  1008. await expect(activePager).toBeVisible()
  1009. // 验证当前页背景色接近 #409EFF
  1010. const bgColor = await activePager.evaluate((el) => {
  1011. return window.getComputedStyle(el).backgroundColor
  1012. })
  1013. // #409EFF 的 RGB 值为 rgb(64, 158, 255)
  1014. expect(bgColor).toMatch(/rgb\(64,\s*158,\s*255\)|rgba\(64,\s*158,\s*255/)
  1015. })
  1016. /**
  1017. * Bug #4557: 摄像头列表状态下拉框显示 active/hold/dead
  1018. */
  1019. test('Bug #4557 - 摄像头列表状态下拉框显示英文选项', async ({ page }) => {
  1020. await login(page)
  1021. await page.goto('/lss-manage/list')
  1022. // 等待表格加载
  1023. await page.waitForTimeout(1000)
  1024. // 点击编辑按钮进入 LSS 编辑抽屉
  1025. const editButton = page.locator('tbody tr').first().locator('button').nth(1)
  1026. await expect(editButton).toBeVisible({ timeout: 10000 })
  1027. await editButton.click()
  1028. // 等待 LSS 编辑抽屉打开
  1029. const drawer = page.locator('.el-drawer').filter({ hasText: 'LSS详情' })
  1030. await expect(drawer).toBeVisible({ timeout: 5000 })
  1031. // 点击"摄像头列表" Tab
  1032. await drawer.locator('.el-tabs__item').filter({ hasText: '摄像头列表' }).click()
  1033. await page.waitForTimeout(500)
  1034. // 点击状态下拉框
  1035. const statusSelect = drawer.locator('.camera-toolbar .el-select').first()
  1036. await statusSelect.click()
  1037. await page.waitForTimeout(300)
  1038. // 验证下拉选项包含 active/hold/dead 而非中文
  1039. const dropdown = page.locator('.el-select-dropdown, .el-popper').last()
  1040. const options = dropdown.locator('.el-select-dropdown__item')
  1041. const optionsText = await options.allTextContents()
  1042. // 验证包含英文选项
  1043. expect(optionsText.some((t) => t.includes('active'))).toBeTruthy()
  1044. expect(optionsText.some((t) => t.includes('hold'))).toBeTruthy()
  1045. expect(optionsText.some((t) => t.includes('dead'))).toBeTruthy()
  1046. // 验证不包含中文状态
  1047. expect(optionsText.some((t) => t.includes('在线'))).toBeFalsy()
  1048. expect(optionsText.some((t) => t.includes('离线'))).toBeFalsy()
  1049. })
  1050. /**
  1051. * Bug #4558: 摄像头列表没有数据时表头要显示
  1052. */
  1053. test('Bug #4558 - 摄像头列表无数据时显示表头', async ({ page }) => {
  1054. await login(page)
  1055. // Mock 摄像头列表 API 返回空数据
  1056. await page.route('**/admin/camera/list*', async (route) => {
  1057. await route.fulfill({
  1058. status: 200,
  1059. contentType: 'application/json',
  1060. body: JSON.stringify({
  1061. success: true,
  1062. errCode: 0,
  1063. data: {
  1064. list: [],
  1065. total: 0
  1066. }
  1067. })
  1068. })
  1069. })
  1070. await page.goto('/lss-manage/list')
  1071. await page.waitForTimeout(1000)
  1072. // 点击编辑按钮进入 LSS 编辑抽屉
  1073. const editButton = page.locator('tbody tr').first().locator('button').nth(1)
  1074. await expect(editButton).toBeVisible({ timeout: 10000 })
  1075. await editButton.click()
  1076. // 等待 LSS 编辑抽屉打开
  1077. const drawer = page.locator('.el-drawer').filter({ hasText: 'LSS详情' })
  1078. await expect(drawer).toBeVisible({ timeout: 5000 })
  1079. // 点击"摄像头列表" Tab
  1080. await drawer.locator('.el-tabs__item').filter({ hasText: '摄像头列表' }).click()
  1081. await page.waitForTimeout(500)
  1082. // 验证表头可见(即使没有数据)
  1083. await expect(drawer.locator('th:has-text("设备ID")')).toBeVisible()
  1084. await expect(drawer.locator('th:has-text("名称")')).toBeVisible()
  1085. await expect(drawer.locator('th:has-text("状态")')).toBeVisible()
  1086. // 验证空状态提示显示
  1087. await expect(drawer.locator('.el-empty')).toBeVisible()
  1088. })
  1089. /**
  1090. * Bug #4593: 删除提示显示正确的设备名称而非undefined
  1091. */
  1092. test('Bug #4593 - 删除提示显示正确的设备名称', async ({ page }) => {
  1093. await login(page)
  1094. // Mock 摄像头列表 API 返回有数据
  1095. const testCameraName = '测试摄像头001'
  1096. await page.route('**/admin/camera/list*', async (route) => {
  1097. await route.fulfill({
  1098. status: 200,
  1099. contentType: 'application/json',
  1100. body: JSON.stringify({
  1101. success: true,
  1102. errCode: 0,
  1103. data: {
  1104. list: [
  1105. {
  1106. id: 1,
  1107. cameraId: 'CAM_TEST_001',
  1108. cameraName: testCameraName,
  1109. lssId: 'LSS_001',
  1110. status: 'active',
  1111. streamSn: 'STREAM_001'
  1112. }
  1113. ],
  1114. total: 1
  1115. }
  1116. })
  1117. })
  1118. })
  1119. await page.goto('/lss-manage/list')
  1120. await page.waitForTimeout(1000)
  1121. // 点击编辑按钮进入 LSS 编辑抽屉
  1122. const editButton = page.locator('tbody tr').first().locator('button').nth(1)
  1123. await expect(editButton).toBeVisible({ timeout: 10000 })
  1124. await editButton.click()
  1125. // 等待 LSS 编辑抽屉打开
  1126. const drawer = page.locator('.el-drawer').filter({ hasText: 'LSS详情' })
  1127. await expect(drawer).toBeVisible({ timeout: 5000 })
  1128. // 点击"摄像头列表" Tab
  1129. await drawer.locator('.el-tabs__item').filter({ hasText: '摄像头列表' }).click()
  1130. await page.waitForTimeout(500)
  1131. // 点击删除按钮
  1132. const deleteButton = drawer
  1133. .locator('tbody tr')
  1134. .first()
  1135. .locator('button[type="button"]')
  1136. .filter({ hasText: '' })
  1137. .last()
  1138. // 使用 Icon 选择器更精确
  1139. const deleteIcon = drawer.locator('tbody tr').first().locator('.iconify--mdi[data-icon*="delete"]').first()
  1140. if ((await deleteIcon.count()) > 0) {
  1141. await deleteIcon.click()
  1142. } else {
  1143. // 备选方案:点击最后一个按钮(删除按钮)
  1144. await drawer.locator('tbody tr').first().locator('button').last().click()
  1145. }
  1146. // 等待确认对话框
  1147. const messageBox = page.locator('.el-message-box')
  1148. await expect(messageBox).toBeVisible({ timeout: 5000 })
  1149. // 验证对话框中显示正确的设备名称,而非 "undefined"
  1150. const messageText = await messageBox.locator('.el-message-box__message').textContent()
  1151. expect(messageText).toContain(testCameraName)
  1152. expect(messageText).not.toContain('undefined')
  1153. // 关闭对话框
  1154. await messageBox.locator('button:has-text("取消")').click()
  1155. })
  1156. /**
  1157. * Bug #4569: 编辑摄像头标题改为"摄像头详情"
  1158. */
  1159. test('Bug #4569 - 编辑摄像头抽屉标题显示"摄像头详情"', async ({ page }) => {
  1160. await login(page)
  1161. await page.goto('/lss-manage/list')
  1162. await page.waitForTimeout(1000)
  1163. // 点击编辑按钮进入 LSS 编辑抽屉
  1164. const editButton = page.locator('tbody tr').first().locator('button').nth(1)
  1165. await expect(editButton).toBeVisible({ timeout: 10000 })
  1166. await editButton.click()
  1167. // 等待 LSS 编辑抽屉打开
  1168. const drawer = page.locator('.el-drawer').filter({ hasText: 'LSS详情' })
  1169. await expect(drawer).toBeVisible({ timeout: 5000 })
  1170. // 点击"摄像头列表" Tab
  1171. await drawer.locator('.el-tabs__item').filter({ hasText: '摄像头列表' }).click()
  1172. await page.waitForTimeout(500)
  1173. // 点击摄像头编辑按钮
  1174. const cameraEditButton = drawer.locator('tbody tr').first().locator('button').first()
  1175. if ((await cameraEditButton.count()) > 0) {
  1176. await cameraEditButton.click()
  1177. // 等待摄像头详情抽屉打开
  1178. const cameraDrawer = page.locator('.el-drawer').filter({ hasText: '摄像头详情' })
  1179. await expect(cameraDrawer).toBeVisible({ timeout: 5000 })
  1180. // 验证标题是"摄像头详情"而非"编辑摄像头"
  1181. await expect(cameraDrawer.locator('.el-drawer__header, .el-drawer__title')).toContainText('摄像头详情')
  1182. }
  1183. })
  1184. /**
  1185. * Bug #4570: 摄像头详情增加"添加时间"字段
  1186. */
  1187. test('Bug #4570 - 摄像头详情显示添加时间', async ({ page }) => {
  1188. await login(page)
  1189. // Mock 摄像头详情 API 返回带有 createdAt 的数据
  1190. await page.route('**/admin/camera/get*', async (route) => {
  1191. await route.fulfill({
  1192. status: 200,
  1193. contentType: 'application/json',
  1194. body: JSON.stringify({
  1195. success: true,
  1196. errCode: 0,
  1197. data: {
  1198. id: 1,
  1199. cameraId: 'CAM_TEST_001',
  1200. cameraName: '测试摄像头',
  1201. lssId: 'LSS_001',
  1202. status: 'active',
  1203. vendorName: 'hikvision',
  1204. model: 'DS-2CD2043G0-I',
  1205. createdAt: '2024-01-15T10:30:00Z'
  1206. }
  1207. })
  1208. })
  1209. })
  1210. await page.goto('/lss-manage/list')
  1211. await page.waitForTimeout(1000)
  1212. // 点击编辑按钮进入 LSS 编辑抽屉
  1213. const editButton = page.locator('tbody tr').first().locator('button').nth(1)
  1214. await expect(editButton).toBeVisible({ timeout: 10000 })
  1215. await editButton.click()
  1216. // 等待 LSS 编辑抽屉打开
  1217. const drawer = page.locator('.el-drawer').filter({ hasText: 'LSS详情' })
  1218. await expect(drawer).toBeVisible({ timeout: 5000 })
  1219. // 点击"摄像头列表" Tab
  1220. await drawer.locator('.el-tabs__item').filter({ hasText: '摄像头列表' }).click()
  1221. await page.waitForTimeout(500)
  1222. // 点击摄像头编辑按钮
  1223. const cameraEditButton = drawer.locator('tbody tr').first().locator('button').first()
  1224. if ((await cameraEditButton.count()) > 0) {
  1225. await cameraEditButton.click()
  1226. // 等待摄像头详情抽屉打开
  1227. const cameraDrawer = page.locator('.el-drawer').filter({ hasText: '摄像头详情' })
  1228. await expect(cameraDrawer).toBeVisible({ timeout: 5000 })
  1229. // 验证有"添加时间"字段
  1230. await expect(cameraDrawer.locator('label:has-text("添加时间")')).toBeVisible()
  1231. // 验证添加时间值显示正确格式
  1232. const timeValue = cameraDrawer.locator('label:has-text("添加时间")').locator('..').locator('.form-value')
  1233. const timeText = await timeValue.textContent()
  1234. // 验证时间格式或包含日期
  1235. expect(timeText).toMatch(/\d{4}-\d{2}-\d{2}|\-/)
  1236. }
  1237. })
  1238. /**
  1239. * Bug #4545: 按钮大小统一,圆角框
  1240. */
  1241. test('Bug #4545 - 按钮有统一的圆角', async ({ page }) => {
  1242. await login(page)
  1243. await page.goto('/lss-manage/list')
  1244. // 等待页面加载
  1245. await page.waitForTimeout(500)
  1246. // 获取查询按钮
  1247. const searchButton = page.locator('[data-id="btn-search"]')
  1248. await expect(searchButton).toBeVisible()
  1249. // 验证按钮有圆角
  1250. const borderRadius = await searchButton.evaluate((el) => {
  1251. return window.getComputedStyle(el).borderRadius
  1252. })
  1253. // 验证圆角值不为0
  1254. expect(borderRadius).not.toBe('0px')
  1255. expect(parseInt(borderRadius)).toBeGreaterThanOrEqual(4)
  1256. })
  1257. /**
  1258. * Bug #4549: LSS列表作为「LSS 管理」的子菜单
  1259. */
  1260. test('Bug #4549 - LSS列表作为LSS管理的子菜单', async ({ page }) => {
  1261. await login(page)
  1262. // 等待侧边栏加载
  1263. await page.waitForTimeout(500)
  1264. // 验证"LSS 管理"父菜单存在
  1265. const lssManageMenu = page.locator('.layout__nav-item--parent').filter({ hasText: 'LSS 管理' })
  1266. await expect(lssManageMenu).toBeVisible()
  1267. // 点击展开子菜单
  1268. await lssManageMenu.click()
  1269. await page.waitForTimeout(300)
  1270. // 验证"LSS 列表"子菜单存在
  1271. const lssListMenu = page.locator('.layout__nav-item--child').filter({ hasText: 'LSS 列表' })
  1272. await expect(lssListMenu).toBeVisible()
  1273. // 点击子菜单导航到页面
  1274. await lssListMenu.click()
  1275. await expect(page).toHaveURL(/\/lss-manage\/list/)
  1276. })
  1277. /**
  1278. * Bug #4554 & #4555: 摄像头列表搜索字段
  1279. */
  1280. test('Bug #4554/#4555 - 摄像头列表有设备ID和设备名称搜索字段', async ({ page }) => {
  1281. await login(page)
  1282. await page.goto('/lss-manage/list')
  1283. await page.waitForTimeout(1000)
  1284. // 点击编辑按钮进入 LSS 编辑抽屉
  1285. const editButton = page.locator('tbody tr').first().locator('button').nth(1)
  1286. await expect(editButton).toBeVisible({ timeout: 10000 })
  1287. await editButton.click()
  1288. // 等待 LSS 编辑抽屉打开
  1289. const drawer = page.locator('.el-drawer').filter({ hasText: 'LSS详情' })
  1290. await expect(drawer).toBeVisible({ timeout: 5000 })
  1291. // 点击"摄像头列表" Tab
  1292. await drawer.locator('.el-tabs__item').filter({ hasText: '摄像头列表' }).click()
  1293. await page.waitForTimeout(500)
  1294. // 验证有"设备ID"搜索框
  1295. await expect(drawer.getByPlaceholder('设备ID')).toBeVisible()
  1296. // 验证有"名称"搜索框
  1297. await expect(drawer.getByPlaceholder('名称')).toBeVisible()
  1298. // 验证没有"IP / 设备ID / 名称"混合搜索框
  1299. const mixedSearch = drawer.getByPlaceholder('IP / 设备ID / 名称')
  1300. await expect(mixedSearch).not.toBeVisible()
  1301. })
  1302. /**
  1303. * Bug #4562: 摄像头列表有分页功能
  1304. */
  1305. test('Bug #4562 - 摄像头列表有分页功能', async ({ page }) => {
  1306. await login(page)
  1307. await page.goto('/lss-manage/list')
  1308. await page.waitForTimeout(1000)
  1309. // 点击编辑按钮进入 LSS 编辑抽屉
  1310. const editButton = page.locator('tbody tr').first().locator('button').nth(1)
  1311. await expect(editButton).toBeVisible({ timeout: 10000 })
  1312. await editButton.click()
  1313. // 等待 LSS 编辑抽屉打开
  1314. const drawer = page.locator('.el-drawer').filter({ hasText: 'LSS详情' })
  1315. await expect(drawer).toBeVisible({ timeout: 5000 })
  1316. // 点击"摄像头列表" Tab
  1317. await drawer.locator('.el-tabs__item').filter({ hasText: '摄像头列表' }).click()
  1318. await page.waitForTimeout(500)
  1319. // 验证分页组件存在
  1320. await expect(drawer.locator('.el-pagination')).toBeVisible()
  1321. })
  1322. /**
  1323. * Bug #4567: List厂商显示和详情页一样
  1324. */
  1325. test('Bug #4567 - 厂商列使用vendorName字段', async ({ page }) => {
  1326. await login(page)
  1327. // Mock 摄像头列表 API 返回带有 vendorName 的数据
  1328. await page.route('**/admin/camera/list*', async (route) => {
  1329. await route.fulfill({
  1330. status: 200,
  1331. contentType: 'application/json',
  1332. body: JSON.stringify({
  1333. success: true,
  1334. errCode: 0,
  1335. data: {
  1336. list: [
  1337. {
  1338. id: 1,
  1339. cameraId: 'CAM_001',
  1340. cameraName: '测试摄像头',
  1341. lssId: 'LSS_001',
  1342. status: 'active',
  1343. vendorName: 'hikvision',
  1344. model: 'DS-2CD2T45'
  1345. }
  1346. ],
  1347. total: 1
  1348. }
  1349. })
  1350. })
  1351. })
  1352. await page.goto('/lss-manage/list')
  1353. await page.waitForTimeout(1000)
  1354. // 点击编辑按钮进入 LSS 编辑抽屉
  1355. const editButton = page.locator('tbody tr').first().locator('button').nth(1)
  1356. await expect(editButton).toBeVisible({ timeout: 10000 })
  1357. await editButton.click()
  1358. // 等待 LSS 编辑抽屉打开
  1359. const drawer = page.locator('.el-drawer').filter({ hasText: 'LSS详情' })
  1360. await expect(drawer).toBeVisible({ timeout: 5000 })
  1361. // 点击"摄像头列表" Tab
  1362. await drawer.locator('.el-tabs__item').filter({ hasText: '摄像头列表' }).click()
  1363. await page.waitForTimeout(500)
  1364. // 验证厂商列显示正确的格式化名称
  1365. const vendorCell = drawer.locator('tbody tr').first().locator('td').nth(5)
  1366. const vendorText = await vendorCell.textContent()
  1367. expect(vendorText).toContain('HIKVISION')
  1368. })
  1369. /**
  1370. * Bug #4588: 参数配置更新按钮蓝底白字
  1371. */
  1372. test('Bug #4588 - 参数配置更新按钮使用蓝底白字', async ({ page }) => {
  1373. await login(page)
  1374. await page.goto('/lss-manage/list')
  1375. await page.waitForTimeout(1000)
  1376. // 点击编辑按钮进入 LSS 编辑抽屉
  1377. const editButton = page.locator('tbody tr').first().locator('button').nth(1)
  1378. await expect(editButton).toBeVisible({ timeout: 10000 })
  1379. await editButton.click()
  1380. // 等待 LSS 编辑抽屉打开
  1381. const drawer = page.locator('.el-drawer').filter({ hasText: 'LSS详情' })
  1382. await expect(drawer).toBeVisible({ timeout: 5000 })
  1383. // 点击"摄像头列表" Tab
  1384. await drawer.locator('.el-tabs__item').filter({ hasText: '摄像头列表' }).click()
  1385. await page.waitForTimeout(500)
  1386. // 点击参数配置"查看"按钮
  1387. const viewButton = drawer.locator('tbody tr').first().locator('button:has-text("查看")').first()
  1388. if ((await viewButton.count()) > 0) {
  1389. await viewButton.click()
  1390. // 等待参数配置抽屉打开
  1391. const paramsDrawer = page.locator('.params-drawer')
  1392. await expect(paramsDrawer).toBeVisible({ timeout: 5000 })
  1393. // 验证更新按钮是蓝色
  1394. const updateButton = paramsDrawer.locator('button:has-text("更新")')
  1395. await expect(updateButton).toHaveClass(/el-button--primary/)
  1396. }
  1397. })
  1398. /**
  1399. * Bug #4594: 删除确认对话框确定按钮蓝底白字
  1400. */
  1401. test('Bug #4594 - 删除确认对话框确定按钮蓝底白字', async ({ page }) => {
  1402. await login(page)
  1403. // Mock 摄像头列表 API
  1404. await page.route('**/admin/camera/list*', async (route) => {
  1405. await route.fulfill({
  1406. status: 200,
  1407. contentType: 'application/json',
  1408. body: JSON.stringify({
  1409. success: true,
  1410. errCode: 0,
  1411. data: {
  1412. list: [{ id: 1, cameraId: 'CAM_001', cameraName: '测试', status: 'active' }],
  1413. total: 1
  1414. }
  1415. })
  1416. })
  1417. })
  1418. await page.goto('/lss-manage/list')
  1419. await page.waitForTimeout(1000)
  1420. // 点击编辑按钮进入 LSS 编辑抽屉
  1421. const editButton = page.locator('tbody tr').first().locator('button').nth(1)
  1422. await expect(editButton).toBeVisible({ timeout: 10000 })
  1423. await editButton.click()
  1424. // 等待 LSS 编辑抽屉打开
  1425. const drawer = page.locator('.el-drawer').filter({ hasText: 'LSS详情' })
  1426. await expect(drawer).toBeVisible({ timeout: 5000 })
  1427. // 点击"摄像头列表" Tab
  1428. await drawer.locator('.el-tabs__item').filter({ hasText: '摄像头列表' }).click()
  1429. await page.waitForTimeout(500)
  1430. // 点击删除按钮
  1431. await drawer.locator('tbody tr').first().locator('button').last().click()
  1432. // 等待确认对话框
  1433. const messageBox = page.locator('.el-message-box')
  1434. await expect(messageBox).toBeVisible({ timeout: 5000 })
  1435. // 验证确定按钮是蓝色
  1436. const confirmButton = messageBox.locator('button.el-button--primary')
  1437. await expect(confirmButton).toBeVisible()
  1438. const bgColor = await confirmButton.evaluate((el) => {
  1439. return window.getComputedStyle(el).backgroundColor
  1440. })
  1441. // #409EFF 的 RGB 值为 rgb(64, 158, 255)
  1442. expect(bgColor).toMatch(/rgb\(64,\s*158,\s*255\)|rgba\(64,\s*158,\s*255/)
  1443. // 关闭对话框
  1444. await messageBox.locator('button:has-text("取消")').click()
  1445. })
  1446. })