]> git.lizzy.rs Git - rust.git/blob - src/test/rustdoc-gui/settings.goml
Auto merge of #96602 - TApplencourt:patch-1, r=Mark-Simulacrum
[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: "#main-content.hidden"
9 assert-css: ("#settings", {"display": "block"})
10 // Let's close it by clicking on the same button.
11 click: "#settings-menu"
12 assert-false: "#alternative-display #settings"
13 assert: "#not-displayed #settings"
14 assert: "#main-content:not(.hidden)"
15
16 // Let's open and then close it again with the "close settings" button.
17 click: "#settings-menu"
18 wait-for: "#alternative-display #settings"
19 assert: "#main-content.hidden"
20 click: "#back"
21 wait-for: "#not-displayed #settings"
22 assert: "#main-content:not(.hidden)"
23
24 // Let's check that pressing "ESCAPE" is closing it.
25 click: "#settings-menu"
26 wait-for: "#alternative-display #settings"
27 press-key: "Escape"
28 wait-for: "#not-displayed #settings"
29 assert: "#main-content:not(.hidden)"
30
31 // Let's click on it when the search results are displayed.
32 focus: ".search-input"
33 write: "test"
34 wait-for: "#alternative-display #search"
35 click: "#settings-menu"
36 wait-for: "#alternative-display #settings"
37 assert: "#not-displayed #search"
38 assert: "#main-content.hidden"
39
40 // Now let's check the content of the settings menu.
41 local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"}
42 reload:
43 click: "#settings-menu"
44 wait-for: "#settings"
45
46 // We check that the "Use system theme" is disabled.
47 assert-property: ("#use-system-theme", {"checked": "false"})
48 assert: "//*[@class='setting-line']/*[text()='Use system theme']"
49 // Meaning that only the "theme" menu is showing up.
50 assert: ".setting-line:not(.hidden) #theme"
51 assert: ".setting-line.hidden #preferred-dark-theme"
52 assert: ".setting-line.hidden #preferred-light-theme"
53
54 // We check that the correct theme is selected.
55 assert-property: ("#theme .choices #theme-dark", {"checked": "true"})
56
57 // We now switch the display.
58 click: "#use-system-theme"
59 // Wait for the hidden element to show up.
60 wait-for: ".setting-line:not(.hidden) #preferred-dark-theme"
61 assert: ".setting-line:not(.hidden) #preferred-light-theme"
62 // Check that the theme picking is hidden.
63 assert: ".setting-line.hidden #theme"
64
65 // We check their text as well.
66 assert-text: ("#preferred-dark-theme .setting-name", "Preferred dark theme")
67 assert-text: ("#preferred-light-theme .setting-name", "Preferred light theme")
68
69 // Now we go to the settings page to check that the CSS is loaded as expected.
70 goto: file://|DOC_PATH|/settings.html
71 wait-for: "#settings"
72 assert-css: (".setting-line .toggle", {"width": "45px", "margin-right": "20px"})