| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- describe('设备管理 CRUD 流程', () => {
- const testData = {
- device: {
- name: '测试设备 ' + Date.now(),
- type: '水泵',
- location: '测试区域 A'
- }
- };
-
- beforeEach(() => {
- cy.login();
- cy.visit('/devices');
- });
-
- it('创建新设备', () => {
- cy.createDevice(testData.device);
-
- // 验证设备创建成功
- cy.contains(testData.device.name).should('be.visible');
- cy.contains(testData.device.type).should('be.visible');
- cy.contains(testData.device.location).should('be.visible');
- });
-
- it('查看设备详情', () => {
- // 假设已有设备,点击查看详情
- cy.get('.device-item').first().click();
-
- // 验证详情页面显示
- cy.get('.device-detail-modal').should('be.visible');
- cy.get('.device-name').should('be.visible');
- });
-
- it('更新设备信息', () => {
- // 先创建设备
- cy.createDevice(testData.device);
-
- // 找到刚创建的设备并编辑
- cy.contains(testData.device.name).siblings('.edit-btn').click();
-
- // 修改设备信息
- cy.get('input[name="name"]').clear().type(testData.device.name + ' - 更新');
- cy.get('button[type="submit"]').click();
-
- // 验证更新成功
- cy.contains(testData.device.name + ' - 更新').should('be.visible');
- });
-
- it('删除设备', () => {
- // 先创建设备
- cy.createDevice(testData.device);
-
- // 找到刚创建的设备并删除
- cy.contains(testData.device.name).siblings('.delete-btn').click();
-
- // 确认删除
- cy.get('.confirm-delete').click();
-
- // 验证删除成功
- cy.contains(testData.device.name).should('not.exist');
- });
- });
|