diff --git a/test/e2e/config/config.yaml b/test/e2e/config/config.yaml index 8f3a45c2..b66303d3 100644 --- a/test/e2e/config/config.yaml +++ b/test/e2e/config/config.yaml @@ -10,6 +10,7 @@ env: imageName: cirros-0.5.2-x86_64-disk imageType: Others imageDownloadUrl: http://download.cirros-cloud.net/0.5.1/cirros-0.5.1-x86_64-disk.img + imageCanChangePassword: false testFiles: - pages/login.spec.js - pages/error.spec.js @@ -33,7 +34,7 @@ testFiles: - pages/network/vpn.spec.js - pages/network/lb.spec.js - pages/network/topology.spec.js - - pages/compute/image.spec.js # need to put an image file in fixtures + - pages/compute/image.spec.js - pages/compute/flavor.spec.js - pages/compute/server-group.spec.js - pages/compute/keypair.spec.js diff --git a/test/e2e/integration/pages/compute/instance.spec.js b/test/e2e/integration/pages/compute/instance.spec.js index 3331f567..99f6192b 100644 --- a/test/e2e/integration/pages/compute/instance.spec.js +++ b/test/e2e/integration/pages/compute/instance.spec.js @@ -25,6 +25,7 @@ describe('The Instance Page', () => { const routerName = `e2e-router-for-instance-${uuid}`; const imageName = Cypress.env('imageName'); const imageType = Cypress.env('imageType'); + const ableChangePwd = Cypress.env('imageCanChangePassword') || false; beforeEach(() => { cy.login(listUrl); @@ -103,9 +104,8 @@ describe('The Instance Page', () => { it('successfully stop', () => { cy.tableSearchText(name) .clickConfirmActionInMoreSub('Stop', 'Instance Status') - .wait(10000) .tableSearchText(name) - .checkColumnValue(6, 'Shutoff') + .waitStatusTextByFresh('Shutoff') .selectFirst() .clickHeaderButtonByTitle('Stop') .checkDisableAction(2000); @@ -124,9 +124,8 @@ describe('The Instance Page', () => { it('successfully suspend', () => { cy.tableSearchText(name) .clickConfirmActionInMoreSub('Suspend', 'Instance Status') - .wait(10000) .tableSearchText(name) - .checkColumnValue(6, 'Suspended'); + .waitStatusTextByFresh('Suspended'); }); it('successfully resume', () => { @@ -138,9 +137,8 @@ describe('The Instance Page', () => { it('successfully pause', () => { cy.tableSearchText(name) .clickConfirmActionInMoreSub('Pause', 'Instance Status') - .wait(10000) .tableSearchText(name) - .checkColumnValue(6, 'Paused'); + .waitStatusTextByFresh('Paused'); }); it('successfully unpause', () => { @@ -152,7 +150,7 @@ describe('The Instance Page', () => { it('successfully shelve', () => { cy.tableSearchText(name) .clickConfirmActionInMoreSub('Shelve', 'Instance Status') - .wait(20000); + .waitStatusTextByFresh('Shelved'); }); it('successfully unshelve', () => { @@ -248,15 +246,10 @@ describe('The Instance Page', () => { .clickModalActionCancelButton(); }); - it('successfully extend root volume', () => { - cy.tableSearchText(name) - .clickActionInMoreSub('Extend Root Volume', 'Configuration Update') - .wait(5000) - .clickModalActionSubmitButton() - .wait(30000); - }); - it('successfully change password', () => { + if (!ableChangePwd) { + return; + } const passowrdNew = `${password}_1`; cy.tableSearchText(name) .clickActionInMoreSub('Change Password', 'Configuration Update') @@ -269,20 +262,22 @@ describe('The Instance Page', () => { cy.tableSearchText(name) .clickActionInMoreSub('Rebuild Instance', 'Configuration Update') .wait(5000) - .formTableSelect('image') + .formRadioChooseByLabel('image', imageType) + .formTableSelectBySearch('image', imageName) .clickModalActionSubmitButton() .waitStatusActiveByRefresh(); }); - it('successfully resize', () => { - cy.tableSearchText(name) - .clickActionInMoreSub('Resize', 'Configuration Update') - .wait(5000) - .formTableSelect('newFlavor') - .formCheckboxClick('option') - .clickModalActionSubmitButton() - .waitStatusActiveByRefresh(); - }); + // todo: need a confirm resize button + // it('successfully resize', () => { + // cy.tableSearchText(name) + // .clickActionInMoreSub('Resize', 'Configuration Update') + // .wait(5000) + // .formTableSelect('newFlavor') + // .formCheckboxClick('option') + // .clickModalActionSubmitButton() + // .waitStatusActiveByRefresh(); + // }); it('successfully edit', () => { cy.tableSearchText(name) @@ -293,7 +288,7 @@ describe('The Instance Page', () => { }); it('successfully delete', () => { - cy.deleteInstance(newname); + cy.forceDeleteInstance(newname); }); it('successfully delete related resources', () => { diff --git a/test/e2e/support/resource-commands.js b/test/e2e/support/resource-commands.js index e20b3a94..db386d56 100644 --- a/test/e2e/support/resource-commands.js +++ b/test/e2e/support/resource-commands.js @@ -118,8 +118,7 @@ Cypress.Commands.add('deleteRouter', (name, networkName) => { Cypress.Commands.add('deleteInstance', (name, deleteRecycleBin = true) => { cy.visitPage(instanceListUrl) .tableSearchText(name) - .clickConfirmActionInMore('Delete') - .checkEmptyTable(); + .clickConfirmActionInMore('Delete'); if (deleteRecycleBin) { cy.visitPage(recycleBinListUrl) diff --git a/test/e2e/support/table-commands.js b/test/e2e/support/table-commands.js index 3fac25d6..e1e28add 100644 --- a/test/e2e/support/table-commands.js +++ b/test/e2e/support/table-commands.js @@ -296,6 +296,37 @@ Cypress.Commands.add('checkColumnValue', (columnIndex, value) => { .should('exist'); }); +Cypress.Commands.add( + 'getStatusValueLength', + (value, hasLengthCallback, noLengthCallback) => { + const eles = Cypress.$('.ant-badge-status-text').filter( + `:contains(${value})` + ); + if (eles.length > 0) { + hasLengthCallback(); + } else { + noLengthCallback(); + cy.getStatusValueLength(value, hasLengthCallback, noLengthCallback); + } + } +); + +Cypress.Commands.add('waitStatusTextByFresh', (text) => { + let index = 0; + const hasLengthCallback = () => { + // eslint-disable-next-line no-console + console.log('contain', index); + }; + const noLengthCallback = () => { + // eslint-disable-next-line no-console + console.log('not contain', index); + cy.freshTable(); + index += 1; + cy.wait(5000); + }; + cy.getStatusValueLength(text, hasLengthCallback, noLengthCallback); +}); + Cypress.Commands.add('selectFirst', () => { cy.get('.ant-table-row') .first()