Changeset View
Changeset View
Standalone View
Standalone View
cypress/integration/layout.spec.js
/** | /** | ||||
* Copyright (C) 2019 The Software Heritage developers | * Copyright (C) 2019-2020 The Software Heritage developers | ||||
* See the AUTHORS file at the top-level directory of this distribution | * See the AUTHORS file at the top-level directory of this distribution | ||||
* License: GNU Affero General Public License version 3, or any later version | * License: GNU Affero General Public License version 3, or any later version | ||||
* See top-level LICENSE file for more information | * See top-level LICENSE file for more information | ||||
*/ | */ | ||||
const url = '/browse/help/'; | const url = '/browse/help/'; | ||||
const statusUrl = 'https://status.softwareheritage.org'; | |||||
describe('Test top-bar', function() { | describe('Test top-bar', function() { | ||||
beforeEach(function() { | beforeEach(function() { | ||||
cy.clearLocalStorage(); | cy.clearLocalStorage(); | ||||
cy.visit(url); | cy.visit(url); | ||||
}); | }); | ||||
it('should should contain all navigation links', function() { | it('should should contain all navigation links', function() { | ||||
cy.get('.swh-top-bar a') | cy.get('.swh-top-bar a') | ||||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | it('should restore container width when loading page again', function() { | ||||
cy.get('#swh-full-width-switch') | cy.get('#swh-full-width-switch') | ||||
.click({force: true}); | .click({force: true}); | ||||
cy.visit(url) | cy.visit(url) | ||||
.get('#swh-web-content') | .get('#swh-web-content') | ||||
.should('have.class', 'container') | .should('have.class', 'container') | ||||
.should('not.have.class', 'container-fluid'); | .should('not.have.class', 'container-fluid'); | ||||
}); | }); | ||||
function genStatusResponse(status, statusCode) { | |||||
return { | |||||
'result': { | |||||
'status': [ | |||||
{ | |||||
'id': '5f7c4c567f50b304c1e7bd5f', | |||||
'name': 'Save Code Now', | |||||
'updated': '2020-11-30T13:51:21.151Z', | |||||
'status': 'Operational', | |||||
'status_code': 100 | |||||
}, | |||||
{ | |||||
'id': '5f7c4c6f8338bc04b7f476fe', | |||||
'name': 'Source Code Crawlers', | |||||
'updated': '2020-11-30T13:51:21.151Z', | |||||
'status': status, | |||||
'status_code': statusCode | |||||
} | |||||
] | |||||
} | |||||
}; | |||||
} | |||||
it('should display swh status widget when data are available', function() { | |||||
const statusTestData = [ | |||||
{ | |||||
status: 'Operational', | |||||
statusCode: 100, | |||||
color: 'green' | |||||
}, | |||||
{ | |||||
status: 'Scheduled Maintenance', | |||||
statusCode: 200, | |||||
color: 'blue' | |||||
}, | |||||
{ | |||||
status: 'Degraded Performance', | |||||
statusCode: 300, | |||||
color: 'yellow' | |||||
}, | |||||
{ | |||||
status: 'Partial Service Disruption', | |||||
statusCode: 400, | |||||
color: 'yellow' | |||||
}, | |||||
{ | |||||
status: 'Service Disruption', | |||||
statusCode: 500, | |||||
color: 'red' | |||||
}, | |||||
{ | |||||
status: 'Security Event', | |||||
statusCode: 600, | |||||
color: 'red' | |||||
} | |||||
]; | |||||
for (let std of statusTestData) { | |||||
cy.server(); | |||||
cy.route({ | |||||
url: `${statusUrl}/**`, | |||||
response: genStatusResponse(std.status, std.statusCode) | |||||
}).as('getSwhStatusData'); | |||||
cy.visit(url); | |||||
cy.wait('@getSwhStatusData'); | |||||
cy.get('.swh-current-status-indicator').should('have.class', std.color); | |||||
cy.get('#swh-current-status-description').should('have.text', std.status); | |||||
} | |||||
}); | |||||
it('should not display swh status widget when data are not available', function() { | |||||
cy.server(); | |||||
cy.route({ | |||||
url: `${statusUrl}/**`, | |||||
response: {} | |||||
}).as('getSwhStatusData'); | |||||
cy.visit(url); | |||||
cy.wait('@getSwhStatusData'); | |||||
cy.get('.swh-current-status').should('not.be.visible'); | |||||
}); | |||||
}); | }); | ||||
describe('Test navbar', function() { | describe('Test navbar', function() { | ||||
it('should redirect to search page when submitting search form in navbar', function() { | it('should redirect to search page when submitting search form in navbar', function() { | ||||
const keyword = 'python'; | const keyword = 'python'; | ||||
cy.get('#swh-origins-search-top-input') | cy.get('#swh-origins-search-top-input') | ||||
.type(keyword); | .type(keyword); | ||||
Show All 31 Lines |