Skip to content

Commit 3eb9e1a

Browse files
Add/update GUI tests for help pocket menu
1 parent cc4f804 commit 3eb9e1a

File tree

3 files changed

+74
-15
lines changed

3 files changed

+74
-15
lines changed

src/test/rustdoc-gui/escape-key.goml

-12
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,13 @@ wait-for: "#alternative-display #search"
2121
assert-attribute: ("#main-content", {"class": "content hidden"})
2222
assert-document-property: ({"URL": "index.html?search=test"}, ENDS_WITH)
2323

24-
// Now let's check that when the help popup is displayed and we press Escape, it doesn't
25-
// hide the search results too.
26-
click: "#help-button"
27-
assert-document-property: ({"URL": "index.html?search=test"}, [ENDS_WITH])
28-
assert-attribute: ("#help", {"class": ""})
29-
press-key: "Escape"
30-
wait-for: "#alternative-display #search"
31-
assert-attribute: ("#help", {"class": "hidden"})
32-
assert-attribute: ("#main-content", {"class": "content hidden"})
33-
assert-document-property: ({"URL": "index.html?search=test"}, [ENDS_WITH])
34-
3524
// Check that Escape hides the search results when a search result is focused.
3625
focus: ".search-input"
3726
assert: ".search-input:focus"
3827
press-key: "ArrowDown"
3928
assert-false: ".search-input:focus"
4029
assert: "#results a:focus"
4130
press-key: "Escape"
42-
assert-attribute: ("#help", {"class": "hidden"})
4331
wait-for: "#not-displayed #search"
4432
assert-false: "#alternative-display #search"
4533
assert-attribute: ("#main-content", {"class": "content"})

src/test/rustdoc-gui/pocket-menu.goml

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// This test ensures that the "pocket menus" are working as expected.
2+
goto: file://|DOC_PATH|/test_docs/index.html
3+
// First we check that the help menu doesn't exist yet.
4+
assert-false: "#help-button .popover"
5+
// Then we display the help menu.
6+
click: "#help-button"
7+
assert: "#help-button .popover"
8+
assert-css: ("#help-button .popover", {"display": "block"})
9+
10+
// Now we click somewhere else on the page to ensure it is handling the blur event
11+
// correctly.
12+
click: ".sidebar"
13+
assert-css: ("#help-button .popover", {"display": "none"})
14+
15+
// Now we will check that we cannot have two "pocket menus" displayed at the same time.
16+
click: "#help-button"
17+
assert-css: ("#help-button .popover", {"display": "block"})
18+
click: "#settings-menu"
19+
assert-css: ("#help-button .popover", {"display": "none"})
20+
assert-css: ("#settings-menu .popover", {"display": "block"})
21+
22+
// Now the other way.
23+
click: "#help-button"
24+
assert-css: ("#help-button .popover", {"display": "block"})
25+
assert-css: ("#settings-menu .popover", {"display": "none"})
26+
27+
// We check the borders color now:
28+
29+
// Ayu theme
30+
local-storage: {
31+
"rustdoc-theme": "ayu",
32+
"rustdoc-use-system-theme": "false",
33+
}
34+
reload:
35+
36+
click: "#help-button"
37+
assert-css: (
38+
"#help-button .popover",
39+
{"display": "block", "border-color": "rgb(92, 103, 115)"},
40+
)
41+
compare-elements-css: ("#help-button .popover", "#help-button .top", ["border-color"])
42+
compare-elements-css: ("#help-button .popover", "#help-button .bottom", ["border-color"])
43+
44+
// Dark theme
45+
local-storage: {
46+
"rustdoc-theme": "dark",
47+
"rustdoc-use-system-theme": "false",
48+
}
49+
reload:
50+
51+
click: "#help-button"
52+
assert-css: (
53+
"#help-button .popover",
54+
{"display": "block", "border-color": "rgb(210, 210, 210)"},
55+
)
56+
compare-elements-css: ("#help-button .popover", "#help-button .top", ["border-color"])
57+
compare-elements-css: ("#help-button .popover", "#help-button .bottom", ["border-color"])
58+
59+
// Light theme
60+
local-storage: {
61+
"rustdoc-theme": "light",
62+
"rustdoc-use-system-theme": "false",
63+
}
64+
reload:
65+
66+
click: "#help-button"
67+
assert-css: (
68+
"#help-button .popover",
69+
{"display": "block", "border-color": "rgb(221, 221, 221)"},
70+
)
71+
compare-elements-css: ("#help-button .popover", "#help-button .top", ["border-color"])
72+
compare-elements-css: ("#help-button .popover", "#help-button .bottom", ["border-color"])

src/test/rustdoc-gui/shortcuts.goml

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ press-key: "Escape"
88
assert-false: "input.search-input:focus"
99
// We now check for the help popup.
1010
press-key: "?"
11-
assert-css: ("#help", {"display": "flex"})
12-
assert-false: "#help.hidden"
11+
assert-css: ("#help-button .popover", {"display": "block"})
1312
press-key: "Escape"
14-
assert-css: ("#help.hidden", {"display": "none"})
13+
assert-css: ("#help-button .popover", {"display": "none"})

0 commit comments

Comments
 (0)