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

[RHOAIENG-12310] Error cases for storage class admin table #3213

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 14 additions & 5 deletions frontend/src/__mocks__/mockStorageClasses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,28 @@ export const mockStorageClassList = (
items: storageClasses,
});

export const buildMockStorageClass = (
export const buildMockStorageClassConfig = (
mockStorageClass: MockStorageClass,
config: Partial<StorageClassConfig>,
): string =>
JSON.stringify({
...JSON.parse(
String(mockStorageClass.metadata.annotations?.['opendatahub.io/sc-config'] ?? null),
),
...config,
});

export const buildMockStorageClass = (
mockStorageClass: MockStorageClass,
config: Partial<StorageClassConfig> | string,
): MockStorageClass => ({
...mockStorageClass,
metadata: {
...mockStorageClass.metadata,
annotations: {
...mockStorageClass.metadata.annotations,
'opendatahub.io/sc-config': JSON.stringify({
...JSON.parse(String(mockStorageClass.metadata.annotations?.['opendatahub.io/sc-config'])),
...config,
}),
'opendatahub.io/sc-config':
typeof config !== 'string' ? buildMockStorageClassConfig(mockStorageClass, config) : config,
},
},
});
Expand Down
36 changes: 31 additions & 5 deletions frontend/src/__tests__/cypress/cypress/pages/storageClasses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,32 @@ class StorageClassesTableRow extends TableRow {
return this.find().findByTestId('openshift-sc-default-label');
}

findEnableSwitch() {
findEnableSwitchInput() {
return this.find().findByTestId('enable-switch');
}

findDefaultRadio() {
findDefaultRadioInput() {
return this.find().findByTestId('set-default-radio');
}

findOpenshiftScName() {
return this.find().find(`[data-label="Openshift storage class"]`);
findDisplayNameValue() {
return this.find().find(`[data-label="Display name"]`);
}

findEnableValue() {
return this.find().find(`[data-label="Enable"]`);
}

findDefaultValue() {
return this.find().find(`[data-label="Default"]`);
}

findLastModifiedValue() {
return this.find().find(`[data-label="Last modified"]`);
}

findCorruptedMetadataAlert() {
return cy.findByTestId('corrupted-metadata-alert');
}
}

Expand All @@ -48,13 +64,19 @@ class StorageClassesTable {
}

getRowByName(name: string) {
return new StorageClassesTableRow(() =>
this.find().find(`[data-label="Openshift storage class"]`).contains(name).parents('tr'),
);
}

getRowByConfigName(name: string) {
return new StorageClassesTableRow(() =>
this.find().find(`[data-label="Display name"]`).contains(name).parents('tr'),
);
}

findRowByName(name: string) {
return this.getRowByName(name).find();
return this.getRowByConfigName(name).find();
}

mockUpdateStorageClass(storageClassName: string, times?: number) {
Expand Down Expand Up @@ -119,6 +141,10 @@ class StorageClassEditModal extends Modal {
return this.findFooter().findByTestId('modal-submit-button');
}

findInfoAlert() {
return this.find().findByTestId('edit-sc-modal-info-alert');
}

mockUpdateStorageClass(storageClassName: string, times?: number) {
return cy.interceptOdh(
`PUT /api/storage-class/:name/config`,
Expand Down
Loading
Loading