Changeset View
Changeset View
Standalone View
Standalone View
cypress/integration/layout.spec.js
Show First 20 Lines • Show All 156 Lines • ▼ Show 20 Lines | const statusTestData = [ | ||||
}, | }, | ||||
{ | { | ||||
status: 'Security Event', | status: 'Security Event', | ||||
statusCode: 600, | statusCode: 600, | ||||
color: 'red' | color: 'red' | ||||
} | } | ||||
]; | ]; | ||||
const responses = []; | for (let i = 0; i < statusTestData.length; ++i) { | ||||
for (const std of statusTestData) { | |||||
responses.push(genStatusResponse(std.status, std.statusCode)); | |||||
} | |||||
const checkStatusDisplay = (i) => { | |||||
cy.visit(url); | cy.visit(url); | ||||
// trick to override the response of an intercepted request | cy.intercept(`${statusUrl}/**`, { | ||||
// https://github.com/cypress-io/cypress/issues/9302 | body: genStatusResponse(statusTestData[i].status, statusTestData[i].statusCode) | ||||
cy.intercept(`${statusUrl}/**`, req => req.reply(responses.shift())) | }).as(`getSwhStatusData`); | ||||
.as(`getSwhStatusData${i}`); | cy.wait(`@getSwhStatusData`); | ||||
cy.wait(`@getSwhStatusData${i}`); | |||||
cy.get('.swh-current-status-indicator').should('have.class', statusTestData[i].color); | cy.get('.swh-current-status-indicator').should('have.class', statusTestData[i].color); | ||||
cy.get('#swh-current-status-description').should('have.text', statusTestData[i].status); | cy.get('#swh-current-status-description').should('have.text', statusTestData[i].status); | ||||
}; | } | ||||
checkStatusDisplay(0); // Operationnal | |||||
checkStatusDisplay(1); // Scheduled Maintenance | |||||
checkStatusDisplay(2); // Degraded Performance | |||||
checkStatusDisplay(3); // Partial Service Disruption | |||||
checkStatusDisplay(4); // Service Disruption | |||||
checkStatusDisplay(5); // Security Event | |||||
}); | }); | ||||
it('should not display swh status widget when data are not available', function() { | it('should not display swh status widget when data are not available', function() { | ||||
cy.intercept(`${statusUrl}/**`, { | cy.intercept(`${statusUrl}/**`, { | ||||
body: {} | body: {} | ||||
}).as('getSwhStatusData'); | }).as('getSwhStatusData'); | ||||
cy.visit(url); | cy.visit(url); | ||||
▲ Show 20 Lines • Show All 43 Lines • Show Last 20 Lines |