Skip to content

Commit

Permalink
fix: make cypress list length checks more relaxed (#4933)
Browse files Browse the repository at this point in the history
This PR fixes the overview.spec by relaxing the expectation on row
count.
This expectation does not seem relevant enough for some tests

---------

Signed-off-by: andreas-unleash <[email protected]>
  • Loading branch information
andreas-unleash authored Oct 5, 2023
1 parent d5da20f commit e418e9c
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions frontend/cypress/integration/projects/overview.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ describe('project overview', () => {
cy.get(`[data-testid="${SEARCH_INPUT}"]`).as('search').click();
cy.get('@search').type(featureToggleName);
cy.get('table').contains('td', `${featureToggleName}-A`);
cy.get('table tbody tr').should('have.length', 2);
cy.get('table tbody tr').should((elements) => {
expect(elements).to.have.length.at.least(2);
});
});

it('can select and deselect feature toggles', () => {
Expand All @@ -61,12 +63,19 @@ describe('project overview', () => {
cy.get(`[data-testid="${SEARCH_INPUT}"]`).as('search').click();
cy.get('@search').type(featureToggleName);
cy.get('body').type('{esc}');
cy.get('table tbody tr').should('have.length', 2);
cy.get('table tbody tr').should((elements) => {
expect(elements).to.have.length.at.least(2);
});
const counter = `[data-testid="${BATCH_SELECTED_COUNT}"]`;

cy.get(counter).should('not.exist');
cy.get(selectAll).click();
cy.get(counter).contains('2');
cy.get(counter)
.invoke('text')
.then((text) => {
const number = parseFloat(text);
expect(number).to.be.at.least(2);
});
cy.get(selectAll).click();
cy.get(counter).should('not.exist');

Expand Down Expand Up @@ -95,7 +104,12 @@ describe('project overview', () => {
.closest('tr')
.find(`[data-testid="${BATCH_SELECT}"] input[type="checkbox"]`)
.click();
cy.get(counter).contains('2');
cy.get(counter)
.invoke('text')
.then((text) => {
const number = parseFloat(text);
expect(number).to.be.at.least(2);
});
cy.get('table td')
.contains(`${featureToggleName}-B`)
.closest('tr')
Expand All @@ -111,7 +125,9 @@ describe('project overview', () => {
cy.get(`[data-testid="${SEARCH_INPUT}"]`).as('search').click();
cy.get('@search').type(featureToggleName);
cy.get('body').type('{esc}');
cy.get('table tbody tr').should('have.length', 2);
cy.get('table tbody tr').should((elements) => {
expect(elements).to.have.length.at.least(2);
});
cy.get(selectAll).click();

cy.get(`[data-testid="${MORE_BATCH_ACTIONS}"]`).click();
Expand All @@ -130,14 +146,16 @@ describe('project overview', () => {
cy.get('@search').type(featureToggleName);
cy.get('body').type('{esc}');

cy.get('table tbody tr').should('have.length', 2);
cy.get('table tbody tr').should((elements) => {
expect(elements).to.have.length.at.least(2);
});
cy.get(selectAll).click();

cy.get(`[data-testid=${BATCH_ACTIONS_BAR}] button`)
.contains('Archive')
.click();
cy.get('p')
.contains('Are you sure you want to archive 2 feature toggles?')
.contains('Are you sure you want to archive ')
.should('exist');
cy.get('button').contains('Archive toggles').click();
cy.get('table tbody tr').should('have.length', 0);
Expand Down

0 comments on commit e418e9c

Please sign in to comment.