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 - Verifies users can start, stop, launch and delete a running workbench from project details page #3637

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 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
3681244
dummy commit
antowaddle Nov 26, 2024
fb11cc5
Removed RHOAI bug workaround
antowaddle Nov 26, 2024
e0b9cca
Removed comments
antowaddle Nov 26, 2024
06167d8
Last comment change
antowaddle Nov 26, 2024
ae51479
Merge branch 'main' of github.com:opendatahub-io/odh-dashboard
antowaddle Dec 9, 2024
dac0574
Merge branch 'main' of github.com:opendatahub-io/odh-dashboard
antowaddle Dec 10, 2024
2cd1f7e
Merge branch 'main' of github.com:opendatahub-io/odh-dashboard
antowaddle Dec 11, 2024
645dca1
Merge branch 'main' of github.com:opendatahub-io/odh-dashboard
antowaddle Dec 13, 2024
f044a29
Merge branch 'main' of github.com:opendatahub-io/odh-dashboard
antowaddle Dec 16, 2024
7aa9059
Merge branch 'main' of github.com:opendatahub-io/odh-dashboard
antowaddle Dec 16, 2024
ff28a5d
Merge branch 'main' of github.com:opendatahub-io/odh-dashboard
antowaddle Dec 18, 2024
bca2ef3
Merge branch 'main' of https://github.com/antowaddle/odh-dashboard
antowaddle Dec 18, 2024
45dd834
Merge branch 'main' of github.com:opendatahub-io/odh-dashboard
antowaddle Dec 31, 2024
bd20cdd
Merge branch 'main' of github.com:opendatahub-io/odh-dashboard
antowaddle Jan 2, 2025
d7afb9d
Merge branch 'main' of github.com:opendatahub-io/odh-dashboard
antowaddle Jan 6, 2025
290d114
Merge branch 'main' of github.com:opendatahub-io/odh-dashboard
antowaddle Jan 7, 2025
60d6e41
Merge branch 'main' of github.com:opendatahub-io/odh-dashboard
antowaddle Jan 9, 2025
a87272f
Merge branch 'main' of github.com:opendatahub-io/odh-dashboard
antowaddle Jan 10, 2025
adbde2c
Initial commit
antowaddle Jan 10, 2025
38fc1fa
WIP Test
antowaddle Jan 10, 2025
dbae434
Committing running test
antowaddle Jan 13, 2025
1d8a2c8
Merge branch 'main' into cypress-RHOAIENG-17502
antowaddle Jan 13, 2025
2674191
Merge branch 'main' into cypress-RHOAIENG-17502
antowaddle Jan 13, 2025
c546e0b
Merge branch 'main' into cypress-RHOAIENG-17502
antowaddle Jan 13, 2025
f89748a
Merge branch 'main' into cypress-RHOAIENG-17502
antowaddle Jan 13, 2025
4233e4e
Merge branch 'main' into cypress-RHOAIENG-17502
antowaddle Jan 13, 2025
7ca7ca1
Merge branch 'main' into cypress-RHOAIENG-17502
FedeAlonso Jan 13, 2025
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# testWorkbenchControlSuite.cy.ts Test Data #
controlSuiteTestNamespace: 'dsp-wb-controls-test'
controlSuiteTestDescription: 'This is a test description.'
15 changes: 15 additions & 0 deletions frontend/src/__tests__/cypress/cypress/pages/workbench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,20 @@ class NotebookConfirmModal extends Modal {
}
}

class NotebookDeleteModal extends Modal {
constructor() {
super('Delete workbench?');
}

findDeleteModal() {
return cy.get('[data-testid="delete-modal-input"]');
}

findDeleteWorkbenchButton() {
return cy.contains('span.pf-v6-c-button__text', 'Delete workbench');
}
}

