blob: ec5710fbcdcd27dec7b94e878f33e2267aed3fa0 [file] [log] [blame]
Guillaume Gomez34a4e5c2022-12-21 20:21:31 +01001// This tests checks that the "scraped examples" toggle is working as expected.
Guillaume Gomez7659ef42024-04-05 21:38:55 +02002include: "utils.goml"
Guillaume Gomez010fa002023-04-11 19:11:34 +02003go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html"
Will Crichton212d03d2022-12-06 09:59:49 -08004
Guillaume Gomez457f6c82022-12-24 08:29:17 +01005// Checking the color of the toggle line.
6show-text: true
7define-function: (
8 "check-color",
Guillaume Gomez59120d02024-04-01 21:11:22 +02009 [theme, toggle_line_color, toggle_line_hover_color],
Guillaume Gomez009064f2023-01-06 15:18:51 +010010 block {
Guillaume Gomez7659ef42024-04-05 21:38:55 +020011 call-function: ("switch-theme", {"theme": |theme|})
Guillaume Gomez66bc97c2024-04-08 12:14:41 +020012 reload:
Guillaume Gomez457f6c82022-12-24 08:29:17 +010013
14 // Clicking "More examples..." will open additional examples
Guillaume Gomez009064f2023-01-06 15:18:51 +010015 assert-attribute-false: (".more-examples-toggle", {"open": ""})
16 click: ".more-examples-toggle"
17 assert-attribute: (".more-examples-toggle", {"open": ""})
Guillaume Gomez457f6c82022-12-24 08:29:17 +010018
Guillaume Gomez009064f2023-01-06 15:18:51 +010019 assert-css: (".toggle-line-inner", {"background-color": |toggle_line_color|}, ALL)
20 move-cursor-to: ".toggle-line"
21 assert-css: (
Guillaume Gomez457f6c82022-12-24 08:29:17 +010022 ".toggle-line:hover .toggle-line-inner",
23 {"background-color": |toggle_line_hover_color|},
Guillaume Gomez009064f2023-01-06 15:18:51 +010024 )
Guillaume Gomez66bc97c2024-04-08 12:14:41 +020025 // We put the toggle in the original state.
26 click: ".more-examples-toggle"
Guillaume Gomez457f6c82022-12-24 08:29:17 +010027 // Moving cursor away from the toggle line to prevent disrupting next test.
Michael Howell8511e402024-11-22 12:58:20 -070028 move-cursor-to: "rustdoc-toolbar #search-button"
Guillaume Gomez009064f2023-01-06 15:18:51 +010029 },
Guillaume Gomez457f6c82022-12-24 08:29:17 +010030)
31
32call-function: ("check-color", {
33 "theme": "ayu",
Guillaume Gomez9625fc52023-08-05 12:47:05 +020034 "toggle_line_color": "#999",
35 "toggle_line_hover_color": "#c5c5c5",
Guillaume Gomez457f6c82022-12-24 08:29:17 +010036})
37call-function: ("check-color", {
38 "theme": "dark",
Guillaume Gomez9625fc52023-08-05 12:47:05 +020039 "toggle_line_color": "#999",
40 "toggle_line_hover_color": "#c5c5c5",
Guillaume Gomez457f6c82022-12-24 08:29:17 +010041})
42call-function: ("check-color", {
43 "theme": "light",
Guillaume Gomez9625fc52023-08-05 12:47:05 +020044 "toggle_line_color": "#ccc",
45 "toggle_line_hover_color": "#999",
Guillaume Gomez457f6c82022-12-24 08:29:17 +010046})
Will Crichton212d03d2022-12-06 09:59:49 -080047
48// Toggling all docs will close additional examples
49click: "#toggle-all-docs"
50assert-attribute-false: (".more-examples-toggle", {"open": ""})
51
52// After re-opening the docs, the additional examples should stay closed
53click: "#toggle-all-docs"
54assert-attribute-false: (".more-examples-toggle", {"open": ""})