]> git.lizzy.rs Git - rust.git/blob - src/test/rustdoc-gui/settings.goml
Auto merge of #96881 - est31:join_osstr, r=dtolnay
[rust.git] / src / test / rustdoc-gui / settings.goml
1 // This test ensures that the settings menu display is working as expected.
2 goto: file://|DOC_PATH|/test_docs/index.html
3 // First, we check that the settings page doesn't exist.
4 assert-false: "#settings"
5 // We now click on the settings button.
6 click: "#settings-menu"
7 wait-for: "#settings"
8 assert-css: ("#settings", {"display": "block"})
9 // Let's close it by clicking on the same button.
10 click: "#settings-menu"
11 wait-for-css: ("#settings", {"display": "none"})
12
13 // Let's check that pressing "ESCAPE" is closing it.
14 click: "#settings-menu"
15 wait-for-css: ("#settings", {"display": "block"})
16 press-key: "Escape"
17 wait-for-css: ("#settings", {"display": "none"})
18
19 // Let's click on it when the search results are displayed.
20 focus: ".search-input"
21 write: "test"
22 wait-for: "#alternative-display #search"
23 click: "#settings-menu"
24 wait-for-css: ("#settings", {"display": "block"})
25 // Ensure that the search is still displayed.
26 wait-for: "#alternative-display #search"
27 assert: "#main-content.hidden"
28
29 // Now let's check the content of the settings menu.
30 local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"}
31 reload:
32 click: "#settings-menu"
33 wait-for: "#settings"
34
35 // We check that the "Use system theme" is disabled.
36 assert-property: ("#use-system-theme", {"checked": "false"})
37 assert: "//*[@class='setting-line']//span[text()='Use system theme']"
38 // Meaning that only the "theme" menu is showing up.
39 assert: ".setting-line:not(.hidden) #theme"
40 assert: ".setting-line.hidden #preferred-dark-theme"
41 assert: ".setting-line.hidden #preferred-light-theme"
42
43 // We check that the correct theme is selected.
44 assert-property: ("#theme .choices #theme-dark", {"checked": "true"})
45
46 // We now switch the display.
47 click: "#use-system-theme"
48 // Wait for the hidden element to show up.
49 wait-for: ".setting-line:not(.hidden) #preferred-dark-theme"
50 assert: ".setting-line:not(.hidden) #preferred-light-theme"
51 // Check that the theme picking is hidden.
52 assert: ".setting-line.hidden #theme"
53
54 // We check their text as well.
55 assert-text: ("#preferred-dark-theme .setting-name", "Preferred dark theme")
56 assert-text: ("#preferred-light-theme .setting-name", "Preferred light theme")
57
58 // We now check that clicking on the "sliders"' text is like clicking on the slider.
59 // To test it, we use the "Disable keyboard shortcuts".
60 local-storage: {"rustdoc-disable-shortcuts": "false"}
61 click: ".setting-line:last-child .toggle .label"
62 assert-local-storage: {"rustdoc-disable-shortcuts": "true"}
63
64 // Now we go to the settings page to check that the CSS is loaded as expected.
65 goto: file://|DOC_PATH|/settings.html
66 wait-for: "#settings"
67 assert-css: (".setting-line .toggle .slider", {"width": "45px", "margin-right": "20px"})
68
69 // We now check the display with JS disabled.
70 assert-false: "noscript section"
71 javascript: false
72 reload:
73 assert-css: ("noscript section", {"display": "block"})