-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathscrolling-threshold.html
More file actions
64 lines (54 loc) · 2.26 KB
/
scrolling-threshold.html
File metadata and controls
64 lines (54 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<script src="/react-scroll-to-bottom.development.js"></script>
<script src="/test-harness.js"></script>
<script src="/assets/page-object-model.js"></script>
</head>
<body>
<div id="app"></div>
</body>
<script type="text/babel" data-presets="react">
'use strict';
run(async function () {
await new Promise(resolve =>
ReactDOM.render(
<ReactScrollToBottom.default
className="react-scroll-to-bottom"
followButtonClassName="follow"
scrollViewClassName="scrollable"
autoScrollThreshold={50}
>
{pageObjects.paragraphs.map(paragraph => (
<p key={paragraph}>{paragraph}</p>
))}
</ReactScrollToBottom.default>,
document.getElementById('app'),
resolve
)
);
await pageObjects.scrollStabilizedAtBottom();
expect(document.getElementsByClassName('follow')[0]).toBeFalsy();
// Scroll up by 40px, which is within the 50px threshold
// Note: mouseWheel(-40) might not translate exactly to 40px pixel scroll depending on implementation
// But typically it should be enough to test "small scroll" vs "large scroll".
// Let's try to set scrollTop directly if possible, but pageObjects is safer.
// Assuming mouseWheel units are pixels or close to it.
// Let's use a explicit scroll to be safe if pageObjects allows,
// otherwise use mouseWheel and hope it maps linearly or use step-by-step.
// Checking pageObjects.scrollStabilized usage in other files...
await pageObjects.mouseWheel(-40);
await pageObjects.scrollStabilized();
// Should still be sticky, so NO follow button
expect(document.getElementsByClassName('follow')[0]).toBeFalsy();
// Scroll up another 20px, total 60px (> 50px)
await pageObjects.mouseWheel(-20);
await pageObjects.scrollStabilized();
// Should show follow button now
expect(document.getElementsByClassName('follow')[0]).toBeTruthy();
});
</script>
</html>