From 513d2cb526de33ba0b13697dc2c83ed3b85c9705 Mon Sep 17 00:00:00 2001 From: "Jingwei.Zhang" Date: Tue, 28 Sep 2021 15:50:29 +0800 Subject: [PATCH] test: Update e2e case 1. Add setting case 2. Update ironic case: repaire flavor by ironic create 3. Update flavor case: remove given name by custom flavor 4. Update virutal adapater case: assocate fip in detail page Change-Id: If5c23b6c69bf4fd19506d3b68e69a4a8ae0ac056 --- test/e2e/config/config.yaml | 1 + test/e2e/fixtures/flavor-family.json | 66 +++++++++++++++++++ .../integration/pages/compute/flavor.spec.js | 4 -- .../integration/pages/compute/ironic.spec.js | 6 ++ .../pages/configuration/setting.spec.js | 54 +++++++++++++++ .../pages/network/virtual-adapter.spec.js | 3 +- test/e2e/support/constants.js | 2 + test/e2e/support/detail-commands.js | 12 ++++ test/e2e/support/form-commands.js | 5 +- test/e2e/support/resource-commands.js | 24 +++++++ 10 files changed, 170 insertions(+), 7 deletions(-) create mode 100644 test/e2e/fixtures/flavor-family.json create mode 100644 test/e2e/integration/pages/configuration/setting.spec.js diff --git a/test/e2e/config/config.yaml b/test/e2e/config/config.yaml index ca373e9a..8f3a45c2 100644 --- a/test/e2e/config/config.yaml +++ b/test/e2e/config/config.yaml @@ -45,5 +45,6 @@ testFiles: # - pages/management/recycle-bin.spec.js - pages/configuration/metadata.spec.js - pages/configuration/system.spec.js + - pages/configuration/setting.spec.js - pages/heat/stack.spec.js diff --git a/test/e2e/fixtures/flavor-family.json b/test/e2e/fixtures/flavor-family.json new file mode 100644 index 00000000..e9fb1d06 --- /dev/null +++ b/test/e2e/fixtures/flavor-family.json @@ -0,0 +1,66 @@ +[ + { + "architecture": "x86_architecture", + "categories": [ + { + "name": "general_purpose", + "properties": [] + }, + { + "name": "compute_optimized", + "properties": [] + }, + { + "name": "memory_optimized", + "properties": [] + }, + { + "name": "high_clock_speed", + "properties": [] + } + ] + }, + { + "architecture": "heterogeneous_computing", + "categories": [ + { + "name": "compute_optimized_type_with_gpu", + "properties": [] + }, + { + "name": "visualization_compute_optimized_type_with_gpu", + "properties": [] + } + ] + }, + { + "architecture": "bare_metal", + "categories": [ + { + "name": "general_purpose", + "properties": [] + } + ] + }, + { + "architecture": "arm_architecture", + "categories": [ + { + "name": "general_purpose", + "properties": [] + }, + { + "name": "compute_optimized", + "properties": [] + }, + { + "name": "memory_optimized", + "properties": [] + }, + { + "name": "high_clock_speed", + "properties": [] + } + ] + } +] diff --git a/test/e2e/integration/pages/compute/flavor.spec.js b/test/e2e/integration/pages/compute/flavor.spec.js index 3da0f462..e702f4a8 100644 --- a/test/e2e/integration/pages/compute/flavor.spec.js +++ b/test/e2e/integration/pages/compute/flavor.spec.js @@ -17,7 +17,6 @@ import { flavorListUrl } from '../../../support/constants'; describe('The Flavor Page', () => { const listUrl = flavorListUrl; const name = `e2e-flavor-${Cypress._.random(0, 1e6)}`; - const customName = '1C.1G'; beforeEach(() => { cy.loginAdmin(listUrl); @@ -51,7 +50,6 @@ describe('The Flavor Page', () => { .checkDetailName(name) .clickDetailTab('Instance', 'members'); cy.goBackToList(listUrl); - cy.clickTab('Custom').goToDetail().clickDetailTab('Instance', 'members'); }); it('successfully manage access', () => { @@ -64,7 +62,6 @@ describe('The Flavor Page', () => { it('successfully manage metadata', () => { cy.clickTab('Custom') - .tableSearchText(customName) .clickActionButtonByTitle('Manage Metadata') .wait(5000) .formTransferLeftCheck('systems', 0) @@ -72,7 +69,6 @@ describe('The Flavor Page', () => { // todo: remove key-value metadata cy.clickTab('Custom') - .tableSearchText(customName) .clickActionButtonByTitle('Manage Metadata') .wait(5000) .formTransferRightCheck('systems', 0) diff --git a/test/e2e/integration/pages/compute/ironic.spec.js b/test/e2e/integration/pages/compute/ironic.spec.js index 1d51c97a..6c1a23aa 100644 --- a/test/e2e/integration/pages/compute/ironic.spec.js +++ b/test/e2e/integration/pages/compute/ironic.spec.js @@ -20,6 +20,7 @@ describe('The Ironic Page', () => { const name = `e2e-ironic-${uuid}`; const newname = `${name}-1`; const password = 'passW0rd_1'; + const flavorName = `e2e-flavor-for-ironic-${uuid}`; const networkName = `e2e-network-for-ironic-${uuid}`; const routerName = `e2e-router-for-ironic-${uuid}`; const imageName = Cypress.env('imageName'); @@ -29,6 +30,10 @@ describe('The Ironic Page', () => { cy.login(listUrl); }); + it('successfully prepair resource by admin', () => { + cy.loginAdmin().createIronicFlavor(flavorName); + }); + it('successfully prepair resource', () => { cy.createNetwork({ name: networkName }); cy.createRouter({ name: routerName, network: networkName }); @@ -179,5 +184,6 @@ describe('The Ironic Page', () => { cy.deleteAll('fip'); cy.deleteRouter(routerName, networkName); cy.deleteAll('network', networkName); + cy.loginAdmin().deleteAll('flavor', flavorName, 'Bare Metal'); }); }); diff --git a/test/e2e/integration/pages/configuration/setting.spec.js b/test/e2e/integration/pages/configuration/setting.spec.js new file mode 100644 index 00000000..04e764aa --- /dev/null +++ b/test/e2e/integration/pages/configuration/setting.spec.js @@ -0,0 +1,54 @@ +// Copyright 2021 99cloud +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import { settingUrl, flavorListUrl } from '../../../support/constants'; + +describe('The Setting Page', () => { + const listUrl = settingUrl; + const name = 'flavor_families'; + const filename = 'flavor-family.json'; + + beforeEach(() => { + cy.loginAdmin(listUrl); + }); + + it('successfully view', () => { + cy.tableSimpleSearchText(name) + .clickFirstActionButton() + .clickConfirmButtonInModal(); + }); + + it('successfully edit', () => { + cy.fixture(filename).then((data) => { + cy.tableSimpleSearchText(name) + .clickActionInMore('Edit') + .formJsonInput('value', data) + .wait(2000) + .clickModalActionSubmitButton(); + + cy.visitPage(flavorListUrl) + .clickTab('Custom', 'custom') + .clickTab('Heterogeneous Computing', 'heterogeneous_computing') + .clickTab('ARM Architecture', 'arm_architecture') + .clickTab('X86 Architecture', 'x86_architecture') + .clickTab('Bare Metal', 'bare_metal'); + }); + }); + + it('successfully reset', () => { + cy.tableSimpleSearchText(name).clickConfirmActionInMore( + 'Reset To Initial Value' + ); + }); +}); diff --git a/test/e2e/integration/pages/network/virtual-adapter.spec.js b/test/e2e/integration/pages/network/virtual-adapter.spec.js index e0755a7a..77b1a990 100644 --- a/test/e2e/integration/pages/network/virtual-adapter.spec.js +++ b/test/e2e/integration/pages/network/virtual-adapter.spec.js @@ -86,7 +86,8 @@ describe('The Virtual Adapter Page', () => { it('successfully associate floating IP', () => { cy.tableSearchText(name) - .clickActionInMore('Associate Floating IP') + .goToDetail() + .clickDetailActionInMore('Associate Floating IP') .wait(5000) .formTableSelect('fixed_ip') .wait(5000) diff --git a/test/e2e/support/constants.js b/test/e2e/support/constants.js index 4983fe97..25426135 100644 --- a/test/e2e/support/constants.js +++ b/test/e2e/support/constants.js @@ -55,6 +55,7 @@ export const domainListUrl = '/identity/domain-admin'; // configuration export const metadataListUrl = '/configuration-admin/metadata'; export const infoListUrl = '/configuration-admin/info'; +export const settingUrl = '/configuration-admin/setting'; // stack export const stackListUrl = '/heat/stack'; @@ -63,6 +64,7 @@ export default { // compute instance: instanceListUrl, image: imageListUrl, + flavor: flavorListUrl, // storage volume: volumeListUrl, diff --git a/test/e2e/support/detail-commands.js b/test/e2e/support/detail-commands.js index fdd566a0..dda72154 100644 --- a/test/e2e/support/detail-commands.js +++ b/test/e2e/support/detail-commands.js @@ -34,3 +34,15 @@ Cypress.Commands.add('clickDetailTab', (label, urlTab, waitTime = 2000) => { } cy.waitTableLoading(); }); + +Cypress.Commands.add('clickDetailActionInMore', (title, waitTime = 2000) => { + cy.get('.detail-main') + .first() + .find('.ant-dropdown-trigger') + .trigger('mouseover'); + const realTitle = getTitle(title); + cy.get('ul.ant-dropdown-menu-light') + .contains(realTitle) + .click({ force: true }) + .wait(waitTime); +}); diff --git a/test/e2e/support/form-commands.js b/test/e2e/support/form-commands.js index 8ba1dca9..cc3a086f 100644 --- a/test/e2e/support/form-commands.js +++ b/test/e2e/support/form-commands.js @@ -137,11 +137,12 @@ Cypress.Commands.add('formText', (formItemName, value) => { }); Cypress.Commands.add('formJsonInput', (formItemName, content) => { - const value = JSON.stringify(content).replace('{', '{{}'); + const value = JSON.stringify(content); cy.get(getId(formItemName)) .find('textarea') .clear({ force: true }) - .type(value, { force: true }); + .wait(1000) + .type(value, { force: true, parseSpecialCharSequences: false }); }); Cypress.Commands.add('formInputName', (formItemName, typeName) => { diff --git a/test/e2e/support/resource-commands.js b/test/e2e/support/resource-commands.js index 879b26bb..e20b3a94 100644 --- a/test/e2e/support/resource-commands.js +++ b/test/e2e/support/resource-commands.js @@ -25,6 +25,8 @@ import urlMap, { fipListUrl, imageListUrl, projectListUrl, + settingUrl, + flavorListUrl, } from './constants'; Cypress.Commands.add('createInstance', ({ name, networkName }) => { @@ -229,6 +231,28 @@ Cypress.Commands.add('createProject', ({ name }) => { .clickModalActionSubmitButton(); }); +Cypress.Commands.add('createIronicFlavor', (name) => { + const filename = 'flavor-family.json'; + const settingName = 'flavor_families'; + cy.fixture(filename).then((data) => { + cy.visitPage(settingUrl) + .tableSimpleSearchText(settingName) + .clickActionInMore('Edit') + .formJsonInput('value', data) + .wait(2000) + .clickModalActionSubmitButton(); + + cy.visitPage(flavorListUrl) + .clickTab('Bare Metal', 'bare_metal') + .clickHeaderButton(1) + .formRadioChoose('category', 0) + .formInput('name', name) + .clickStepActionNextButton() + .wait(2000) + .clickStepActionNextButton(); + }); +}); + Cypress.Commands.add('createIronicImage', ({ name }) => { const filename = 'cirros-0.4.0-x86_64-disk.qcow2'; cy.visitPage(imageListUrl)