merge from ecomp a88f0072 - Modern UI
[vid.git] / vid-webpack-master / cypress / support / steps / menu.step.ts
diff --git a/vid-webpack-master/cypress/support/steps/menu.step.ts b/vid-webpack-master/cypress/support/steps/menu.step.ts
new file mode 100644 (file)
index 0000000..a0bfdb6
--- /dev/null
@@ -0,0 +1,19 @@
+declare namespace Cypress {
+  interface Chainable {
+    assertMenuItemsForNode: typeof assertMenuItemsForNode
+  }
+}
+ function assertMenuItemsForNode(enabledActions: string[], nodeName: string, index: number = 0) : Chainable<any> {
+  let node = cy.getElementByDataTestsId(nodeName).eq(+index);
+  node.trigger('mouseover').click().then(()=> {
+
+    //waiting to the menu to appear to catch options that shall not exist but actually exist
+    cy.get('.ngx-contextmenu').should('exist').then(()=> {
+      for (let option of ['duplicate', 'showAuditInfo', 'addGroupMember', 'delete', 'undoDelete', 'remove', ...enabledActions]) {
+        cy.getElementByDataTestsId(`context-menu-${option}`).should(enabledActions.some(s => s === option) ? 'exist' : 'not.exist');
+    }});
+  });
+  return node;
+}
+
+Cypress.Commands.add('assertMenuItemsForNode', assertMenuItemsForNode);