Changeset View
Changeset View
Standalone View
Standalone View
cypress/integration/origin-search.spec.js
Show First 20 Lines • Show All 494 Lines • ▼ Show 20 Lines | context('Test invalid SWHIDs', function() { | ||||
it('should show not found for content', function() { | it('should show not found for content', function() { | ||||
const swhid = `swh:1:cnt:${this.unarchivedRepo.content[0].sha1git}`; | const swhid = `swh:1:cnt:${this.unarchivedRepo.content[0].sha1git}`; | ||||
const msg = `Content with sha1_git checksum equals to ${this.unarchivedRepo.content[0].sha1git} not found!`; | const msg = `Content with sha1_git checksum equals to ${this.unarchivedRepo.content[0].sha1git} not found!`; | ||||
searchShouldShowNotFound(swhid, msg); | searchShouldShowNotFound(swhid, msg); | ||||
}); | }); | ||||
}); | }); | ||||
context('Test fixable malformed SWHIDs', function() { | |||||
function checkMalformedSWHIDgetsFixed(url, searchInputElt, repoData) { | |||||
const malformedSWHIDs = [`swh:1:cnt:${repoData.content[0].sha1git};lines=45-60/`, | |||||
`swh:1:cnt:${repoData.content[0].sha1git};origin=https://example.org/project//`]; | |||||
for (let malformedSWHID of malformedSWHIDs) { | |||||
cy.visit(url); | |||||
cy.get(searchInputElt) | |||||
.type(malformedSWHID); | |||||
// to trigger input change event | |||||
cy.get('body').click(); | |||||
cy.get(searchInputElt) | |||||
.should('have.value', malformedSWHID.slice(0, -1)); | |||||
} | |||||
} | |||||
it('should remove invalid trailing slash when copying a malformed SWHID in search page input', function() { | |||||
checkMalformedSWHIDgetsFixed(this.Urls.browse_search(), '#swh-origins-url-patterns', this.unarchivedRepo); | |||||
}); | |||||
it('should remove invalid trailing slash when copying a malformed SWHID in top right search input', function() { | |||||
checkMalformedSWHIDgetsFixed(this.Urls.browse_help(), '#swh-origins-search-top-input', this.unarchivedRepo); | |||||
}); | |||||
}); | |||||
}); | }); |