17500: Rearranges test in order to reduce its flakyness.
[arvados-workbench2.git] / cypress / support / commands.js
index 8dc003fee1288f8b10cd76ec8bee7d27f1a17fc8..929ffb83d849a357c18d74680d9e762f0b833bdc 100644 (file)
@@ -36,7 +36,7 @@ Cypress.Commands.add(
         token = systemToken, auth = false, followRedirect = true) => {
     return cy.request({
         method: method,
-        url: `${controllerURL}/${path}`,
+        url: `${controllerURL.replace(/\/+$/, '')}/${path.replace(/^\/+/, '')}`,
         body: data,
         qs: auth ? qs : Object.assign({ api_token: token }, qs),
         auth: auth ? { bearer: `${token}` } : undefined,
@@ -176,7 +176,7 @@ Cypress.Commands.add(
 Cypress.Commands.add(
     "loginAs", (user) => {
         cy.visit(`/token/?api_token=${user.token}`);
-        cy.url().should('contain', '/projects/');
+        cy.url({timeout: 10000}).should('contain', '/projects/');
         cy.get('div#root').should('contain', 'Arvados Workbench (zzzzz)');
         cy.get('div#root').should('not.contain', 'Your account is inactive');
     }
@@ -188,6 +188,12 @@ Cypress.Commands.add(
     }
 )
 
+Cypress.Commands.add(
+    "goToPath", (path) => {
+        return cy.window().its('appHistory').invoke('push', path);
+    }
+)
+
 Cypress.Commands.add('getAll', (...elements) => {
     const promise = cy.wrap([], { log: false })
 
@@ -207,13 +213,13 @@ Cypress.Commands.add('shareWith', (srcUserToken, targetUserUUID, itemUUID, permi
     });
 })
 
-Cypress.Commands.add('addToFavorites', (activeUserToken, activeUserUUID, itemUUID) => {
-    cy.createLink(activeUserToken, {
+Cypress.Commands.add('addToFavorites', (userToken, userUUID, itemUUID) => {
+    cy.createLink(userToken, {
         head_uuid: itemUUID,
         link_class: 'star',
         name: '',
-        owner_uuid: activeUserUUID,
-        tail_uuid: activeUserUUID,
+        owner_uuid: userUUID,
+        tail_uuid: userUUID,
     });
 })