Skip to content

Commit

Permalink
Cypress e2e - Implementation of Cypress Grep (#3609)
Browse files Browse the repository at this point in the history
* Initial WIP version of resource creation test

* Experimental changes to poll the UI for updates

* Working version if resource is present

* increase card timeout and delete active wait

* Added changes to find namespace from variables

* Final changes to read variables, cleaned up utils

* Small change to a comment

* Dummy change to trigger mocks

* Save changes on cypress-RHOAIENG-12649

* Changed file directories and names as requested on a PR comment

* Saving changes to current branch

* Additional directory/file name changes

* Additional changes to save

* Resolving timeout issue breaking mock tests, also resolved latest PR comments

* Further changes for this test

* Changes to revert the exist method appended to getCardView.

* Fixed linting

* Linting fixes

* Final comments added

* Fixed merge conflict

* Small change to page object name

* dummy commit

* Removed RHOAI bug workaround

* Removed comments

* Last comment change

* Initial Cypress Grep implementation commit

* Comitting additional package.json files

* Added splitting of Smoke tests into 2

---------

Co-authored-by: Fede Alonso <fealonso@redhat.com>
  • Loading branch information
antowaddle and FedeAlonso authored Jan 3, 2025
1 parent 0f2b4f8 commit ce63518
Show file tree
Hide file tree
Showing 22 changed files with 749 additions and 603 deletions.
46 changes: 46 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,12 @@
"tslib": "^2.5.0",
"typescript": "^5.3.3",
"url-loader": "^4.1.1",
"victory-core": "^37.1.1",
"victory-area": "^37.1.1",
"victory-axis": "^37.1.1",
"victory-bar": "^37.1.1",
"victory-box-plot": "^37.1.1",
"victory-chart": "^37.1.1",
"victory-core": "^37.1.1",
"victory-create-container": "^37.1.1",
"victory-cursor-container": "^37.1.1",
"victory-group": "^37.1.1",
Expand All @@ -174,6 +174,7 @@
"@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "^7.21.5",
"@cypress/code-coverage": "^3.12.34",
"@cypress/grep": "^4.1.0",
"@jsdevtools/coverage-istanbul-loader": "^3.0.5",
"@testing-library/cypress": "^10.0.1",
"@testing-library/dom": "^9.3.4",
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/__tests__/cypress/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import path from 'path';
import fs from 'fs';

// @ts-expect-error: Types are not available for this third-party library
import registerCypressGrep from '@cypress/grep/src/plugin';
import { defineConfig } from 'cypress';
import coverage from '@cypress/code-coverage/task';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
Expand Down Expand Up @@ -52,6 +55,7 @@ export default defineConfig({
},
ODH_PRODUCT_NAME: env.ODH_PRODUCT_NAME,
resolution: 'high',
grepFilterSpecs: true,
},
defaultCommandTimeout: 10000,
e2e: {
Expand All @@ -63,6 +67,7 @@ export default defineConfig({
: `cypress/tests/e2e/**/*.cy.ts`,
experimentalInteractiveRunEvents: true,
setupNodeEvents(on, config) {
registerCypressGrep(config);
cypressHighResolution(on, config);
coverage(on, config);
setupWebsockets(on, config);
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/__tests__/cypress/cypress/support/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
// @ts-expect-error: Types are not available for this third-party library
import registerCypressGrep from '@cypress/grep';

registerCypressGrep();

import chaiSubset from 'chai-subset';
import '@cypress/code-coverage/support';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HTPASSWD_CLUSTER_ADMIN_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers';

describe('application', { testIsolation: false }, () => {
it('should login and load page', () => {
it('should login and load page', { tags: ['@Smoke', '@SmokeSet2', '@Dashboard'] }, () => {
cy.visitWithLogin('/');
cy.findByRole('banner', { name: 'page masthead' }).contains(
HTPASSWD_CLUSTER_ADMIN_USER.USERNAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,27 @@ describe('Verify RHODS Explore Section Contains Only Expected ISVs', () => {
});
});

it('Validate that configured ISVs display in the Explore Section', () => {
// Authentication and navigation
cy.step('Login to the application');
cy.visitWithLogin('/', HTPASSWD_CLUSTER_ADMIN_USER);
it(
'Validate that configured ISVs display in the Explore Section',
{ tags: ['@Smoke', '@SmokeSet1', '@ODS-1890', '@Dashboard', '@Tier1'] },
() => {
// 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();
// 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 and rhoai-app manifest flag');
expectedISVs.forEach((isv) => {
explorePage
.findCardLocator(isv)
.should('be.visible')
.then(() => {
cy.log(`✅ Application found: ${isv}`);
});
});
});
cy.step('Searching for each ISV based on the oc command output and rhoai-app manifest flag');
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
Expand Up @@ -3,29 +3,33 @@ import { extractLauncherUrls } from '~/__tests__/cypress/cypress/utils/urlExtrac
import { header } from '~/__tests__/cypress/cypress/pages/components/Header';

describe('Verify the RHOAI Application and Switcher links in the Dashboard Navigation', () => {
it('Verify the various application tabs and switcher links are operational', () => {
// Authentication and navigation
cy.step('Log into the application');
cy.visitWithLogin('/', HTPASSWD_CLUSTER_ADMIN_USER);
it(
'Verify the various application tabs and switcher links are operational',
{ tags: ['@Smoke', '@SmokeSet1', '@ODS-771', '@Dashboard'] },
() => {
// Authentication and navigation
cy.step('Log into the application');
cy.visitWithLogin('/', HTPASSWD_CLUSTER_ADMIN_USER);

//Click the Application launcher then verify the Application and Switcher URLs
cy.step('Click the Application Launcher');
header.findApplicationLauncher().click();
//Click the Application launcher then verify the Application and Switcher URLs
cy.step('Click the Application Launcher');
header.findApplicationLauncher().click();

cy.step('Extract the Application and Switcher URLs');
extractLauncherUrls().then((urls) => {
cy.log(`Extracted URLs: ${urls.join(', ')}`);
cy.step('Extract the Application and Switcher URLs');
extractLauncherUrls().then((urls) => {
cy.log(`Extracted URLs: ${urls.join(', ')}`);

cy.step('Verify that each URL is accessible and that a 200 is returned');
urls.forEach((url) => {
cy.request(url).then((response) => {
const { status } = response;
const logMessage =
status === 200 ? `✅ ${url} - Status: ${status}` : `❌ ${url} - Status: ${status}`;
cy.log(logMessage);
expect(status).to.eq(200);
cy.step('Verify that each URL is accessible and that a 200 is returned');
urls.forEach((url) => {
cy.request(url).then((response) => {
const { status } = response;
const logMessage =
status === 200 ? `✅ ${url} - Status: ${status}` : `❌ ${url} - Status: ${status}`;
cy.log(logMessage);
expect(status).to.eq(200);
});
});
});
});
});
},
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,37 @@ describe('Verify that all the URLs referenced in the Manifest directory are oper
});
});

it('Reads the manifest directory, filters out test/sample URLs and validates the remaining URLs', () => {
const manifestsDir = '../../../../manifests';
cy.log(`Resolved manifests directory: ${manifestsDir}`);
it(
'Reads the manifest directory, filters out test/sample URLs and validates the remaining URLs',
{ tags: ['@Smoke', '@SmokeSet1', '@ODS-327', '@ODS-492', '@Dashboard'] },
() => {
const manifestsDir = '../../../../manifests';
cy.log(`Resolved manifests directory: ${manifestsDir}`);

// Extract URLs from the manifests directory using the registered task
cy.task<string[]>('extractHttpsUrls', manifestsDir).then((urls) => {
// Filter out Sample/Test URLs
const filteredUrls = urls.filter((url) => !isUrlExcluded(url, excludedSubstrings));
// Extract URLs from the manifests directory using the registered task
cy.task<string[]>('extractHttpsUrls', manifestsDir).then((urls) => {
// Filter out Sample/Test URLs
const filteredUrls = urls.filter((url) => !isUrlExcluded(url, excludedSubstrings));

// Log filtered URLs for debugging
filteredUrls.forEach((url) => {
cy.log(url);
});
// Log filtered URLs for debugging
filteredUrls.forEach((url) => {
cy.log(url);
});

// Verify that each remaining URL is accessible and returns a 200 status code
cy.step(
'Verify that each filtered URL is accessible and that a 200 is returned - currently failing due to issues linked RHOAIENG-9235',
);
filteredUrls.forEach((url) => {
cy.request(url).then((response) => {
const { status } = response;
const logMessage =
status === 200 ? `✅ ${url} - Status: ${status}` : `❌ ${url} - Status: ${status}`;
cy.log(logMessage);
expect(status).to.eq(200); // Assert that the response status is 200
// Verify that each remaining URL is accessible and returns a 200 status code
cy.step(
'Verify that each filtered URL is accessible and that a 200 is returned - currently failing due to issues linked RHOAIENG-9235',
);
filteredUrls.forEach((url) => {
cy.request(url).then((response) => {
const { status } = response;
const logMessage =
status === 200 ? `✅ ${url} - Status: ${status}` : `❌ ${url} - Status: ${status}`;
cy.log(logMessage);
expect(status).to.eq(200); // Assert that the response status is 200
});
});
});
});
});
},
);
});
Loading

0 comments on commit ce63518

Please sign in to comment.