diff --git a/tests/cypress/e2e/unit_tests/first_login_rancher.spec.ts b/tests/cypress/e2e/unit_tests/first_login_rancher.spec.ts index 845634fe..09f74a7c 100644 --- a/tests/cypress/e2e/unit_tests/first_login_rancher.spec.ts +++ b/tests/cypress/e2e/unit_tests/first_login_rancher.spec.ts @@ -31,7 +31,7 @@ describe('First login on Rancher', { tags: '@login' }, () => { cy.contains('Dashboard').should('be.visible'); cypressLib.accesMenu('Clusters'); cy.fleetNamespaceToggle('fleet-local'); - cy.verifyTableRow(0, 'Active', ' ' ); + cy.verifyTableRow(0, 'Active'); cy.get("td[data-testid='sortable-cell-0-2']", { timeout: 300000 }).should("not.contain", '0'); }) ); diff --git a/tests/cypress/e2e/unit_tests/p0_fleet.spec.ts b/tests/cypress/e2e/unit_tests/p0_fleet.spec.ts index 93d790c3..c277039f 100644 --- a/tests/cypress/e2e/unit_tests/p0_fleet.spec.ts +++ b/tests/cypress/e2e/unit_tests/p0_fleet.spec.ts @@ -44,6 +44,8 @@ describe('Test Fleet deployment on PUBLIC repos', { tags: '@p0' }, () => { cy.contains('apiVersion: fleet.cattle.io/v1alpha1').should('be.visible'); cy.clickButton('Create') cy.checkGitRepoStatus(repoName, '1 / 1', '6 / 6'); + // Click on "Resources" option + cy.get('a[data-testid="btn-resources"]').contains('Resources').should('be.visible').click(); cy.verifyTableRow(1, 'Service', 'frontend'); cy.verifyTableRow(3, 'Service', 'redis-master'); cy.verifyTableRow(5, 'Service', 'redis-slave'); diff --git a/tests/cypress/e2e/unit_tests/p1_fleet.spec.ts b/tests/cypress/e2e/unit_tests/p1_fleet.spec.ts index 000def62..6254846e 100644 --- a/tests/cypress/e2e/unit_tests/p1_fleet.spec.ts +++ b/tests/cypress/e2e/unit_tests/p1_fleet.spec.ts @@ -263,7 +263,9 @@ if (!/\/2\.7/.test(Cypress.env('rancher_version'))) { cy.accesMenuSelection('local', 'Workloads'); cy.nameSpaceMenuToggle('All Namespaces'); cy.filterInSearchBox('fleet-controller'); - cy.verifyTableRow(0, 'Running', 'fleet-controller') + cy.verifyTableRow(0, 'Active', 'fleet-controller') + // This is to check "Running" count is present behind dropdown + cy.get('span.counts-label').contains('Running').should('exist'); cy.deleteAllFleetRepos(); }) ) diff --git a/tests/cypress/support/commands.ts b/tests/cypress/support/commands.ts index 8ae7a1e0..63e82620 100644 --- a/tests/cypress/support/commands.ts +++ b/tests/cypress/support/commands.ts @@ -141,39 +141,30 @@ Cypress.Commands.add('open3dotsMenu', (name, selection, checkNotInMenu=false) => } }); -// Verify textvalues in table giving the row number -// More items can be added with new ".and" -Cypress.Commands.add('verifyTableRow', (rowNumber, expectedText1, expectedText2) => { - // Adding small wait to give time for things to settle a bit - // Could not find a better way to wait, but can be improved - cy.wait(1000) - // Ensure table is loaded and visible - cy.contains('tr.main-row[data-testid="sortable-table-0-row"]').should('not.be.empty', { timeout: 25000 }); - cy.get(`table > tbody > tr.main-row[data-testid="sortable-table-${rowNumber}-row"]`, { timeout: 60000 }).should(($row) => { - // Replace whitespaces by a space and trim the string for both expected texts - const text = $row.text().replace(/\s+/g, ' ').trim(); - - // Check if expectedTextX is a regular expression or a string and perform the assertion - if (expectedText1) { - // If expectedText1 is provided, perform the check - if (expectedText1 instanceof RegExp) { - expect(text).to.match(expectedText1); - } else { - expect(text).to.include(expectedText1); - } - } - - if (expectedText2) { - // If expectedText2 is provided, perform the check - if (expectedText2 instanceof RegExp) { - expect(text).to.match(expectedText2); - } else { - expect(text).to.include(expectedText2); - } - } - }); +// Verify all elemennts desired in a table, given an specific row +Cypress.Commands.add('verifyTableRow', (rowNumber, ...expectedTexts) => { + // Adding small wait to give time for things to settle a bit + // Could not find a better way to wait, but can be improved + cy.wait(1000) + + cy.get(`table > tbody > tr.main-row[data-testid="sortable-table-${rowNumber}-row"]`, { timeout: 60000 }).should('be.visible').then(($row) => { + + // Replace whitespaces by a space and trim the string for both expected texts + const text = $row.text().replace(/\s+/g, ' ').trim(); + + // Check if expectedTextX is a regular expression or a string and perform the assertion + expectedTexts.forEach(expectedText => { + if (expectedTexts instanceof RegExp) { + expect(text).to.match(expectedText); + } + else { + cy.contains(expectedText, { timeout: 30000 }).should('be.visible'); + } + }); + }); }); + // Namespace Toggle Cypress.Commands.add('nameSpaceMenuToggle', (namespaceName) => { cy.get('.top > .ns-filter').should('be.visible'); @@ -348,7 +339,7 @@ Cypress.Commands.add('assignRoleToUser', (userName, roleName) => { // Sortering by Age so first row is the desired user cy.contains('Age').should('be.visible').click(); // Verifying name only given in 2.9 there is only icon - cy.verifyTableRow(0, userName, ''); + cy.verifyTableRow(0, userName); }) // Delete created user diff --git a/tests/cypress/support/e2e.ts b/tests/cypress/support/e2e.ts index 31d82a85..ba3bc3ec 100644 --- a/tests/cypress/support/e2e.ts +++ b/tests/cypress/support/e2e.ts @@ -25,7 +25,7 @@ declare global { gitRepoAuth(AuthType: string, userOrPublicKey?: string, pwdOrPrivateKey?: string, gitOrHelmAuth?: string, helmUrlRegex?: string): Chainable; addFleetGitRepo(repoName: string, repoUrl?: string, branch?: string, path?: string, fleetNamespace?: string): Chainable; fleetNamespaceToggle(toggleOption: string): Chainable; - verifyTableRow(rowNumber: number, expectedText1?: string|RegExp, expectedText2?: string|RegExp): Chainable; + verifyTableRow(rowNumber: number, expectedTexts?: string|RegExp): Chainable; nameSpaceMenuToggle(namespaceName: string): Chainable; accesMenuSelection(firstAccessMenu: string, secondAccessMenu?: string, clickOption?: string): Chainable; filterInSearchBox(filterText: string): Chainable;