]> git.lizzy.rs Git - rust.git/blob - tests/rustdoc-gui/sidebar-source-code.goml
Rollup merge of #107777 - compiler-errors:derive_const-actually-derive-const, r=fee1...
[rust.git] / tests / rustdoc-gui / sidebar-source-code.goml
1 // The goal of this test is to ensure that the sidebar is working as expected in the source
2 // code pages.
3 goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
4 show-text: true
5
6 // First, check the sidebar colors.
7 define-function: (
8     "check-colors",
9     (theme, color, background_color),
10     block {
11         local-storage: {
12             "rustdoc-theme": |theme|,
13             "rustdoc-use-system-theme": "false",
14         }
15         reload:
16         // Checking results colors.
17         assert-css: (".source .sidebar", {
18             "color": |color|,
19             "background-color": |background_color|
20         }, ALL)
21     },
22 )
23
24 call-function: (
25     "check-colors",
26     {
27         "theme": "ayu",
28         "color": "rgb(197, 197, 197)",
29         "background_color": "rgb(20, 25, 31)",
30     }
31 )
32 call-function: (
33     "check-colors",
34     {
35         "theme": "dark",
36         "color": "rgb(221, 221, 221)",
37         "background_color": "rgb(80, 80, 80)",
38     }
39 )
40 call-function: (
41     "check-colors",
42     {
43         "theme": "light",
44         "color": "rgb(0, 0, 0)",
45         "background_color": "rgb(245, 245, 245)",
46     }
47 )
48
49 // Next, desktop mode layout.
50 size: (1100, 800)
51 // We check that the sidebar isn't expanded and has the expected width.
52 assert-css: ("nav.sidebar", {"width": "50px"})
53 // We now click on the button to expand the sidebar.
54 click: (10, 10)
55 // We wait for the sidebar to be expanded.
56 wait-for-css: (".source-sidebar-expanded nav.sidebar", {"width": "300px"})
57 assert-css: (".source-sidebar-expanded nav.sidebar a", {"font-size": "14px"})
58 // We collapse the sidebar.
59 click: (10, 10)
60 // We ensure that the class has been removed.
61 wait-for: "html:not(.expanded)"
62 assert: "nav.sidebar"
63
64 // Checking that only the path to the current file is "open".
65 goto: "file://" + |DOC_PATH| + "/src/lib2/another_folder/sub_mod/mod.rs.html"
66 // First we expand the sidebar again.
67 click: (10, 10)
68 // We wait for the sidebar to be expanded.
69 wait-for-css: (".source-sidebar-expanded nav.sidebar", {"width": "300px"})
70 assert: "//*[@class='dir-entry' and @open]/*[text()='lib2']"
71 assert: "//*[@class='dir-entry' and @open]/*[text()='another_folder']"
72 assert: "//*[@class='dir-entry' and @open]/*[text()='sub_mod']"
73 // Only "another_folder" should be "open" in "lib2".
74 assert: "//*[@class='dir-entry' and not(@open)]/*[text()='another_mod']"
75 // All other trees should be collapsed.
76 assert-count: ("//*[@id='source-sidebar']/details[not(text()='lib2') and not(@open)]", 8)
77
78 // We now switch to mobile mode.
79 size: (600, 600)
80 wait-for-css: (".source-sidebar-expanded nav.sidebar", {"left": "0px"})
81 // We collapse the sidebar.
82 click: (10, 10)
83 // We check that the sidebar has been moved off-screen.
84 assert-css: ("nav.sidebar", {"left": "-1000px"})
85 // We ensure that the class has been removed.
86 assert-false: ".source-sidebar-expanded"
87 assert: "nav.sidebar"
88
89 // Check that the topbar is not visible
90 assert-false: ".mobile-topbar"