From 018444c68779d42266dce8c471194e5fa070e29c Mon Sep 17 00:00:00 2001 From: luanfreitasdev Date: Mon, 2 Oct 2023 13:40:42 -0300 Subject: [PATCH] fix cypress tests --- package-lock.json | 8 +-- package.json | 2 +- .../cypress/e2e/action-rules/checkbox.cy.js | 17 +++--- .../cypress/e2e/action-rules/radio.cy.js | 17 +++--- .../cypress/e2e/action-rules/rows.cy.js | 60 +++++++++---------- yarn.lock | 8 +-- 6 files changed, 54 insertions(+), 58 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7a7a2f5d..0924710e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,7 @@ "devDependencies": { "autoprefixer": "^10.4.14", "blade-formatter": "^1.37.1", - "cypress": "^13.2.0", + "cypress": "^13.3.0", "flatpickr": "^4.6.13", "postcss": "^8.4.29", "resolve-url-loader": "^5.0.0", @@ -4505,9 +4505,9 @@ } }, "node_modules/cypress": { - "version": "13.2.0", - "resolved": "https://registry.npmjs.org/cypress/-/cypress-13.2.0.tgz", - "integrity": "sha512-AvDQxBydE771GTq0TR4ZUBvv9m9ffXuB/ueEtpDF/6gOcvFR96amgwSJP16Yhqw6VhmwqspT5nAGzoxxB+D89g==", + "version": "13.3.0", + "resolved": "https://registry.npmjs.org/cypress/-/cypress-13.3.0.tgz", + "integrity": "sha512-mpI8qcTwLGiA4zEQvTC/U1xGUezVV4V8HQCOYjlEOrVmU1etVvxOjkCXHGwrlYdZU/EPmUiWfsO3yt1o+Q2bgw==", "dev": true, "hasInstallScript": true, "dependencies": { diff --git a/package.json b/package.json index 28d7df45..f18c450e 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "devDependencies": { "autoprefixer": "^10.4.14", "blade-formatter": "^1.37.1", - "cypress": "^13.2.0", + "cypress": "^13.3.0", "flatpickr": "^4.6.13", "postcss": "^8.4.29", "resolve-url-loader": "^5.0.0", diff --git a/tests/cypress/cypress/e2e/action-rules/checkbox.cy.js b/tests/cypress/cypress/e2e/action-rules/checkbox.cy.js index 45f0363d..73124e56 100644 --- a/tests/cypress/cypress/e2e/action-rules/checkbox.cy.js +++ b/tests/cypress/cypress/e2e/action-rules/checkbox.cy.js @@ -16,15 +16,14 @@ describe('Action Rules::checkbox', () => { cy.get('[data-cy=apply-rules]').click() - cy.get('.power-grid-table tbody tr').each(($tr, index) => { - const input = $tr.eq(0).find('div label input') - - if (index === 0) { - cy.wrap(input).should('have.class', '!text-red-500') - } else { - cy.wrap(input).should('not.have.class', '!text-red-500') - } - }); + cy.get('.power-grid-table tbody tr').eq(0).find('div label input') + .should('have.class', '!text-red-500'); + + cy.get('.power-grid-table tbody tr').eq(1).find('div label input') + .should('not.have.class', '!text-red-500'); + + cy.get('.power-grid-table tbody tr').eq(2).find('div label input') + .should('not.have.class', '!text-red-500'); }) it('should be able to add multiple class conditions with setAttribute', () => { diff --git a/tests/cypress/cypress/e2e/action-rules/radio.cy.js b/tests/cypress/cypress/e2e/action-rules/radio.cy.js index 08e7b961..bff21dd2 100644 --- a/tests/cypress/cypress/e2e/action-rules/radio.cy.js +++ b/tests/cypress/cypress/e2e/action-rules/radio.cy.js @@ -16,15 +16,14 @@ describe('Action Rules::radio', () => { cy.get('[data-cy=apply-rules]').click() - cy.get('.power-grid-table tbody tr').each(($tr, index) => { - const input = $tr.eq(0).find('div label input') - - if (index === 0) { - cy.wrap(input).should('have.class', '!text-red-500') - } else { - cy.wrap(input).should('not.have.class', '!text-red-500') - } - }); + cy.get('.power-grid-table tbody tr').eq(0).find('div label input') + .should('have.class', '!text-red-500'); + + cy.get('.power-grid-table tbody tr').eq(1).find('div label input') + .should('not.have.class', '!text-red-500'); + + cy.get('.power-grid-table tbody tr').eq(2).find('div label input') + .should('not.have.class', '!text-red-500'); }) it('should be able to add multiple class conditions with setAttribute', () => { diff --git a/tests/cypress/cypress/e2e/action-rules/rows.cy.js b/tests/cypress/cypress/e2e/action-rules/rows.cy.js index 98b08b6f..8c0dd6bb 100644 --- a/tests/cypress/cypress/e2e/action-rules/rows.cy.js +++ b/tests/cypress/cypress/e2e/action-rules/rows.cy.js @@ -15,9 +15,17 @@ describe('Action Rules::rows', () => { cy.get('[data-cy=apply-rules]').click() - cy.get('.power-grid-table tbody tr').each(($tr) => { - cy.wrap($tr).should('have.class', '!cursor-pointer'); - }); + cy.get('.power-grid-table tbody tr').eq(0) + .should('have.class', '!cursor-pointer'); + + cy.get('.power-grid-table tbody tr').eq(1) + .should('have.class', '!cursor-pointer'); + + cy.get('.power-grid-table tbody tr').eq(2) + .should('have.class', '!cursor-pointer'); + + cy.get('.power-grid-table tbody tr').eq(3) + .should('have.class', '!cursor-pointer'); }) it('should be able to add class attribute using Rule::rows -> setAttribute when dishId == 1', () => { @@ -29,13 +37,11 @@ describe('Action Rules::rows', () => { cy.get('[data-cy=apply-rules]').click() - cy.get('.power-grid-table tbody tr').each(($tr, index) => { - if (index === 0) { - cy.wrap($tr).should('have.class', '!cursor-pointer'); - } else { - cy.wrap($tr).should('not.have.class', '!cursor-pointer'); - } - }); + cy.get('.power-grid-table tbody tr').eq(0) + .should('have.class', '!cursor-pointer'); + + cy.get('.power-grid-table tbody tr').eq(1) + .should('not.have.class', '!cursor-pointer'); }) it('should be able to add class attribute using Rule::rows -> setAttribute when dishId != 1', () => { @@ -47,13 +53,11 @@ describe('Action Rules::rows', () => { cy.get('[data-cy=apply-rules]').click() - cy.get('.power-grid-table tbody tr').each(($tr, index) => { - if (index === 0) { - cy.wrap($tr).should('not.have.class', '!cursor-pointer'); - } else { - cy.wrap($tr).should('have.class', '!cursor-pointer'); - } - }); + cy.get('.power-grid-table tbody tr').eq(0) + .should('not.have.class', '!cursor-pointer'); + + cy.get('.power-grid-table tbody tr').eq(1) + .should('have.class', '!cursor-pointer'); }) it('should be able to add multiple class conditions using Rule::rows -> setAttribute', () => { @@ -68,23 +72,17 @@ describe('Action Rules::rows', () => { cy.get('[data-cy=apply-rules]').click() - cy.get('.power-grid-table tbody tr').each(($tr, index) => { - if (index === 0) { - cy.wrap($tr).should('have.class', '!bg-red-100'); - } + cy.get('.power-grid-table tbody tr').eq(0) + .should('not.have.class', '!bg-red-100'); - if (index === 0) { - cy.wrap($tr).should('not.have.class', '!bg-green-100'); - } + cy.get('.power-grid-table tbody tr').eq(0) + .should('not.have.class', '!bg-green-100'); - if (index === 1) { - cy.wrap($tr).should('have.class', '!bg-green-100'); - } + cy.get('.power-grid-table tbody tr').eq(1) + .should('not.have.class', '!bg-green-100'); - if (index === 1) { - cy.wrap($tr).should('not.have.class', '!bg-red-100'); - } - }); + cy.get('.power-grid-table tbody tr').eq(1) + .should('not.have.class', '!bg-red-100'); }) it('should be able to add multiple attributes using Rule::rows -> setAttribute when dishId == 3', () => { diff --git a/yarn.lock b/yarn.lock index 31b5af9b..bfaaab57 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2665,10 +2665,10 @@ csso@^4.2.0: dependencies: css-tree "^1.1.2" -cypress@^13.2.0: - version "13.2.0" - resolved "https://registry.npmjs.org/cypress/-/cypress-13.2.0.tgz" - integrity sha512-AvDQxBydE771GTq0TR4ZUBvv9m9ffXuB/ueEtpDF/6gOcvFR96amgwSJP16Yhqw6VhmwqspT5nAGzoxxB+D89g== +cypress@^13.3.0: + version "13.3.0" + resolved "https://registry.npmjs.org/cypress/-/cypress-13.3.0.tgz" + integrity sha512-mpI8qcTwLGiA4zEQvTC/U1xGUezVV4V8HQCOYjlEOrVmU1etVvxOjkCXHGwrlYdZU/EPmUiWfsO3yt1o+Q2bgw== dependencies: "@cypress/request" "^3.0.0" "@cypress/xvfb" "^1.2.4"