diff --git a/cypress/integration/origin-search.spec.js b/cypress/integration/origin-search.spec.js --- a/cypress/integration/origin-search.spec.js +++ b/cypress/integration/origin-search.spec.js @@ -67,7 +67,7 @@ // .should('have.focus'); }); - it('should redirect to browse when origin url is searched', function() { + it('should redirect to browse when archived URL is searched', function() { cy.get('#swh-origins-url-patterns') .type(origin.url); cy.get('.swh-search-icon') @@ -75,11 +75,30 @@ cy.location('pathname') .should('eq', this.Urls.browse_origin_directory()); - cy.location('search') .should('eq', `?origin_url=${origin.url}`); }); + it('should not redirect for non valid URL', function() { + cy.get('#swh-origins-url-patterns') + .type('www.example'); // Invalid URL + cy.get('.swh-search-icon') + .click(); + + cy.location('pathname') + .should('eq', this.Urls.browse_search()); // Stay in the current page + }); + + it('should not redirect for valid non archived URL', function() { + cy.get('#swh-origins-url-patterns') + .type('http://eaxmple.com/test/'); // Valid URL, but not archived + cy.get('.swh-search-icon') + .click(); + + cy.location('pathname') + .should('eq', this.Urls.browse_search()); // Stay in the current page + }); + it('should remove origin URL with no archived content', function() { stubOriginVisitLatestRequests(404);