From bdde5dccd1fffc7b368a1156207f5400376702e5 Mon Sep 17 00:00:00 2001 From: Julien ADAMEK Date: Thu, 27 Oct 2022 09:42:44 +0200 Subject: [PATCH] Use the elemental plugin in the UI CI (#468) * Use Elemental plugin in UI CI --- .github/workflows/e2e-obs-Dev.yaml | 2 - .github/workflows/e2e-obs-Stable.yaml | 2 - .github/workflows/e2e-obs-Staging.yaml | 2 - .github/workflows/e2e.yaml | 2 - .github/workflows/master-e2e.yaml | 6 +-- .github/workflows/ui-e2e.yaml | 5 +-- .../e2e/unit_tests/elemental_plugin.spec.ts | 40 +++++++++++++++++++ cypress/support/e2e.ts | 2 + cypress/support/elemental.ts | 14 +++---- cypress/support/functions.ts | 38 +++++++++++++++--- package.json | 12 +++--- tests/e2e/install_test.go | 11 +++-- 12 files changed, 95 insertions(+), 41 deletions(-) create mode 100644 cypress/e2e/unit_tests/elemental_plugin.spec.ts diff --git a/.github/workflows/e2e-obs-Dev.yaml b/.github/workflows/e2e-obs-Dev.yaml index 8da526447..bdd71c035 100644 --- a/.github/workflows/e2e-obs-Dev.yaml +++ b/.github/workflows/e2e-obs-Dev.yaml @@ -16,7 +16,6 @@ jobs: with: iso_to_test: https://download.opensuse.org/repositories/isv:/Rancher:/Elemental:/Dev:/Teal53/media/iso/elemental-teal.x86_64.iso cluster_name: cluster-k3s - dashboard_version: latest k8s_version_to_provision: v1.24.4+k3s1 rancher_channel: stable rancher_version: latest @@ -34,7 +33,6 @@ jobs: with: iso_to_test: https://download.opensuse.org/repositories/isv:/Rancher:/Elemental:/Dev:/Teal53/media/iso/elemental-teal.x86_64.iso cluster_name: cluster-rke2 - dashboard_version: latest k8s_version_to_provision: v1.24.4+rke2r1 rancher_channel: stable rancher_version: latest diff --git a/.github/workflows/e2e-obs-Stable.yaml b/.github/workflows/e2e-obs-Stable.yaml index 1d5bffa51..440f8c278 100644 --- a/.github/workflows/e2e-obs-Stable.yaml +++ b/.github/workflows/e2e-obs-Stable.yaml @@ -16,7 +16,6 @@ jobs: with: iso_to_test: https://download.opensuse.org/repositories/isv:/Rancher:/Elemental:/Stable:/Teal53/media/iso/elemental-teal.x86_64.iso cluster_name: cluster-k3s - dashboard_version: latest k8s_version_to_provision: v1.24.4+k3s1 rancher_channel: stable rancher_version: latest @@ -34,7 +33,6 @@ jobs: with: iso_to_test: https://download.opensuse.org/repositories/isv:/Rancher:/Elemental:/Stable:/Teal53/media/iso/elemental-teal.x86_64.iso cluster_name: cluster-rke2 - dashboard_version: latest k8s_version_to_provision: v1.24.4+rke2r1 rancher_channel: stable rancher_version: latest diff --git a/.github/workflows/e2e-obs-Staging.yaml b/.github/workflows/e2e-obs-Staging.yaml index dc472da46..de3c803cf 100644 --- a/.github/workflows/e2e-obs-Staging.yaml +++ b/.github/workflows/e2e-obs-Staging.yaml @@ -16,7 +16,6 @@ jobs: with: iso_to_test: https://download.opensuse.org/repositories/isv:/Rancher:/Elemental:/Staging:/Teal53/media/iso/elemental-teal.x86_64.iso cluster_name: cluster-k3s - dashboard_version: latest k8s_version_to_provision: v1.24.4+k3s1 rancher_channel: stable rancher_version: latest @@ -34,7 +33,6 @@ jobs: with: iso_to_test: https://download.opensuse.org/repositories/isv:/Rancher:/Elemental:/Staging:/Teal53/media/iso/elemental-teal.x86_64.iso cluster_name: cluster-rke2 - dashboard_version: latest k8s_version_to_provision: v1.24.4+rke2r1 rancher_channel: stable rancher_version: latest diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index d9ba41f02..83c139fed 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -21,7 +21,6 @@ jobs: credentials: ${{ secrets.GCP_CREDENTIALS }} with: cluster_name: cluster-k3s - dashboard_version: latest k8s_version_to_provision: v1.24.4+k3s1 rancher_channel: stable rancher_version: latest @@ -38,7 +37,6 @@ jobs: credentials: ${{ secrets.GCP_CREDENTIALS }} with: cluster_name: cluster-rke2 - dashboard_version: latest k8s_version_to_provision: v1.24.4+rke2r1 rancher_channel: stable rancher_version: latest diff --git a/.github/workflows/master-e2e.yaml b/.github/workflows/master-e2e.yaml index f43e6f8dd..7d832aae3 100644 --- a/.github/workflows/master-e2e.yaml +++ b/.github/workflows/master-e2e.yaml @@ -13,10 +13,6 @@ on: description: Name of the provisioned cluster required: true type: string - dashboard_version: - description: Version of the dashboard UI to use - required: true - type: string iso_to_test: description: ISO to test (default built one is empty) required: false @@ -136,7 +132,6 @@ jobs: # Looks a little bit weird but we have to keep the ISO in build! mv -f elemental-*.iso build/ - name: Clean local Helm repositories - if: ${{ inputs.test_type == 'cli' }} run: | # Clean Helm repo HELM_REPO=$(helm repo list 2>/dev/null | awk '(NR>1) { print $1 }') @@ -158,6 +153,7 @@ jobs: RANCHER_USER: admin SPEC: | cypress/e2e/unit_tests/first_connection.spec.ts + cypress/e2e/unit_tests/elemental_plugin.spec.ts cypress/e2e/unit_tests/menu.spec.ts cypress/e2e/unit_tests/machine_registration.spec.ts run: make -f tests/Makefile start-cypress-tests diff --git a/.github/workflows/ui-e2e.yaml b/.github/workflows/ui-e2e.yaml index 744960d64..71f0e7ffd 100644 --- a/.github/workflows/ui-e2e.yaml +++ b/.github/workflows/ui-e2e.yaml @@ -17,10 +17,9 @@ jobs: credentials: ${{ secrets.GCP_CREDENTIALS }} with: cluster_name: cluster-k3s - dashboard_version: elemental-dev k8s_version_to_provision: v1.24.4+k3s1 - rancher_channel: stable - rancher_version: latest + rancher_channel: latest + rancher_version: devel runner: elemental-e2e-ci-runner-spot-x86-64-1 start_condition: success test_type: ui diff --git a/cypress/e2e/unit_tests/elemental_plugin.spec.ts b/cypress/e2e/unit_tests/elemental_plugin.spec.ts new file mode 100644 index 000000000..242da3882 --- /dev/null +++ b/cypress/e2e/unit_tests/elemental_plugin.spec.ts @@ -0,0 +1,40 @@ +import { TopLevelMenu } from '~/cypress/support/toplevelmenu'; +import '~/cypress/support/functions'; +import { Elemental } from '../../support/elemental'; + +Cypress.config(); +describe('Install Elemental plugin', () => { + const topLevelMenu = new TopLevelMenu(); + const elemental = new Elemental(); + + 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.clickButton('OK'); + cy.contains('No Extensions installed', {timeout: 40000}); + }); + + it('Install Elemental plugin', () => { + topLevelMenu.openIfClosed(); + cy.contains('Extensions').click(); + cy.contains('elemental'); + cy.get('.plugin').contains('Install').click(); + cy.contains('Install Extension elemental'); + cy.clickButton('Install'); + cy.contains('Installing'); + cy.wait(20000); + }); +}); diff --git a/cypress/support/e2e.ts b/cypress/support/e2e.ts index ed2f09ed2..8c876f61e 100644 --- a/cypress/support/e2e.ts +++ b/cypress/support/e2e.ts @@ -11,6 +11,7 @@ declare global { confirmDelete(): Chainable; clickNavMenu(listLabel: string[],): Chainable; clickElementalMenu(label: string,): Chainable; + clickClusterMenu(listLabel: string[],): Chainable; typeValue(label: string, value: string, noLabel?: boolean, log?: boolean): Chainable; typeKeyValue(key: string, value: string,): Chainable; getDetail(name: string, type: string, namespace?: string): Chainable; @@ -22,6 +23,7 @@ declare global { checkMachRegAnnotation(machRegName: string, annotationName: string, annotationValue: string):Chainable; addMachRegAnnotation(annotationName: string, annotationValue: string):Chainable; editMachReg(machRegName: string, addLabel?: boolean, addAnnotation?: boolean, withYAML?: boolean): Chainable; + addHelmRepo(repoName: string, repoUrl: string, repoType?: string,): Chainable; } }} diff --git a/cypress/support/elemental.ts b/cypress/support/elemental.ts index 149c3c5f5..c25751e1b 100644 --- a/cypress/support/elemental.ts +++ b/cypress/support/elemental.ts @@ -3,9 +3,9 @@ export class Elemental { firstLogin() { cy.get('input').type(Cypress.env('password'), {log: false}); cy.clickButton('Log in with Local User'); - cy.contains('I agree').click('left'); + cy.contains('By checking').click('left'); cy.clickButton('Continue'); - cy.contains("Getting Started", {timeout: 10000}); + cy.get('[data-testid="banner-title"]').contains('Welcome to Rancher'); } elementalIcon() { @@ -24,15 +24,13 @@ export class Elemental { // Check all listed options once accordion is opened cy.get('li.child.nav-type').should(($lis) => { - expect($lis).to.have.length(8); + expect($lis).to.have.length(6); expect($lis.eq(0)).to.contain('Dashboard'); expect($lis.eq(1)).to.contain('Machine Registrations'); expect($lis.eq(2)).to.contain('Machine Inventories'); - expect($lis.eq(3)).to.contain('Mach. Inv. Selectors'); - expect($lis.eq(4)).to.contain('Mach. Inv. Selec. Templates'); - expect($lis.eq(5)).to.contain('Managed OS Versions'); - expect($lis.eq(6)).to.contain('Managed OS Version Channels'); - expect($lis.eq(7)).to.contain('OS Image Upgrades'); + expect($lis.eq(3)).to.contain('Managed OS Versions'); + expect($lis.eq(4)).to.contain('Managed OS Version Channels'); + expect($lis.eq(5)).to.contain('OS Image Upgrades'); }) } diff --git a/cypress/support/functions.ts b/cypress/support/functions.ts index f352e57a0..fb7544b4f 100644 --- a/cypress/support/functions.ts +++ b/cypress/support/functions.ts @@ -19,7 +19,7 @@ Cypress.Commands.add('login', (username = Cypress.env('username'), password = Cy cy.get('button').click(); cy.wait('@loginReq'); - cy.contains("Getting Started", {timeout: 10000}).should('be.visible'); + cy.get('[data-testid="banner-title"]').contains('Welcome to Rancher'); } if (cacheSession) { @@ -60,6 +60,13 @@ Cypress.Commands.add('typeValue', ({label, value, noLabel, log=true}) => { } }); +// 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); @@ -87,6 +94,27 @@ for (const command of ['visit', 'click', 'trigger', 'type', 'clear', 'reload', ' }); }; +// 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', {timeout: 8000}).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'); +}); + // Machine registration functions // Create a machine registration @@ -105,16 +133,16 @@ Cypress.Commands.add('createMachReg', ({machRegName, namespace='fleet-default', if (checkLabels) { cy.clickButton('Add Label'); cy.contains('.row', 'Labels').within(() => { - cy.get('.kv-item.key').type('myLabel1'); - cy.get('.kv-item.value').type('myLabelValue1'); + cy.get(':nth-child(2) > [data-layer="Content"]').type('myLabel1'); + cy.get(':nth-child(1) > .key-value > .kv-container > .value > .no-resize').type('myLabelValue1'); }) } if (checkAnnotations) { cy.clickButton('Add Annotation') cy.contains('.row', 'Annotations').within(() => { - cy.get('.kv-item.key').type('myAnnotation1'); - cy.get('.kv-item.value').type('myAnnotationValue1'); + cy.get(':nth-child(3) > [data-layer="Content"]').type('myAnnotation1'); + cy.get(':nth-child(3) > .key-value > .kv-container > .value > .no-resize').type('myAnnotationValue1'); }) } diff --git a/package.json b/package.json index eb21501ca..bebd63385 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "epinio-end-to-end-tests", + "name": "elemental-ui-e2e", "version": "1.0.0", - "description": "Cypress tests to test the Epinio UI", + "description": "Cypress tests to test the Elemental UI", "main": "index.js", "directories": { "doc": "docs" @@ -11,15 +11,15 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/epinio/epinio-end-to-end-tests.git" + "url": "git+https://github.com/rancher/elemental.git" }, "keywords": [], - "author": "Epinio team", + "author": "Elemental team", "license": "ISC", "bugs": { - "url": "https://github.com/epinio/epinio-end-to-end-tests/issues" + "url": "https://github.com/rancher/elemental/issues" }, - "homepage": "https://github.com/epinio/epinio-end-to-end-tests#readme", + "homepage": "https://github.com/rancher/elemental#readme", "dependencies": { "cy-verify-downloads": "^0.1.8", "cypress": "^10.0.0", diff --git a/tests/e2e/install_test.go b/tests/e2e/install_test.go index a71317fe6..de6cfa349 100644 --- a/tests/e2e/install_test.go +++ b/tests/e2e/install_test.go @@ -109,7 +109,6 @@ var _ = Describe("E2E - Install Rancher Manager", Label("install"), func() { // Set flags for Rancher Manager installation hostname := os.Getenv("HOSTNAME") - uiVersion := os.Getenv("DASHBOARD_VERSION") flags := []string{ "upgrade", "--install", "rancher", "rancher/rancher", "--namespace", "cattle-system", @@ -119,16 +118,16 @@ var _ = Describe("E2E - Install Rancher Manager", Label("install"), func() { "--set", "extraEnv[0].value=https://" + hostname, "--set", "extraEnv[1].name=CATTLE_BOOTSTRAP_PASSWORD", "--set", "extraEnv[1].value=rancherpassword", - "--set", "extraEnv[2].name=CATTLE_UI_DASHBOARD_INDEX", - "--set", "extraEnv[2].value=https://releases.rancher.com/dashboard/" + uiVersion + "/index.html", - "--set", "extraEnv[3].name=CATTLE_UI_OFFLINE_PREFERRED", - "--set", "extraEnv[3].value=Remote", "--set", "replicas=1", } // Set specified version if needed if rancherVersion != "" && rancherVersion != "latest" { - flags = append(flags, "--version", rancherVersion) + if rancherVersion == "devel" { + flags = append(flags, "--devel") + } else { + flags = append(flags, "--version", rancherVersion) + } } err = kubectl.RunHelmBinaryWithCustomErr(flags...)