From cd2b77aa0e181d7662a57871a5a4b88a377cfc10 Mon Sep 17 00:00:00 2001 From: Martijn Dirkse Date: Tue, 22 Mar 2022 11:50:45 +0100 Subject: [PATCH] Try to fix flaky tests debug_filterTable (#111) Try to fix flaky tests debug_filterTable --- cypress/integration/debug_filterTable.spec.js | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/cypress/integration/debug_filterTable.spec.js b/cypress/integration/debug_filterTable.spec.js index e9e96db6..6ceb05c0 100644 --- a/cypress/integration/debug_filterTable.spec.js +++ b/cypress/integration/debug_filterTable.spec.js @@ -21,23 +21,21 @@ describe('Table size and toggle filter', function () { }) it('Typing in a table size and retyping it', function () { - // The default value for the maximum is 10 and there are 2 reports, so expect 2. + // We only assume here that the default is two or more. cy.get('.table-responsive tbody').find('tr').should('have.length', 2); + cy.get('#displayAmount').type('{selectAll}{del}'); + cy.get('.table-responsive tbody').find('tr').should('have.length', 0); + // From now on, we type one character at a time. Cypress can type very rapidly. + // We do not expect our app to catch up without guards. cy.get('#displayAmount').type(1); cy.get('.table-responsive tbody').find('tr').should('have.length', 1); - cy.get('#displayAmount').type("{backspace}2"); + cy.get('#displayAmount').type("{backspace}"); + cy.get('.table-responsive tbody').find('tr').should('have.length', 0); + cy.get('#displayAmount').type("2"); cy.get('.table-responsive tbody').find('tr').should('have.length', 2); - // If we would omit typing 1 here, we would test that the length remained 2 - // when the edit field changed from 2 to 10. This would not be a good test, because - // Cypress would not see when the typing of 10 would have effect. - cy.get('#displayAmount').type("{backspace}1"); - cy.get('.table-responsive tbody').find('tr').should('have.length', 1); - // Martijn Monday February 21. Changed {backspace}10 to {backspace}9 - // to make this test stable. Originally, the test succeeded on Martijn's - // computer but was unstable on GitHub. Martijn could not reproduce the - // failure manually. Martijn and Chakir guessed that Cypress can - // type faster than real users. - cy.get('#displayAmount').type("{backspace}9") + cy.get('#displayAmount').type("{backspace}"); + cy.get('.table-responsive tbody').find('tr').should('have.length', 0); + cy.get('#displayAmount').type("9") cy.get('.table-responsive tbody').find('tr').should('have.length', 2) })