diff --git a/cypress/integration/origin-search.spec.js b/cypress/integration/origin-search.spec.js new file mode 100644 --- /dev/null +++ b/cypress/integration/origin-search.spec.js @@ -0,0 +1,43 @@ +/** + * 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 origin = 'https://github.com/memononen/libtess2'; + +let url; + +describe('Test origin-search', function() { + before(function() { + url = this.Urls.browse_search(); + }); + + beforeEach(function() { + cy.visit(url); + }); + + it('should show in result for any url substring', function() { + // Randomly select substring of origin url + const startIndex = Math.floor(Math.random() * origin.length); + const length = Math.floor(Math.random() * (origin.length - startIndex - 1)) + 1; + const originSubstring = origin.substr(startIndex, length); + + cy.get('#origins-url-patterns') + .type(originSubstring); + cy.get('.swh-search-icon') + .click(); + + cy.get('#origin-search-results') + .should('be.visible'); + cy.contains('tr', origin) + .should('be.visible') + .children('#visit-status-origin-2') + .wait(100) + .children('i') + .should('have.class', 'fa-check') + .and('have.attr', 'title', + 'Origin has at least one full visit by Software Heritage'); + }); +});