class NotebookRow extends TableRow {
shouldHaveNotebookImageName(name: string) {
this.find().find(`[data-label="Notebook image"]`).find('span').should('have.text', name);
Expand Down Expand Up @@ -484,6 +498,7 @@ class NotFoundSpawnerPage {
export const workbenchPage = new WorkbenchPage();
export const createSpawnerPage = new CreateSpawnerPage();
export const notebookConfirmModal = new NotebookConfirmModal();
export const notebookDeleteModal = new NotebookDeleteModal();
export const editSpawnerPage = new EditSpawnerPage();
export const storageModal = new StorageModal();
export const notFoundSpawnerPage = new NotFoundSpawnerPage();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import type { WBControlSuiteTestData } from '~/__tests__/cypress/cypress/types';
import { projectDetails, projectListPage } from '~/__tests__/cypress/cypress/pages/projects';
import {
workbenchPage,
createSpawnerPage,
notebookConfirmModal,
notebookDeleteModal,
} from '~/__tests__/cypress/cypress/pages/workbench';
import { HTPASSWD_CLUSTER_ADMIN_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers';
import { loadWBControlSuiteFixture } from '~/__tests__/cypress/cypress/utils/dataLoader';
import { createCleanProject } from '~/__tests__/cypress/cypress/utils/projectChecker';
import { deleteOpenShiftProject } from '~/__tests__/cypress/cypress/utils/oc_commands/project';

describe('Start, Stop, Launch and Delete a Workbench in RHOAI', () => {
let controlSuiteTestNamespace: string;
let controlSuiteTestDescription: string;

// Setup: Load test data and ensure clean state
before(() => {
return loadWBControlSuiteFixture('e2e/dataScienceProjects/testWorkbenchControlSuite.yaml')
.then((fixtureData: WBControlSuiteTestData) => {
controlSuiteTestNamespace = fixtureData.controlSuiteTestNamespace;
controlSuiteTestDescription = fixtureData.controlSuiteTestDescription;

if (!controlSuiteTestNamespace) {
throw new Error('Project name is undefined or empty in the loaded fixture');
}
cy.log(`Loaded project name: ${controlSuiteTestNamespace}`);
return createCleanProject(controlSuiteTestNamespace);
})
.then(() => {
cy.log(
`Project ${controlSuiteTestNamespace} confirmed to be created and verified successfully`,
);
});
});
after(() => {
// Delete provisioned Project
if (controlSuiteTestNamespace) {
cy.log(`Deleting Project ${controlSuiteTestNamespace} after the test has finished.`);
deleteOpenShiftProject(controlSuiteTestNamespace);
}
});

it(
'Starting, Stopping, Launching and Deleting a Workbench',
{ tags: ['@Sanity', '@SanitySet1', '@ODS-1818', '@ODS-1823', '@Dashboard'] },
() => {
const workbenchName = controlSuiteTestNamespace.replace('dsp-', '');

// Authentication and navigation
cy.step('Log into the application');
cy.visitWithLogin('/', HTPASSWD_CLUSTER_ADMIN_USER);

// Project navigation and select workbences
cy.step(`Navigate to workbenches tab of Project ${controlSuiteTestNamespace}`);
projectListPage.navigate();
projectListPage.filterProjectByName(controlSuiteTestNamespace);
projectListPage.findProjectLink(controlSuiteTestNamespace).click();
projectDetails.findSectionTab('workbenches').click();

// Create workbench
cy.step(`Create workbench ${controlSuiteTestNamespace}`);
workbenchPage.findCreateButton().click();
createSpawnerPage.getNameInput().fill(workbenchName);
createSpawnerPage.getDescriptionInput().type(controlSuiteTestDescription);
createSpawnerPage.findNotebookImage('code-server-notebook').click();
createSpawnerPage.findSubmitButton().click();

// Wait for workbench to run
cy.step(`Wait for workbench ${workbenchName} to display a "Running" status`);
const notebookRow = workbenchPage.getNotebookRow(workbenchName);
notebookRow.findNotebookDescription(controlSuiteTestDescription);
notebookRow.expectStatusLabelToBe('Running', 120000);
notebookRow.shouldHaveNotebookImageName('code-server');
notebookRow.shouldHaveContainerSize('Small');

// Stop workbench
cy.step('Stop workbench and validate it has been stopped');
notebookRow.findNotebookStop().click();
notebookConfirmModal.findStopWorkbenchButton().click();
notebookRow.expectStatusLabelToBe('Stopped', 120000);

// Restart workbench and confirm initiation
cy.step('Restart workbench and validate it starts successfully');
notebookRow.findNotebookStart().click();
notebookRow.expectStatusLabelToBe('Running', 120000);

// Delete workbench
cy.step('Delete workbench and confirm deleteion');
notebookRow.findKebab().click();
notebookRow.findKebabAction('Delete workbench').click();
notebookDeleteModal.findDeleteModal().click();
notebookDeleteModal.findDeleteModal().type(workbenchName);
notebookDeleteModal.findDeleteWorkbenchButton().click();
workbenchPage.findEmptyState().should('exist');
},
);
});
5 changes: 5 additions & 0 deletions frontend/src/__tests__/cypress/cypress/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ export type WBEditTestData = {
pvcEditDisplayName: string;
};

export type WBControlSuiteTestData = {
controlSuiteTestNamespace: string;
controlSuiteTestDescription: string;
};

export type CommandLineResult = {
code: number;
stdout: string;
Expand Down
10 changes: 10 additions & 0 deletions frontend/src/__tests__/cypress/cypress/utils/dataLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type {
PVCReplacements,
ResourcesData,
WBEditTestData,
WBControlSuiteTestData,
} from '~/__tests__/cypress/cypress/types';

// Load fixture function that returns DataScienceProjectData
Expand Down Expand Up @@ -36,3 +37,12 @@ export const loadPVCEditFixture = (fixturePath: string): Cypress.Chainable<WBEdi
return data;
});
};
export const loadWBControlSuiteFixture = (
fixturePath: string,
): Cypress.Chainable<WBControlSuiteTestData> => {
return cy.fixture(fixturePath, 'utf8').then((yamlContent: string) => {
const data = yaml.load(yamlContent) as WBControlSuiteTestData;

return data;
});
};
Loading