Changeset View
Changeset View
Standalone View
Standalone View
cypress/integration/vault.spec.js
/** | /** | ||||
* Copyright (C) 2019-2020 The Software Heritage developers | * Copyright (C) 2019-2020 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 | ||||
*/ | */ | ||||
let vaultItems = []; | let vaultItems = []; | ||||
const progressbarColors = { | const progressbarColors = { | ||||
'new': 'rgba(128, 128, 128, 0.5)', | 'new': 'rgba(128, 128, 128, 0.5)', | ||||
'pending': 'rgba(0, 0, 255, 0.5)', | 'pending': 'rgba(0, 0, 255, 0.5)', | ||||
'done': 'rgb(92, 184, 92)' | 'done': 'rgb(92, 184, 92)' | ||||
}; | }; | ||||
function adminLogin() { | |||||
cy.visit('/admin/') | |||||
.get('input[name="username"]') | |||||
.type('admin') | |||||
.get('input[name="password"]') | |||||
.type('admin') | |||||
.get('form') | |||||
.submit(); | |||||
} | |||||
function checkVaultCookingTask(objectType) { | function checkVaultCookingTask(objectType) { | ||||
cy.contains('button', 'Download') | cy.contains('button', 'Download') | ||||
.click(); | .click(); | ||||
cy.contains('.dropdown-item', objectType) | cy.contains('.dropdown-item', objectType) | ||||
.click(); | .click(); | ||||
cy.wait('@checkVaultCookingTask'); | cy.wait('@checkVaultCookingTask'); | ||||
▲ Show 20 Lines • Show All 158 Lines • ▼ Show 20 Lines | it('should create a directory cooking task and report its status', function() { | ||||
cy.wait('@fetchCookedArchive').then((xhr) => { | cy.wait('@fetchCookedArchive').then((xhr) => { | ||||
assert.isNotNull(xhr.response.body); | assert.isNotNull(xhr.response.body); | ||||
}); | }); | ||||
}); | }); | ||||
it('should create a revision cooking task and report its status', function() { | it('should create a revision cooking task and report its status', function() { | ||||
adminLogin(); | cy.adminLogin(); | ||||
// Browse a revision | // Browse a revision | ||||
cy.visit(this.revisionUrl); | cy.visit(this.revisionUrl); | ||||
// Stub responses when requesting the vault API to simulate | // Stub responses when requesting the vault API to simulate | ||||
// a task has been created | // a task has been created | ||||
cy.route({ | cy.route({ | ||||
method: 'GET', | method: 'GET', | ||||
▲ Show 20 Lines • Show All 166 Lines • ▼ Show 20 Lines | cy.get('.modal-dialog') | ||||
.contains('button:visible', 'Ok') | .contains('button:visible', 'Ok') | ||||
.click(); | .click(); | ||||
cy.wait('@fetchCookedArchive'); | cy.wait('@fetchCookedArchive'); | ||||
}); | }); | ||||
it('should offer to immediately download a revision gitfast archive if already cooked', function() { | it('should offer to immediately download a revision gitfast archive if already cooked', function() { | ||||
adminLogin(); | cy.adminLogin(); | ||||
// Browse a directory | // Browse a directory | ||||
cy.visit(this.revisionUrl); | cy.visit(this.revisionUrl); | ||||
// Stub responses when requesting the vault API to simulate | // Stub responses when requesting the vault API to simulate | ||||
// the directory tarball has already been cooked | // the directory tarball has already been cooked | ||||
cy.route({ | cy.route({ | ||||
method: 'GET', | method: 'GET', | ||||
url: this.vaultRevisionUrl, | url: this.vaultRevisionUrl, | ||||
▲ Show 20 Lines • Show All 47 Lines • Show Last 20 Lines |