Merge branch '21448-menu-reorder'
[arvados.git] / services / workbench2 / cypress / support / commands.js
index 8fe0b06aafebb6adb3aca33f94e701b3b515213c..529d776088886baf753b45c12f8f0a52a437480b 100644 (file)
@@ -182,11 +182,11 @@ Cypress.Commands.add("createWorkflow", (token, data) => {
     });
 });
 
-Cypress.Commands.add("createCollection", (token, data) => {
+Cypress.Commands.add("createCollection", (token, data, keep = false) => {
     return cy.createResource(token, "collections", {
         collection: JSON.stringify(data),
         ensure_unique_name: true,
-    });
+    }, keep);
 });
 
 Cypress.Commands.add("getCollection", (token, uuid) => {
@@ -321,16 +321,19 @@ Cypress.Commands.add("getResource", (token, suffix, uuid) => {
         });
 });
 
-Cypress.Commands.add("createResource", (token, suffix, data) => {
+Cypress.Commands.add("createResource", (token, suffix, data, keep = false) => {
     return cy
         .doRequest("POST", "/arvados/v1/" + suffix, data, null, token, true)
         .its("body")
         .then(function (resource) {
-            createdResources.push({ suffix, uuid: resource.uuid });
+            if (! keep) {
+                createdResources.push({ suffix, uuid: resource.uuid });
+            };
             return resource;
         });
 });
 
+
 Cypress.Commands.add("deleteResource", (token, suffix, uuid, failOnStatusCode = true) => {
     return cy
         .doRequest("DELETE", "/arvados/v1/" + suffix + "/" + uuid, null, null, token, false, true, failOnStatusCode)
@@ -350,8 +353,11 @@ Cypress.Commands.add("updateResource", (token, suffix, uuid, data) => {
 });
 
 Cypress.Commands.add("loginAs", user => {
+    // This shouldn't be necessary unless we need to call loginAs multiple times
+    // in the same test.
     cy.clearCookies();
-    cy.clearLocalStorage();
+    cy.clearAllLocalStorage();
+    cy.clearAllSessionStorage();
     cy.visit(`/token/?api_token=${user.token}`);
     // Use waitUntil to avoid permafail race conditions with window.location being undefined
     cy.waitUntil(() => cy.window().then(win =>