Skip to content

Commit

Permalink
fix: Use correct empty state for 404 upgrade risks (#551)
Browse files Browse the repository at this point in the history
  • Loading branch information
gkarat authored Apr 20, 2023
1 parent 5ce6825 commit 9d97587
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 22 deletions.
8 changes: 8 additions & 0 deletions cypress/utils/interceptors.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ export const upgradeRisksInterceptors = {
statusCode: 503,
}
),
'error, not found': () =>
cy.intercept(
'GET',
/\/api\/insights-results-aggregator\/v2\/cluster\/.*\/upgrade-risks-prediction/,
{
statusCode: 404,
}
),
'error, other': () =>
cy.intercept(
'GET',
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Cluster/Cluster.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ describe('upgrade risks banner', () => {
});
});

it('upgrade risks service not available', () => {
upgradeRisksInterceptors['error, not available']();
it('upgrade risks not found', () => {
upgradeRisksInterceptors['error, not found']();
mount();

cy.get(ALERT).should('have.class', 'pf-m-warning');
Expand Down
2 changes: 1 addition & 1 deletion src/Components/UpgradeRisksAlert/UpgradeRisksAlert.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const UpgradeRisksAlert = () => {
isInline
title={intl.formatMessage(messages.noKnownUpgradeRisks)}
/>
) : isError && error.status === 503 ? (
) : isError && error.status === 404 ? (
<Alert
variant="warning"
isInline
Expand Down
17 changes: 17 additions & 0 deletions src/Components/UpgradeRisksTable/UpgradeRisksTable.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,23 @@ describe('error, service down', () => {
mount();
});

it('renders empty state', () => {
// can't apply checkEmptyState since "something went wrong" component doesn't use OUIA id
cy.get('.pf-c-empty-state h4').should('have.text', 'Something went wrong');
cy.get('.pf-c-empty-state__icon').should('be.visible');
});

it('header is present', () => {
checkTableHeaders(['Name']);
});
});

describe('error, not found', () => {
beforeEach(() => {
interceptors['error, not found']();
mount();
});

it('renders empty state', () => {
checkEmptyState('Upgrade risks are not available', true);
});
Expand Down
26 changes: 7 additions & 19 deletions src/Components/UpgradeRisksTable/UpgradeRisksTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,29 +148,17 @@ const UpgradeRisksTable = () => {
</Tr>
</Tbody>
</>
) : noRisks ? (
<Tbody>
<Tr>
<Td colSpan={2}>
<NoUpgradeRisks />
</Td>
</Tr>
</Tbody>
) : isError && error.status === 503 ? (
<Tbody>
<Tr>
<Td colSpan={2}>
<UpgradeRisksNotAvailable />
{/* back end is temporarily not available */}
</Td>
</Tr>
</Tbody>
) : (
<Tbody>
<Tr>
<Td colSpan={2}>
<ErrorState />
{/* default state for unexpected errors */}
{noRisks ? (
<NoUpgradeRisks />
) : isError && error.status === 404 ? (
<UpgradeRisksNotAvailable />
) : (
<ErrorState />
)}
</Td>
</Tr>
</Tbody>
Expand Down

0 comments on commit 9d97587

Please sign in to comment.