]> git.lizzy.rs Git - rust.git/blob - tests/rustdoc-gui/toggle-docs.goml
Rollup merge of #107790 - tharunsuresh-code:snap_curl, r=jyn514
[rust.git] / tests / rustdoc-gui / toggle-docs.goml
1 // Checks that the documentation toggles have the correct position, style and work as expected.
2 goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
3 assert-attribute: ("#main-content > details.top-doc", {"open": ""})
4 assert-text: ("#toggle-all-docs", "[−]")
5 click: "#toggle-all-docs"
6 wait-for: 50
7 // This is now collapsed so there shouldn't be the "open" attribute on details.
8 assert-attribute-false: ("#main-content > details.top-doc", {"open": ""})
9 assert-text: ("#toggle-all-docs", "[+]")
10 assert-css: (
11     "#main-content > details.top-doc > summary",
12     {"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'},
13 )
14 click: "#toggle-all-docs"
15 // Not collapsed anymore so the "open" attribute should be back.
16 wait-for-attribute: ("#main-content > details.top-doc", {"open": ""})
17 assert-text: ("#toggle-all-docs", "[−]")
18
19 // Check that it works on non-module pages as well.
20 goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"
21 // We first check that everything is visible.
22 assert-text: ("#toggle-all-docs", "[−]")
23 assert-attribute: ("#implementations-list details.toggle", {"open": ""}, ALL)
24 assert-attribute: ("#trait-implementations-list details.toggle", {"open": ""}, ALL)
25 assert-attribute-false: (
26     "#blanket-implementations-list > details.toggle",
27     {"open": ""},
28     ALL,
29 )
30
31 // We collapse them all.
32 click: "#toggle-all-docs"
33 wait-for-text: ("#toggle-all-docs", "[+]")
34 // We check that all <details> are collapsed (except for the impl block ones).
35 assert-attribute-false: ("details.toggle:not(.implementors-toggle)", {"open": ""}, ALL)
36 assert-attribute: ("#implementations-list > details.implementors-toggle", {"open": ""})
37 // We now check that the other impl blocks are collapsed.
38 assert-attribute-false: (
39     "#blanket-implementations-list > details.toggle.implementors-toggle",
40     {"open": ""},
41     ALL,
42 )
43 // We open them all again.
44 click: "#toggle-all-docs"
45 wait-for-text: ("#toggle-all-docs", "[−]")
46 assert-attribute: ("details.toggle", {"open": ""}, ALL)
47
48 // Checking the toggles style.
49 show-text: true
50 define-function: (
51     "check-color",
52     (theme, filter),
53     block {
54         // Setting the theme.
55         local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
56         // We reload the page so the local storage settings are being used.
57         reload:
58
59         assert-css: ("details.toggle > summary::before", {
60             "opacity": "0.5",
61             "filter": |filter|,
62         }, ALL)
63         move-cursor-to: "details.toggle summary"
64         assert-css: ("details.toggle > summary:hover::before", {
65             "opacity": "1",
66             "filter": |filter|,
67         })
68         // moving the cursor somewhere else to not mess with next function calls.
69         move-cursor-to: ".search-input"
70     },
71 )
72
73 call-function: ("check-color", {"theme": "ayu", "filter": "invert(1)"})
74 call-function: ("check-color", {"theme": "dark", "filter": "invert(1)"})
75 call-function: ("check-color", {"theme": "light", "filter": "none"})