Skip to content

Commit 6ea6c60

Browse files
authored
Fix access mode e2e tests and add more test cases (opendatahub-io#5493)
* Fix access mode e2e tests and add more test cases * fix tests * address comments * address comments * address review comments
1 parent 38b4d17 commit 6ea6c60

16 files changed

Lines changed: 610 additions & 151 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*.md
2+
*.yaml
3+
*.yml
4+
*.json
5+
results/
6+
node_modules/
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# testClusterStorageAccessModes.cy.ts Test Data #
2+
projectName: "test-cluster-storage-access-modes"
3+
storageClassRWO: "sc-rwo-preset"
4+
storageClassRWX: "sc-rwx-preset"
5+
storageClassROX: "sc-rox-preset"
6+
storageClassRWOP: "sc-rwop-preset"
7+
storageClassMultiAccess: "sc-multi-preset"
8+
storageName: "test-storage-rwx"
9+
storageDescription: "Test storage with ReadWriteMany access mode"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# testWorkbenchStorageClasses.cy.ts Test Data #
2+
projectName: "test-workbench-storage-preset"
3+
storageClassRWO: "sc-rwo"
4+
storageClassMultiAccess: "sc-multi-access"
5+
workbenchRWO: "wb-rwo-test"
6+
workbenchMultiAccessA: "wb-multi-a"
7+
workbenchMultiAccessB: "wb-multi-b"
8+
storageRWO: "storage-rwo"
9+
storageMultiAccess: "storage-multi"
10+
mountPathA: "mnt/path-a"
11+
mountPathB: "mnt/path-b"
12+
mountPathC: "mnt/path-c"

frontend/src/__tests__/cypress/cypress/pages/clusterStorage.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ class SelectStorageClass {
7373
}
7474

7575
selectStorageClassSelectOption(name: string | RegExp) {
76-
cy.findByRole('option', { name, hidden: true }).click();
76+
// Use contains to find the visible option text and click it
77+
cy.contains('[role="option"]', name).should('be.visible').click();
7778
}
7879

7980
findSelectStorageClassLabel(name: string | RegExp, accessMode: AccessMode) {
@@ -284,12 +285,16 @@ class ClusterStorage {
284285
);
285286
}
286287

287-
findCreateButton() {
288-
return cy.findByTestId('cluster-storage-button');
289-
}
290-
291-
findCreateButtonFromActions() {
292-
return cy.findByTestId('actions-cluster-storage-button');
288+
findAddClusterStorageButton() {
289+
// Use Cypress's built-in handling to try one selector, then another if the first fails
290+
return cy.get('body').then(() =>
291+
cy
292+
.get(
293+
'[data-testid="cluster-storage-button"], [data-testid="actions-cluster-storage-button"]',
294+
)
295+
.first()
296+
.then(($el) => cy.wrap($el)),
297+
);
293298
}
294299

295300
findKebabToggle() {

frontend/src/__tests__/cypress/cypress/pages/workbench.ts

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,35 @@
1+
import type { AccessMode } from '#~/__tests__/cypress/cypress/types';
12
import { K8sNameDescriptionField } from '#~/__tests__/cypress/cypress/pages/components/subComponents/K8sNameDescriptionField';
23
import { Contextual } from './components/Contextual';
34
import { Modal } from './components/Modal';
45
import { TableRow } from './components/table';
56

7+
class SelectStorageClass {
8+
find() {
9+
return cy.findByTestId('storage-classes-selector');
10+
}
11+
12+
selectStorageClassSelectOption(name: string | RegExp) {
13+
cy.findByRole('option', { name, hidden: true }).click();
14+
}
15+
16+
findSelectStorageClassLabel(name: string | RegExp, accessMode: AccessMode) {
17+
return cy.findByRole('option', { name, hidden: true }).findByTestId(`${accessMode}-label`);
18+
}
19+
}
620
class StorageModal extends Modal {
721
constructor() {
822
super('Add storage to Test Notebook');
923
}
1024

25+
findNameInput() {
26+
return this.find().findByTestId('create-new-storage-name');
27+
}
28+
29+
findStorageClassSelect() {
30+
return new SelectStorageClass();
31+
}
32+
1133
selectExistingPersistentStorage(name: string) {
1234
cy.findByTestId('persistent-storage-group')
1335
.findByRole('button', { name: 'Typeahead menu toggle' })
@@ -16,7 +38,7 @@ class StorageModal extends Modal {
1638
}
1739

1840
findSubmitButton() {
19-
return this.find().findByTestId('attach-storage');
41+
return this.find().findByTestId('modal-submit-button');
2042
}
2143

2244
findWorkbenchRestartAlert() {
@@ -26,6 +48,18 @@ class StorageModal extends Modal {
2648
findMountField() {
2749
return this.find().findByTestId('mount-path-folder-value');
2850
}
51+
52+
findRWOAccessMode() {
53+
return this.find().findByTestId('ReadWriteOnce-radio');
54+
}
55+
56+
findRWXAccessMode() {
57+
return this.find().findByTestId('ReadWriteMany-radio');
58+
}
59+
60+
findROXAccessMode() {
61+
return this.find().findByTestId('ReadOnlyMany-radio');
62+
}
2963
}
3064
class WorkbenchPage {
3165
visit(projectName: string) {
@@ -397,6 +431,27 @@ class StorageTable {
397431
>,
398432
);
399433
}
434+
435+
/**
436+
* Verify that a storage with a specific name has the expected access mode
437+
* @param storageName - The name of the storage to find
438+
* @param accessMode - The expected access mode label (e.g., 'ReadWriteOnce')
439+
*/
440+
verifyStorageAccessMode(storageName: string, accessMode: string) {
441+
this.find().within(() => {
442+
cy.contains('tr', storageName).within(() => {
443+
cy.contains(accessMode).should('exist');
444+
});
445+
});
446+
}
447+
448+
/**
449+
* Find a table row by storage name
450+
* @param storageName - The name of the storage to find
451+
*/
452+
findRowByName(storageName: string) {
453+
return this.find().contains('tr', storageName);
454+
}
400455
}
401456

402457
class NotebookImageGroup extends Contextual<HTMLElement> {}
@@ -451,6 +506,10 @@ class CreateSpawnerPage {
451506
return cy.findByTestId('existing-storage-button');
452507
}
453508

509+
findCreateStorageButton() {
510+
return cy.findByTestId('create-storage-button');
511+
}
512+
454513
selectPVSize(name: string) {
455514
this.findPVSizeSelectButton().click();
456515
cy.findByRole('menuitem', { name }).click();

0 commit comments

Comments
 (0)