Skip to content

Commit

Permalink
Show no-default alert correctly when first loading storage classes se…
Browse files Browse the repository at this point in the history
…ttings page (opendatahub-io#3427)
  • Loading branch information
DaoDaoNoCode authored Nov 5, 2024
1 parent 915b866 commit 23821ad
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ class StorageClassesPage {
return cy.findByTestId('storage-classes-empty-state');
}

findNoDefaultAlert() {
return cy.findByTestId('no-default-storage-class-alert');
}

mockGetStorageClasses(storageClasses?: StorageClassKind[], times?: number) {
return cy.interceptK8sList(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,5 +434,21 @@ describe('Storage classes', () => {
toolbar.fillSearchInput('test');
storageClassesTable.findRows().should('have.length', 1);
});

it('should not show no default alert when there is an OpenShift default storage class', () => {
storageClassesPage.mockGetStorageClasses([openshiftDefaultStorageClass]);
storageClassesTable.mockUpdateStorageClass(openshiftDefaultStorageClass.metadata.name, 1);
storageClassesPage.visit();

storageClassesPage.findNoDefaultAlert().should('not.exist');
});

it('should show no default alert when there is no OpenShift default storage classes', () => {
storageClassesPage.mockGetStorageClasses([otherStorageClass]);
storageClassesTable.mockUpdateStorageClass(otherStorageClass.metadata.name, 1);
storageClassesPage.visit();

storageClassesPage.findNoDefaultAlert().should('exist');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export const StorageClassContextProvider: React.FC<StorageClassContextProviderPr
if (successResponses.length) {
await refresh();

if (!defaultStorageClassName) {
if (!openshiftDefaultScName) {
setIsAutoDefaultAlertOpen(true);
}
}
Expand Down
1 change: 1 addition & 0 deletions frontend/src/pages/storageClasses/StorageClassesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ const StorageClassesPage: React.FC = () => {
isInline
title="Review default storage class"
actionClose={<AlertActionCloseButton onClose={() => setIsAlertOpen(false)} />}
data-testid="no-default-storage-class-alert"
>
Some OpenShift AI features won&apos;t work without a default storage class. No
OpenShift default exists, so an OpenShift AI default was set automatically. Review
Expand Down

0 comments on commit 23821ad

Please sign in to comment.