Skip to content

Commit

Permalink
Fix: RHOAIENG-14370 Cypress test - Make it compatible with ODH (#3524)
Browse files Browse the repository at this point in the history
* test: Cypress - Verify users can create a workbench and connect an existent PersistentVolume

* lint fixes

* Add PVC size

* PR Fixes

* fix: Make the test ODH compatible
  • Loading branch information
FedeAlonso authored Nov 26, 2024
1 parent 12e390f commit dab6af5
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 14 deletions.
33 changes: 24 additions & 9 deletions frontend/src/__tests__/cypress/cypress/pages/workbench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,27 @@ class NotebookRow extends TableRow {
}
}

class AttachExistingStorageModal extends Modal {
constructor() {
super('Attach Existing Storage');
}

selectExistingPersistentStorage(name: string) {
cy.findByTestId('persistent-storage-group')
.findByPlaceholderText('Select a persistent storage')
.click();
cy.findByTestId('persistent-storage-group').contains('button.pf-v5-c-menu__item', name).click();
}

findStandardPathInput() {
return cy.findByTestId('mount-path-folder-value');
}

findAttachButton() {
return cy.findByTestId('modal-submit-button');
}
}

class AttachConnectionModal extends Modal {
constructor() {
super('Attach existing connections');
Expand Down Expand Up @@ -263,15 +284,8 @@ class CreateSpawnerPage {
return cy.findByTestId('value-unit-select');
}

findExsistingPersistentStorageRadio() {
return cy.findByTestId('persistent-existing-storage-type-radio');
}

selectExistingPersistentStorage(name: string) {
cy.findByTestId('persistent-storage-group')
.findByRole('button', { name: 'Typeahead menu toggle' })
.click();
cy.get('[id="dashboard-page-main"]').contains('button.pf-v5-c-menu__item', name).click();
findAttachExistingStorageButton() {
return cy.findByTestId('existing-storage-button');
}

selectPVSize(name: string) {
Expand Down Expand Up @@ -451,3 +465,4 @@ export const editSpawnerPage = new EditSpawnerPage();
export const storageModal = new StorageModal();
export const notFoundSpawnerPage = new NotFoundSpawnerPage();
export const attachConnectionModal = new AttachConnectionModal();
export const attachExistingStorageModal = new AttachExistingStorageModal();
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import type { PVCReplacements } from '~/__tests__/cypress/cypress/types';
import { projectDetails, projectListPage } from '~/__tests__/cypress/cypress/pages/projects';
import { workbenchPage, createSpawnerPage } from '~/__tests__/cypress/cypress/pages/workbench';
import {
workbenchPage,
createSpawnerPage,
attachExistingStorageModal,
} from '~/__tests__/cypress/cypress/pages/workbench';
import { clusterStorage } from '~/__tests__/cypress/cypress/pages/clusterStorage';
import { HTPASSWD_CLUSTER_ADMIN_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers';
import { loadPVCFixture } from '~/__tests__/cypress/cypress/utils/dataLoader';
Expand Down Expand Up @@ -69,8 +73,10 @@ describe('Workbench and PVSs tests', () => {
workbenchPage.findCreateButton().click();
createSpawnerPage.getNameInput().fill(workbenchName);
createSpawnerPage.findNotebookImage('s2i-minimal-notebook').click();
createSpawnerPage.findExsistingPersistentStorageRadio().click();
createSpawnerPage.selectExistingPersistentStorage(PVCDisplayName);
createSpawnerPage.findAttachExistingStorageButton().click();
attachExistingStorageModal.selectExistingPersistentStorage(PVCDisplayName);
attachExistingStorageModal.findStandardPathInput().fill(workbenchName);
attachExistingStorageModal.findAttachButton().click();
createSpawnerPage.findSubmitButton().click();

cy.step(`Wait for Workbench ${workbenchName} to display a "Running" status`);
Expand All @@ -81,7 +87,9 @@ describe('Workbench and PVSs tests', () => {

cy.step(`Check the cluster storage ${PVCDisplayName} is now connected to ${workbenchName}`);
projectDetails.findSectionTab('cluster-storages').click();
const csRow = clusterStorage.getClusterStorageRow(PVCDisplayName);
// TODO: Bug RHOAIENG-16239
// const csRow = clusterStorage.getClusterStorageRow(PVCDisplayName);
const csRow = clusterStorage.getClusterStorageRow(PVCName);
csRow.findConnectedWorkbenches().should('have.text', workbenchName);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ export const createPersistentVolumeClaim = (
yamlFilePath = 'resources/yaml/persistentVolumeClaim.yaml',
): Cypress.Chainable<CommandLineResult> => {
return cy.fixture(yamlFilePath).then((yamlContent) => {
cy.log(yamlContent);
const modifiedYamlContent = replacePlaceholdersInYaml(
yamlContent,
persistentVolumeClaimReplacements,
);
cy.log(modifiedYamlContent);
return applyOpenShiftYaml(modifiedYamlContent);
});
};

0 comments on commit dab6af5

Please sign in to comment.