diff --git a/cypress/integration/errors.spec.js b/cypress/integration/errors.spec.js new file mode 100644 --- /dev/null +++ b/cypress/integration/errors.spec.js @@ -0,0 +1,30 @@ +/** + * Copyright (C) 2019 The Software Heritage developers + * See the AUTHORS file at the top-level directory of this distribution + * License: GNU Affero General Public License version 3, or any later version + * See top-level LICENSE file for more information + */ + +const unarchivedRepoUrl = 'https://github.com/SoftwareHeritage/swh-web'; + +function urlShouldShowError(url, errorCode, errorMsg) { + cy.visit(url, { + failOnStatusCode: false + }); + cy.get('.swh-http-error') + .should('be.visible'); + cy.get('.swh-http-error-code') + .should('contain', errorCode); + cy.get('.swh-http-error-desc') + .should('contain', errorMsg); +} + +describe('Test Errors', function() { + it('should display NotFoundExc for unarchived repo', function() { + const url = 'browse/origin/' + unarchivedRepoUrl + '/directory/'; + + const errorCode = '404'; + const errorMsg = 'NotFoundExc: Origin with url ' + unarchivedRepoUrl + ' not found!'; + urlShouldShowError(url, errorCode, errorMsg); + }); +});