Skip to content

Commit

Permalink
fix cypress tests
Browse files Browse the repository at this point in the history
  • Loading branch information
luanfreitasdev committed Oct 2, 2023
1 parent c742a04 commit 018444c
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 58 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
17 changes: 8 additions & 9 deletions tests/cypress/cypress/e2e/action-rules/checkbox.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
17 changes: 8 additions & 9 deletions tests/cypress/cypress/e2e/action-rules/radio.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
60 changes: 29 additions & 31 deletions tests/cypress/cypress/e2e/action-rules/rows.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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', () => {
Expand All @@ -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', () => {
Expand All @@ -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', () => {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 018444c

Please sign in to comment.