From 72b351fb14e52c99103be9884759a6ddbdc97db0 Mon Sep 17 00:00:00 2001 From: Tal Hilzenrat Date: Mon, 2 Mar 2026 17:14:59 -0500 Subject: [PATCH] Adjust cypress flow to 4.20 --- cypress/support/commands.js | 25 +++++++++----- cypress/views/common.js | 16 ++++++--- cypress/views/devicesPage.js | 48 +++++++++++++------------- cypress/views/fleetsPage.js | 56 +++++++++++++++---------------- cypress/views/repositoriesPage.js | 24 ++++++------- 5 files changed, 92 insertions(+), 77 deletions(-) diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 3bf675a..f73c337 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -4,8 +4,8 @@ require('cypress-downloadfile/lib/downloadFileCommand') Cypress.Commands.add('login', (url=`${Cypress.env('host')}`, auth=`${Cypress.env('auth')}`, user=`${Cypress.env('username')}`, password=`${Cypress.env('password')}`) => { cy.visit(url) cy.origin(auth, { args: { username: user, password: password } }, ({ username, password }) => { - cy.get(':nth-child(1) > .pf-c-button', { timeout: 60000 }) - cy.contains('kube:admin').click() + //cy.get('.pf-c-button', { timeout: 60000 }) + cy.get('.pf-v6-c-button').contains('kube:admin').click() cy.get('#inputUsername').should('exist') cy.get('#inputUsername').should('be.visible') cy.get('#inputPassword').should('exist') @@ -14,14 +14,21 @@ Cypress.Commands.add('login', (url=`${Cypress.env('host')}`, auth=`${Cypress.env cy.get('#inputPassword').type(password) cy.get('#inputUsername').should('have.value', username) cy.get('#inputPassword').should('have.value', password) - cy.contains('button', 'Log in').click() + cy.get('#co-login-button').click() }) - cy.get('.pf-v5-c-modal-box__close > .pf-v5-c-button', { timeout: 60000 }) - cy.get('.pf-v5-c-modal-box__close > .pf-v5-c-button').should('be.visible') - cy.get('.pf-v5-c-modal-box__close > .pf-v5-c-button').click() - cy.url().should('include', `${Cypress.env('host')}`) - //cy.get('[data-test-id="cluster-dropdown-toggle"]', { timeout: 30000 }).should('be.visible').click() - //cy.get('button.pf-v5-c-menu__item').contains('All Clusters').click() + const tryCloseOnboardingModal = (attempt = 1, maxRetries = 5, retryDelay = 2000) => { + cy.get('body').then(($body) => { + const $btn = $body.find('[data-ouia-component-id="clustersOnboardingModal-ModalBoxCloseButton"]') + if ($btn.length > 0) { + cy.get('[data-ouia-component-id="clustersOnboardingModal-ModalBoxCloseButton"]').click() + } else if (attempt < maxRetries) { + cy.wait(retryDelay) + tryCloseOnboardingModal(attempt + 1, maxRetries, retryDelay) + } + }) + } + tryCloseOnboardingModal() + cy.url().should('include', `${Cypress.env('host')}`) }) Cypress.Commands.add('downloadClifile', (platform = `${Cypress.env('platform')}`, arch = `${Cypress.env('arch')}`) => { diff --git a/cypress/views/common.js b/cypress/views/common.js index 95a0560..c22978f 100644 --- a/cypress/views/common.js +++ b/cypress/views/common.js @@ -7,8 +7,16 @@ export const common = { * @param {string} page - The page to navigate to (e.g., 'Devices', 'Fleets', 'Repositories') */ navigateTo: (page) => { - cy.get('#nav-toggle').should('exist') - cy.get('#nav-toggle').click() + cy.get('#nav-toggle',{ timeout: 30000 }).should('exist') + // Only open the sidebar if it's collapsed (clicking when open would close it) + cy.get('body').then(($body) => { + const sidebarExpanded = + $body.find('.pf-v6-c-page__sidebar.pf-m-expanded').length > 0 || + $body.find('#nav-toggle').attr('aria-expanded') === 'true' + if (!sidebarExpanded) { + cy.get('#nav-toggle').click() + } + }) cy.contains('Edge Management').click() cy.contains(page).click() common.selectOrganizationIfNeeded('Default') @@ -17,7 +25,7 @@ export const common = { /** * Select organization if the selection page appears */ - selectOrganizationIfNeeded: (orgName = 'Default', maxRetries = 5, retryDelay = 1000) => { + selectOrganizationIfNeeded: (orgName = 'Default', maxRetries = 10, retryDelay = 1000) => { const checkForOrgSelection = (attempt = 1) => { cy.log(`Checking for organization selection page (attempt ${attempt}/${maxRetries})`) @@ -28,7 +36,7 @@ export const common = { cy.log(`Organization selection page detected, selecting ${orgName}`) cy.contains(orgName).click() cy.contains('button', 'Continue').click() - cy.get('.pf-v5-c-page', { timeout: 30000 }).should('exist') + cy.get('.pf-v6-c-page', { timeout: 30000 }).should('exist') } else if (attempt < maxRetries) { cy.log(`Organization selection not found yet, retrying...`) checkForOrgSelection(attempt + 1) diff --git a/cypress/views/devicesPage.js b/cypress/views/devicesPage.js index 4ac6f69..bed39fe 100644 --- a/cypress/views/devicesPage.js +++ b/cypress/views/devicesPage.js @@ -10,15 +10,15 @@ export const devicesPage = { approveDevice: (deviceName = 'test-device') => { common.navigateTo('Devices') - cy.get('h2.pf-v5-c-title.pf-m-3xl').contains('Devices pending approval') - cy.get('[data-label="Approve"] > .pf-v5-c-button').should('exist') - cy.get('[data-label="Approve"] > .pf-v5-c-button').should('be.visible') - cy.get('[data-label="Approve"] > .pf-v5-c-button').click() + cy.get('h2.pf-v6-c-title.pf-m-3xl').contains('Devices pending approval') + cy.get('[data-label="Approve"] > .pf-v6-c-button').should('exist') + cy.get('[data-label="Approve"] > .pf-v6-c-button').should('be.visible') + cy.get('[data-label="Approve"] > .pf-v6-c-button').click() cy.get('#rich-validation-field-deviceAlias').should('be.visible') cy.get('#rich-validation-field-deviceAlias').type(deviceName) cy.get('#rich-validation-field-deviceAlias').should('have.value', deviceName) - cy.get('.pf-v5-c-form__actions > .pf-m-primary').should('be.visible') - cy.get('.pf-v5-c-form__actions > .pf-m-primary').click() + cy.get('.pf-v6-c-form__actions > .pf-m-primary').should('be.visible') + cy.get('.pf-v6-c-form__actions > .pf-m-primary').click() cy.get('[data-label="Device status"]', { timeout: 50000 }).should('contain', 'Online') }, @@ -29,7 +29,7 @@ export const devicesPage = { common.navigateTo('Devices') cy.get('a > .fctl-resource-link__text').contains(currentName) - cy.get('.pf-v5-c-table__action > .pf-v5-c-menu-toggle').click() + cy.get('.pf-v6-c-table__action > .pf-v6-c-menu-toggle').click() cy.wait(1000) cy.contains('Edit device configurations').click() cy.wait(1000) @@ -37,15 +37,15 @@ export const devicesPage = { cy.get('#rich-validation-field-deviceAlias').should('have.value', currentName) cy.get('#rich-validation-field-deviceAlias').clear() cy.get('#rich-validation-field-deviceAlias').type(newName) - cy.get('.pf-v5-c-wizard__footer > .pf-m-primary').click() + cy.get('span.pf-v6-c-button__text').contains('Next').click() cy.get('#textfield-osImage').should('be.visible') cy.get('#textfield-osImage').clear() cy.get('#textfield-osImage').type(image) cy.get('#textfield-osImage').should('have.value', image) - cy.get('.pf-v5-c-wizard__footer > .pf-m-primary').click() - cy.get('.pf-v5-c-wizard__footer > .pf-m-primary').click() - cy.get('.pf-v5-c-wizard__footer > .pf-m-primary').click() - cy.get('.pf-v5-c-title > .pf-v5-l-grid > .pf-m-6-col-on-md', { timeout: 50000 }).should('contain', newName) + cy.get('span.pf-v6-c-button__text').contains('Next').click() + cy.get('span.pf-v6-c-button__text').contains('Next').click() + cy.get('span.pf-v6-c-button__text').contains('Save').click() + cy.get('.pf-v6-c-title > .pf-v6-l-grid > .pf-m-6-col-on-md', { timeout: 50000 }).should('contain', newName) }, /** @@ -54,20 +54,20 @@ export const devicesPage = { decommissionDevice: () => { common.navigateTo('Devices') - cy.get('.pf-v5-c-table__tbody > .pf-v5-c-table__tr > .pf-v5-c-table__check > label > input').should('be.visible') - cy.get('.pf-v5-c-table__tbody > .pf-v5-c-table__tr > .pf-v5-c-table__check > label > input').click() - cy.get('#devices-toolbar > :nth-child(1) > .pf-v5-c-toolbar__content-section > :nth-child(3) > .pf-v5-c-button').should('be.visible') - cy.get('#devices-toolbar > :nth-child(1) > .pf-v5-c-toolbar__content-section > :nth-child(3) > .pf-v5-c-button').click() + cy.get('.pf-v6-c-table__tbody > .pf-v6-c-table__tr > .pf-v6-c-table__check > label > input').should('be.visible') + cy.get('.pf-v6-c-table__tbody > .pf-v6-c-table__tr > .pf-v6-c-table__check > label > input').click() + cy.get('#devices-toolbar > :nth-child(1) > .pf-v6-c-toolbar__content-section > :nth-child(3) > .pf-v6-c-button').should('be.visible') + cy.get('#devices-toolbar > :nth-child(1) > .pf-v6-c-toolbar__content-section > :nth-child(3) > .pf-v6-c-button').click() cy.get('.pf-m-danger').should('be.visible') cy.get('.pf-m-danger').click() - cy.get('.pf-v5-c-table__thead > .pf-v5-c-table__tr > .pf-v5-c-table__check > label > input').should('be.visible') - cy.get('.pf-v5-c-table__thead > .pf-v5-c-table__tr > .pf-v5-c-table__check > label > input').click() - cy.get('.pf-v5-c-toolbar__group > :nth-child(3) > .pf-v5-c-button').should('be.visible') - cy.get('.pf-v5-c-toolbar__group > :nth-child(3) > .pf-v5-c-button').click() + cy.get('.pf-v6-c-table__thead > .pf-v6-c-table__tr > .pf-v6-c-table__check > label > input').should('be.visible') + cy.get('.pf-v6-c-table__thead > .pf-v6-c-table__tr > .pf-v6-c-table__check > label > input').click() + cy.get('.pf-v6-c-toolbar__group > :nth-child(3) > .pf-v6-c-button').should('be.visible') + cy.get('.pf-v6-c-toolbar__group > :nth-child(3) > .pf-v6-c-button').click() cy.get('.pf-m-danger').should('be.visible') cy.get('.pf-m-danger').click() - cy.get('.pf-v5-c-switch__toggle').should('be.visible') - cy.get('.pf-v5-c-switch__toggle').click() + cy.get('.pf-v6-c-switch__toggle').should('be.visible') + cy.get('.pf-v6-c-switch__toggle').click() }, /** @@ -80,7 +80,7 @@ export const devicesPage = { cy.get('a > .fctl-resource-link__text').click() cy.contains('Terminal').should('be.visible') cy.contains('Terminal').click() - cy.get('.pf-v5-l-bullseye', { timeout: 50000 }).should('be.visible') - cy.get('.pf-v5-l-bullseye').click() + cy.get('.pf-v6-l-bullseye', { timeout: 50000 }).should('be.visible') + cy.get('.pf-v6-l-bullseye').click() }, } diff --git a/cypress/views/fleetsPage.js b/cypress/views/fleetsPage.js index 9282e08..619adeb 100644 --- a/cypress/views/fleetsPage.js +++ b/cypress/views/fleetsPage.js @@ -10,20 +10,20 @@ export const fleetsPage = { createFleet: (img = Cypress.env('image'), fleetname = Cypress.env('fleetname')) => { common.navigateTo('Fleets') - cy.get(':nth-child(2) > .pf-v5-l-split > :nth-child(1) > .pf-v5-c-button').should('exist') - cy.get(':nth-child(2) > .pf-v5-l-split > :nth-child(1) > .pf-v5-c-button').should('be.visible') - cy.get(':nth-child(2) > .pf-v5-l-split > :nth-child(1) > .pf-v5-c-button').click() + cy.get(':nth-child(2) > .pf-v6-l-split > :nth-child(1) > .pf-v6-c-button').should('exist') + cy.get(':nth-child(2) > .pf-v6-l-split > :nth-child(1) > .pf-v6-c-button').should('be.visible') + cy.get(':nth-child(2) > .pf-v6-l-split > :nth-child(1) > .pf-v6-c-button').click() cy.get('#rich-validation-field-name').should('be.visible') cy.get('#rich-validation-field-name').type(fleetname) cy.get('#rich-validation-field-name').should('have.value', 'test-fleet') - cy.get('.pf-v5-l-stack__item > .pf-v5-c-label-group > .pf-v5-c-label-group__main > .pf-v5-c-label-group__list').click() - cy.get('.pf-v5-c-wizard__footer > .pf-m-primary').click() + cy.get('.pf-v6-l-stack__item > .pf-v6-c-label-group > .pf-v6-c-label-group__main > .pf-v6-c-label-group__list').click() + cy.get('span.pf-v6-c-button__text').contains('Next').click() cy.get('#textfield-osImage').should('be.visible') cy.get('#textfield-osImage').type(img) cy.get('#textfield-osImage').should('have.value', img) - cy.get('.pf-v5-c-wizard__footer > .pf-m-primary').click() - cy.get('.pf-v5-c-wizard__footer > .pf-m-primary').click() - cy.get('.pf-v5-c-wizard__footer > .pf-m-primary').click() + cy.get('span.pf-v6-c-button__text').contains('Next').click() + cy.get('span.pf-v6-c-button__text').contains('Next').click() + cy.get('span.pf-v6-c-button__text').contains('Create fleet').click() }, /** @@ -33,20 +33,20 @@ export const fleetsPage = { common.navigateTo('Fleets') cy.get('[data-label="Name"]').contains(fleetname) - cy.get('.pf-v5-c-table__action > .pf-v5-c-menu-toggle').click() - cy.get('td.pf-v5-c-table__td').then($cells => cy.wrap($cells.eq(-1))) - cy.get('.pf-v5-c-table__action > .pf-v5-c-menu-toggle').should('be.visible') - cy.get('[data-ouia-component-id="OUIA-Generated-DropdownItem-2"] > .pf-v5-c-menu__item > .pf-v5-c-menu__item-main > .pf-v5-c-menu__item-text').click() - cy.get(':nth-child(1) > .pf-v5-c-form__group-label > .pf-v5-c-form__label > .pf-v5-c-form__label-text').should('contain', 'Fleet name') - cy.get('.pf-v5-c-wizard__footer > .pf-m-primary').click() + cy.get('.pf-v6-c-table__action > .pf-v6-c-menu-toggle').click() + cy.get('td.pf-v6-c-table__td').then($cells => cy.wrap($cells.eq(-1))) + cy.get('.pf-v6-c-table__action > .pf-v6-c-menu-toggle').should('be.visible') + cy.get('[data-ouia-component-id="OUIA-Generated-DropdownItem-2"] > .pf-v6-c-menu__item > .pf-v6-c-menu__item-main > .pf-v6-c-menu__item-text').click() + cy.get(':nth-child(1) > .pf-v6-c-form__group-label > .pf-v6-c-form__label > .pf-v6-c-form__label-text').should('contain', 'Fleet name') + cy.get('span.pf-v6-c-button__text').contains('Next').click() cy.get('#textfield-osImage').should('be.visible') cy.get('#textfield-osImage').clear() cy.get('#textfield-osImage').type(img1) cy.get('#textfield-osImage').should('have.value', img1) - cy.get('.pf-v5-c-wizard__footer > .pf-m-primary').click() - cy.get('.pf-v5-c-wizard__footer > .pf-m-primary').click() - cy.get('.pf-v5-c-wizard__footer > .pf-m-primary').click() - cy.get('.pf-v5-c-title').should('contain', fleetname) + cy.get('span.pf-v6-c-button__text').contains('Next').click() + cy.get('span.pf-v6-c-button__text').contains('Next').click() + cy.get('span.pf-v6-c-button__text').contains('Next').click() + cy.get('.pf-v6-c-title').should('contain', fleetname) }, /** @@ -56,9 +56,9 @@ export const fleetsPage = { common.navigateTo('Fleets') cy.get('[data-label="Name"]').contains(fleetname) - cy.get('.pf-v5-c-table__tbody > .pf-v5-c-table__tr > .pf-v5-c-table__check > label > input').click() - cy.get('button.pf-v5-c-button.pf-m-secondary').contains('Delete fleets').should('be.visible') - cy.get('button.pf-v5-c-button.pf-m-secondary').contains('Delete fleets').click() + cy.get('.pf-v6-c-table__tbody > .pf-v6-c-table__tr > .pf-v6-c-table__check > label > input').click() + cy.get('button.pf-v6-c-button.pf-m-secondary').contains('Delete fleets').should('be.visible') + cy.get('button.pf-v6-c-button.pf-m-secondary').contains('Delete fleets').click() cy.get('.pf-m-danger').should('be.visible') cy.get('.pf-m-danger').click() }, @@ -69,21 +69,21 @@ export const fleetsPage = { importFleet: (repo = Cypress.env('repository'), fleetname = Cypress.env('fleetname'), resource = Cypress.env('resource'), resourcename = Cypress.env('resourcename'), revision = Cypress.env('revision')) => { common.navigateTo('Fleets') - cy.get(':nth-child(2) > .pf-v5-l-split > :nth-child(2) > .pf-v5-c-button').should('exist') - cy.get(':nth-child(2) > .pf-v5-l-split > :nth-child(2) > .pf-v5-c-button').should('be.visible') - cy.get(':nth-child(2) > .pf-v5-l-split > :nth-child(2) > .pf-v5-c-button').click() + cy.get(':nth-child(2) > .pf-v6-l-split > :nth-child(2) > .pf-v6-c-button').should('exist') + cy.get(':nth-child(2) > .pf-v6-l-split > :nth-child(2) > .pf-v6-c-button').should('be.visible') + cy.get(':nth-child(2) > .pf-v6-l-split > :nth-child(2) > .pf-v6-c-button').click() cy.get('#rich-validation-field-name').type(fleetname) cy.get('#textfield-url').type(repo) - cy.get('.pf-v5-c-wizard__footer > .pf-m-primary').click() + cy.get('span.pf-v6-c-button__text').contains('Next').click() cy.get('#rich-validation-field-resourceSyncs\\[0\\]\\.name').clear() cy.get('#rich-validation-field-resourceSyncs\\[0\\]\\.name').type('test-resource') cy.get('#textfield-resourceSyncs\\[0\\]\\.targetRevision').clear() cy.get('#textfield-resourceSyncs\\[0\\]\\.targetRevision').type(revision) cy.get('#textfield-resourceSyncs\\[0\\]\\.path').clear() cy.get('#textfield-resourceSyncs\\[0\\]\\.path').type(resourcename) - cy.get('.pf-v5-c-wizard__footer > .pf-m-primary').should('be.visible') - cy.get('.pf-v5-c-wizard__footer > .pf-m-primary').click() - cy.get('.pf-v5-c-wizard__footer > .pf-m-primary').click() + cy.get('span.pf-v6-c-button__text').contains('Next').should('be.visible') + cy.get('span.pf-v6-c-button__text').contains('Next').click() + cy.get('span.pf-v6-c-button__text').contains('Import').click() cy.get('td[data-label="Status"]', { timeout: 1000000 }).should('contain', 'Valid') }, } diff --git a/cypress/views/repositoriesPage.js b/cypress/views/repositoriesPage.js index 1113a6b..edb337c 100644 --- a/cypress/views/repositoriesPage.js +++ b/cypress/views/repositoriesPage.js @@ -10,20 +10,20 @@ export const repositoriesPage = { createRepository: (reponame = Cypress.env('repositoryname'), repo = Cypress.env('repository'), revision = Cypress.env('revision'), resource = Cypress.env('resource')) => { common.navigateTo('Repositories') - cy.get('.pf-v5-c-toolbar__content-section > :nth-child(2) > .pf-v5-c-button').should('be.visible') - cy.get('.pf-v5-c-toolbar__content-section > :nth-child(2) > .pf-v5-c-button').click() + cy.get('.pf-v6-c-toolbar__content-section > :nth-child(2) > .pf-v6-c-button').should('be.visible') + cy.get('.pf-v6-c-toolbar__content-section > :nth-child(2) > .pf-v6-c-button').click() cy.get('#rich-validation-field-name').should('be.visible') cy.get('#rich-validation-field-name').type('test-repository') cy.get('#rich-validation-field-name').should('have.value', 'test-repository') cy.get('#use-resource-syncs').should('be.visible') cy.get('#textfield-url').type(repo) cy.get('#textfield-url').should('have.value', repo) - cy.get('.pf-v5-c-form__section').should('be.visible') + cy.get('.pf-v6-c-form__section').should('be.visible') cy.contains('Resource sync name').type('test-resource') cy.get('#textfield-resourceSyncs\\[0\\]\\.targetRevision').type(revision) cy.get('#textfield-resourceSyncs\\[0\\]\\.path').type(resource) - cy.get('.pf-v5-c-form__actions > .pf-m-primary').click() - cy.get('.pf-v5-c-description-list__text > .pf-v5-l-flex > :nth-child(2)', { timeout: 100000 }).should('contain', 'Accessible') + cy.get('.pf-v6-c-form__actions > .pf-m-primary').click() + cy.get('.pf-v6-c-description-list__text > .pf-v6-l-flex > :nth-child(2)', { timeout: 100000 }).should('contain', 'Accessible') }, /** @@ -33,9 +33,9 @@ export const repositoriesPage = { common.navigateTo('Repositories') cy.contains(reponame).should('be.visible') - cy.get('.pf-v5-c-table__action').click() - cy.get('[data-ouia-component-id="OUIA-Generated-DropdownItem-1"] > .pf-v5-c-menu__item > .pf-v5-c-menu__item-main > .pf-v5-c-menu__item-text').contains('Edit repository').click() - cy.get('.pf-v5-c-check__body > .pf-m-link').click() + cy.get('.pf-v6-c-table__action').click() + cy.get('[data-ouia-component-id="OUIA-Generated-DropdownItem-1"] > .pf-v6-c-menu__item > .pf-v6-c-menu__item-main > .pf-v6-c-menu__item-text').contains('Edit repository').click() + cy.get('.pf-v6-c-check__body > .pf-m-link').click() cy.get('#rich-validation-field-resourceSyncs\\[1\\]\\.name').should('be.visible') cy.get('#rich-validation-field-resourceSyncs\\[1\\]\\.name').clear() cy.get('#rich-validation-field-resourceSyncs\\[1\\]\\.name').type('test-resource1') @@ -43,8 +43,8 @@ export const repositoriesPage = { cy.get('#textfield-resourceSyncs\\[1\\]\\.targetRevision').type(revision) cy.get('#textfield-resourceSyncs\\[1\\]\\.path').clear() cy.get('#textfield-resourceSyncs\\[1\\]\\.path').type(newyaml) - cy.get('.pf-v5-c-form__actions > .pf-m-primary').click() - cy.get('.pf-v5-c-description-list__text > .pf-v5-l-flex > :nth-child(2)', { timeout: 100000 }).should('contain', 'Accessible') + cy.get('.pf-v6-c-form__actions > .pf-m-primary').click() + cy.get('.pf-v6-c-description-list__text > .pf-v6-l-flex > :nth-child(2)', { timeout: 100000 }).should('contain', 'Accessible') }, /** @@ -54,8 +54,8 @@ export const repositoriesPage = { common.navigateTo('Repositories') cy.get('[data-label="Name"]').should('contain', reponame) - cy.get('.pf-v5-c-table__tbody > .pf-v5-c-table__tr > .pf-v5-c-table__check > label > input').should('be.visible') - cy.get('.pf-v5-c-table__tbody > .pf-v5-c-table__tr > .pf-v5-c-table__check > label > input').click() + cy.get('.pf-v6-c-table__tbody > .pf-v6-c-table__tr > .pf-v6-c-table__check > label > input').should('be.visible') + cy.get('.pf-v6-c-table__tbody > .pf-v6-c-table__tr > .pf-v6-c-table__check > label > input').click() cy.contains('Delete repositories').should('be.visible') cy.contains('Delete repositories').click() cy.get('.pf-m-danger').should('be.visible')