Changeset View
Changeset View
Standalone View
Standalone View
cypress/integration/vault.spec.js
Show All 22 Lines | function createVaultCookingTask(objectType) { | ||||
cy.contains('.dropdown-item', objectType) | cy.contains('.dropdown-item', objectType) | ||||
.click(); | .click(); | ||||
cy.get('.modal-dialog') | cy.get('.modal-dialog') | ||||
.contains('button:visible', 'Ok') | .contains('button:visible', 'Ok') | ||||
.click(); | .click(); | ||||
} | } | ||||
function updateVaultItemList(vaultUrl, vaultItems) { | |||||
cy.visit(vaultUrl) | |||||
.then(() => { | |||||
// Add uncooked task to localStorage | |||||
// which updates it in vault items list | |||||
window.localStorage.setItem('swh-vault-cooking-tasks', JSON.stringify(vaultItems)); | |||||
}); | |||||
} | |||||
// Mocks API response : /api/1/vault/(:objectType)/(:hash) | // Mocks API response : /api/1/vault/(:objectType)/(:hash) | ||||
// objectType : {'directory', 'revision'} | // objectType : {'directory', 'revision'} | ||||
function genVaultCookingResponse(objectType, objectId, status, message, fetchUrl) { | function genVaultCookingResponse(objectType, objectId, status, message, fetchUrl) { | ||||
return { | return { | ||||
'obj_type': objectType, | 'obj_type': objectType, | ||||
'id': 1, | 'id': 1, | ||||
'progress_message': message, | 'progress_message': message, | ||||
'status': status, | 'status': status, | ||||
▲ Show 20 Lines • Show All 199 Lines • ▼ Show 20 Lines | cy.get(`#vault-task-${this.revision} .vault-dl-link button`) | ||||
.click(); | .click(); | ||||
cy.wait('@fetchCookedArchive').then((xhr) => { | cy.wait('@fetchCookedArchive').then((xhr) => { | ||||
assert.isNotNull(xhr.response.body); | assert.isNotNull(xhr.response.body); | ||||
}); | }); | ||||
}); | }); | ||||
it('should offer to recook an archive if no more available to download', function() { | it('should offer to recook an archive if no more available to download', function() { | ||||
cy.visit(this.Urls.browse_vault()) | |||||
.then(() => { | updateVaultItemList(this.Urls.browse_vault(), vaultItems); | ||||
// Add uncooked task to localStorage | |||||
// which updates it in vault items list | |||||
window.localStorage.setItem('swh-vault-cooking-tasks', JSON.stringify(vaultItems)); | |||||
}); | |||||
// Send 404 when fetching vault item | // Send 404 when fetching vault item | ||||
cy.route({ | cy.route({ | ||||
method: 'GET', | method: 'GET', | ||||
status: 404, | status: 404, | ||||
url: this.vaultFetchRevisionUrl, | url: this.vaultFetchRevisionUrl, | ||||
response: { | response: { | ||||
'exception': 'NotFoundExc', | 'exception': 'NotFoundExc', | ||||
Show All 28 Lines | cy.wait('@fetchCookedArchive').then(() => { | ||||
cy.wait('@createVaultCookingTask') | cy.wait('@createVaultCookingTask') | ||||
.wait('@checkVaultCookingTask') | .wait('@checkVaultCookingTask') | ||||
.then(() => { | .then(() => { | ||||
testStatus(this.revision, progressbarColors['new'], 'new', 'new'); | testStatus(this.revision, progressbarColors['new'], 'new', 'new'); | ||||
}); | }); | ||||
}); | }); | ||||
}); | }); | ||||
it('should remove selected vault items', function() { | |||||
updateVaultItemList(this.Urls.browse_vault(), vaultItems); | |||||
cy.get(`#vault-task-${this.revision}`) | |||||
.find('input[type="checkbox"]') | |||||
.click(); | |||||
cy.contains('button', 'Remove selected tasks') | |||||
.click(); | |||||
cy.get(`#vault-task-${this.revision}`) | |||||
.should('not.exist'); | |||||
}); | |||||
}); | }); |