+
+Cypress.Commands.add(
+ "createResource", (token, suffix, data) => {
+ return cy.doRequest('POST', '/arvados/v1/' + suffix, data, null, token, true)
+ .its('body').as('resource')
+ .then(function () {
+ return this.resource;
+ })
+ }
+)
+
+Cypress.Commands.add(
+ "deleteResource", (token, suffix, uuid) => {
+ return cy.doRequest('DELETE', '/arvados/v1/' + suffix + '/' + uuid)
+ .its('body').as('resource')
+ .then(function () {
+ return this.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;
+ })
+ }
+)
+
+Cypress.Commands.add(
+ "loginAs", (user) => {
+ cy.visit(`/token/?api_token=${user.token}`);
+ cy.url().should('contain', '/projects/');
+ cy.get('div#root').should('contain', 'Arvados Workbench (zzzzz)');
+ cy.get('div#root').should('not.contain', 'Your account is inactive');
+ }
+)
+
+Cypress.Commands.add(
+ "doSearch", (searchTerm) => {
+ cy.get('[data-cy=searchbar-input-field]').type(`{selectall}${searchTerm}{enter}`);
+ }
+)
+
+Cypress.Commands.add('getAll', (...elements) => {
+ const promise = cy.wrap([], { log: false })
+
+ for (let element of elements) {
+ promise.then(arr => cy.get(element).then(got => cy.wrap([...arr, got])))
+ }
+
+ return promise
+})
\ No newline at end of file