16971: Added tests to cover more places
[arvados-workbench2.git] / cypress / support / commands.js
index dbb9cd0b1f9a82b33118d8cad630d8c87789128b..97bb2450909566ca0a964ffcc8edaa03adec28c9 100644 (file)
@@ -192,6 +192,32 @@ Cypress.Commands.add(
     }
 )
 
+Cypress.Commands.add(
+    "editProjectOrCollection", (container, oldName, newName, newDescription, isProject = true) => {
+        cy.get(container).contains(oldName).rightclick();
+        cy.get('[data-cy=context-menu]').contains(isProject ? 'Edit project' : 'Edit collection').click();
+        cy.get('[data-cy=form-dialog]').within(() => {
+            cy.get('input[name=name]').clear().type(newName);
+            cy.get(isProject ? 'div[contenteditable=true]' : 'input[name=description]').type(newDescription);
+            cy.get('[data-cy=form-submit-btn]').click();
+        });
+
+        cy.get(container).contains(newName).rightclick();
+        cy.get('[data-cy=context-menu]').contains(isProject ? 'Edit project' : 'Edit collection').click();
+        cy.get('[data-cy=form-dialog]').within(() => {
+            cy.get('input[name=name]').should('have.value', newName);
+
+            if (isProject) {
+                cy.get('span[data-text=true]').contains(newDescription);
+            } else {
+                cy.get('input[name=description]').should('have.value', newDescription);
+            }
+
+            cy.get('[data-cy=form-cancel-btn]').click();
+        });
+    }
+)
+
 Cypress.Commands.add(
     "doSearch", (searchTerm) => {
         cy.get('[data-cy=searchbar-input-field]').type(`{selectall}${searchTerm}{enter}`);