fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

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