]> git.lizzy.rs Git - rust.git/blob - src/test/rustdoc-gui/settings.goml
Merge 'rust-clippy/master' into clippyup
[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']/*[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 // Now we go to the settings page to check that the CSS is loaded as expected.
59 goto: file://|DOC_PATH|/settings.html
60 wait-for: "#settings"
61 assert-css: (".setting-line .toggle", {"width": "45px", "margin-right": "20px"})