From 32b8702b9c471569ec9c4186c4fc6f03f10de3a1 Mon Sep 17 00:00:00 2001 From: Brandon Caton Date: Fri, 13 Dec 2024 11:27:28 -0500 Subject: [PATCH] ui: fixing cypress flake (PROJQUAY-8352) (#3509) There's a flake in the web/cypress/e2e/repository-permissions.cy.ts test where it is intermittently unable to type in the "Search for user, add/create robot account" search dropdown which occasionally fails the test. Since updating cypress the test fails consistently. This changes waits and clicks on the input allowing the type to complete and the dropdown to populate. --- web/cypress/e2e/repository-permissions.cy.ts | 45 +++++++++++--------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/web/cypress/e2e/repository-permissions.cy.ts b/web/cypress/e2e/repository-permissions.cy.ts index 664e926ae8..564aaff1e0 100644 --- a/web/cypress/e2e/repository-permissions.cy.ts +++ b/web/cypress/e2e/repository-permissions.cy.ts @@ -120,13 +120,14 @@ describe('Repository Settings - Permissions', () => { it('Adds user/robot/team permission', () => { cy.contains('Add permissions').click(); cy.get('#add-permission-form').within(() => { - // avoiding flaky test case by not chaining commands belows - cy.get('#entity-search-input', {timeout: 4000}).as('entity-search-input'); - cy.get('@entity-search-input') - .find('input', {timeout: 4000}) - .as('search-input'); - cy.get('@search-input').type('user'); - cy.get('@search-input').should('have.value', 'user'); + // We need the wait otherwise the dropdown won't open + cy.wait(2000); + cy.get('input[placeholder="Search for user, add/create robot account"]') + .click() + .type('user'); + cy.get( + 'input[placeholder="Search for user, add/create robot account"]', + ).should('have.value', 'user'); cy.get('button:contains("user2")').click(); cy.contains('admin').click(); @@ -141,13 +142,14 @@ describe('Repository Settings - Permissions', () => { }); cy.contains('Add permissions').click(); cy.get('#add-permission-form').within(() => { - // avoiding flaky test case by not chaining commands belows - cy.get('#entity-search-input', {timeout: 4000}).as('entity-search-input'); - cy.get('@entity-search-input') - .find('input', {timeout: 4000}) - .as('search-input'); - cy.get('@search-input').type('test'); - cy.get('@search-input').should('have.value', 'test'); + // We need the wait otherwise the dropdown won't open + cy.wait(2000); + cy.get('input[placeholder="Search for user, add/create robot account"]') + .click() + .type('test'); + cy.get( + 'input[placeholder="Search for user, add/create robot account"]', + ).should('have.value', 'test'); cy.contains('testorg+testrobot2').click(); cy.contains('admin').click(); @@ -165,13 +167,14 @@ describe('Repository Settings - Permissions', () => { }); cy.contains('Add permissions').click(); cy.get('#add-permission-form').within(() => { - // avoiding flaky test case by not chaining commands belows - cy.get('#entity-search-input', {timeout: 4000}).as('entity-search-input'); - cy.get('@entity-search-input') - .find('input', {timeout: 4000}) - .as('search-input'); - cy.get('@search-input').type('test'); - cy.get('@search-input').should('have.value', 'test'); + // We need the wait otherwise the dropdown won't open + cy.wait(2000); + cy.get('input[placeholder="Search for user, add/create robot account"]') + .click() + .type('test'); + cy.get( + 'input[placeholder="Search for user, add/create robot account"]', + ).should('have.value', 'test'); cy.contains('testteam2').click(); cy.contains('admin').click();