1 // The goal of this test is to ensure that the sidebar is working as expected in the source
3 goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
6 // First, check the sidebar colors.
9 (theme, color, background_color),
12 "rustdoc-theme": |theme|,
13 "rustdoc-use-system-theme": "false",
16 // Checking results colors.
17 assert-css: (".source .sidebar", {
19 "background-color": |background_color|
28 "color": "rgb(197, 197, 197)",
29 "background_color": "rgb(20, 25, 31)",
36 "color": "rgb(221, 221, 221)",
37 "background_color": "rgb(80, 80, 80)",
44 "color": "rgb(0, 0, 0)",
45 "background_color": "rgb(245, 245, 245)",
49 // Next, desktop mode layout.
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.
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.
60 // We ensure that the class has been removed.
61 wait-for: "html:not(.expanded)"
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.
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)
78 // We now switch to mobile mode.
80 wait-for-css: (".source-sidebar-expanded nav.sidebar", {"left": "0px"})
81 // We collapse the sidebar.
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"
89 // Check that the topbar is not visible
90 assert-false: ".mobile-topbar"