File: toggle-docs.goml

package info (click to toggle)
rustc 1.85.0%2Bdfsg3-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, sid, trixie
  • size: 893,396 kB
  • sloc: xml: 158,127; python: 35,830; javascript: 19,497; cpp: 19,002; sh: 17,245; ansic: 13,127; asm: 4,376; makefile: 1,051; perl: 29; lisp: 29; ruby: 19; sql: 11
file content (73 lines) | stat: -rw-r--r-- 2,892 bytes parent folder | download | duplicates (3)
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
65
66
67
68
69
70
71
72
73
// Checks that the documentation toggles have the correct position, style and work as expected.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
assert-attribute: ("#main-content > details.top-doc", {"open": ""})
assert-text: ("#toggle-all-docs", "Summary")
click: "#toggle-all-docs"
wait-for: 50
// This is now collapsed so there shouldn't be the "open" attribute on details.
assert-attribute-false: ("#main-content > details.top-doc", {"open": ""})
assert-text: ("#toggle-all-docs", "Show all")
assert-css: (
    "#main-content > details.top-doc > summary",
    {"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'},
)
click: "#toggle-all-docs"
// Not collapsed anymore so the "open" attribute should be back.
wait-for-attribute: ("#main-content > details.top-doc", {"open": ""})
assert-text: ("#toggle-all-docs", "Summary")

// Check that it works on non-module pages as well.
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"
// We first check that everything is visible.
assert-text: ("#toggle-all-docs", "Summary")
assert-attribute: ("#implementations-list details.toggle", {"open": ""}, ALL)
assert-attribute: ("#trait-implementations-list details.toggle", {"open": ""}, ALL)
assert-attribute-false: (
    "#blanket-implementations-list > details.toggle",
    {"open": ""},
    ALL,
)

// We collapse them all.
click: "#toggle-all-docs"
wait-for-text: ("#toggle-all-docs", "Show all")
// We check that all <details> are collapsed (except for the impl block ones).
assert-attribute-false: ("details.toggle:not(.implementors-toggle)", {"open": ""}, ALL)
assert-attribute: ("#implementations-list > details.implementors-toggle", {"open": ""})
// We now check that the other impl blocks are collapsed.
assert-attribute-false: (
    "#blanket-implementations-list > details.toggle.implementors-toggle",
    {"open": ""},
    ALL,
)
// We open them all again.
click: "#toggle-all-docs"
wait-for-text: ("#toggle-all-docs", "Summary")
assert-attribute: ("details.toggle", {"open": ""}, ALL)

// Checking the toggles style.
show-text: true
define-function: (
    "check-color",
    [theme, filter],
    block {
        call-function: ("switch-theme", {"theme": |theme|})

        assert-css: ("details.toggle > summary::before", {
            "opacity": "0.5",
            "filter": |filter|,
        }, ALL)
        move-cursor-to: "details.toggle summary"
        assert-css: ("details.toggle > summary:hover::before", {
            "opacity": "1",
            "filter": |filter|,
        })
        // moving the cursor somewhere else to not mess with next function calls.
        move-cursor-to: ".search-input"
    },
)

call-function: ("check-color", {"theme": "ayu", "filter": "invert(1)"})
call-function: ("check-color", {"theme": "dark", "filter": "invert(1)"})
call-function: ("check-color", {"theme": "light", "filter": "none"})