Skip to content

Commit

Permalink
fix: restore @lmiller1990's changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tgriesser committed Feb 1, 2022
1 parent 3c5d11e commit 9aac0e3
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions packages/driver/cypress/e2e/commands/actions/type.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,25 @@ describe('src/cy/commands/actions/type - #type', () => {
cy.get(':text:first').type('foo', { animationDistanceThreshold: 1000 }).then(() => {
const { args } = cy.ensureElementIsNotAnimating.firstCall

expect(args[1]).to.deep.eq([fromElWindow, fromElWindow])
const plusMinusOne = (n) => [n - 1, n + 1]

for (const key of Object.keys(fromElWindow)) {
// TODO: These should be pixel perfect, but they are off
// by 1px, on CI, for Firefox only.
if (typeof fromElWindow[key] === 'number') {
if (Cypress.isBrowser({ family: 'firefox' })) {
expect(args[1][0][key]).to.be.within(...plusMinusOne(fromElWindow[key]))
expect(args[1][1][key]).to.be.within(...plusMinusOne(fromElWindow[key]))
} else {
expect(args[1][0][key]).to.eq(fromElWindow[key])
expect(args[1][1][key]).to.eq(fromElWindow[key])
}
} else {
// non number arg - just do the comparison
expect(args[1][0][key]).to.eq(fromElWindow[key])
expect(args[1][1][key]).to.eq(fromElWindow[key])
}
}

expect(args[2]).to.eq(1000)
})
Expand All @@ -378,7 +396,25 @@ describe('src/cy/commands/actions/type - #type', () => {
cy.get(':text:first').type('foo').then(() => {
const { args } = cy.ensureElementIsNotAnimating.firstCall

expect(args[1]).to.deep.eq([fromElWindow, fromElWindow])
const plusMinusOne = (n) => [n - 1, n + 1]

for (const key of Object.keys(fromElWindow)) {
// TODO: These should be pixel perfect, but they are off
// by 1px, on CI, for Firefox only.
if (typeof fromElWindow[key] === 'number') {
if (Cypress.isBrowser({ family: 'firefox' })) {
expect(args[1][0][key]).to.be.within(...plusMinusOne(fromElWindow[key]))
expect(args[1][1][key]).to.be.within(...plusMinusOne(fromElWindow[key]))
} else {
expect(args[1][0][key]).to.eq(fromElWindow[key])
expect(args[1][1][key]).to.eq(fromElWindow[key])
}
} else {
// non number arg - just do the comparison
expect(args[1][0][key]).to.eq(fromElWindow[key])
expect(args[1][1][key]).to.eq(fromElWindow[key])
}
}

expect(args[2]).to.eq(animationDistanceThreshold)
})
Expand Down

1 comment on commit 9aac0e3

@lmiller1990
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:(

I hate that this is necessary.

Please sign in to comment.