| 1 |
// Tests for collapsed heading sidebar navigation. |
| 2 |
|
| 3 |
set-window-size: (1400, 800) |
| 4 |
go-to: |DOC_PATH| + "heading-nav/collapsed.html" |
| 5 |
|
| 6 |
assert-count: (".header-item", 11) |
| 7 |
assert-count: (".current-header", 1) |
| 8 |
assert-text: (".current-header", "Heading 1") |
| 9 |
// Collapsed elements do not have "expanded" class. |
| 10 |
assert-attribute: ("li:has(> span > a[href='#heading-12'])", {"class": "header-item"}) |
| 11 |
assert-attribute: ("li:has(> span > a[href='#heading-21'])", {"class": "header-item"}) |
| 12 |
assert-css: ("//a[@href='#heading-12']/../following-sibling::ol", {"display": "none"}) |
| 13 |
assert-css: ("//a[@href='#heading-21']/../following-sibling::ol", {"display": "none"}) |
| 14 |
|
| 15 |
assert-property: ("div.on-this-page", {"innerHTML": '<ol class="section"><li class="header-item expanded"><span class="chapter-link-wrapper"><a href="#heading-1" class="header-in-summary current-header">Heading 1</a></span><ol class="section"><li class="header-item expanded"><span class="chapter-link-wrapper"><a href="#heading-11" class="header-in-summary">Heading 1.1</a></span></li><li class="header-item"><span class="chapter-link-wrapper"><a href="#heading-12" class="header-in-summary">Heading 1.2</a><a class="chapter-fold-toggle header-toggle"><div>❱</div></a></span><ol class="section"><li class="header-item expanded"><span class="chapter-link-wrapper"><a href="#heading-121" class="header-in-summary">Heading 1.2.1</a></span></li><li class="header-item expanded"><span class="chapter-link-wrapper"><a href="#heading-122" class="header-in-summary">Heading 1.2.2</a></span></li></ol></li><li class="header-item expanded"><span class="chapter-link-wrapper"><a href="#heading-13" class="header-in-summary">Heading 1.3</a></span></li></ol></li><li class="header-item expanded"><span class="chapter-link-wrapper"><a href="#heading-2" class="header-in-summary">Heading 2</a></span><ol class="section"><li class="header-item"><span class="chapter-link-wrapper"><a href="#heading-21" class="header-in-summary">Heading 2.1</a><a class="chapter-fold-toggle header-toggle"><div>❱</div></a></span><ol class="section"><li class="header-item"><span class="chapter-link-wrapper"><a href="#heading-211" class="header-in-summary">Heading 2.1.1</a><a class="chapter-fold-toggle header-toggle"><div>❱</div></a></span><ol class="section"><li class="header-item"><span class="chapter-link-wrapper"><a href="#heading-2111" class="header-in-summary">Heading 2.1.1.1</a><a class="chapter-fold-toggle header-toggle"><div>❱</div></a></span><ol class="section"><li class="header-item expanded"><span class="chapter-link-wrapper"><a href="#heading-21111" class="header-in-summary">Heading 2.1.1.1.1</a></span></li></ol></li></ol></li></ol></li></ol></li></ol>'}) |
| 16 |
|
| 17 |
// Click 1.2, expands it. |
| 18 |
click: "a.header-in-summary[href='#heading-12']" |
| 19 |
wait-for-attribute: ("li:has(> span > a[href='#heading-12'])", {"class": "header-item expanded"}) |
| 20 |
wait-for-attribute: ("li:has(> span > a[href='#heading-21'])", {"class": "header-item"}) |
| 21 |
wait-for-css: ("//a[@href='#heading-12']/../following-sibling::ol", {"display": "block"}) |
| 22 |
|
| 23 |
// Click 1.1, should collapse it. |
| 24 |
click: "a.header-in-summary[href='#heading-11']" |
| 25 |
wait-for-attribute: ("li:has(> span > a[href='#heading-12'])", {"class": "header-item"}) |
| 26 |
wait-for-attribute: ("li:has(> span > a[href='#heading-21'])", {"class": "header-item"}) |
| 27 |
wait-for-css: ("//a[@href='#heading-12']/../following-sibling::ol", {"display": "none"}) |
| 28 |
|
| 29 |
// Click the chevron, should expand it. |
| 30 |
click: "a.header-in-summary[href='#heading-12'] ~ a.header-toggle" |
| 31 |
wait-for-attribute: ("li:has(> span > a[href='#heading-12'])", {"class": "header-item expanded"}) |
| 32 |
wait-for-attribute: ("li:has(> span > a[href='#heading-21'])", {"class": "header-item"}) |
| 33 |
wait-for-css: ("//a[@href='#heading-12']/../following-sibling::ol", {"display": "block"}) |
| 34 |
|
| 35 |
assert-css: ("//a[@href='#heading-21']/../following-sibling::ol", {"display": "none"}) |
| 36 |
// Click 1.3 |
| 37 |
click: "a.header-in-summary[href='#heading-13']" |
| 38 |
// Everything should be collapsed |
| 39 |
wait-for-attribute: ("li:has(> span > a[href='#heading-12'])", {"class": "header-item"}) |
| 40 |
wait-for-attribute: ("li:has(> span > a[href='#heading-21'])", {"class": "header-item"}) |
| 41 |
wait-for-css: ("//a[@href='#heading-12']/../following-sibling::ol", {"display": "none"}) |
| 42 |
wait-for-css: ("//a[@href='#heading-21']/../following-sibling::ol", {"display": "none"}) |
| 43 |
wait-for-attribute: ("li:has(> span > a[href='#heading-211'])", {"class": "header-item"}) |
| 44 |
wait-for-attribute: ("li:has(> span > a[href='#heading-2111'])", {"class": "header-item"}) |
| 45 |
|
| 46 |
// Scroll to bottom of page |
| 47 |
press-key: 'PageDown' |
| 48 |
press-key: 'PageDown' |
| 49 |
press-key: 'PageDown' |
| 50 |
press-key: 'PageDown' |
| 51 |
// 2.1.1.1.1 should be visible, and all the chevrons should be open, and expanded should be on each one |
| 52 |
wait-for-attribute: ("li:has(> span > a[href='#heading-12'])", {"class": "header-item"}) |
| 53 |
wait-for-attribute: ("li:has(> span > a[href='#heading-21'])", {"class": "header-item expanded"}) |
| 54 |
wait-for-attribute: ("li:has(> span > a[href='#heading-211'])", {"class": "header-item expanded"}) |
| 55 |
wait-for-attribute: ("li:has(> span > a[href='#heading-2111'])", {"class": "header-item expanded"}) |
| 56 |
wait-for-css: ("//a[@href='#heading-12']/../following-sibling::ol", {"display": "none"}) |
| 57 |
wait-for-css: ("//a[@href='#heading-21']/../following-sibling::ol", {"display": "block"}) |
| 58 |
wait-for-css: ("//a[@href='#heading-211']/../following-sibling::ol", {"display": "block"}) |
| 59 |
wait-for-css: ("//a[@href='#heading-2111']/../following-sibling::ol", {"display": "block"}) |