Skip to content

Commit 9531606

Browse files
authored
Rollup merge of #123624 - GuillaumeGomez:theme-switch-tests, r=notriddle
[rustdoc] [GUI tests] Make theme switching closer to reality Better to actually perform actions user do rather than only testing the change through local storage. As for `browser-ui-test` update: I updated `puppeteer` version (to `0.19.4`) and fixed a bug when displaying the file if it came from an `include`. r? `@notriddle`
2 parents b809c42 + 9fadad7 commit 9531606

File tree

7 files changed

+45
-33
lines changed

7 files changed

+45
-33
lines changed

src/ci/docker/host-x86_64/x86_64-gnu-tools/Dockerfile

+10-12
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,6 @@ ENV PATH="$NODE_FOLDER:${PATH}"
7878

7979
COPY host-x86_64/x86_64-gnu-tools/browser-ui-test.version /tmp/
8080

81-
# For now, we need to use `--unsafe-perm=true` to go around an issue when npm tries
82-
# to create a new folder. For reference:
83-
# https://github.com/puppeteer/puppeteer/issues/375
84-
#
85-
# We also specify the version in case we need to update it to go around cache limitations.
86-
#
87-
# The `browser-ui-test.version` file is also used by bootstrap to emit warnings in case
88-
# the local version of the package is different than the one used by the CI.
89-
RUN npm install -g browser-ui-test@$(head -n 1 /tmp/browser-ui-test.version) --unsafe-perm=true
90-
9181
ENV RUST_CONFIGURE_ARGS \
9282
--build=x86_64-unknown-linux-gnu \
9383
--save-toolstates=/tmp/toolstate/toolstates.json \
@@ -100,6 +90,14 @@ COPY host-x86_64/dist-x86_64-linux/build-gccjit.sh /scripts/
10090

10191
RUN /scripts/build-gccjit.sh /scripts
10292

93+
# For now, we need to use `--unsafe-perm=true` to go around an issue when npm tries
94+
# to create a new folder. For reference:
95+
# https://github.com/puppeteer/puppeteer/issues/375
96+
#
97+
# We also specify the version in case we need to update it to go around cache limitations.
98+
#
99+
# The `browser-ui-test.version` file is also used by bootstrap to emit warnings in case
100+
# the local version of the package is different than the one used by the CI.
103101
ENV SCRIPT /tmp/checktools.sh ../x.py && \
104-
NODE_PATH=`npm root -g` python3 ../x.py test tests/rustdoc-gui --stage 2 \
105-
--test-args "'--no-sandbox --jobs 1'"
102+
npm install browser-ui-test@$(head -n 1 /tmp/browser-ui-test.version) --unsafe-perm=true && \
103+
python3 ../x.py test tests/rustdoc-gui --stage 2 --test-args "'--no-sandbox --jobs 1'"
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.17.1
1+
0.17.2

tests/rustdoc-gui/docblock-code-block-line-number.goml

+9-7
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,25 @@
22
include: "utils.goml"
33
go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"
44

5-
// Otherwise, we can't check text color
6-
show-text: true
7-
85
// We check that without this setting, there is no line number displayed.
96
assert-false: "pre.example-line-numbers"
107

8+
// We set the setting to show the line numbers on code examples.
9+
set-local-storage: {"rustdoc-line-numbers": "true"}
10+
reload:
11+
// We wait for the line numbers to be added into the DOM by the JS...
12+
wait-for: "pre.example-line-numbers"
13+
14+
// Otherwise, we can't check text color
15+
show-text: true
16+
1117
// Let's now check some CSS properties...
1218
define-function: (
1319
"check-colors",
1420
[theme, color],
1521
block {
16-
// We now set the setting to show the line numbers on code examples.
17-
set-local-storage: {"rustdoc-line-numbers": "true"}
1822
// Page will be reloaded in "switch-theme".
1923
call-function: ("switch-theme", {"theme": |theme|})
20-
// We wait for the line numbers to be added into the DOM by the JS...
21-
wait-for: "pre.example-line-numbers"
2224
// If the test didn't fail, it means that it was found!
2325
assert-css: (
2426
"pre.example-line-numbers",

tests/rustdoc-gui/scrape-examples-toggle.goml

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ define-function: (
99
[theme, toggle_line_color, toggle_line_hover_color],
1010
block {
1111
call-function: ("switch-theme", {"theme": |theme|})
12+
reload:
1213

1314
// Clicking "More examples..." will open additional examples
1415
assert-attribute-false: (".more-examples-toggle", {"open": ""})
@@ -21,6 +22,8 @@ define-function: (
2122
".toggle-line:hover .toggle-line-inner",
2223
{"background-color": |toggle_line_hover_color|},
2324
)
25+
// We put the toggle in the original state.
26+
click: ".more-examples-toggle"
2427
// Moving cursor away from the toggle line to prevent disrupting next test.
2528
move-cursor-to: ".search-input"
2629
},

tests/rustdoc-gui/search-result-color.goml

+6-9
Original file line numberDiff line numberDiff line change
@@ -210,24 +210,21 @@ call-function: ("check-search-color", {
210210

211211
// Check the alias.
212212
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
213-
// If the text isn't displayed, the browser doesn't compute color style correctly...
214-
show-text: true
213+
214+
write-into: (".search-input", "thisisanalias")
215+
// To be SURE that the search will be run.
216+
press-key: 'Enter'
217+
// Waiting for the search results to appear...
218+
wait-for: "#search-tabs"
215219

216220
define-function: (
217221
"check-alias",
218222
[theme, alias, grey],
219223
block {
220224
call-function: ("switch-theme", {"theme": |theme|})
221-
write-into: (".search-input", "thisisanalias")
222-
// To be SURE that the search will be run.
223-
press-key: 'Enter'
224-
// Waiting for the search results to appear...
225-
wait-for: "#search-tabs"
226225
// Checking that the colors for the alias element are the ones expected.
227226
assert-css: (".result-name .path .alias", {"color": |alias|})
228227
assert-css: (".result-name .path .alias > .grey", {"color": |grey|})
229-
// Leave the search results to prevent reloading with an already filled search input.
230-
press-key: "Escape"
231228
},
232229
)
233230

tests/rustdoc-gui/settings.goml

+6-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ wait-for: "#alternative-display #search"
3636
assert: "#main-content.hidden"
3737

3838
// Now let's check the content of the settings menu.
39-
call-function: ("switch-theme", {"theme": "dark"})
39+
// If we are on the settings page, the menu doesn't work the same so we set
40+
// the theme manually.
41+
set-local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"}
42+
// We reload the page so the local storage settings are being used.
43+
reload:
44+
4045
click: "#settings-menu"
4146
wait-for: "#settings"
4247

tests/rustdoc-gui/utils.goml

+10-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,15 @@ define-function: (
44
[theme],
55
block {
66
// Set the theme.
7-
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
8-
// We reload the page so the local storage settings are being used.
9-
reload:
7+
// Open the settings menu.
8+
click: "#settings-menu"
9+
// Wait for the popover to appear...
10+
wait-for: "#settings"
11+
// Change the setting.
12+
click: "#theme-"+ |theme|
13+
// Close the popover.
14+
click: "#settings-menu"
15+
// Ensure that the local storage was correctly updated.
16+
assert-local-storage: {"rustdoc-theme": |theme|}
1017
},
1118
)

0 commit comments

Comments
 (0)