Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add scroll test to detect issue - run ci #30441

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions system-tests/lib/system-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ type ExecOptions = {
* Run Cypress with a custom user node version.
*/
userNodeVersion?: string
runnerUi: boolean
}

type Server = {
Expand Down Expand Up @@ -790,6 +791,10 @@ const systemTests = {
args.push(`--userNodeVersion=${options.userNodeVersion}`)
}

if (options.runnerUi !== undefined) {
args.push(options.runnerUi ? '--runner-ui' : '--no-runner-ui')
}

return args
},

Expand Down
10 changes: 10 additions & 0 deletions system-tests/projects/e2e/cypress/e2e/scroll-events.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
describe('handles scroll events as expected', () => {
it('waits for javascript to finish', () => {
cy.visit('/scroll-events.html')
cy.contains('stage:1')
cy.contains('stage:2')
cy.contains('stage:3')
cy.contains('done')
cy.get('#number-of-scrolls').should('have.text', '4')
})
})
98 changes: 98 additions & 0 deletions system-tests/projects/e2e/scroll-events.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<!DOCTYPE html>
<html>
<head>
<title>Colorful Boxes</title>
<style>
.box {
width: 500px;
height: 500px;
color: white;
overflow-y: scroll;
}
.nested-box {
width: 200px;
height: 200px;
font-size: 50px;
}
#first {
background-color: red;
}
#second {
background-color: green;
}
#third {
background-color: blue;
}
.nested-box-1 {
background-color: purple;
}
.nested-box-2 {
background-color: yellow;
}
.nested-box-3 {
background-color: pink;
}
.nested-box-4 {
background-color: orange;
}
.nested-box-5 {
background-color: cyan;
}
</style>
</head>
<body>
<div id="first" class="box"></div>
<div id="second" class="box">
<!-- Nested boxes inside the second box -->
<div class="nested-box nested-box-1"></div>
<div class="nested-box nested-box-2"></div>
<div class="nested-box nested-box-3"></div>
<div class="nested-box nested-box-4"></div>
<div class="nested-box nested-box-5"></div>
</div>
<div id="third" class="box"></div>

<!-- helps track what step of the scrip we are on -->
<div id="stage">mount</div>
<div id="number-of-scrolls">0</div>

<script>
window.addEventListener('scroll', (event) => {
const numberOfScrolls = document.getElementById('number-of-scrolls')
numberOfScrolls.innerText = parseInt(numberOfScrolls.innerText) + 1
}, true)
window.onload = function () {
const stageEl = document.getElementById('stage')
setTimeout(() => {
const thirdEl = document.getElementById('third')
thirdEl.scrollIntoView()
thirdEl.style.marginTop = '400px'
stageEl.innerText = 'stage:1'
console.log('stage:1')

setTimeout(() => {
const secondEl = document.getElementById('second')
secondEl.scrollIntoView()
secondEl.style.marginTop = '400px'
stageEl.innerText = 'stage:2'
console.log('stage:2')

setTimeout(() => {
// Select the middle nested box
const middleNestedBox = secondEl.children[2]
middleNestedBox.scrollIntoView()
middleNestedBox.style.marginTop = '100px'
stageEl.innerText = 'stage:3'
console.log('stage:3')

setTimeout(() => {
middleNestedBox.innerText = 'done'
console.log('done')
}, 500)
}, 500)
}, 500)
}, 500)
}
</script>
</body>
</html>
19 changes: 19 additions & 0 deletions system-tests/test/scroll_events_spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import systemTests from '../lib/system-tests'

const it = systemTests.it

describe('scroll events', () => {
it('validates that scrolls can be listened to - runner UI', {
browser: 'electron',
project: 'e2e',
spec: 'scroll-events.cy.js',
runnerUi: true,
})

it('validates that scrolls can be listened to - no runner UI', {
browser: 'electron',
project: 'e2e',
spec: 'scroll-events.cy.js',
runnerUi: false,
})
})