Skip to content

Commit

Permalink
Show deprecated alert correctly when the storage class is new created
Browse files Browse the repository at this point in the history
  • Loading branch information
DaoDaoNoCode committed Oct 28, 2024
1 parent 7e65faf commit 9bccad0
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ class ClusterStorageRow extends TableRow {
return this.find().findByTestId('storage-class-deprecated');
}

queryDeprecatedLabel() {
return this.find().get('[data-testid="storage-class-deprecated"]');
}

shouldHaveDeprecatedTooltip() {
cy.findByTestId('storage-class-deprecated-tooltip').should('be.visible');
return this;
Expand Down Expand Up @@ -144,6 +148,10 @@ class ClusterStorage {
);
}

shouldNotHaveDeprecatedAlertMessage() {
return cy.get('[date-testid="storage-class-deprecated-alert"]').should('not.exist');
}

closeDeprecatedAlert() {
cy.findByTestId('storage-class-deprecated-alert-close-button').click();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const initInterceptors = ({ isEmpty = false, storageClassName }: HandlersProps)
? []
: [
mockPVCK8sResource({ uid: 'test-id', storageClassName }),
mockPVCK8sResource({ displayName: 'Another Cluster Storage' }),
mockPVCK8sResource({ displayName: 'Another Cluster Storage', storageClassName }),
],
),
);
Expand Down Expand Up @@ -81,7 +81,23 @@ describe('ClusterStorage', () => {
}),
);

cy.interceptK8sList(StorageClassModel, mockStorageClassList());
cy.interceptK8sList(
StorageClassModel,
mockStorageClassList([
...mockStorageClasses,
buildMockStorageClass(
{
...mockStorageClasses[0],
metadata: {
...mockStorageClasses[0].metadata,
name: 'test-initial-storage-class',
annotations: {},
},
},
{},
),
]),
);
});

it('Check whether the Storage class column is present', () => {
Expand All @@ -103,6 +119,15 @@ describe('ClusterStorage', () => {
clusterStorage.shouldHaveDeprecatedAlertMessage();
clusterStorage.closeDeprecatedAlert();
});

it('Should hide deprecated alert when the storage class is not configured', () => {
initInterceptors({ storageClassName: 'test-initial-storage-class' });
clusterStorage.visit('test-project');

const clusterStorageRow = clusterStorage.getClusterStorageRow('Test Storage');
clusterStorageRow.queryDeprecatedLabel().should('not.exist');
clusterStorage.shouldNotHaveDeprecatedAlertMessage();
});
});

it('Empty state', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,10 @@ describe('Storage classes', () => {
const storageClasses = [
...mockStorageClasses,
buildMockStorageClass(
{ ...mockStorageClasses[0], metadata: { ...mockStorageClasses[0], name: 'sc-2' } },
{
...mockStorageClasses[0],
metadata: { ...mockStorageClasses[0].metadata, name: 'sc-2' },
},
{ displayName: 'Test SC 2' },
),
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ const StorageTable: React.FC<StorageTableProps> = ({ pvcs, refresh, onAddPVC })
() =>
storageClassesLoaded &&
storageTableData.some(
(data) => !data.storageClass || !getStorageClassConfig(data.storageClass)?.isEnabled,
(data) =>
!data.storageClass || getStorageClassConfig(data.storageClass)?.isEnabled === false,
),
[storageClassesLoaded, storageTableData],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const StorageTableRow: React.FC<StorageTableRowProps> = ({
</Label>
</Tooltip>
) : (
!storageClassConfig?.isEnabled && (
storageClassConfig?.isEnabled === false && (
<Tooltip
data-testid="storage-class-deprecated-tooltip"
content="This storage class is deprecated, but the cluster storage is still active."
Expand Down

0 comments on commit 9bccad0

Please sign in to comment.