summary refs log tree commit diff
path: root/src/test/rustdoc-gui/settings.goml
blob: 18270264266f424ff792987660e6a7415ced2e39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// This test ensures that the settings menu display is working as expected.
goto: file://|DOC_PATH|/test_docs/index.html
// First, we check that the settings page doesn't exist.
assert-false: "#settings"
// We now click on the settings button.
click: "#settings-menu"
wait-for: "#settings"
assert: "#main-content.hidden"
assert-css: ("#settings", {"display": "block"})
// Let's close it by clicking on the same button.
click: "#settings-menu"
assert-false: "#alternative-display #settings"
assert: "#not-displayed #settings"
assert: "#main-content:not(.hidden)"

// Let's open and then close it again with the "close settings" button.
click: "#settings-menu"
wait-for: "#alternative-display #settings"
assert: "#main-content.hidden"
click: "#back"
wait-for: "#not-displayed #settings"
assert: "#main-content:not(.hidden)"

// Let's check that pressing "ESCAPE" is closing it.
click: "#settings-menu"
wait-for: "#alternative-display #settings"
press-key: "Escape"
wait-for: "#not-displayed #settings"
assert: "#main-content:not(.hidden)"

// Let's click on it when the search results are displayed.
focus: ".search-input"
write: "test"
wait-for: "#alternative-display #search"
click: "#settings-menu"
wait-for: "#alternative-display #settings"
assert: "#not-displayed #search"
assert: "#main-content.hidden"

// Now let's check the content of the settings menu.
local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"}
reload:
click: "#settings-menu"
wait-for: "#settings"

// We check that the "Use system theme" is disabled.
assert-property: ("#use-system-theme", {"checked": "false"})
assert: "//*[@class='setting-line']/*[text()='Use system theme']"
// Meaning that only the "theme" menu is showing up.
assert: ".setting-line:not(.hidden) #theme"
assert: ".setting-line.hidden #preferred-dark-theme"
assert: ".setting-line.hidden #preferred-light-theme"

// We check that the correct theme is selected.
assert-property: ("#theme .choices #theme-dark", {"checked": "true"})

// We now switch the display.
click: "#use-system-theme"
// Wait for the hidden element to show up.
wait-for: ".setting-line:not(.hidden) #preferred-dark-theme"
assert: ".setting-line:not(.hidden) #preferred-light-theme"
// Check that the theme picking is hidden.
assert: ".setting-line.hidden #theme"

// We check their text as well.
assert-text: ("#preferred-dark-theme .setting-name", "Preferred dark theme")
assert-text: ("#preferred-light-theme .setting-name", "Preferred light theme")

// Now we go to the settings page to check that the CSS is loaded as expected.
goto: file://|DOC_PATH|/settings.html
wait-for: "#settings"
assert-css: (".setting-line .toggle", {"width": "45px", "margin-right": "20px"})