Changeset View
Changeset View
Standalone View
Standalone View
cypress/e2e/origin-search.cy.js
/** | /** | ||||
* Copyright (C) 2019-2021 The Software Heritage developers | * Copyright (C) 2019-2022 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 nonExistentText = 'NoMatchExists'; | const nonExistentText = 'NoMatchExists'; | ||||
let origin; | let origin; | ||||
▲ Show 20 Lines • Show All 295 Lines • ▼ Show 20 Lines | for (const visitType of ['git', 'tar']) { | ||||
cy.get('tbody tr td.swh-origin-visit-type').then(elts => { | cy.get('tbody tr td.swh-origin-visit-type').then(elts => { | ||||
for (const elt of elts) { | for (const elt of elts) { | ||||
cy.get(elt).should('have.text', visitType); | cy.get(elt).should('have.text', visitType); | ||||
} | } | ||||
}); | }); | ||||
} | } | ||||
}); | }); | ||||
it('should encode origin argument in latest visit URL queried by XHR', function() { | |||||
// origin added in tests data by Python | |||||
const originUrl = 'https://example.org/project/download.php?version=2.0'; | |||||
cy.intercept(`**/api/1/origin/${encodeURIComponent(originUrl)}/visit/latest/**`) | |||||
.as('checkOriginVisit'); | |||||
doSearch(originUrl); | |||||
cy.wait('@checkOriginVisit'); | |||||
cy.get('.swh-search-result-entry') | |||||
.should('have.length', 1); | |||||
cy.get('.swh-search-result-entry#origin-0 .swh-origin-visit-type') | |||||
.should('have.text', 'tar'); | |||||
cy.get('.swh-search-result-entry#origin-0 td a') | |||||
.should('have.text', originUrl); | |||||
cy.get('.swh-search-result-entry#origin-0 .swh-visit-status') | |||||
.should('have.text', 'Archived'); | |||||
}); | |||||
context('Test pagination', function() { | context('Test pagination', function() { | ||||
it('should not paginate if there are not many results', function() { | it('should not paginate if there are not many results', function() { | ||||
// Setup search | // Setup search | ||||
cy.get('#swh-search-origins-with-visit') | cy.get('#swh-search-origins-with-visit') | ||||
.uncheck({force: true}) | .uncheck({force: true}) | ||||
.get('#swh-filter-empty-visits') | .get('#swh-filter-empty-visits') | ||||
.uncheck({force: true}) | .uncheck({force: true}) | ||||
.then(() => { | .then(() => { | ||||
▲ Show 20 Lines • Show All 332 Lines • Show Last 20 Lines |