diff --git a/cypress/utils/interceptors.js b/cypress/utils/interceptors.js index e76fdb14..8ea1ebce 100644 --- a/cypress/utils/interceptors.js +++ b/cypress/utils/interceptors.js @@ -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', diff --git a/src/Components/Cluster/Cluster.cy.js b/src/Components/Cluster/Cluster.cy.js index 769d7a70..28176beb 100644 --- a/src/Components/Cluster/Cluster.cy.js +++ b/src/Components/Cluster/Cluster.cy.js @@ -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'); diff --git a/src/Components/UpgradeRisksAlert/UpgradeRisksAlert.js b/src/Components/UpgradeRisksAlert/UpgradeRisksAlert.js index bfdcb1ca..c55d8b7f 100644 --- a/src/Components/UpgradeRisksAlert/UpgradeRisksAlert.js +++ b/src/Components/UpgradeRisksAlert/UpgradeRisksAlert.js @@ -33,7 +33,7 @@ const UpgradeRisksAlert = () => { isInline title={intl.formatMessage(messages.noKnownUpgradeRisks)} /> - ) : isError && error.status === 503 ? ( + ) : isError && error.status === 404 ? ( { 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); }); diff --git a/src/Components/UpgradeRisksTable/UpgradeRisksTable.js b/src/Components/UpgradeRisksTable/UpgradeRisksTable.js index 42985387..25b2a645 100644 --- a/src/Components/UpgradeRisksTable/UpgradeRisksTable.js +++ b/src/Components/UpgradeRisksTable/UpgradeRisksTable.js @@ -148,29 +148,17 @@ const UpgradeRisksTable = () => { - ) : noRisks ? ( - - - - - - - - ) : isError && error.status === 503 ? ( - - - - - {/* back end is temporarily not available */} - - - ) : ( - - {/* default state for unexpected errors */} + {noRisks ? ( + + ) : isError && error.status === 404 ? ( + + ) : ( + + )}