Changeset View
Changeset View
Standalone View
Standalone View
cypress/integration/vault.spec.js
Show First 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | .then(() => { | ||||
assert.isNotNull(vaultItem); | assert.isNotNull(vaultItem); | ||||
assert.strictEqual(vaultItem.status, status); | assert.strictEqual(vaultItem.status, status); | ||||
}); | }); | ||||
} | } | ||||
describe('Vault Cooking User Interface Tests', function() { | describe('Vault Cooking User Interface Tests', function() { | ||||
before(function() { | before(function() { | ||||
this.directory = this.origin[0].directory[0].id; | const dirInfo = this.origin[0].directory[0]; | ||||
this.directoryUrl = this.Urls.browse_directory(this.directory); | this.directory = dirInfo.id; | ||||
this.directoryUrl = this.Urls.browse_origin_directory() + | |||||
`?origin_url=${this.origin[0].url}&path=${dirInfo.path}`; | |||||
this.vaultDirectoryUrl = this.Urls.api_1_vault_cook_directory(this.directory); | this.vaultDirectoryUrl = this.Urls.api_1_vault_cook_directory(this.directory); | ||||
this.vaultFetchDirectoryUrl = this.Urls.api_1_vault_fetch_directory(this.directory); | this.vaultFetchDirectoryUrl = this.Urls.api_1_vault_fetch_directory(this.directory); | ||||
this.revision = this.origin[1].revisions[0]; | this.revision = this.origin[1].revisions[0]; | ||||
this.revisionUrl = this.Urls.browse_revision(this.revision); | this.revisionUrl = this.Urls.browse_revision(this.revision); | ||||
this.vaultRevisionUrl = this.Urls.api_1_vault_cook_revision_gitfast(this.revision); | this.vaultRevisionUrl = this.Urls.api_1_vault_cook_revision_gitfast(this.revision); | ||||
this.vaultFetchRevisionUrl = this.Urls.api_1_vault_fetch_revision_gitfast(this.revision); | this.vaultFetchRevisionUrl = this.Urls.api_1_vault_fetch_revision_gitfast(this.revision); | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | cy.contains('button', 'Download') | ||||
.click(); | .click(); | ||||
cy.route({ | cy.route({ | ||||
method: 'GET', | method: 'GET', | ||||
url: this.vaultDirectoryUrl, | url: this.vaultDirectoryUrl, | ||||
response: this.genVaultDirCookingResponse('new') | response: this.genVaultDirCookingResponse('new') | ||||
}).as('checkVaultCookingTask'); | }).as('checkVaultCookingTask'); | ||||
cy.window().then(win => { | |||||
const swhIdsContext = win.swh.webapp.getSwhIdsContext(); | |||||
const browseDirectoryUrl = swhIdsContext.directory.swhid_with_context_url; | |||||
// Create a vault cooking task through the GUI | // Create a vault cooking task through the GUI | ||||
cy.get('.modal-dialog') | cy.get('.modal-dialog') | ||||
.contains('button:visible', 'Ok') | .contains('button:visible', 'Ok') | ||||
.click(); | .click(); | ||||
cy.wait('@createVaultCookingTask'); | cy.wait('@createVaultCookingTask'); | ||||
// Check that a redirection to the vault UI has been performed | // Check that a redirection to the vault UI has been performed | ||||
cy.url().should('eq', Cypress.config().baseUrl + this.Urls.browse_vault()); | cy.url().should('eq', Cypress.config().baseUrl + this.Urls.browse_vault()); | ||||
cy.wait('@checkVaultCookingTask').then(() => { | cy.wait('@checkVaultCookingTask').then(() => { | ||||
testStatus(this.directory, progressbarColors['new'], 'new', 'new'); | testStatus(this.directory, progressbarColors['new'], 'new', 'new'); | ||||
}); | }); | ||||
// Stub response to the vault API indicating the task is processing | // Stub response to the vault API indicating the task is processing | ||||
cy.route({ | cy.route({ | ||||
method: 'GET', | method: 'GET', | ||||
url: this.vaultDirectoryUrl, | url: this.vaultDirectoryUrl, | ||||
response: this.genVaultDirCookingResponse('pending', 'Processing...') | response: this.genVaultDirCookingResponse('pending', 'Processing...') | ||||
}).as('checkVaultCookingTask'); | }).as('checkVaultCookingTask'); | ||||
cy.wait('@checkVaultCookingTask').then(() => { | cy.wait('@checkVaultCookingTask').then(() => { | ||||
testStatus(this.directory, progressbarColors['pending'], 'Processing...', 'pending'); | testStatus(this.directory, progressbarColors['pending'], 'Processing...', 'pending'); | ||||
}); | }); | ||||
// Stub response to the vault API indicating the task is finished | // Stub response to the vault API indicating the task is finished | ||||
cy.route({ | cy.route({ | ||||
method: 'GET', | method: 'GET', | ||||
url: this.vaultDirectoryUrl, | url: this.vaultDirectoryUrl, | ||||
response: this.genVaultDirCookingResponse('done') | response: this.genVaultDirCookingResponse('done') | ||||
}).as('checkVaultCookingTask'); | }).as('checkVaultCookingTask'); | ||||
cy.wait('@checkVaultCookingTask').then(() => { | cy.wait('@checkVaultCookingTask').then(() => { | ||||
testStatus(this.directory, progressbarColors['done'], 'done', 'done'); | testStatus(this.directory, progressbarColors['done'], 'done', 'done'); | ||||
}); | }); | ||||
// Stub response to the vault API to simulate archive download | // Stub response to the vault API to simulate archive download | ||||
cy.route({ | cy.route({ | ||||
method: 'GET', | method: 'GET', | ||||
url: this.vaultFetchDirectoryUrl, | url: this.vaultFetchDirectoryUrl, | ||||
response: `fx:${this.directory}.tar.gz,binary`, | response: `fx:${this.directory}.tar.gz,binary`, | ||||
headers: { | headers: { | ||||
'Content-disposition': `attachment; filename=${this.directory}.tar.gz`, | 'Content-disposition': `attachment; filename=${this.directory}.tar.gz`, | ||||
'Content-Type': 'application/gzip' | 'Content-Type': 'application/gzip' | ||||
} | } | ||||
}).as('fetchCookedArchive'); | }).as('fetchCookedArchive'); | ||||
cy.get(`#vault-task-${this.directory} .vault-origin a`) | |||||
.should('have.text', this.origin[0].url) | |||||
.should('have.attr', 'href', `${this.Urls.browse_origin()}?origin_url=${this.origin[0].url}`); | |||||
cy.get(`#vault-task-${this.directory} .vault-object-info a`) | |||||
.should('have.text', this.directory) | |||||
.should('have.attr', 'href', browseDirectoryUrl); | |||||
cy.get(`#vault-task-${this.directory} .vault-dl-link button`) | cy.get(`#vault-task-${this.directory} .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 create a revision cooking task and report its status', function() { | it('should create a revision cooking task and report its status', function() { | ||||
cy.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', | ||||
url: this.vaultRevisionUrl, | url: this.vaultRevisionUrl, | ||||
response: {'exception': 'NotFoundExc'} | response: {'exception': 'NotFoundExc'} | ||||
}).as('checkVaultCookingTask'); | }).as('checkVaultCookingTask'); | ||||
cy.route({ | cy.route({ | ||||
method: 'POST', | method: 'POST', | ||||
url: this.vaultRevisionUrl, | url: this.vaultRevisionUrl, | ||||
response: this.genVaultRevCookingResponse('new') | response: this.genVaultRevCookingResponse('new') | ||||
}).as('createVaultCookingTask'); | }).as('createVaultCookingTask'); | ||||
// Create a vault cooking task through the GUI | // Create a vault cooking task through the GUI | ||||
checkVaultCookingTask('as git'); | checkVaultCookingTask('as git'); | ||||
cy.route({ | cy.route({ | ||||
method: 'GET', | method: 'GET', | ||||
url: this.vaultRevisionUrl, | url: this.vaultRevisionUrl, | ||||
response: this.genVaultRevCookingResponse('new') | response: this.genVaultRevCookingResponse('new') | ||||
}).as('checkVaultCookingTask'); | }).as('checkVaultCookingTask'); | ||||
cy.window().then(win => { | |||||
const swhIdsContext = win.swh.webapp.getSwhIdsContext(); | |||||
const browseRevisionUrl = swhIdsContext.revision.swhid_url; | |||||
// Create a vault cooking task through the GUI | // Create a vault cooking task through the GUI | ||||
cy.get('.modal-dialog') | cy.get('.modal-dialog') | ||||
.contains('button:visible', 'Ok') | .contains('button:visible', 'Ok') | ||||
.click(); | .click(); | ||||
cy.wait('@createVaultCookingTask'); | cy.wait('@createVaultCookingTask'); | ||||
// Check that a redirection to the vault UI has been performed | // Check that a redirection to the vault UI has been performed | ||||
cy.url().should('eq', Cypress.config().baseUrl + this.Urls.browse_vault()); | cy.url().should('eq', Cypress.config().baseUrl + this.Urls.browse_vault()); | ||||
cy.wait('@checkVaultCookingTask').then(() => { | cy.wait('@checkVaultCookingTask').then(() => { | ||||
testStatus(this.revision, progressbarColors['new'], 'new', 'new'); | testStatus(this.revision, progressbarColors['new'], 'new', 'new'); | ||||
}); | }); | ||||
// Stub response to the vault API indicating the task is processing | // Stub response to the vault API indicating the task is processing | ||||
cy.route({ | cy.route({ | ||||
method: 'GET', | method: 'GET', | ||||
url: this.vaultRevisionUrl, | url: this.vaultRevisionUrl, | ||||
response: this.genVaultRevCookingResponse('pending', 'Processing...') | response: this.genVaultRevCookingResponse('pending', 'Processing...') | ||||
}).as('checkVaultCookingTask'); | }).as('checkVaultCookingTask'); | ||||
cy.wait('@checkVaultCookingTask').then(() => { | cy.wait('@checkVaultCookingTask').then(() => { | ||||
testStatus(this.revision, progressbarColors['pending'], 'Processing...', 'pending'); | testStatus(this.revision, progressbarColors['pending'], 'Processing...', 'pending'); | ||||
}); | }); | ||||
// Stub response to the vault API indicating the task is finished | // Stub response to the vault API indicating the task is finished | ||||
cy.route({ | cy.route({ | ||||
method: 'GET', | method: 'GET', | ||||
url: this.vaultRevisionUrl, | url: this.vaultRevisionUrl, | ||||
response: this.genVaultRevCookingResponse('done') | response: this.genVaultRevCookingResponse('done') | ||||
}).as('checkVaultCookingTask'); | }).as('checkVaultCookingTask'); | ||||
cy.wait('@checkVaultCookingTask').then(() => { | cy.wait('@checkVaultCookingTask').then(() => { | ||||
testStatus(this.revision, progressbarColors['done'], 'done', 'done'); | testStatus(this.revision, progressbarColors['done'], 'done', 'done'); | ||||
}); | }); | ||||
// Stub response to the vault API indicating to simulate archive | // Stub response to the vault API indicating to simulate archive | ||||
// download | // download | ||||
cy.route({ | cy.route({ | ||||
method: 'GET', | method: 'GET', | ||||
url: this.vaultFetchRevisionUrl, | url: this.vaultFetchRevisionUrl, | ||||
response: `fx:${this.revision}.gitfast.gz,binary`, | response: `fx:${this.revision}.gitfast.gz,binary`, | ||||
headers: { | headers: { | ||||
'Content-disposition': `attachment; filename=${this.revision}.gitfast.gz`, | 'Content-disposition': `attachment; filename=${this.revision}.gitfast.gz`, | ||||
'Content-Type': 'application/gzip' | 'Content-Type': 'application/gzip' | ||||
} | } | ||||
}).as('fetchCookedArchive'); | }).as('fetchCookedArchive'); | ||||
cy.get(`#vault-task-${this.revision} .vault-origin`) | |||||
.should('have.text', 'unknown'); | |||||
cy.get(`#vault-task-${this.revision} .vault-object-info a`) | |||||
.should('have.text', this.revision) | |||||
.should('have.attr', 'href', browseRevisionUrl); | |||||
cy.get(`#vault-task-${this.revision} .vault-dl-link button`) | 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() { | ||||
updateVaultItemList(this.Urls.browse_vault(), vaultItems); | updateVaultItemList(this.Urls.browse_vault(), vaultItems); | ||||
// Send 404 when fetching vault item | // Send 404 when fetching vault item | ||||
cy.route({ | cy.route({ | ||||
method: 'GET', | method: 'GET', | ||||
▲ Show 20 Lines • Show All 148 Lines • Show Last 20 Lines |