From 0d61292f1ce718f5cc252f45d6e220c70246c922 Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Fri, 8 Apr 2022 11:27:30 -0300 Subject: [PATCH] 18881: Improves & expands resource handling commands. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- cypress/support/commands.js | 52 +++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 5a2428b2..a28308e3 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -135,11 +135,7 @@ Cypress.Commands.add( Cypress.Commands.add( "getCollection", (token, uuid) => { - return cy.doRequest('GET', `/arvados/v1/collections/${uuid}`, null, {}, token) - .its('body') - .then(function (theCollection) { - return theCollection; - }) + return cy.getResource(token, 'collections', uuid) } ) @@ -160,6 +156,20 @@ Cypress.Commands.add( } ) +Cypress.Commands.add( + "getContainer", (token, uuid) => { + return cy.getResource(token, 'containers', uuid) + } +) + +Cypress.Commands.add( + "updateContainer", (token, uuid, data) => { + return cy.updateResource(token, 'containers', uuid, { + container: JSON.stringify(data) + }) + } +) + Cypress.Commands.add( 'createContainerRequest', (token, data) => { return cy.createResource(token, 'container_requests', { @@ -212,13 +222,23 @@ Cypress.Commands.add( } ) +Cypress.Commands.add( + "getResource", (token, suffix, uuid) => { + return cy.doRequest('GET', `/arvados/v1/${suffix}/${uuid}`, null, {}, token) + .its('body') + .then(function (resource) { + return resource; + }) + } +) + Cypress.Commands.add( "createResource", (token, suffix, data) => { return cy.doRequest('POST', '/arvados/v1/' + suffix, data, null, token, true) - .its('body').as('resource') - .then(function () { - createdResources.push({suffix, uuid: this.resource.uuid}); - return this.resource; + .its('body') + .then(function (resource) { + createdResources.push({suffix, uuid: resource.uuid}); + return resource; }) } ) @@ -226,19 +246,19 @@ Cypress.Commands.add( Cypress.Commands.add( "deleteResource", (token, suffix, uuid, failOnStatusCode = true) => { return cy.doRequest('DELETE', '/arvados/v1/' + suffix + '/' + uuid, null, null, token, false, true, failOnStatusCode) - .its('body').as('resource') - .then(function () { - return this.resource; + .its('body') + .then(function (resource) { + return resource; }) } ) Cypress.Commands.add( "updateResource", (token, suffix, uuid, data) => { - return cy.doRequest('PUT', '/arvados/v1/' + suffix + '/' + uuid, data, null, token, true) - .its('body').as('resource') - .then(function () { - return this.resource; + return cy.doRequest('PATCH', '/arvados/v1/' + suffix + '/' + uuid, data, null, token, true) + .its('body') + .then(function (resource) { + return resource; }) } ) -- 2.30.2