X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/2742a401dcc330697a14d2edb3c4c81115f67402..273119605b7f33940a5ef9b1422eb1ff152d6764:/cypress/support/commands.js diff --git a/cypress/support/commands.js b/cypress/support/commands.js index c2d78b54b2..f09d959b8f 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -73,30 +73,48 @@ Cypress.Commands.add( }), return_to: ',https://example.local' }, null, systemToken, true, false) // Don't follow redirects so we can catch the token - .its('headers.location').as('location') - // Get its token and set the account up as admin and/or active + .its('headers.location').as('location') + // Get its token and set the account up as admin and/or active + .then(function () { + this.userToken = this.location.split("=")[1] + assert.isString(this.userToken) + return cy.doRequest('GET', '/arvados/v1/users', null, { + filters: `[["username", "=", "${username}"]]` + }) + .its('body.items.0').as('aUser') .then(function () { - this.userToken = this.location.split("=")[1] - assert.isString(this.userToken) - return cy.doRequest('GET', '/arvados/v1/users', null, { - filters: `[["username", "=", "${username}"]]` + cy.doRequest('PUT', `/arvados/v1/users/${this.aUser.uuid}`, { + user: { + is_admin: is_admin, + is_active: is_active + } }) - .its('body.items.0') - .as('aUser') + .its('body').as('theUser') + .then(function () { + cy.doRequest('GET', '/arvados/v1/api_clients', null, { + filters: `[["is_trusted", "=", false]]`, + order: `["created_at desc"]` + }) + .its('body.items').as('apiClients') .then(function () { - cy.doRequest('PUT', `/arvados/v1/users/${this.aUser.uuid}`, { - user: { - is_admin: is_admin, - is_active: is_active - } - }) - .its('body') - .as('theUser') - .then(function () { - return { user: this.theUser, token: this.userToken }; + if (this.apiClients.length > 0) { + cy.doRequest('PUT', `/arvados/v1/api_clients/${this.apiClients[0].uuid}`, { + api_client: { + is_trusted: true + } }) + .its('body').as('updatedApiClient') + .then(function() { + assert(this.updatedApiClient.is_trusted); + }) + } }) + .then(function () { + return { user: this.theUser, token: this.userToken }; + }) + }) }) + }) } ) @@ -369,9 +387,11 @@ Cypress.Commands.add( { prevSubject: 'element', }, - (subject, file, fileName) => { + (subject, file, fileName, binaryMode = true) => { cy.window().then(window => { - const blob = b64toBlob(file, '', 512); + const blob = binaryMode + ? b64toBlob(file, '', 512) + : new Blob([file], {type: 'text/plain'}); const testFile = new window.File([blob], fileName); cy.wrap(subject).trigger('drop', { @@ -405,7 +425,10 @@ function b64toBlob(b64Data, contentType = '', sliceSize = 512) { // From https://github.com/cypress-io/cypress/issues/7306#issuecomment-1076451070= // This command requires the async package (https://www.npmjs.com/package/async) Cypress.Commands.add('waitForDom', () => { - cy.window().then(win => { + cy.window().then({ + // Don't timeout before waitForDom finishes + timeout: 10000 + }, win => { let timeElapsed = 0; cy.log("Waiting for DOM mutations to complete");