diff --git a/tests/cypress/1.0.0/cypress.config.ts b/tests/cypress/1.0.0/cypress.config.ts deleted file mode 100644 index 3d4fad189..000000000 --- a/tests/cypress/1.0.0/cypress.config.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { defineConfig } from 'cypress' - -export default defineConfig({ - defaultCommandTimeout: 10000, - e2e: { - // We've imported your old cypress plugins here. - // You may want to clean this up later by importing these. - setupNodeEvents(on, config) { - return require('./plugins/index.ts')(on, config) - }, - experimentalSessionAndOrigin: true, - supportFile: './support/e2e.ts', - fixturesFolder: './fixtures', - screenshotsFolder: './screenshots', - videosFolder :'./videos', - downloadsFolder :'./downloads', - specPattern: - 'e2e/unit_tests/*.spec.ts', - }, -}) diff --git a/tests/cypress/1.0.0/e2e/unit_tests/advanced_filtering.spec.ts b/tests/cypress/1.0.0/e2e/unit_tests/advanced_filtering.spec.ts deleted file mode 100644 index 5ea81805b..000000000 --- a/tests/cypress/1.0.0/e2e/unit_tests/advanced_filtering.spec.ts +++ /dev/null @@ -1,85 +0,0 @@ -/* -Copyright © 2022 - 2023 SUSE LLC - -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 { TopLevelMenu } from '~/support/toplevelmenu'; -import { Elemental } from '~/support/elemental'; -import '~/support/functions'; -import filterTests from '~/support/filterTests.js'; - -filterTests(['main'], () => { - Cypress.config(); - describe('Advanced filtering testing', () => { - const elemental = new Elemental(); - const elementalUser = "elemental-user" - const uiAccount = Cypress.env('ui_account'); - const uiPassword = "rancherpassword" - const topLevelMenu = new TopLevelMenu(); - - beforeEach(() => { - (uiAccount == "user") ? cy.login(elementalUser, uiPassword) : cy.login(); - cy.visit('/'); - - // Open the navigation menu - topLevelMenu.openIfClosed(); - - // Click on the Elemental's icon - elemental.accessElementalMenu(); - }); - - it('Create fake machine inventories', () => { - // TODO: Use loop? - cy.importMachineInventory({machineInventoryFile: 'machine_inventory_1.yaml', - machineInventoryName: 'test-filter-one'}); - cy.importMachineInventory({machineInventoryFile: 'machine_inventory_2.yaml', - machineInventoryName: 'test-filter-two'}); - cy.importMachineInventory({machineInventoryFile: 'machine_inventory_3.yaml', - machineInventoryName: 'shouldnotmatch'}); - }); - - it('Two machine inventories should appear by filtering on test-filter', () => { - // Only test-filter-one and test-filter-two should appear with test-filter as filter - cy.checkFilter({filterName: 'test-filter', - testFilterOne: true, - testFilterTwo: true, - shouldNotMatch: false}); - }); - - it('One machine inventory should appear by filtering on test-filter-one', () => { - // Only test-filter-one should appear with test-filter-one as filter - cy.checkFilter({filterName: 'test-filter-one', - testFilterOne: true, - testFilterTwo: false, - shouldNotMatch: false}); - }); - - it('No machine inventory should appear by filtering on test-bad-filter', () => { - // This test will also serve as no regression test for https://github.com/rancher/elemental-ui/issues/41 - cy.checkFilter({filterName: 'test-bad-filter', - testFilterOne: false, - testFilterTwo: false, - shouldNotMatch: false}); - cy.contains('There are no rows which match your search query.') - }); - - it('Delete all fake machine inventories', () => { - cy.clickNavMenu(["Inventory of Machines"]); - cy.get('[width="30"] > .checkbox-outer-container > .checkbox-container > .checkbox-custom') - .click(); - cy.clickButton('Actions'); - cy.get('.tooltip-inner > :nth-child(1) > .list-unstyled > :nth-child(3)') - .click(); - cy.confirmDelete(); - }); - }); -}); diff --git a/tests/cypress/1.0.0/e2e/unit_tests/deploy_app.spec.ts b/tests/cypress/1.0.0/e2e/unit_tests/deploy_app.spec.ts deleted file mode 100644 index 747eb2750..000000000 --- a/tests/cypress/1.0.0/e2e/unit_tests/deploy_app.spec.ts +++ /dev/null @@ -1,73 +0,0 @@ -/* -Copyright © 2022 - 2023 SUSE LLC - -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 { TopLevelMenu } from '~/support/toplevelmenu'; -import '~/support/functions'; -import filterTests from '~/support/filterTests.js'; - -filterTests(['main'], () => { - Cypress.config(); - describe('Deploy application in fresh Elemental Cluster', () => { - const topLevelMenu = new TopLevelMenu(); - const clusterName = "mycluster" - beforeEach(() => { - cy.login(); - cy.visit('/'); - }); - - it('Deploy CIS Benchmark application', () => { - topLevelMenu.openIfClosed(); - cy.contains(clusterName) - .click(); - cy.contains('Apps') - .click(); - cy.contains('Charts') - .click(); - cy.contains('CIS Benchmark') - .click(); - cy.contains('.name-logo-install', 'CIS Benchmark', {timeout:20000}); - cy.clickButton('Install'); - cy.clickButton('Next'); - cy.clickButton('Install'); - cy.contains('SUCCESS: helm upgrade', {timeout:30000}); - cy.reload; - cy.contains('CIS Benchmark'); - }); - - it('Remove CIS Benchmark application', () => { - topLevelMenu.openIfClosed(); - cy.contains(clusterName) - .click(); - cy.contains('Apps') - .click(); - cy.contains('Installed Apps') - .click(); - cy.contains('.title', 'Installed Apps', {timeout:20000}); - cy.get('.ns-dropdown > .icon') - .click() - .type('cis-operator'); - cy.contains('cis-operator') - .click(); - cy.get('.ns-dropdown > .icon-chevron-up') - .click(); - cy.get('[width="30"] > .checkbox-outer-container') - .click(); - cy.clickButton('Delete'); - cy.confirmDelete(); - cy.contains('SUCCESS: helm uninstall', {timeout:30000}); - cy.contains('.apps', 'CIS Benchmark') - .should('not.exist'); - }); - }); -}); diff --git a/tests/cypress/1.0.0/e2e/unit_tests/elemental_plugin.spec.ts b/tests/cypress/1.0.0/e2e/unit_tests/elemental_plugin.spec.ts deleted file mode 100644 index 51c4ff971..000000000 --- a/tests/cypress/1.0.0/e2e/unit_tests/elemental_plugin.spec.ts +++ /dev/null @@ -1,77 +0,0 @@ -/* -Copyright © 2022 - 2023 SUSE LLC - -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 { TopLevelMenu } from '~/support/toplevelmenu'; -import '~/support/functions'; -import filterTests from '~/support/filterTests.js'; - -filterTests(['main', 'upgrade'], () => { - Cypress.config(); - describe('Install Elemental plugin', () => { - const elemental_ui_version = Cypress.env('elemental_ui_version'); - const topLevelMenu = new TopLevelMenu(); - - beforeEach(() => { - cy.login(); - cy.visit('/'); - }); - - it('Add elemental-ui repo', () => { - topLevelMenu.openIfClosed(); - cy.contains('local') - .click(); - cy.addHelmRepo({repoName: 'elemental-ui', - repoUrl: 'https://github.com/rancher/elemental-ui.git', - repoType: 'git'}); - }); - - it('Enable extension support', () => { - topLevelMenu.openIfClosed(); - cy.contains('Extensions') - .click(); - cy.clickButton('Enable'); - cy.contains('Enable Extension Support?') - cy.contains('Add the Rancher Extension Repository') - .click(); - cy.clickButton('OK'); - cy.get('.tabs', {timeout: 40000}) - .contains('Installed Available Updates All'); - }); - - it('Install Elemental plugin', () => { - topLevelMenu.openIfClosed(); - cy.contains('Extensions') - .click(); - cy.contains('elemental'); - cy.get('.plugin') - .contains('Install') - .click(); - cy.contains('Install Extension elemental'); - if (elemental_ui_version != 'latest') { - cy.get('.labeled-select') - .click(); - cy.contains(elemental_ui_version) - .click(); - } - cy.clickButton('Install'); - cy.contains('Installing'); - cy.contains('Extensions changed - reload required', {timeout: 40000}); - cy.clickButton('Reload'); - cy.get('.plugins') - .children() - .should('contain', 'elemental') - .and('contain', 'Uninstall'); - }); - }); -}); diff --git a/tests/cypress/1.0.0/e2e/unit_tests/first_connection.spec.ts b/tests/cypress/1.0.0/e2e/unit_tests/first_connection.spec.ts deleted file mode 100644 index 5c1b8b905..000000000 --- a/tests/cypress/1.0.0/e2e/unit_tests/first_connection.spec.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* -Copyright © 2022 - 2023 SUSE LLC - -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 { Elemental } from '~/support/elemental'; -import filterTests from '~/support/filterTests.js'; - -filterTests(['main', 'upgrade'], () => { - Cypress.config(); - describe('First login on Rancher', () => { - const elemental = new Elemental(); - - it('Log in and accept terms and conditions', () => { - cy.visit('/auth/login'); - cy.get("span").then($text => { - if ($text.text().includes('your first time visiting Rancher')) { - elemental.firstLogin(); - } - else { - cy.log('Rancher already initialized, no need to handle first login.') - } - }) - }); - }); -}) diff --git a/tests/cypress/1.0.0/e2e/unit_tests/machine_inventory.spec.ts b/tests/cypress/1.0.0/e2e/unit_tests/machine_inventory.spec.ts deleted file mode 100644 index 2658961b5..000000000 --- a/tests/cypress/1.0.0/e2e/unit_tests/machine_inventory.spec.ts +++ /dev/null @@ -1,135 +0,0 @@ -/* -Copyright © 2022 - 2023 SUSE LLC - -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 { TopLevelMenu } from '~/support/toplevelmenu'; -import { Elemental } from '~/support/elemental'; -import '~/support/functions'; -import filterTests from '~/support/filterTests.js'; - -Cypress.config(); -describe('Machine inventory testing', () => { - const elemental = new Elemental(); - const elementalUser = "elemental-user" - const hwLabels = ["TotalCPUThread", "TotalMemory", "CPUModel", - "CPUVendor", "NumberBlockDevices", "NumberNetInterface", - "CPUVendorTotalCPUCores"] - const k8sVersion = Cypress.env('k8s_version'); - const clusterName = "mycluster" - const proxy = "http://172.17.0.1:3128" - const topLevelMenu = new TopLevelMenu(); - const uiAccount = Cypress.env('ui_account'); - const uiPassword = "rancherpassword" - - beforeEach(() => { - (uiAccount == "user") ? cy.login(elementalUser, uiPassword) : cy.login(); - cy.visit('/'); - - // Open the navigation menu - topLevelMenu.openIfClosed(); - - // Click on the Elemental's icon - elemental.accessElementalMenu(); - }); - - filterTests(['main'], () => { - it('Check that machine inventory has been created', () => { - cy.clickNavMenu(["Inventory of Machines"]); - cy.contains('.badge-state', 'Active') - .should('exist'); - cy.contains('.sortable-table', 'my-machine') - .should('exist'); - cy.contains('Namespace: fleet-default') - .should('exist'); - }); - - it('Check we can see our embedded hardware labels', () => { - cy.clickNavMenu(["Inventory of Machines"]); - cy.contains('my-machine') - .click() - cy.checkMachInvLabel({machRegName: 'machine-registration', - labelName: 'myInvLabel1', - labelValue: 'myInvLabelValue1', - afterBoot: true}); - for (var hwLabel in hwLabels) { - cy.clickNavMenu(["Inventory of Machines"]); - cy.get('.table-options-group > .btn > .icon') - .click() - .parent() - .parent() - .contains(hwLabels[hwLabel]) - .click({force: true}) - cy.contains(hwLabels[hwLabel]); - } - }); - }); - - filterTests(['main', 'upgrade'], () => { - it('Create Elemental cluster', () => { - cy.contains('Create Elemental Cluster') - .click(); - cy.typeValue({label: 'Cluster Name', value: clusterName}); - cy.typeValue({label: 'Cluster Description', value: 'My Elemental testing cluster'}); - cy.contains('Show deprecated Kubernetes') - .click(); - cy.contains('Kubernetes Version') - .click(); - cy.contains(k8sVersion) - .click(); - // Configure proxy if proxy is set to elemental - if ( Cypress.env('proxy') == "elemental") { - cy.contains('Agent Environment Vars') - .click(); - cy.get('#agentEnv > .key-value') - .contains('Add') - .click(); - cy.get('.key > input') - .type('HTTP_PROXY'); - cy.get('.no-resize') - .type(proxy); - cy.get('#agentEnv > .key-value') - .contains('Add') - .click(); - cy.get(':nth-child(7) > input') - .type('HTTPS_PROXY'); - cy.get(':nth-child(8) > .no-resize') - .type(proxy); - cy.get('#agentEnv > .key-value') - .contains('Add') - .click(); - cy.get(':nth-child(10) > input') - .type('NO_PROXY'); - cy.get(':nth-child(11) > .no-resize') - .type('localhost,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,.svc,.cluster.local'); - } - cy.clickButton('Create'); - cy.contains('Updating ' + clusterName, {timeout: 120000}); - cy.contains('Active ' + clusterName, {timeout: 360000}); - }); - }); - - filterTests(['main', 'upgrade'], () => { - it('Check Elemental cluster status', () => { - topLevelMenu.openIfClosed(); - cy.contains('Home') - .click(); - // The new cluster must be in active state - cy.get('[data-node-id="fleet-default/'+clusterName+'"]') - .contains('Active'); - // Go into the dedicated cluster page - topLevelMenu.openIfClosed(); - cy.contains(clusterName) - .click(); - }) - }); -}); diff --git a/tests/cypress/1.0.0/e2e/unit_tests/machine_registration.spec.ts b/tests/cypress/1.0.0/e2e/unit_tests/machine_registration.spec.ts deleted file mode 100644 index 946b98a6e..000000000 --- a/tests/cypress/1.0.0/e2e/unit_tests/machine_registration.spec.ts +++ /dev/null @@ -1,155 +0,0 @@ -/* -Copyright © 2022 - 2023 SUSE LLC - -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 { TopLevelMenu } from '~/support/toplevelmenu'; -import { Elemental } from '~/support/elemental'; -import '~/support/functions'; -import filterTests from '~/support/filterTests.js'; - -Cypress.config(); -describe('Machine registration testing', () => { - const elemental = new Elemental(); - const elementalUser = "elemental-user" - const topLevelMenu = new TopLevelMenu(); - const uiAccount = Cypress.env('ui_account'); - const uiPassword = "rancherpassword" - - beforeEach(() => { - (uiAccount == "user") ? cy.login(elementalUser, uiPassword) : cy.login(); - cy.visit('/'); - - // Open the navigation menu - topLevelMenu.openIfClosed(); - - // Click on the Elemental's icon - elemental.accessElementalMenu(); - - // Delete all files previously downloaded - cy.exec('rm cypress/downloads/*', {failOnNonZeroExit: false}); - - // Delete all existing machine registrations - cy.contains('Manage Registration Endpoints') - .click(); - cy.get('.outlet > header').contains('Registration Endpoints'); - cy.get('body').then(($body) => { - if (!$body.text().includes('There are no rows to show.')) { - cy.deleteAllResources(); - }; - }); - }); - - filterTests(['main'], () => { - it('Create machine registration with default options', () => { - cy.createMachReg({machRegName: 'default-options-test'}); - }); - - it('Create machine registration with labels and annotations', () => { - cy.createMachReg({machRegName: 'labels-annotations-test', - checkLabels: true, - checkAnnotations: true}); - }); - - it('Delete machine registration', () => { - cy.createMachReg({machRegName: 'delete-test'}); - cy.deleteMachReg({machRegName: 'delete-test'}); - }); - - it('Edit a machine registration with edit config button', () => { - cy.createMachReg({machRegName: 'edit-config-test'}); - cy.editMachReg({machRegName: 'edit-config-test', - addLabel: true, - addAnnotation: true }); - cy.clickButton('Save'); - - // Check that we can see our label and annotation in the YAML - cy.checkMachRegLabel({machRegName: 'edit-config-test', - labelName: 'myLabel1', - labelValue: 'myLabelValue1'}); - cy.checkMachRegAnnotation({machRegName: 'edit-config-test', - annotationName: 'myAnnotation1', - annotationValue: 'myAnnotationValue1'}); - }); - - it('Edit a machine registration with edit YAML button', () => { - cy.createMachReg({machRegName: 'edit-yaml-test'}); - cy.editMachReg({machRegName: 'edit-yaml-test', - addLabel: true, - addAnnotation: true, - withYAML: true }); - cy.clickButton('Save'); - - // Check that we can see our label and annotation in the YAML - cy.checkMachRegLabel({machRegName: 'edit-yaml-test', - labelName: 'myLabel1', - labelValue: 'myLabelValue1'}); - cy.checkMachRegAnnotation({machRegName: 'edit-yaml-test', - annotationName: 'myAnnotation1', - annotationValue: 'myAnnotationValue1'}); - }); - - it('Clone a machine registration', () => { - cy.createMachReg({machRegName: 'clone-test', - checkLabels: true, - checkAnnotations: true}); - cy.contains('clone-test') - .click(); - cy.get('div.actions > .role-multi-action') - .click() - cy.contains('li', 'Clone') - .click(); - cy.typeValue({label: 'Name', value: 'cloned-machine-reg'}); - cy.clickButton('Create'); - cy.contains('.masthead', 'Registration Endpoint: cloned-machine-regActive') - .should('exist'); - - // Check that we got the same label and annotation in both machine registration - cy.checkMachRegLabel({machRegName: 'cloned-machine-reg', - labelName: 'myLabel1', - labelValue: 'myLabelValue1'}); - cy.contains('cloned-machine-reg') - .click(); - cy.checkMachRegAnnotation({machRegName: 'cloned-machine-reg', - annotationName: 'myAnnotation1', - annotationValue: 'myAnnotationValue1'}); - cy.contains('cloned-machine-reg') - .click(); - }); - - it('Download Machine registration YAML', () => { - cy.createMachReg({machRegName: 'download-yaml-test'}); - cy.contains('download-yaml-test') - .click(); - cy.get('div.actions > .role-multi-action') - .click() - cy.contains('li', 'Download YAML') - .click(); - cy.verifyDownload('download-yaml-test.yaml'); - }); - }); - - // This test must stay the last one because we use this machine registration when we test adding a node. - // It also tests using a custom cloud config by using read from file button. - filterTests(['main', 'upgrade'], () => { - it('Create Machine registration we will use to test adding a node', () => { - cy.createMachReg({machRegName: 'machine-registration', - checkInventoryLabels: true, - checkInventoryAnnotations: true, - customCloudConfig: 'custom_cloud-config.yaml', - checkDefaultCloudConfig: false}); - cy.checkMachInvLabel({machRegName: 'machine-registration', - labelName: 'myInvLabel1', - labelValue: 'myInvLabelValue1'}); - }); - }); -}); diff --git a/tests/cypress/1.0.0/e2e/unit_tests/machine_selector.spec.ts b/tests/cypress/1.0.0/e2e/unit_tests/machine_selector.spec.ts deleted file mode 100644 index 884c71df6..000000000 --- a/tests/cypress/1.0.0/e2e/unit_tests/machine_selector.spec.ts +++ /dev/null @@ -1,79 +0,0 @@ -/* -Copyright © 2022 - 2023 SUSE LLC - -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 { TopLevelMenu } from '~/support/toplevelmenu'; -import { Elemental } from '~/support/elemental'; -import '~/support/functions'; -import filterTests from '~/support/filterTests.js'; - -filterTests(['main'], () => { - Cypress.config(); - describe('Machine selector testing', () => { - const elemental = new Elemental(); - const elementalUser = "elemental-user" - const k8sVersion = Cypress.env('k8s_version'); - const topLevelMenu = new TopLevelMenu(); - const uiAccount = Cypress.env('ui_account'); - const uiPassword = "rancherpassword" - - beforeEach(() => { - (uiAccount == "user") ? cy.login(elementalUser, uiPassword) : cy.login(); - cy.visit('/'); - - // Open the navigation menu - topLevelMenu.openIfClosed(); - - // Click on the Elemental's icon - elemental.accessElementalMenu(); - - // Go to the cluster creation page - elemental.accessClusterMenu(); - }); - - it('Testing selector without any rule', () => { - cy.contains('.banner', 'Matches all 1 existing Inventory of Machines') - .should('exist'); - }); - - it('Testing selector with unmatching rule', () => { - //cy.clickButton('Add Rule'); - // TODO: Cannot use the clickButton here, I do not know why yet - cy.get('[cluster="[provisioning.cattle.io.cluster: undefined]"]') - .contains('Add Rule') - .click(); - cy.get('[data-testid="input-match-expression-values-0"] > input') - .click() - .type('wrong'); - cy.contains('.banner', 'Matches no existing Inventory of Machines') - .should('exist'); - }); - - it('Testing selector with matching rule', () => { - //cy.clickButton('Add Rule'); - // TODO: Cannot use the clickButton here, I do not know why yet - cy.get('[cluster="[provisioning.cattle.io.cluster: undefined]"]') - .contains('Add Rule') - .click(); - cy.get('#vs6__combobox') - .click() - cy.contains('myInvLabel1') - .click(); - cy.get('[data-testid="input-match-expression-values-0"] > input') - .click() - .type('myInvLabelValue1'); - cy.contains('.banner', 'Matches all 1 existing Inventory of Machines') - .should('exist'); - }); - }); -}); diff --git a/tests/cypress/1.0.0/e2e/unit_tests/menu.spec.ts b/tests/cypress/1.0.0/e2e/unit_tests/menu.spec.ts deleted file mode 100644 index 9da0876d4..000000000 --- a/tests/cypress/1.0.0/e2e/unit_tests/menu.spec.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* -Copyright © 2022 - 2023 SUSE LLC - -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 { TopLevelMenu } from '~/support/toplevelmenu'; -import { Elemental } from '~/support/elemental'; -import '~/support/functions'; -import filterTests from '~/support/filterTests.js'; - -filterTests(['main'], () => { - Cypress.config(); - describe('Menu testing', () => { - const elemental = new Elemental(); - const elementalUser = "elemental-user" - const topLevelMenu = new TopLevelMenu(); - const uiAccount = Cypress.env('ui_account'); - const uiPassword = "rancherpassword" - - beforeEach(() => { - (uiAccount == "user") ? cy.login(elementalUser, uiPassword) : cy.login(); - cy.visit('/'); - }); - - it('Check Elemental logo', () => { - topLevelMenu.openIfClosed(); - - // Elemental's icon should appear in the side menu - elemental.elementalIcon().should('exist'); - }); - - it('Check Elemental menu', () => { - topLevelMenu.openIfClosed(); - - // Elemental's icon should appear in the side menu - elemental.elementalIcon().should('exist'); - - // Click on the Elemental's icon - elemental.accessElementalMenu(); - - // Check Elemental's side menu - elemental.checkElementalNav(); - }); - }); -}); diff --git a/tests/cypress/1.0.0/e2e/unit_tests/upgrade.spec.ts b/tests/cypress/1.0.0/e2e/unit_tests/upgrade.spec.ts deleted file mode 100644 index 83e4bcec6..000000000 --- a/tests/cypress/1.0.0/e2e/unit_tests/upgrade.spec.ts +++ /dev/null @@ -1,107 +0,0 @@ -/* -Copyright © 2022 - 2023 SUSE LLC -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 { TopLevelMenu } from '~/support/toplevelmenu'; -import '~/support/functions'; -import { Elemental } from '~/support/elemental'; -import 'cypress-file-upload'; -import filterTests from '~/support/filterTests.js'; - - -Cypress.config(); -describe('Upgrade tests', () => { - const channelName = "mychannel" - const clusterName = "mycluster" - const checkK3s: RegExp = /k3s/ - const elemental = new Elemental(); - const elementalUIVersion = Cypress.env('elemental_ui_version') - const elementalUser = "elemental-user" - const k8sVersion = Cypress.env('k8s_version') - const topLevelMenu = new TopLevelMenu(); - const uiAccount = Cypress.env('ui_account'); - const uiPassword = "rancherpassword" - const upgradeChannelList = Cypress.env('upgrade_channel_list') - const upgradeImage = Cypress.env('upgrade_image') - - beforeEach(() => { - (uiAccount == "user") ? cy.login(elementalUser, uiPassword) : cy.login(); - cy.visit('/'); - - // Open the navigation menu - topLevelMenu.openIfClosed(); - - // Click on the Elemental's icon - elemental.accessElementalMenu(); - }); - filterTests(['upgrade'], () => { - it('Upgrade one node (different methods if rke2 or k3s)', () => { - // K3s cluster upgraded with OS Image - // RKE2 cluster upgraded with OS version channel - cy.get('.nav') - .contains('Advanced') - .click(); - cy.get('.nav') - .contains('Update Groups') - .click(); - cy.clickButton('Create'); - cy.get('.primaryheader') - .contains('Update Group: Create'); - cy.typeValue({label: 'Name', value: 'upgrade'}); - cy.contains('Target Cluster') - .click(); - cy.contains(clusterName) - .click(); - cy.typeValue({label: 'OS Image', value: upgradeImage}); - cy.clickButton('Create'); - // Status changes a lot right after the creation so let's wait 10 secondes - // before checking - cy.wait(10000); - cy.get('[data-testid="sortable-cell-0-0"]') - .contains('Active'); - - // Workaround to avoid sporadic issue with Upgrade - // https://github.com/rancher/elemental/issues/410 - // Restart fleet agent inside downstream cluster - topLevelMenu.openIfClosed(); - cy.contains(clusterName) - .click(); - cy.contains('Workload') - .click(); - cy.contains('Pods') - .click(); - cy.get('.header-buttons > :nth-child(2)') - .click(); - cy.wait(20000); - cy.get('.shell-body') - .type('kubectl scale deployment/fleet-agent -n cattle-fleet-system --replicas=0{enter}'); - cy.get('.shell-body') - .type('kubectl scale deployment/fleet-agent -n cattle-fleet-system --replicas=1{enter}'); - - // Check if the node reboots to apply the upgrade - topLevelMenu.openIfClosed(); - elemental.accessElementalMenu(); - cy.clickNavMenu(["Dashboard"]); - cy.clickButton('Manage Elemental Clusters'); - cy.get('.title') - .contains('Clusters'); - cy.contains(clusterName) - .click(); - cy.get('.primaryheader') - .contains('Active'); - cy.get('.primaryheader') - .contains('Updating', {timeout: 240000}); - cy.get('.primaryheader') - .contains('Active', {timeout: 240000}); - }); - }); -}); diff --git a/tests/cypress/1.0.0/e2e/unit_tests/user.spec.ts b/tests/cypress/1.0.0/e2e/unit_tests/user.spec.ts deleted file mode 100644 index c5e590514..000000000 --- a/tests/cypress/1.0.0/e2e/unit_tests/user.spec.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -Copyright © 2022 - 2023 SUSE LLC - -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 { TopLevelMenu } from '~/support/toplevelmenu'; -import { Elemental } from '~/support/elemental'; -import '~/support/functions'; -import filterTests from '~/support/filterTests.js'; - -Cypress.config(); -describe('User role testing', () => { - const elemental = new Elemental(); - const elementalUser = "elemental-user" - const stdUser = "std-user" - const topLevelMenu = new TopLevelMenu(); - const uiPassword = "rancherpassword" - - beforeEach(() => { - cy.visit('/'); - }); - - filterTests(['main', 'upgrade'], () => { - it('Create elemental user', () => { - // User with the elemental-administrator role - cy.login(); - topLevelMenu.openIfClosed(); - cy.contains('Users & Authentication') - .click(); - cy.contains('.title', 'Users') - .should('exist'); - cy.clickButton('Create'); - cy.typeValue({label: 'Username', value: stdUser}); - cy.typeValue({label: 'New Password', value: uiPassword}); - cy.typeValue({label: 'Confirm Password', value: uiPassword}); - cy.clickButton('Create'); - }); - - it('Create standard user', () => { - // User without the elemental-administrator role - cy.login(); - topLevelMenu.openIfClosed(); - cy.contains('Users & Authentication') - .click(); - cy.contains('.title', 'Users') - .should('exist'); - cy.clickButton('Create'); - cy.typeValue({label: 'Username', value: elementalUser}); - cy.typeValue({label: 'New Password', value: uiPassword}); - cy.typeValue({label: 'Confirm Password', value: uiPassword}); - cy.contains('Elemental Administrator') - .click(); - cy.clickButton('Create'); - }); - }); - - filterTests(['main'], () => { - it('Elemental user should access the OS management menu', () => { - cy.login(elementalUser, uiPassword); - cy.get('[data-testid="banner-title"]') - .contains('Welcome to Rancher'); - topLevelMenu.openIfClosed(); - elemental.elementalIcon().should('exist'); - elemental.accessElementalMenu(); - elemental.checkElementalNav(); - }); - - it('Standard user should not access the OS management menu', () => { - cy.login(stdUser, uiPassword); - cy.get('[data-testid="banner-title"]') - .contains('Welcome to Rancher'); - topLevelMenu.openIfClosed(); - elemental.elementalIcon().should('exist'); - elemental.accessElementalMenu(); - // User without appropriate role will get a specific page - cy.contains('Elemental is a software stack'); - }); - }); -}); diff --git a/tests/cypress/1.0.0/fixtures/custom_cloud-config.yaml b/tests/cypress/1.0.0/fixtures/custom_cloud-config.yaml deleted file mode 100644 index edf851e19..000000000 --- a/tests/cypress/1.0.0/fixtures/custom_cloud-config.yaml +++ /dev/null @@ -1,11 +0,0 @@ -config: - cloud-config: - users: - - name: root - passwd: root - elemental: - install: - poweroff: true - device: /dev/sda - debug: true -machineName: my-machine diff --git a/tests/cypress/1.0.0/fixtures/machine_inventory_1.yaml b/tests/cypress/1.0.0/fixtures/machine_inventory_1.yaml deleted file mode 100644 index 575bd0a05..000000000 --- a/tests/cypress/1.0.0/fixtures/machine_inventory_1.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: elemental.cattle.io/v1beta1 -kind: MachineInventory -metadata: - annotations: - myInvAnnotation1: myInvAnnotationValue1 - labels: - testfilter: test-filter-one - name: test-filter-one - namespace: fleet-default -spec: - tpmHash: 725d98e34a6d05336f1c8f3e1b468449b6952f91439df6f2b1b704efe87fe811 - diff --git a/tests/cypress/1.0.0/fixtures/machine_inventory_2.yaml b/tests/cypress/1.0.0/fixtures/machine_inventory_2.yaml deleted file mode 100644 index e1152b35d..000000000 --- a/tests/cypress/1.0.0/fixtures/machine_inventory_2.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: elemental.cattle.io/v1beta1 -kind: MachineInventory -metadata: - annotations: - myInvAnnotation1: myInvAnnotationValue1 - labels: - testfilter: test-filter-two - name: test-filter-two - namespace: fleet-default -spec: - tpmHash: 725d98e34a6d05336f1c8f3e1b468449b6952f91439df6f2b1b704efe87fe812 - diff --git a/tests/cypress/1.0.0/fixtures/machine_inventory_3.yaml b/tests/cypress/1.0.0/fixtures/machine_inventory_3.yaml deleted file mode 100644 index a017a5406..000000000 --- a/tests/cypress/1.0.0/fixtures/machine_inventory_3.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: elemental.cattle.io/v1beta1 -kind: MachineInventory -metadata: - annotations: - myInvAnnotation1: myInvAnnotationValue1 - name: shouldnotmatch - namespace: fleet-default -spec: - tpmHash: 725d98e34a6d05336f1c8f3e1b468449b6952f91439df6f2b1b704efe87fe813 - diff --git a/tests/cypress/1.0.0/package.json b/tests/cypress/1.0.0/package.json deleted file mode 100644 index bae783336..000000000 --- a/tests/cypress/1.0.0/package.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "name": "elemental-ui-e2e", - "version": "1.0.0", - "description": "Cypress tests to test the Elemental UI", - "main": "index.js", - "directories": { - "doc": "docs" - }, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/rancher/elemental.git" - }, - "keywords": [], - "author": "Elemental team", - "license": "Apache License 2.0", - "bugs": { - "url": "https://github.com/rancher/elemental/issues" - }, - "homepage": "https://github.com/rancher/elemental#readme", - "dependencies": { - "cy-verify-downloads": "^0.1.8", - "cypress": "^10.0.0", - "cypress-dark": "^1.8.3", - "cypress-file-upload": "^5.0.8", - "cypress-plugin-tab": "^1.0.5", - "dotenv": "^10.0.0", - "typescript": "^4.5.2" - } -} diff --git a/tests/cypress/1.0.0/plugins/index.ts b/tests/cypress/1.0.0/plugins/index.ts deleted file mode 100644 index d9c0ce757..000000000 --- a/tests/cypress/1.0.0/plugins/index.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -Copyright © 2022 - 2023 SUSE LLC - -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. -*/ - -/// -require('dotenv').config(); - -/** - * @type {Cypress.PluginConfig} - */ -// eslint-disable-next-line no-unused-vars -module.exports = (on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions) => { - // `on` is used to hook into various events Cypress emits - // `config` is the resolved Cypress config - const url = process.env.RANCHER_URL || 'https://localhost:8005'; - const { isFileExist, findFiles } = require('cy-verify-downloads'); - on('task', { isFileExist, findFiles }) - - config.baseUrl = url.replace(/\/$/, ); - config.env.cache_session = process.env.CACHE_SESSION || false; - config.env.cluster = process.env.CLUSTER_NAME; - config.env.cypress_tags = process.env.CYPRESS_TAGS; - config.env.elemental_ui_version = process.env.ELEMENTAL_UI_VERSION; - config.env.k8s_version = process.env.K8S_VERSION_TO_PROVISION; - config.env.operator_version = process.env.OPERATOR_VERSION; - config.env.password = process.env.RANCHER_PASSWORD; - config.env.proxy_ip = process.env.PROXY_IP; - config.env.proxy = process.env.PROXY; - config.env.ui_account = process.env.UI_ACCOUNT; - config.env.upgrade_channel_list = process.env.UPGRADE_CHANNEL_LIST; - config.env.upgrade_image = process.env.UPGRADE_IMAGE; - config.env.username = process.env.RANCHER_USER; - - return config; -}; diff --git a/tests/cypress/1.0.0/support/e2e.ts b/tests/cypress/1.0.0/support/e2e.ts deleted file mode 100644 index 1922cb9bb..000000000 --- a/tests/cypress/1.0.0/support/e2e.ts +++ /dev/null @@ -1,62 +0,0 @@ -/* -Copyright © 2022 - 2023 SUSE LLC - -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 './functions'; - -declare global { - // eslint-disable-next-line no-unused-vars - namespace Cypress { - interface Chainable { - // Functions declared in functions.ts - addHelmRepo(repoName: string, repoUrl: string, repoType?: string,): Chainable; - addMachInvAnnotation(annotationName: string, annotationValue: string):Chainable; - addMachInvLabel(labelName: string, labelValue: string, useHardwareLabels: boolean):Chainable; - addMachRegAnnotation(annotationName: string, annotationValue: string):Chainable; - addMachRegLabel(labelName: string, labelValue: string):Chainable; - byLabel(label: string,): Chainable; - checkFilter(filterName: string, testFilterOne: boolean, testFilterTwo: boolean, shouldNotMatch: boolean): Chainable; - checkMachInvAnnotation(machRegName: string, annotationName: string, annotationValue: string):Chainable; - checkMachInvLabel(machRegName: string, labelName: string, labelValue: string, useHardwareLabels: boolean, afterBoot: boolean):Chainable; - checkMachRegAnnotation(machRegName: string, annotationName: string, annotationValue: string):Chainable; - checkMachRegLabel(machRegName: string, labelName: string, labelValue: string):Chainable; - clickButton(label: string,): Chainable; - clickClusterMenu(listLabel: string[],): Chainable; - clickElementalMenu(label: string,): Chainable; - clickNavMenu(listLabel: string[],): Chainable; - confirmDelete(): Chainable; - createMachReg(machRegName: string, namespace?: string, checkLabels?: boolean, checkAnnotations?: boolean, customCloudConfig?: string, checkDefaultCloudConfig?: boolean): Chainable; - deleteAllResources():Chainable; - deleteMachReg(machRegName: string): Chainable; - editMachReg(machRegName: string, addLabel?: boolean, addAnnotation?: boolean, withYAML?: boolean): Chainable; - getDetail(name: string, type: string, namespace?: string): Chainable; - importMachineInventory(machineInventoryFile: string, machineInventoryName: string): Chainable; - login(username?: string, password?: string, cacheSession?: boolean,): Chainable; - typeKeyValue(key: string, value: string,): Chainable; - typeValue(label: string, value: string, noLabel?: boolean, log?: boolean): Chainable; - } -}} - -// TODO handle redirection errors better? -// we see a lot of 'error navigation cancelled' uncaught exceptions that don't actually break anything; ignore them here -Cypress.on('uncaught:exception', (err, runnable) => { - // returning false here prevents Cypress from failing the test - if (err.message.includes('navigation guard')) { - return false; - } -}); - -require('cypress-dark'); -require('cy-verify-downloads').addCustomCommand(); -require('cypress-plugin-tab'); - diff --git a/tests/cypress/1.0.0/support/elemental.ts b/tests/cypress/1.0.0/support/elemental.ts deleted file mode 100644 index 5998e7e25..000000000 --- a/tests/cypress/1.0.0/support/elemental.ts +++ /dev/null @@ -1,75 +0,0 @@ -/* -Copyright © 2022 - 2023 SUSE LLC - -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. -*/ - -export class Elemental { - // Go into the cluster creation menu - accessClusterMenu() { - cy.contains('.title', 'Dashboard') - .should('exist'); - cy.contains('Dashboard') - .click(); - cy.contains('Create Elemental Cluster') - .should('exist'); - cy.contains('Create Elemental Cluster') - .click(); - } - - // Go into the Elemental menu - accessElementalMenu() { - cy.contains('OS Management') - .click(); - } - - // Make sure we get all menus - checkElementalNav() { - // Open advanced accordion - cy.get('div.header > i') - .eq(0) - .click() - cy.get('div.header') - .contains('Advanced') - .should('be.visible') - // Check all listed options once accordion is opened - cy.get('li.child.nav-type') - .should(($lis) => { - expect($lis).to.have.length(6); - expect($lis.eq(0)).to.contain('Dashboard'); - expect($lis.eq(1)).to.contain('Registration Endpoints'); - expect($lis.eq(2)).to.contain('Inventory of Machines'); - expect($lis.eq(3)).to.contain('Update Groups'); - expect($lis.eq(4)).to.contain('OS Versions'); - expect($lis.eq(5)).to.contain('OS Version Channels'); - }) - } - - // Make sure Elemental logo appears - elementalIcon() { - if (Cypress.env('elemental_ui_version') != '1.0.0') { - return cy.get('.option .icon.group-icon.icon-elemental'); - } - return cy.get('.option .icon.group-icon.icon-os-management'); - } - - // Handle first login in Rancher - firstLogin() { - cy.get('input') - .type(Cypress.env('password'), {log: false}); - cy.clickButton('Log in with Local User'); - cy.contains('By checking') - .click('left'); - cy.clickButton('Continue'); - cy.get('[data-testid="banner-title"]') - .contains('Welcome to Rancher'); - } -} diff --git a/tests/cypress/1.0.0/support/filterTests.js b/tests/cypress/1.0.0/support/filterTests.js deleted file mode 100644 index 9d7cf3ad3..000000000 --- a/tests/cypress/1.0.0/support/filterTests.js +++ /dev/null @@ -1,11 +0,0 @@ -// Allow to filter Cypress tests with tags -const TestFilters = (givenTags, runTest) => { - const tags = Cypress.env('cypress_tags').split(',') - const isFound = givenTags.some((givenTag) => tags.includes(givenTag)) - - if (isFound) { - runTest() - } -}; - -export default TestFilters diff --git a/tests/cypress/1.0.0/support/functions.ts b/tests/cypress/1.0.0/support/functions.ts deleted file mode 100644 index 5a7203be2..000000000 --- a/tests/cypress/1.0.0/support/functions.ts +++ /dev/null @@ -1,496 +0,0 @@ -/* -Copyright © 2022 - 2023 SUSE LLC - -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 'cypress-file-upload'; - -// Global -interface hardwareLabels { - [key: string]: string; -}; - -const hwLabels: hardwareLabels = { - 'CPUModel': '${System Data/CPU/Model}', - 'CPUVendor': '${System Data/CPU/Vendor}', - 'NumberBlockDevices': '${System Data/Block Devices/Number Devices}', - 'NumberNetInterface': '${System Data/Network/Number Interfaces}', - 'CPUVendorTotalCPUCores': '${System Data/CPU/Total Cores}', - 'TotalCPUThread': '${System Data/CPU/Total Threads}', - 'TotalMemory': '${System Data/Memory/Total Physical Bytes}' -}; - -// Generic functions - -// Log into Rancher -Cypress.Commands.add('login', ( - username = Cypress.env('username'), - password = Cypress.env('password'), - cacheSession = Cypress.env('cache_session')) => { - const login = () => { - let loginPath ="/v3-public/localProviders/local*"; - cy.intercept('POST', loginPath).as('loginReq'); - - cy.visit('/auth/login'); - - cy.byLabel('Username') - .focus() - .type(username, {log: false}); - - cy.byLabel('Password') - .focus() - .type(password, {log: false}); - - cy.get('button').click(); - cy.wait('@loginReq'); - cy.get('[data-testid="banner-title"]').contains('Welcome to Rancher'); - } - - if (cacheSession) { - cy.session([username, password], login); - } else { - login(); - } -}); - -// Search fields by label -Cypress.Commands.add('byLabel', (label) => { - cy.get('.labeled-input') - .contains(label) - .siblings('input'); -}); - -// Search button by label -Cypress.Commands.add('clickButton', (label) => { - cy.get('.btn') - .contains(label) - .click(); -}); - -// Confirm the delete operation -Cypress.Commands.add('confirmDelete', () => { - cy.get('.card-actions') - .contains('Delete') - .click(); -}); - -// Make sure we are in the desired menu inside a cluster (local by default) -// You can access submenu by giving submenu name in the array -// ex: cy.clickClusterMenu(['Menu', 'Submenu']) -Cypress.Commands.add('clickNavMenu', (listLabel: string[]) => { - listLabel.forEach(label => cy.get('nav').contains(label).click()); -}); - -// Insert a value in a field *BUT* force a clear before! -Cypress.Commands.add('typeValue', ({label, value, noLabel, log=true}) => { - if (noLabel === true) { - cy.get(label) - .focus() - .clear() - .type(value, {log: log}); - } else { - cy.byLabel(label) - .focus() - .clear() - .type(value, {log: log}); - } -}); - -// Make sure we are in the desired menu inside a cluster (local by default) -// You can access submenu by giving submenu name in the array -// ex: cy.clickClusterMenu(['Menu', 'Submenu']) -Cypress.Commands.add('clickClusterMenu', (listLabel: string[]) => { - listLabel.forEach(label => cy.get('nav').contains(label).click()); -}); - -// Insert a key/value pair -Cypress.Commands.add('typeKeyValue', ({key, value}) => { - cy.get(key) - .clear() - .type(value); -}); - -Cypress.Commands.overwrite('type', (originalFn, subject, text, options = {}) => { - options.delay = 100; - return originalFn(subject, text, options); -}); - -// Add a delay between command without using cy.wait() -// https://github.com/cypress-io/cypress/issues/249#issuecomment-443021084 -const COMMAND_DELAY = 1000; - -for (const command of ['visit', 'click', 'trigger', 'type', 'clear', 'reload', 'contains']) { - Cypress.Commands.overwrite(command, (originalFn, ...args) => { - const origVal = originalFn(...args); - - return new Promise((resolve) => { - setTimeout(() => { - resolve(origVal); - }, COMMAND_DELAY); - }); - }); -}; - -// Add Helm repo -Cypress.Commands.add('addHelmRepo', ({repoName, repoUrl, repoType}) => { - cy.clickClusterMenu(['Apps', 'Repositories']) - - // Make sure we are in the 'Repositories' screen (test failed here before) - cy.contains('header', 'Repositories') - .should('be.visible'); - cy.contains('Create') - .should('be.visible'); - - cy.clickButton('Create'); - cy.contains('Repository: Create') - .should('be.visible'); - cy.typeValue({label: 'Name', value: repoName}); - if (repoType === 'git') { - cy.contains('Git repository') - .click(); - cy.typeValue({label: 'Git Repo URL', value: repoUrl}); - cy.typeValue({label: 'Git Branch', value: 'main'}); - } else { - cy.typeValue({label: 'Index URL', value: repoUrl}); - } - cy.clickButton('Create'); -}); - -// Delete all resources from a page -Cypress.Commands.add('deleteAllResources', () => { - cy.get('[width="30"] > .checkbox-outer-container') - .click(); - cy.clickButton('Delete'); - cy.confirmDelete(); - // Sometimes, UI is crashing when a resource is deleted - // A reload should workaround the failure - cy.get('body').then(($body) => { - if (!$body.text().includes('There are no rows to show.')) { - cy.reload(); - cy.log('RELOAD TRIGGERED'); - cy.screenshot('reload-triggered'); - }; - }); - cy.contains('There are no rows to show', {timeout: 15000}); -}); - -// Machine registration functions - -// Create a machine registration -Cypress.Commands.add('createMachReg', ({ - machRegName, - namespace='fleet-default', - checkLabels=false, - checkAnnotations=false, - checkInventoryLabels=false, - checkInventoryAnnotations=false, - customCloudConfig='', - checkDefaultCloudConfig=true }) => { - cy.clickNavMenu(["Dashboard"]); - cy.clickButton("Create Registration Endpoint"); - if (namespace != "fleet-default") { - cy.get('div.vs__selected-options') - .eq(0) - .click() - cy.get('li.vs__dropdown-option') - .contains('Create a New Namespace') - .click() - cy.get(':nth-child(1) > .labeled-input') - .type(namespace); - cy.focused() - .tab() - .tab() - .type(machRegName); - } else { - cy.typeValue({label: 'Name', value: machRegName}); - } - - if (customCloudConfig != '') { - cy.get('input[type="file"]') - .attachFile({filePath: customCloudConfig}); - } - - if (checkLabels) { - cy.addMachRegLabel({labelName: 'myLabel1', labelValue: 'myLabelValue1'}); - } - - if (checkAnnotations) { - cy.addMachRegAnnotation({ - annotationName: 'myAnnotation1', - annotationValue: 'myAnnotationValue1'}); - } - - if (checkInventoryLabels) { - cy.addMachInvLabel({ - labelName: 'myInvLabel1', - labelValue: 'myInvLabelValue1'}); - } - - if (checkInventoryAnnotations) { - cy.addMachInvAnnotation({ - annotationName: 'myInvAnnotation1', - annotationValue: 'myInvAnnotationValue1'}); - } - - cy.clickButton("Create"); - - // Make sure the machine registration is created and active - cy.contains('.masthead', 'Registration Endpoint: '+ machRegName + 'Active') - .should('exist'); - - // Check the namespace - cy.contains('.masthead', 'Namespace: '+ namespace) - .should('exist'); - - // Make sure there is an URL registration in the Registration URL block - cy.contains('.mt-40 > .col', /https:\/\/.*elemental\/registration/); - - // Try to download the registration file and check it - cy.clickButton("Download"); - cy.verifyDownload(machRegName + '_registrationURL.yaml'); - cy.contains('Saving') - .should('not.exist'); - - // Check Cloud configuration - // TODO: Maybe the check may be improved in one line - if (checkDefaultCloudConfig) { - cy.get('[data-testid="yaml-editor-code-mirror"]') - .should('include.text','config:') - .should('include.text','cloud-config:') - .should('include.text','users:') - .should('include.text','- name: root') - .should('include.text','passwd: root') - .should('include.text','elemental:') - .should('include.text','install:') - .should('include.text','device: /dev/nvme0n1') - .should('include.text','poweroff: true'); - } - - // Check label and annotation in YAML - // For now, we can only check in YAML because the fields are disabled and we cannot check their content - // It looks like we can use shadow DOM to catch it but too complicated for now - cy.contains('Registration Endpoint') - .click(); - if (checkLabels) {cy.checkMachRegLabel({ - machRegName: machRegName, - labelName: 'myLabel1', - labelValue: 'myLabelValue1'})}; - if (checkAnnotations) {cy.checkMachRegAnnotation({ - machRegName: machRegName, - annotationName: 'myAnnotation1', - annotationValue: 'myAnnotationValue1'});} -}); - -// Add Label to machine registration -Cypress.Commands.add('addMachRegLabel', ({labelName, labelValue}) => { - cy.get('#machine-reg').contains('Registration Endpoint') - .click(); - cy.get('#machine-reg > .mb-30 > .key-value > .footer > .btn') - .click(); - cy.get('#machine-reg > .mb-30 > .key-value > .kv-container > .kv-item.key') - .type(labelName); - cy.get('#machine-reg > .mb-30 > .key-value > .kv-container > .kv-item.value') - .type(labelValue); -}); - -// Add Annotation to machine registration -Cypress.Commands.add('addMachRegAnnotation', ({annotationName, annotationValue}) => { - cy.get('#machine-reg').contains('Registration Endpoint') - .click(); - cy.get('#machine-reg > .mb-10 > .key-value > .footer > .btn') - .click(); - cy.get('#machine-reg > .mb-10 > .key-value > .kv-container > .kv-item.key') - .type(annotationName); - cy.get('#machine-reg > .mb-10 > .key-value > .kv-container > .kv-item.value') - .type(annotationValue); -}); - -// Add Label to machine inventory -Cypress.Commands.add('addMachInvLabel', ({labelName, labelValue, useHardwareLabels=true}) => { - cy.get('#machine-inventory').contains('Inventory of Machines').click(); - cy.clickButton('Add Label'); - cy.get('#machine-inventory > .mb-30 > .key-value > .kv-container > .kv-item.key').type(labelName); - cy.get('#machine-inventory > .mb-30 > .key-value > .kv-container > .kv-item.value').type(labelValue); - if (useHardwareLabels) { - var nthChildIndex = 7; - for (const key in hwLabels) { - const value = hwLabels[key]; - cy.clickButton('Add Label'); - cy.get(`#machine-inventory > .mb-30 > .key-value > .kv-container > :nth-child(${nthChildIndex}) > input`).type(key); - cy.get(`#machine-inventory > .mb-30 > .key-value > .kv-container > :nth-child(${nthChildIndex + 1}) > .no-resize`).type(value, {parseSpecialCharSequences: false}); - nthChildIndex += 3; - }; - }; -}); - -// Add Annotation to machine inventory -Cypress.Commands.add('addMachInvAnnotation', ({annotationName, annotationValue}) => { - cy.get('#machine-inventory') - .contains('Inventory of Machines') - .click(); - cy.clickButton('Add Annotation'); - cy.get('#machine-inventory > .mb-10 > .key-value > .kv-container > .kv-item.key') - .type(annotationName); - cy.get('#machine-inventory > .mb-10 > .key-value > .kv-container > .kv-item.value') - .type(annotationValue); -}); - -// Check machine inventory label in YAML -Cypress.Commands.add('checkMachInvLabel', ({machRegName, labelName, labelValue, userHardwareLabels=true, afterBoot=false}) => { - if (afterBoot == false ) { - cy.contains(machRegName) - .click(); - cy.get('div.actions > .role-multi-action') - .click() - cy.contains('li', 'Edit YAML') - .click(); - cy.contains('Registration Endpoint: '+ machRegName) - .should('exist'); - cy.contains(labelName + ': ' + labelValue); - if (userHardwareLabels) { - for (const key in hwLabels) { - const value = hwLabels[key]; - cy.contains(key +': ' + value); - }; - }; - cy.clickButton('Cancel'); - } else { - cy.contains(labelName + ': ' + labelValue); - if (userHardwareLabels) { - for (const key in hwLabels) { - const value = hwLabels[key]; - cy.contains(key +': '); - }; - }; - } -}); - -// Check machine registration label in YAML -Cypress.Commands.add('checkMachRegLabel', ({ - machRegName, - labelName, - labelValue}) => { - cy.contains(machRegName) - .click(); - cy.get('div.actions > .role-multi-action') - .click() - cy.contains('li', 'Edit YAML') - .click(); - cy.contains('Registration Endpoint: '+ machRegName) - .should('exist'); - cy.contains(labelName + ': ' + labelValue); - cy.clickButton('Cancel'); -}); - -// Check machine registration annotation in YAML -Cypress.Commands.add('checkMachRegAnnotation', ({ - machRegName, - annotationName, - annotationValue}) => { - cy.contains(machRegName) - .click(); - cy.get('div.actions > .role-multi-action') - .click() - cy.contains('li', 'Edit YAML') - .click(); - cy.contains('Registration Endpoint: '+ machRegName) - .should('exist'); - cy.contains(annotationName + ': ' + annotationValue); - cy.clickButton('Cancel'); -}); - -// Edit a machine registration -Cypress.Commands.add('editMachReg', ({ - machRegName, - addLabel=false, - addAnnotation=false, - withYAML=false}) => { - cy.contains(machRegName) - .click(); - // Select the 3dots button and edit configuration - cy.get('div.actions > .role-multi-action') - .click() - if (withYAML) { - cy.contains('li', 'Edit YAML') - .click(); - cy.contains('metadata') - .click(0,0) - .type('{end}{enter} labels:{enter} myLabel1: myLabelValue1'); - cy.contains('metadata') - .click(0,0) - .type('{end}{enter} annotations:{enter} myAnnotation1: myAnnotationValue1'); - } else { - cy.contains('li', 'Edit Config') - .click(); - if (addLabel) {cy.addMachRegLabel({labelName: 'myLabel1', - labelValue: 'myLabelValue1', - withYAML: withYAML})}; - if (addAnnotation) {cy.addMachRegAnnotation({annotationName: 'myAnnotation1', - annotationValue: 'myAnnotationValue1', - withYAML: withYAML})}; - } -}); - -// Delete a machine registration -Cypress.Commands.add('deleteMachReg', ({machRegName}) => { - cy.contains('Registration Endpoint') - .click(); - /* This code cannot be used anymore for now because of - https://github.com/rancher/elemental/issues/714 - As it is not a blocker, we need to bypass it. - Instead of selecting resource to delete by name - we select all resources. - cy.contains(machRegName) - .parent() - .parent() - .click(); - */ - cy.get('[width="30"] > .checkbox-outer-container') - .click(); - cy.clickButton('Delete'); - cy.confirmDelete(); - // Timeout should fix this issue https://github.com/rancher/elemental/issues/643 - cy.contains(machRegName, {timeout: 20000}) - .should('not.exist') -}); - -// Machine Inventory functions - -// Import machine inventory -Cypress.Commands.add('importMachineInventory', ({ - machineInventoryFile, - machineInventoryName}) => { - cy.clickNavMenu(["Inventory of Machines"]); - cy.clickButton('Create from YAML'); - cy.clickButton('Read from File'); - cy.get('input[type="file"]') - .attachFile({filePath: machineInventoryFile}); - cy.clickButton('Create'); - cy.contains('Creating') - .should('not.exist'); - cy.contains(machineInventoryName) - .should('exist'); -}); - -Cypress.Commands.add('checkFilter', ({ - filterName, - testFilterOne, - testFilterTwo, - shouldNotMatch}) => { - cy.clickNavMenu(["Inventory of Machines"]); - cy.clickButton("Add Filter"); - cy.get('.advanced-search-box').type(filterName); - cy.get('.bottom-block > .role-primary').click(); - (testFilterOne) ? cy.contains('test-filter-one').should('exist') : cy.contains('test-filter-one').should('not.exist'); - (testFilterTwo) ? cy.contains('test-filter-two').should('exist') : cy.contains('test-filter-two').should('not.exist'); - (shouldNotMatch) ? cy.contains('shouldnotmatch').should('exist') : cy.contains('shouldnotmatch').should('not.exist'); -}); diff --git a/tests/cypress/1.0.0/support/toplevelmenu.ts b/tests/cypress/1.0.0/support/toplevelmenu.ts deleted file mode 100644 index ea84157ce..000000000 --- a/tests/cypress/1.0.0/support/toplevelmenu.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -Copyright © 2022 - 2023 SUSE LLC - -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. -*/ - -export class TopLevelMenu { - toggle() { - cy.get('[data-testid="top-level-menu"]', {timeout: 12000}).click(); - } - - openIfClosed() { - cy.get('body').then((body) => { - if (body.find('.menu.raised').length === 0) { - this.toggle(); - } - }); - } - - categories() { - cy.get('.side-menu .body .category'); - } - - links() { - cy.get('.side-menu .option'); - } - - clusters(clusterName: string) { - cy.get('.clusters .cluster.selector.option').contains(clusterName).click(); - } - - localization() { - cy.get('.locale-chooser'); - } -} diff --git a/tests/cypress/1.0.0/tsconfig.json b/tests/cypress/1.0.0/tsconfig.json deleted file mode 100644 index ef07851c9..000000000 --- a/tests/cypress/1.0.0/tsconfig.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2018", - "module": "ESNext", - "moduleResolution": "Node", - "lib": [ - "ESNext", - "ESNext.AsyncIterable", - "DOM" - ], - "esModuleInterop": true, - "allowJs": true, - "sourceMap": true, - "strict": true, - "noEmit": true, - "baseUrl": ".", - "paths": { - "~/*": [ - "./*" - ], - "@/*": [ - "./*" - ] - }, - "types": [ - "@types/node", - "@nuxt/types", - "cypress", - "cy-verify-downloads", - "cypress-file-upload" - ] - }, - "exclude": [ - "node_modules" - ] -} diff --git a/tests/cypress/latest/e2e/unit_tests/advanced_filtering.spec.ts b/tests/cypress/latest/e2e/unit_tests/advanced_filtering.spec.ts index 0235accbb..27421f07f 100644 --- a/tests/cypress/latest/e2e/unit_tests/advanced_filtering.spec.ts +++ b/tests/cypress/latest/e2e/unit_tests/advanced_filtering.spec.ts @@ -45,36 +45,26 @@ filterTests(['main'], () => { ]); machineInventoryMap.forEach((value, key) => { - cy.importMachineInventory({machineInventoryFile: key +'.yaml', - machineInventoryName: value}); + cy.importMachineInventory(key +'.yaml', value); }); }); it('Two machine inventories should appear by filtering on test-filter', () => { // Only test-filter-one and test-filter-two should appear with test-filter as filter - cy.checkFilter({filterName: 'test-filter', - testFilterOne: true, - testFilterTwo: true, - shouldNotMatch: false}); + cy.checkFilter('test-filter', true, true, false); }); it('One machine inventory should appear by filtering on test-filter-one', () => { // Only test-filter-one should appear with test-filter-one and Test-Filter_One as filter // Checking with lower and upper case make sure we are not hitting https://github.com/rancher/elemental/issues/627 ['test-filter-one', 'Test-Filter-One'].forEach(filter => { - cy.checkFilter({filterName: filter, - testFilterOne: true, - testFilterTwo: false, - shouldNotMatch: false}); + cy.checkFilter(filter, true, false, false); }); }); it('No machine inventory should appear by filtering on test-bad-filter', () => { // This test will also serve as no regression test for https://github.com/rancher/elemental-ui/issues/41 - cy.checkFilter({filterName: 'test-bad-filter', - testFilterOne: false, - testFilterTwo: false, - shouldNotMatch: false}); + cy.checkFilter('test-bad-filter', false, false, false); cy.contains('There are no rows which match your search query.') }); diff --git a/tests/cypress/latest/e2e/unit_tests/elemental_plugin.spec.ts b/tests/cypress/latest/e2e/unit_tests/elemental_plugin.spec.ts index 58f74f6bd..3830ef35b 100644 --- a/tests/cypress/latest/e2e/unit_tests/elemental_plugin.spec.ts +++ b/tests/cypress/latest/e2e/unit_tests/elemental_plugin.spec.ts @@ -19,7 +19,7 @@ import filterTests from '~/support/filterTests.js'; filterTests(['main', 'upgrade'], () => { Cypress.config(); describe('Install Elemental plugin', () => { - const topLevelMenu = new TopLevelMenu(); + const topLevelMenu = new TopLevelMenu(); beforeEach(() => { cy.login(); @@ -31,9 +31,7 @@ filterTests(['main', 'upgrade'], () => { topLevelMenu.openIfClosed(); cy.contains('local') .click(); - cy.addHelmRepo({repoName: 'elemental-ui', - repoUrl: 'https://github.com/rancher/elemental-ui.git', - repoType: 'git'}); + cy.addHelmRepo('elemental-ui', 'https://github.com/rancher/elemental-ui.git', 'git'); }; }); diff --git a/tests/cypress/latest/e2e/unit_tests/machine_inventory.spec.ts b/tests/cypress/latest/e2e/unit_tests/machine_inventory.spec.ts index c096ce376..bce46eccd 100644 --- a/tests/cypress/latest/e2e/unit_tests/machine_inventory.spec.ts +++ b/tests/cypress/latest/e2e/unit_tests/machine_inventory.spec.ts @@ -58,10 +58,7 @@ describe('Machine inventory testing', () => { cy.clickNavMenu(["Inventory of Machines"]); cy.contains('my-machine') .click() - cy.checkMachInvLabel({machRegName: 'machine-registration', - labelName: 'myInvLabel1', - labelValue: 'myInvLabelValue1', - afterBoot: true}); + cy.checkMachInvLabel('machine-registration', 'myInvLabel1', 'myInvLabelValue1', true); for (var hwLabel in hwLabels) { cy.clickNavMenu(["Inventory of Machines"]); cy.get('.table-options-group > .btn > .icon') diff --git a/tests/cypress/latest/e2e/unit_tests/machine_registration.spec.ts b/tests/cypress/latest/e2e/unit_tests/machine_registration.spec.ts index 67a41a545..7066fb89c 100644 --- a/tests/cypress/latest/e2e/unit_tests/machine_registration.spec.ts +++ b/tests/cypress/latest/e2e/unit_tests/machine_registration.spec.ts @@ -39,8 +39,8 @@ describe('Machine registration testing', () => { // Create OS Version Channels from which to build the ISO // No need to create one if we test stable because it is already created // by the elemental-operator - utils.isOperatorVersion('dev') ? cy.addOsVersionChannel({channelVersion:'dev'}): null; - utils.isOperatorVersion('staging') ? cy.addOsVersionChannel({channelVersion: 'staging'}): null; + utils.isOperatorVersion('dev') ? cy.addOsVersionChannel('dev'): null; + utils.isOperatorVersion('staging') ? cy.addOsVersionChannel('staging'): null; }); beforeEach(() => { @@ -69,61 +69,44 @@ describe('Machine registration testing', () => { filterTests(['main'], () => { it('Create machine registration with default options', () => { - cy.createMachReg({machRegName: 'default-options-test'}); + cy.createMachReg('default-options-test'); }); it('Create machine registration with labels and annotations', () => { - cy.createMachReg({machRegName: 'labels-annotations-test', - checkLabels: true, - checkAnnotations: true}); + cy.createMachReg('labels-annotations-test', 'fleet-default', true, true); }); it('Delete machine registration', () => { - cy.createMachReg({machRegName: 'delete-test'}); - cy.deleteMachReg({machRegName: 'delete-test'}); + cy.createMachReg('delete-test'); + cy.deleteMachReg('delete-test'); }); it('Edit a machine registration with edit config button', () => { - cy.createMachReg({machRegName: 'edit-config-test'}); - cy.editMachReg({machRegName: 'edit-config-test', - addLabel: true, - addAnnotation: true }); + cy.createMachReg('edit-config-test'); + cy.editMachReg('edit-config-test', true, true); cy.getBySel('form-save') .contains('Save') .click(); // Check that we can see our label and annotation in the YAML - cy.checkMachRegLabel({machRegName: 'edit-config-test', - labelName: 'myLabel1', - labelValue: 'myLabelValue1'}); - cy.checkMachRegAnnotation({machRegName: 'edit-config-test', - annotationName: 'myAnnotation1', - annotationValue: 'myAnnotationValue1'}); + cy.checkMachRegLabel('edit-config-test', 'myLabel1', 'myLabelValue1'); + cy.checkMachRegAnnotation('edit-config-test', 'myAnnotation1', 'myAnnotationValue1'); }); it('Edit a machine registration with edit YAML button', () => { - cy.createMachReg({machRegName: 'edit-yaml-test'}); - cy.editMachReg({machRegName: 'edit-yaml-test', - addLabel: true, - addAnnotation: true, - withYAML: true }); + cy.createMachReg('edit-yaml-test'); + cy.editMachReg('edit-yaml-test', true, true, true); cy.getBySel('action-button-async-button') .contains('Save') .click(); // Check that we can see our label and annotation in the YAML - cy.checkMachRegLabel({machRegName: 'edit-yaml-test', - labelName: 'myLabel1', - labelValue: 'myLabelValue1'}); - cy.checkMachRegAnnotation({machRegName: 'edit-yaml-test', - annotationName: 'myAnnotation1', - annotationValue: 'myAnnotationValue1'}); + cy.checkMachRegLabel('edit-yaml-test', 'myLabel1', 'myLabelValue1'); + cy.checkMachRegAnnotation('edit-yaml-test', 'myAnnotation1', 'myAnnotationValue1'); }); it('Clone a machine registration', () => { - cy.createMachReg({machRegName: 'clone-test', - checkLabels: true, - checkAnnotations: true}); + cy.createMachReg('clone-test', 'fleet-default', true, true); cy.contains('clone-test') .click(); cy.get('div.actions > .role-multi-action') @@ -139,20 +122,16 @@ describe('Machine registration testing', () => { .should('exist'); // Check that we got the same label and annotation in both machine registration - cy.checkMachRegLabel({machRegName: 'cloned-machine-reg', - labelName: 'myLabel1', - labelValue: 'myLabelValue1'}); + cy.checkMachRegLabel('cloned-machine-reg','myLabel1', 'myLabelValue1'); cy.contains('cloned-machine-reg') .click(); - cy.checkMachRegAnnotation({machRegName: 'cloned-machine-reg', - annotationName: 'myAnnotation1', - annotationValue: 'myAnnotationValue1'}); + cy.checkMachRegAnnotation('cloned-machine-reg', 'myAnnotation1', 'myAnnotationValue1'); cy.contains('cloned-machine-reg') .click(); }); it('Download Machine registration YAML', () => { - cy.createMachReg({machRegName: 'download-yaml-test'}); + cy.createMachReg('download-yaml-test'); cy.contains('download-yaml-test') .click(); cy.get('div.actions > .role-multi-action') @@ -163,25 +142,32 @@ describe('Machine registration testing', () => { }); it('Check machine registration label name size', () => { - cy.checkLabelSize({sizeToCheck: 'name'}); + cy.checkLabelSize('name'); }); it('Check machine registration label value size', () => { - cy.checkLabelSize({sizeToCheck: 'value'}); + cy.checkLabelSize('value'); }); // This test must stay the last one because we use this machine registration when we test adding a node. // It also tests using a custom cloud config by using read from file button. it('Create Machine registration we will use to test adding a node', () => { - cy.createMachReg({machRegName: 'machine-registration', - checkInventoryLabels: true, - checkInventoryAnnotations: true, - checkIsoBuilding: true, - customCloudConfig: 'custom_cloud-config.yaml', - checkDefaultCloudConfig: false}); - cy.checkMachInvLabel({machRegName: 'machine-registration', - labelName: 'myInvLabel1', - labelValue: 'myInvLabelValue1'}); + cy.createMachReg('machine-registration', + 'fleet-default', + //checkLabels + false, + //checkAnnotations + false, + //checkInventoryLabels + true, + //checkInventoryAnnotations + true, + //checkIsoBuilding + true, + 'custom_cloud-config.yaml', + //checkDefaultCloudConfig + false); + cy.checkMachInvLabel('machine-registration', 'myInvLabel1', 'myInvLabelValue1', false); }); }); @@ -191,15 +177,22 @@ describe('Machine registration testing', () => { // We will move the test to the standard scenario later filterTests(['upgrade'], () => { it('Create Machine registration we will use to test adding a node', () => { - cy.createMachReg({machRegName: 'machine-registration', - checkInventoryLabels: true, - checkInventoryAnnotations: true, - checkIsoBuilding: true, - customCloudConfig: 'custom_cloud-config.yaml', - checkDefaultCloudConfig: false}); - cy.checkMachInvLabel({machRegName: 'machine-registration', - labelName: 'myInvLabel1', - labelValue: 'myInvLabelValue1'}); + cy.createMachReg('machine-registration', + 'fleet-default', + //checkLabels + false, + //checkAnnotations + false, + //checkInventoryLabels + true, + //checkInventoryAnnotations + true, + //checkIsoBuilding + true, + 'custom_cloud-config.yaml', + //checkDefaultCloudConfig + false); + cy.checkMachInvLabel('machine-registration', 'myInvLabel1', 'myInvLabelValue1', false); }); }); }); diff --git a/tests/cypress/latest/e2e/unit_tests/seed_image.spec.ts b/tests/cypress/latest/e2e/unit_tests/seed_image.spec.ts deleted file mode 100644 index 021c06c87..000000000 --- a/tests/cypress/latest/e2e/unit_tests/seed_image.spec.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -Copyright © 2022 - 2023 SUSE LLC - -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 { TopLevelMenu } from '~/support/toplevelmenu'; -import '~/support/commands'; - -Cypress.config(); -describe('SeedImage testing', () => { - const isoToTest = Cypress.env('iso_to_test'); - const seedImageFile = "myseedimage.yaml" - const topLevelMenu = new TopLevelMenu(); - - beforeEach(() => { - cy.login(); - cy.visit('/'); - - // Open the navigation menu - topLevelMenu.openIfClosed(); - }); - - it('Create SeedImage with custom base image', () => { - if (typeof isoToTest !== 'undefined') { - cy.exec(`sed -i "s|baseImage:.*|baseImage: ${isoToTest}|g" fixtures/${seedImageFile}`); - } - cy.contains('local') - .click(); - cy.get('.header-buttons > :nth-child(1)') - .click(); - cy.clickButton('Read from File'); - cy.get('input[type="file"]') - .attachFile({filePath: seedImageFile}); - cy.clickButton('Import'); - cy.get('.badge-state') - .contains('Active'); - cy.clickButton('Close'); - cy.exec('ls'); - }); -}); diff --git a/tests/cypress/latest/e2e/unit_tests/upgrade.spec.ts b/tests/cypress/latest/e2e/unit_tests/upgrade.spec.ts index cf71eb0b6..a287d4a53 100644 --- a/tests/cypress/latest/e2e/unit_tests/upgrade.spec.ts +++ b/tests/cypress/latest/e2e/unit_tests/upgrade.spec.ts @@ -44,7 +44,7 @@ describe('Upgrade tests', () => { filterTests(['upgrade'], () => { it('Create an OS Version Channels', () => { // System was built with stable ISO, so we can upgrade either to staging or dev - utils.isOperatorVersion('staging') ? cy.addOsVersionChannel({channelVersion: 'staging'}): cy.addOsVersionChannel({channelVersion:'dev'}); + utils.isOperatorVersion('staging') ? cy.addOsVersionChannel('staging'): cy.addOsVersionChannel('dev'); }); it('Check OS Versions', () => { diff --git a/tests/cypress/latest/e2e/unit_tests/user.spec.ts b/tests/cypress/latest/e2e/unit_tests/user.spec.ts index 5124821fa..e21492db1 100644 --- a/tests/cypress/latest/e2e/unit_tests/user.spec.ts +++ b/tests/cypress/latest/e2e/unit_tests/user.spec.ts @@ -40,9 +40,9 @@ describe('User role testing', () => { cy.contains('.title', 'Users') .should('exist'); cy.clickButton('Create'); - cy.typeValue({label: 'Username', value: stdUser}); - cy.typeValue({label: 'New Password', value: uiPassword}); - cy.typeValue({label: 'Confirm Password', value: uiPassword}); + cy.typeValue('Username', stdUser); + cy.typeValue('New Password', uiPassword); + cy.typeValue('Confirm Password', uiPassword); cy.clickButton('Create'); }); @@ -58,9 +58,9 @@ describe('User role testing', () => { cy.getBySel('masthead-create') .contains('Create') .click(); - cy.typeValue({label: 'Username', value: elementalUser}); - cy.typeValue({label: 'New Password', value: uiPassword}); - cy.typeValue({label: 'Confirm Password', value: uiPassword}); + cy.typeValue('Username', elementalUser); + cy.typeValue('New Password', uiPassword); + cy.typeValue('Confirm Password', uiPassword); cy.contains('Elemental Administrator') .click(); cy.getBySel('form-save') diff --git a/tests/cypress/latest/support/commands.ts b/tests/cypress/latest/support/commands.ts index d6ed94fba..16720eb34 100644 --- a/tests/cypress/latest/support/commands.ts +++ b/tests/cypress/latest/support/commands.ts @@ -95,7 +95,7 @@ Cypress.Commands.add('clickNavMenu', (listLabel: string[]) => { }); // Insert a value in a field *BUT* force a clear before! -Cypress.Commands.add('typeValue', ({label, value, noLabel, log=true}) => { +Cypress.Commands.add('typeValue', (label, value, noLabel, log=true) => { if (noLabel === true) { cy.get(label) .focus() @@ -117,7 +117,7 @@ Cypress.Commands.add('clickClusterMenu', (listLabel: string[]) => { }); // Insert a key/value pair -Cypress.Commands.add('typeKeyValue', ({key, value}) => { +Cypress.Commands.add('typeKeyValue', (key, value) => { cy.get(key) .clear() .type(value); @@ -145,7 +145,7 @@ for (const command of ['visit', 'click', 'trigger', 'type', 'clear', 'reload', ' }; // Add Helm repo -Cypress.Commands.add('addHelmRepo', ({repoName, repoUrl, repoType}) => { +Cypress.Commands.add('addHelmRepo', (repoName, repoUrl, repoType) => { cy.clickClusterMenu(['Apps', 'Repositories']) // Make sure we are in the 'Repositories' screen (test failed here before) @@ -157,14 +157,14 @@ Cypress.Commands.add('addHelmRepo', ({repoName, repoUrl, repoType}) => { cy.clickButton('Create'); cy.contains('Repository: Create') .should('be.visible'); - cy.typeValue({label: 'Name', value: repoName}); + cy.typeValue('Name', repoName); if (repoType === 'git') { cy.contains('Git repository') .click(); - cy.typeValue({label: 'Git Repo URL', value: repoUrl}); - cy.typeValue({label: 'Git Branch', value: 'main'}); + cy.typeValue('Git Repo URL', repoUrl); + cy.typeValue('Git Branch', 'main'); } else { - cy.typeValue({label: 'Index URL', value: repoUrl}); + cy.typeValue('Index URL', repoUrl); } cy.clickButton('Create'); }); @@ -192,7 +192,7 @@ Cypress.Commands.add('deleteAllResources', () => { // Machine registration commands // Create a machine registration -Cypress.Commands.add('createMachReg', ({ +Cypress.Commands.add('createMachReg', ( machRegName, namespace='fleet-default', checkLabels=false, @@ -201,7 +201,7 @@ Cypress.Commands.add('createMachReg', ({ checkInventoryAnnotations=false, checkIsoBuilding=false, customCloudConfig='', - checkDefaultCloudConfig=true }) => { + checkDefaultCloudConfig=true ) => { cy.clickNavMenu(["Dashboard"]); cy.getBySel('button-create-registration-endpoint') .click(); @@ -213,27 +213,10 @@ Cypress.Commands.add('createMachReg', ({ .attachFile({filePath: customCloudConfig}); } - if (checkLabels) { - cy.addMachRegLabel({labelName: 'myLabel1', labelValue: 'myLabelValue1'}); - } - - if (checkAnnotations) { - cy.addMachRegAnnotation({ - annotationName: 'myAnnotation1', - annotationValue: 'myAnnotationValue1'}); - } - - if (checkInventoryLabels) { - cy.addMachInvLabel({ - labelName: 'myInvLabel1', - labelValue: 'myInvLabelValue1'}); - } - - if (checkInventoryAnnotations) { - cy.addMachInvAnnotation({ - annotationName: 'myInvAnnotation1', - annotationValue: 'myInvAnnotationValue1'}); - } + checkLabels ? cy.addMachRegLabel('myLabel1', 'myLabelValue1') : null; + checkAnnotations? cy.addMachRegAnnotation('myAnnotation1', 'myAnnotationValue1') : null; + checkInventoryLabels ? cy.addMachInvLabel('myInvLabel1', 'myInvLabelValue1') : null; + checkInventoryAnnotations ? cy.addMachInvAnnotation('myInvAnnotation1', 'myInvAnnotationValue1') : null; cy.getBySel('form-save') .contains('Create') @@ -312,18 +295,12 @@ Cypress.Commands.add('createMachReg', ({ // It looks like we can use shadow DOM to catch it but too complicated for now cy.contains('Registration Endpoint') .click(); - if (checkLabels) {cy.checkMachRegLabel({ - machRegName: machRegName, - labelName: 'myLabel1', - labelValue: 'myLabelValue1'})}; - if (checkAnnotations) {cy.checkMachRegAnnotation({ - machRegName: machRegName, - annotationName: 'myAnnotation1', - annotationValue: 'myAnnotationValue1'});} + checkLabels ? cy.checkMachRegLabel(machRegName, 'myLabel1', 'myLabelValue1') : null; + checkAnnotations ? cy.checkMachRegAnnotation(machRegName, 'myAnnotation1', 'myAnnotationValue1') : null; }); // Add Label to machine registration -Cypress.Commands.add('addMachRegLabel', ({labelName, labelValue}) => { +Cypress.Commands.add('addMachRegLabel', (labelName, labelValue) => { cy.getBySel('labels-and-annotations-block') .contains('Registration Endpoint') .click(); @@ -336,7 +313,7 @@ Cypress.Commands.add('addMachRegLabel', ({labelName, labelValue}) => { }); // Add Annotation to machine registration -Cypress.Commands.add('addMachRegAnnotation', ({annotationName, annotationValue}) => { +Cypress.Commands.add('addMachRegAnnotation', (annotationName, annotationValue) => { cy.getBySel('labels-and-annotations-block') .contains('Registration Endpoint') .click(); @@ -349,7 +326,7 @@ Cypress.Commands.add('addMachRegAnnotation', ({annotationName, annotationValue}) }); // Add Label to machine inventory -Cypress.Commands.add('addMachInvLabel', ({labelName, labelValue, useHardwareLabels=true}) => { +Cypress.Commands.add('addMachInvLabel', (labelName, labelValue, useHardwareLabels=true) => { cy.getBySel('labels-and-annotations-block') .contains('Inventory of Machines') .click(); @@ -371,7 +348,7 @@ Cypress.Commands.add('addMachInvLabel', ({labelName, labelValue, useHardwareLabe }); // Add Annotation to machine inventory -Cypress.Commands.add('addMachInvAnnotation', ({annotationName, annotationValue}) => { +Cypress.Commands.add('addMachInvAnnotation', (annotationName, annotationValue) => { cy.getBySel('labels-and-annotations-block') .contains('Inventory of Machines') .click(); @@ -383,7 +360,7 @@ Cypress.Commands.add('addMachInvAnnotation', ({annotationName, annotationValue}) }); // Check machine inventory label in YAML -Cypress.Commands.add('checkMachInvLabel', ({machRegName, labelName, labelValue, userHardwareLabels=true, afterBoot=false}) => { +Cypress.Commands.add('checkMachInvLabel', (machRegName, labelName, labelValue, afterBoot=false, userHardwareLabels=true) => { if (afterBoot == false ) { cy.contains(machRegName) .click(); @@ -417,10 +394,7 @@ Cypress.Commands.add('checkMachInvLabel', ({machRegName, labelName, labelValue, }); // Check machine registration label in YAML -Cypress.Commands.add('checkMachRegLabel', ({ - machRegName, - labelName, - labelValue}) => { +Cypress.Commands.add('checkMachRegLabel', (machRegName, labelName, labelValue) => { cy.contains(machRegName) .click(); cy.get('div.actions > .role-multi-action') @@ -435,10 +409,7 @@ Cypress.Commands.add('checkMachRegLabel', ({ }); // Check machine registration annotation in YAML -Cypress.Commands.add('checkMachRegAnnotation', ({ - machRegName, - annotationName, - annotationValue}) => { +Cypress.Commands.add('checkMachRegAnnotation', ( machRegName, annotationName, annotationValue) => { cy.contains(machRegName) .click(); cy.get('div.actions > .role-multi-action') @@ -453,11 +424,7 @@ Cypress.Commands.add('checkMachRegAnnotation', ({ }); // Edit a machine registration -Cypress.Commands.add('editMachReg', ({ - machRegName, - addLabel=false, - addAnnotation=false, - withYAML=false}) => { +Cypress.Commands.add('editMachReg', ( machRegName, addLabel=false, addAnnotation=false, withYAML=false) => { cy.contains(machRegName) .click(); // Select the 3dots button and edit configuration @@ -475,17 +442,13 @@ Cypress.Commands.add('editMachReg', ({ } else { cy.contains('li', 'Edit Config') .click(); - if (addLabel) {cy.addMachRegLabel({labelName: 'myLabel1', - labelValue: 'myLabelValue1', - withYAML: withYAML})}; - if (addAnnotation) {cy.addMachRegAnnotation({annotationName: 'myAnnotation1', - annotationValue: 'myAnnotationValue1', - withYAML: withYAML})}; + addLabel ? cy.addMachRegLabel('myLabel1', 'myLabelValue1' ) : null; + addAnnotation ? cy.addMachRegAnnotation('myAnnotation1', 'myAnnotationValue1') : null; } }); // Delete a machine registration -Cypress.Commands.add('deleteMachReg', ({machRegName}) => { +Cypress.Commands.add('deleteMachReg', (machRegName) => { cy.contains('Registration Endpoint') .click(); /* This code cannot be used anymore for now because of @@ -512,9 +475,7 @@ Cypress.Commands.add('deleteMachReg', ({machRegName}) => { // Machine Inventory commands // Import machine inventory -Cypress.Commands.add('importMachineInventory', ({ - machineInventoryFile, - machineInventoryName}) => { +Cypress.Commands.add('importMachineInventory', (machineInventoryFile, machineInventoryName) => { cy.clickNavMenu(["Inventory of Machines"]); cy.getBySel('masthead-create-yaml') .click(); @@ -530,11 +491,7 @@ Cypress.Commands.add('importMachineInventory', ({ .should('exist'); }); -Cypress.Commands.add('checkFilter', ({ - filterName, - testFilterOne, - testFilterTwo, - shouldNotMatch}) => { +Cypress.Commands.add('checkFilter', (filterName, testFilterOne, testFilterTwo, shouldNotMatch) => { cy.clickNavMenu(["Inventory of Machines"]); cy.clickButton("Add Filter"); cy.get('.advanced-search-box').type(filterName); @@ -544,16 +501,12 @@ Cypress.Commands.add('checkFilter', ({ (shouldNotMatch) ? cy.contains('shouldnotmatch').should('exist') : cy.contains('shouldnotmatch').should('not.exist'); }); -Cypress.Commands.add('checkLabelSize', ({ - sizeToCheck}) => { +Cypress.Commands.add('checkLabelSize', (sizeToCheck) => { cy.clickNavMenu(["Dashboard"]); cy.getBySel('button-create-registration-endpoint') .click(); - if (sizeToCheck == "name") { - cy.addMachInvLabel({labelName: 'labeltoolonggggggggggggggggggggggggggggggggggggggggggggggggggggg', labelValue: 'mylabelvalue', useHardwareLabels: false}); - } else if (sizeToCheck == "value") { - cy.addMachInvLabel({labelName: 'mylabelname', labelValue: 'valuetoolonggggggggggggggggggggggggggggggggggggggggggggggggggggg', useHardwareLabels: false}); - } + sizeToCheck == "name" ? cy.addMachInvLabel('labeltoolonggggggggggggggggggggggggggggggggggggggggggggggggggggg', 'mylabelvalue', false) : null; + sizeToCheck == "value" ? cy.addMachInvLabel('mylabelname', 'valuetoolonggggggggggggggggggggggggggggggggggggggggggggggggggggg', false) : null; // A banner should appear alerting you about the size exceeded cy.get('.banner > span'); // Create button should be disabled @@ -565,8 +518,7 @@ Cypress.Commands.add('checkLabelSize', ({ // OS Versions commands // Add an OS version channel -Cypress.Commands.add('addOsVersionChannel', ({ - channelVersion}) => { +Cypress.Commands.add('addOsVersionChannel', (channelVersion) => { var channelRepo = `registry.opensuse.org/isv/rancher/elemental/${channelVersion}/teal53/15.4/rancher/elemental-teal-channel/5.3:latest`; cy.clickNavMenu(["Advanced", "OS Version Channels"]); cy.getBySel('masthead-create') diff --git a/tests/cypress/latest/support/e2e.ts b/tests/cypress/latest/support/e2e.ts index 7ccbcc207..7d18f4c1d 100644 --- a/tests/cypress/latest/support/e2e.ts +++ b/tests/cypress/latest/support/e2e.ts @@ -21,7 +21,7 @@ declare global { // Functions declared in commands.ts addHelmRepo(repoName: string, repoUrl: string, repoType?: string,): Chainable; addMachInvAnnotation(annotationName: string, annotationValue: string):Chainable; - addMachInvLabel(labelName: string, labelValue: string, useHardwareLabels: boolean):Chainable; + addMachInvLabel(labelName: string, labelValue: string, useHardwareLabels?: boolean):Chainable; addMachRegAnnotation(annotationName: string, annotationValue: string):Chainable; addMachRegLabel(labelName: string, labelValue: string):Chainable; addOsVersionChannel(channelVersion: string): Chainable; @@ -29,7 +29,7 @@ declare global { checkFilter(filterName: string, testFilterOne: boolean, testFilterTwo: boolean, shouldNotMatch: boolean): Chainable; checkLabelSize(sizeToCheck: string): Chainable; checkMachInvAnnotation(machRegName: string, annotationName: string, annotationValue: string):Chainable; - checkMachInvLabel(machRegName: string, labelName: string, labelValue: string, useHardwareLabels: boolean, afterBoot: boolean):Chainable; + checkMachInvLabel(machRegName: string, labelName: string, labelValue: string, afterBoot: boolean, useHardwareLabels?: boolean):Chainable; checkMachRegAnnotation(machRegName: string, annotationName: string, annotationValue: string):Chainable; checkMachRegLabel(machRegName: string, labelName: string, labelValue: string):Chainable; clickButton(label: string,): Chainable; @@ -37,8 +37,8 @@ declare global { clickElementalMenu(label: string,): Chainable; clickNavMenu(listLabel: string[],): Chainable; confirmDelete(): Chainable; - createMachReg(machRegName: string, namespace?: string, checkLabels?: boolean, checkAnnotations?: boolean, checkIsoBuilding?: boolean, - customCloudConfig?: string, checkDefaultCloudConfig?: boolean): Chainable; + createMachReg(machRegName: string, namespace?: string, checkLabels?: boolean, checkAnnotations?: boolean, checkInventoryLabels?: boolean, + checkInventoryAnnotations?: boolean, checkIsoBuilding?: boolean, customCloudConfig?: string, checkDefaultCloudConfig?: boolean): Chainable; deleteAllResources():Chainable; deleteMachReg(machRegName: string): Chainable; editMachReg(machRegName: string, addLabel?: boolean, addAnnotation?: boolean, withYAML?: boolean): Chainable;