Changeset View
Changeset View
Standalone View
Standalone View
cypress/e2e/origin-save.cy.js
Show All 24 Lines | |||||
const anonymousVisitTypes = ['bzr', 'cvs', 'git', 'hg', 'svn']; | const anonymousVisitTypes = ['bzr', 'cvs', 'git', 'hg', 'svn']; | ||||
const allVisitTypes = ['archives', 'bzr', 'cvs', 'git', 'hg', 'svn']; | const allVisitTypes = ['archives', 'bzr', 'cvs', 'git', 'hg', 'svn']; | ||||
function makeOriginSaveRequest(originType, originUrl) { | function makeOriginSaveRequest(originType, originUrl) { | ||||
cy.get('#swh-input-origin-url') | cy.get('#swh-input-origin-url') | ||||
.type(originUrl) | .type(originUrl) | ||||
.get('#swh-input-visit-type') | .get('#swh-input-visit-type') | ||||
.select(originType) | .select(originType) | ||||
.get('#swh-save-origin-form') | .get('#swh-save-origin-form button[type=submit]') | ||||
.submit(); | .click(); | ||||
} | } | ||||
function checkAlertVisible(alertType, msg) { | function checkAlertVisible(alertType, msg) { | ||||
cy.get('#swh-origin-save-request-status') | cy.get('#swh-origin-save-request-status') | ||||
.should('be.visible') | .should('be.visible') | ||||
.find(`.alert-${alertType}`) | .find(`.alert-${alertType}`) | ||||
.should('be.visible') | .should('be.visible') | ||||
.and('contain', msg); | .and('contain', msg); | ||||
▲ Show 20 Lines • Show All 570 Lines • ▼ Show 20 Lines | cy.get('#swh-input-origin-url') | ||||
.type(originUrl) | .type(originUrl) | ||||
.get('#swh-input-visit-type') | .get('#swh-input-visit-type') | ||||
.select('archives') | .select('archives') | ||||
.get('#swh-input-artifact-url-0') | .get('#swh-input-artifact-url-0') | ||||
.type(artifactUrl) | .type(artifactUrl) | ||||
.get('#swh-input-artifact-version-0') | .get('#swh-input-artifact-version-0') | ||||
.clear() | .clear() | ||||
.type(artifactVersion) | .type(artifactVersion) | ||||
.get('#swh-save-origin-form') | .get('#swh-save-origin-form button[type=submit]') | ||||
.submit(); | .click(); | ||||
cy.wait('@saveRequest').then(() => { | cy.wait('@saveRequest').then(() => { | ||||
checkAlertVisible('success', saveCodeMsg['success']); | checkAlertVisible('success', saveCodeMsg['success']); | ||||
}); | }); | ||||
}); | }); | ||||
it('should submit multiple artifacts for the archives visit type', function() { | it('should submit multiple artifacts for the archives visit type', function() { | ||||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | cy.intercept('POST', this.Urls.api_1_save_origin('archives', originUrl), (req) => { | ||||
saveRequestDate: new Date(), | saveRequestDate: new Date(), | ||||
saveTaskStatus: 'not yet scheduled', | saveTaskStatus: 'not yet scheduled', | ||||
visitDate: null, | visitDate: null, | ||||
visitStatus: null | visitStatus: null | ||||
})); | })); | ||||
}).as('saveRequest'); | }).as('saveRequest'); | ||||
// submit form | // submit form | ||||
cy.get('#swh-save-origin-form') | cy.get('#swh-save-origin-form button[type=submit]') | ||||
.submit(); | .click(); | ||||
// submission should be successful | // submission should be successful | ||||
cy.wait('@saveRequest').then(() => { | cy.wait('@saveRequest').then(() => { | ||||
checkAlertVisible('success', saveCodeMsg['success']); | checkAlertVisible('success', saveCodeMsg['success']); | ||||
}); | }); | ||||
}); | }); | ||||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | it('should use canonical URL for github repository to save', function() { | ||||
]) { | ]) { | ||||
// enter non canonical URL of github repo | // enter non canonical URL of github repo | ||||
cy.get('#swh-input-origin-url') | cy.get('#swh-input-origin-url') | ||||
.clear() | .clear() | ||||
.type(originUrl); | .type(originUrl); | ||||
// submit form | // submit form | ||||
cy.get('#swh-save-origin-form') | cy.get('#swh-save-origin-form button[type=submit]') | ||||
.submit(); | .click(); | ||||
// submission should be successful | // submission should be successful | ||||
cy.wait('@ghWebApiRequest') | cy.wait('@ghWebApiRequest') | ||||
.wait('@saveRequest').then(() => { | .wait('@saveRequest').then(() => { | ||||
checkAlertVisible('success', saveCodeMsg['success']); | checkAlertVisible('success', saveCodeMsg['success']); | ||||
}); | }); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 94 Lines • Show Last 20 Lines |