18284: Try to fix cypress tests
authorStephen Smith <stephen@curii.com>
Thu, 27 Jan 2022 05:02:05 +0000 (00:02 -0500)
committerStephen Smith <stephen@curii.com>
Thu, 27 Jan 2022 05:02:05 +0000 (00:02 -0500)
Arvados-DCO-1.1-Signed-off-by: Stephen Smith <stephen@curii.com>

cypress/integration/virtual-machine-admin.spec.js
src/views/virtual-machine-panel/virtual-machine-user-panel.tsx

index 534e7a9ee11bd17a21061b51351a293b905fa47b..ea39d460a2b7de720247da274c5a6836d6520e0c 100644 (file)
@@ -131,29 +131,34 @@ describe('Virtual machine login manage tests', function() {
         cy.loginAs(adminUser);
         cy.get('header button[title="Admin Panel"]').click();
         cy.get('#admin-menu').contains('Virtual Machines').click();
+
         cy.get('[data-cy=vm-admin-table]')
-            .contains(vmHost)
-            .parents('tr')
-            .within(() => {
-                // Remove user login
-                cy.get('div[role=button]').contains('user').parents('[role=button]').within(() => {
-                    cy.get('svg').click();
-                });
-            });
-        cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
+            .contains('user'); // Wait for page to finish
 
         cy.get('[data-cy=vm-admin-table]')
             .contains(vmHost)
             .parents('tr')
+            .as('vmRow')
+            .contains('user')
+            .parents('[role=button]')
+            .find('svg')
+            .as('removeButton');
+        cy.get('@removeButton').click();
+        cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
+
+        cy.get('@vmRow')
             .within(() => {
                 cy.get('div[role=button]').should('not.contain', 'user');
                 cy.get('div[role=button]').should('have.length', 1)
-
-                // Remove admin login
-                cy.get('div[role=button]').contains('admin').parents('[role=button]').within(() => {
-                    cy.get('svg').click();
-                });
             });
+
+            cy.get('@vmRow')
+            .find('div[role=button]')
+            .contains('admin')
+            .parents('[role=button]')
+            .find('svg')
+            .as('removeButton');
+        cy.get('@removeButton').click();
         cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
 
         cy.get('[data-cy=vm-admin-table]')
@@ -167,7 +172,7 @@ describe('Virtual machine login manage tests', function() {
         cy.get('header button[title="Account Management"]').click();
         cy.get('#account-menu').contains('Virtual Machines').click();
 
-        cy.get('[data-cy=vm-user-table]')
+        cy.get('[data-cy=vm-user-panel]')
             .should('not.contain', vmHost);
 
         // Check activeUser's vm page for login
@@ -175,7 +180,7 @@ describe('Virtual machine login manage tests', function() {
         cy.get('header button[title="Account Management"]').click();
         cy.get('#account-menu').contains('Virtual Machines').click();
 
-        cy.get('[data-cy=vm-user-table]')
+        cy.get('[data-cy=vm-user-panel]')
             .should('not.contain', vmHost);
     });
 });
index d0ee5634f85a5de77917660410accd8c848787aa..66ea017ecf3b43e107f8084af409fdd48d01660a 100644 (file)
@@ -112,7 +112,7 @@ export const VirtualMachineUserPanel = compose(
             render() {
                 const { virtualMachines, links } = this.props;
                 return (
-                    <Grid container spacing={16}>
+                    <Grid container spacing={16} data-cy="vm-user-panel">
                         {virtualMachines.itemsAvailable === 0 && <CardContentWithoutVirtualMachines {...this.props} />}
                         {virtualMachines.itemsAvailable > 0 && links.itemsAvailable > 0 && <CardContentWithVirtualMachines {...this.props} />}
                         {<CardSSHSection {...this.props} />}