Skip to content

Commit 4aa0f53

Browse files
committed
fix cypress firefox >= 124 ci bug
1 parent 57e65cd commit 4aa0f53

File tree

2 files changed

+46
-30
lines changed

2 files changed

+46
-30
lines changed

packages/vue-collapsed/src/utils.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,16 @@ export function isReducedOrDisabled(el: RefEl) {
3939

4040
const { transition } = getComputedStyle(el.value)
4141

42+
console.log(
43+
typeof window.requestAnimationFrame === 'undefined' ||
44+
window.matchMedia('(prefers-reduced-motion: reduce)').matches ||
45+
transition.includes('none') ||
46+
transition.includes('height 0s')
47+
)
48+
4249
return (
4350
typeof window.requestAnimationFrame === 'undefined' ||
44-
matchMedia('(prefers-reduced-motion: reduce)').matches ||
51+
window.matchMedia('(prefers-reduced-motion: reduce)').matches ||
4552
transition.includes('none') ||
4653
transition.includes('height 0s')
4754
)

packages/vue-collapsed/tests/Collapse.cy.ts

+38-29
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
import App from './App.vue'
22
import { getRandomIntInclusive, isFirefox } from '../cypress/support/component'
33

4+
beforeEach(() => {
5+
/**
6+
* For some unknown reason on Cypress Firefox >=124 (only on CI) reduced motion is always set to 'reduce',
7+
* using this stub to force it to return true.
8+
*/
9+
if (isFirefox) {
10+
cy.stub(window, 'matchMedia').withArgs('(prefers-reduced-motion: reduce)').returns({
11+
matches: false,
12+
})
13+
}
14+
})
15+
416
it('Should be able to set different tag name', () => {
517
cy.mount(App, {
618
props: {
@@ -113,42 +125,39 @@ it('Should update data-collapse attribute properly', () => {
113125
}
114126
})
115127

116-
// Bugged CI test, works locally and with any other browser
117-
if (!isFirefox) {
118-
describe('Should execute callbacks properly', () => {
119-
function testCallbacks(isLastActionExpand: boolean) {
120-
const repeatEven = getRandomIntInclusive(10, 20) * 2
121-
for (let i = 0; i < repeatEven; i++) {
122-
cy.get('#TriggerButton').click().wait(50)
123-
}
124-
125-
cy.get('#CountExpand')
126-
.should('have.text', `${repeatEven / 2}`)
127-
.get('#CountExpanded')
128-
.should('have.text', isLastActionExpand ? '0' : '1')
129-
.get('#CountCollapse')
130-
.should('have.text', `${repeatEven / 2}`)
131-
.get('#CountCollapsed')
132-
.should('have.text', isLastActionExpand ? '1' : '0')
128+
describe('Should execute callbacks properly', () => {
129+
function testCallbacks(isLastActionExpand: boolean) {
130+
const repeatEven = getRandomIntInclusive(10, 20) * 2
131+
for (let i = 0; i < repeatEven; i++) {
132+
cy.get('#TriggerButton').click().wait(50)
133133
}
134134

135-
it('Expand as last action', () => {
136-
cy.mount(App)
135+
cy.get('#CountExpand')
136+
.should('have.text', `${repeatEven / 2}`)
137+
.get('#CountExpanded')
138+
.should('have.text', isLastActionExpand ? '0' : '1')
139+
.get('#CountCollapse')
140+
.should('have.text', `${repeatEven / 2}`)
141+
.get('#CountCollapsed')
142+
.should('have.text', isLastActionExpand ? '1' : '0')
143+
}
137144

138-
testCallbacks(true)
139-
})
145+
it('Expand as last action', () => {
146+
cy.mount(App)
140147

141-
it('Collapse as last action', () => {
142-
cy.mount(App, {
143-
props: {
144-
initialValue: true,
145-
},
146-
})
148+
testCallbacks(true)
149+
})
147150

148-
testCallbacks(false)
151+
it('Collapse as last action', () => {
152+
cy.mount(App, {
153+
props: {
154+
initialValue: true,
155+
},
149156
})
157+
158+
testCallbacks(false)
150159
})
151-
}
160+
})
152161

153162
describe('With baseHeight > 0', () => {
154163
it('Should have correct styles if collapsed on mount', () => {

0 commit comments

Comments
 (0)