| 1 |
// This GUI test checks the sidebar scroll position when navigating. |
| 2 |
|
| 3 |
store-value: (windowHeight, 900) |
| 4 |
set-window-size: (1200, |windowHeight|) |
| 5 |
go-to: |DOC_PATH| + "sidebar-scroll/index.html" |
| 6 |
assert-property: (".sidebar-scrollbox", {"scrollTop": 0}) |
| 7 |
|
| 8 |
click: ".chapter a[href='chapter_2.html']" |
| 9 |
assert-text: ("title", "Chapter 2 - sidebar-scroll") |
| 10 |
wait-for-property: (".sidebar-scrollbox", {"scrollTop": 0}) |
| 11 |
|
| 12 |
click: ".chapter a[href='chapter_10.html']" |
| 13 |
assert-text: ("title", "Chapter 10 - sidebar-scroll") |
| 14 |
wait-for-property: (".sidebar-scrollbox", {"scrollTop": 0}) |
| 15 |
|
| 16 |
// Check that heading nav of chapter 10 pushes 11 off the bottom. |
| 17 |
store-position: (".chapter a[href='chapter_11.html']", {"y": chapter_y}) |
| 18 |
assert: |chapter_y| > |windowHeight| |
| 19 |
|
| 20 |
// Clicking 11 should scroll back up because it is not possible for it to stay |
| 21 |
// in position since there are only a few lines above. |
| 22 |
click: ".chapter a[href='chapter_11.html']" |
| 23 |
assert-text: ("title", "Chapter 11 - sidebar-scroll") |
| 24 |
wait-for-property: (".sidebar-scrollbox", {"scrollTop": 0}) |
| 25 |
|
| 26 |
// Scroll down a little, and click on a chapter that can stay in place when |
| 27 |
// clicked. |
| 28 |
scroll-element-to: (".sidebar-scrollbox", (0, 230)) |
| 29 |
store-property: (".sidebar-scrollbox", {"scrollTop": sidebarScrollTop}) |
| 30 |
assert: |sidebarScrollTop| > 0 |
| 31 |
click: ".chapter a[href='chapter_35.html']" |
| 32 |
assert-text: ("title", "Chapter 35 - sidebar-scroll") |
| 33 |
wait-for-property: (".sidebar-scrollbox", {"scrollTop": |sidebarScrollTop|}) |
| 34 |
|
| 35 |
// Go to the next chapter, and verify that it scrolls to the middle. |
| 36 |
press-key: "ArrowRight" |
| 37 |
assert-text: ("title", "Chapter 36 - sidebar-scroll") |
| 38 |
wait-for: ".chapter a.active" |
| 39 |
// The active link should be roughly in the middle of the screen. |
| 40 |
store-position: (".chapter a.active", {"y": active_y}) |
| 41 |
// Approximate check just in case the browser has slight rendering differences. |
| 42 |
assert: |active_y| > 400 |
| 43 |
assert: |active_y| < 450 |
| 44 |
|
| 45 |
// Go to something near the top, it shouldn't scroll. |
| 46 |
store-property: (".sidebar-scrollbox", {"scrollTop": sidebarScrollTop}) |
| 47 |
click: ".chapter a[href='chapter_24.html']" |
| 48 |
assert-text: ("title", "Chapter 24 - sidebar-scroll") |
| 49 |
wait-for-property: (".sidebar-scrollbox", {"scrollTop": |sidebarScrollTop|}) |
| 50 |
|
| 51 |
// Go to the last chapter, and verify it is scrolled to the bottom. |
| 52 |
go-to: |DOC_PATH| + "sidebar-scroll/chapter_100.html" |
| 53 |
store-property: (".sidebar-scrollbox", {"scrollTop": scrollTop, "scrollHeight": scrollHeight, "clientHeight": clientHeight}) |
| 54 |
// This needs to be approximate since there is a slight difference. |
| 55 |
assert: |scrollTop| >= |scrollHeight| - |clientHeight| - 1 |
| 56 |
|
| 57 |
// Clicking upwards shouldn't scroll. |
| 58 |
store-property: (".sidebar-scrollbox", {"scrollTop": sidebarScrollTop}) |
| 59 |
click: ".chapter a[href='chapter_97.html']" |
| 60 |
assert-text: ("title", "Chapter 97 - sidebar-scroll") |
| 61 |
wait-for-property: (".sidebar-scrollbox", {"scrollTop": |sidebarScrollTop|}) |
| 62 |
|
| 63 |
store-property: (".sidebar-scrollbox", {"scrollTop": sidebarScrollTop}) |
| 64 |
click: ".chapter a[href='chapter_76.html']" |
| 65 |
assert-text: ("title", "Chapter 76 - sidebar-scroll") |
| 66 |
wait-for-property: (".sidebar-scrollbox", {"scrollTop": |sidebarScrollTop|}) |