Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cypress e2e Test - Verify RHODS Explore Section Contains Only Expected ISVs #3522

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
cacbfe5
Initial WIP version of resource creation test
antowaddle Nov 20, 2024
0fa2201
Experimental changes to poll the UI for updates
antowaddle Nov 21, 2024
af87ad1
Working version if resource is present
antowaddle Nov 21, 2024
0e9868a
increase card timeout and delete active wait
FedeAlonso Nov 21, 2024
429f086
Merge pull request #1 from FedeAlonso/fix/active_wait
antowaddle Nov 21, 2024
443e530
Added changes to find namespace from variables
antowaddle Nov 22, 2024
966917f
Final changes to read variables, cleaned up utils
antowaddle Nov 22, 2024
69db944
Merge branch 'main' into cypress-RHOAIENG-14368
antowaddle Nov 22, 2024
a9ecfa3
Small change to a comment
antowaddle Nov 22, 2024
6cd6a3e
Dummy change to trigger mocks
antowaddle Nov 22, 2024
fcc6d18
Merge branch 'opendatahub-io:main' into main
antowaddle Nov 22, 2024
c7d471a
Merge branch 'main' into cypress-RHOAIENG-14368
antowaddle Nov 22, 2024
7628316
Save changes on cypress-RHOAIENG-12649
antowaddle Nov 25, 2024
847ad11
Changed file directories and names as requested on a PR comment
antowaddle Nov 25, 2024
552a516
Merge branch 'main' into cypress-RHOAIENG-14368
antowaddle Nov 25, 2024
80cc894
Merge branch 'cypress-RHOAIENG-14368' of https://github.com/antowaddl…
antowaddle Nov 25, 2024
163ed94
Merge remote-tracking branch 'origin/main' into cypress-RHOAIENG-12649
antowaddle Nov 25, 2024
0f7eead
Saving changes to current branch
antowaddle Nov 25, 2024
48c7435
Additional directory/file name changes
antowaddle Nov 25, 2024
14a39de
Additional changes to save
antowaddle Nov 25, 2024
6a93ec2
Resolving timeout issue breaking mock tests, also resolved latest PR …
antowaddle Nov 25, 2024
31b9723
Further changes for this test
antowaddle Nov 25, 2024
f2b636d
Changes to revert the exist method appended to getCardView.
antowaddle Nov 25, 2024
a9feb1b
Fixed linting
antowaddle Nov 25, 2024
aa9430e
Linting fixes
antowaddle Nov 25, 2024
eddd7d8
Merge branch 'main' into cypress-RHOAIENG-12649Merge branch 'main' of…
antowaddle Nov 25, 2024
680a0ee
Final comments added
antowaddle Nov 25, 2024
b6bc5b3
Merge branch 'main' into cypress-RHOAIENG-12649
antowaddle Nov 26, 2024
781e952
Fixed merge conflict
antowaddle Nov 26, 2024
b05b676
Small change to page object name
antowaddle Nov 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions frontend/src/__tests__/cypress/cypress/pages/explore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ class ExplorePage {
cy.findByTestId('explore-applications').should('be.visible');
cy.testA11y();
}

findCardLocator(cardName: string) {
return cy.get(`[data-testid="card ${cardName}"] label`);
}
}

export const explorePage = new ExplorePage();
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { HTPASSWD_CLUSTER_ADMIN_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers';
import { explorePage } from '~/__tests__/cypress/cypress/pages/explore';
import { getOcResourceNames } from '~/__tests__/cypress/cypress/utils/oc_commands/applications';

const applicationNamespace = Cypress.env('TEST_NAMESPACE');

describe('Verify RHODS Explore Section Contains Only Expected ISVs', () => {
let expectedISVs: string[];

before(() => {
// Setup: Retrieve the names of OdhApplication resources in the specified namespace.
getOcResourceNames(applicationNamespace, 'OdhApplication').then((metadataNames) => {
// Filter out the 'rhoai' card from the expected ISVs which displays in RHOAI
expectedISVs = metadataNames.filter((isv) => isv !== 'rhoai');
cy.log(`Expected ISVs (excluding 'rhoai'): ${expectedISVs.join(', ')}`);
});
});

it('Validate that default ISVs display in the Explore Section', () => {
// Authentication and navigation
cy.step('Login to the application');
cy.visitWithLogin('/', HTPASSWD_CLUSTER_ADMIN_USER);

// Navigate to the Explore page and search for each ISV
cy.step('Navigate to the Explore page');
explorePage.visit();

cy.step('Searching for each ISV based on the oc command output');
expectedISVs.forEach((isv) => {
explorePage
.findCardLocator(isv)
.should('be.visible')
.then(() => {
cy.log(`✅ Application found: ${isv}`);
});
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type { CommandLineResult } from '~/__tests__/cypress/cypress/types';

/**
* Executes an OpenShift command to retrieve resource names of a specified kind
* within a given application namespace.
*
* @param applicationNamespace - The namespace in which to search for the resources.
* @param kind - The kind of resource to retrieve (e.g., 'OdhApplication').
* @returns A Cypress.Chainable that resolves to an array of resource names.
*/
export const getOcResourceNames = (
applicationNamespace: string,
kind: string,
): Cypress.Chainable<string[]> => {
const ocCommand = `oc get ${kind} -n ${applicationNamespace} -o json`;
cy.log(`Executing command: ${ocCommand}`);

return cy.exec(ocCommand, { failOnNonZeroExit: false }).then((result: CommandLineResult) => {
const jsonResponse = JSON.parse(result.stdout);
const metadataNames = jsonResponse.items.map(
(item: { metadata: { name: string } }) => item.metadata.name,
);
return metadataNames;
});
};
Loading