智慧水务管理系统 - 精河县供水工程综合管理平台

device-management.cy.js 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. describe('设备管理 CRUD 流程', () => {
  2. const testData = {
  3. device: {
  4. name: '测试设备 ' + Date.now(),
  5. type: '水泵',
  6. location: '测试区域 A'
  7. }
  8. };
  9. beforeEach(() => {
  10. cy.login();
  11. cy.visit('/devices');
  12. });
  13. it('创建新设备', () => {
  14. cy.createDevice(testData.device);
  15. // 验证设备创建成功
  16. cy.contains(testData.device.name).should('be.visible');
  17. cy.contains(testData.device.type).should('be.visible');
  18. cy.contains(testData.device.location).should('be.visible');
  19. });
  20. it('查看设备详情', () => {
  21. // 假设已有设备,点击查看详情
  22. cy.get('.device-item').first().click();
  23. // 验证详情页面显示
  24. cy.get('.device-detail-modal').should('be.visible');
  25. cy.get('.device-name').should('be.visible');
  26. });
  27. it('更新设备信息', () => {
  28. // 先创建设备
  29. cy.createDevice(testData.device);
  30. // 找到刚创建的设备并编辑
  31. cy.contains(testData.device.name).siblings('.edit-btn').click();
  32. // 修改设备信息
  33. cy.get('input[name="name"]').clear().type(testData.device.name + ' - 更新');
  34. cy.get('button[type="submit"]').click();
  35. // 验证更新成功
  36. cy.contains(testData.device.name + ' - 更新').should('be.visible');
  37. });
  38. it('删除设备', () => {
  39. // 先创建设备
  40. cy.createDevice(testData.device);
  41. // 找到刚创建的设备并删除
  42. cy.contains(testData.device.name).siblings('.delete-btn').click();
  43. // 确认删除
  44. cy.get('.confirm-delete').click();
  45. // 验证删除成功
  46. cy.contains(testData.device.name).should('not.exist');
  47. });
  48. });