| Guillaume Gomez | 34a4e5c | 2022-12-21 20:21:31 +0100 | [diff] [blame] | 1 | // This tests checks that the "scraped examples" toggle is working as expected. |
| Guillaume Gomez | 7659ef4 | 2024-04-05 21:38:55 +0200 | [diff] [blame] | 2 | include: "utils.goml" |
| Guillaume Gomez | 010fa00 | 2023-04-11 19:11:34 +0200 | [diff] [blame] | 3 | go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html" |
| Will Crichton | 212d03d | 2022-12-06 09:59:49 -0800 | [diff] [blame] | 4 | |
| Guillaume Gomez | 457f6c8 | 2022-12-24 08:29:17 +0100 | [diff] [blame] | 5 | // Checking the color of the toggle line. |
| 6 | show-text: true |
| 7 | define-function: ( |
| 8 | "check-color", |
| Guillaume Gomez | 59120d0 | 2024-04-01 21:11:22 +0200 | [diff] [blame] | 9 | [theme, toggle_line_color, toggle_line_hover_color], |
| Guillaume Gomez | 009064f | 2023-01-06 15:18:51 +0100 | [diff] [blame] | 10 | block { |
| Guillaume Gomez | 7659ef4 | 2024-04-05 21:38:55 +0200 | [diff] [blame] | 11 | call-function: ("switch-theme", {"theme": |theme|}) |
| Guillaume Gomez | 66bc97c | 2024-04-08 12:14:41 +0200 | [diff] [blame] | 12 | reload: |
| Guillaume Gomez | 457f6c8 | 2022-12-24 08:29:17 +0100 | [diff] [blame] | 13 | |
| 14 | // Clicking "More examples..." will open additional examples |
| Guillaume Gomez | 009064f | 2023-01-06 15:18:51 +0100 | [diff] [blame] | 15 | assert-attribute-false: (".more-examples-toggle", {"open": ""}) |
| 16 | click: ".more-examples-toggle" |
| 17 | assert-attribute: (".more-examples-toggle", {"open": ""}) |
| Guillaume Gomez | 457f6c8 | 2022-12-24 08:29:17 +0100 | [diff] [blame] | 18 | |
| Guillaume Gomez | 009064f | 2023-01-06 15:18:51 +0100 | [diff] [blame] | 19 | assert-css: (".toggle-line-inner", {"background-color": |toggle_line_color|}, ALL) |
| 20 | move-cursor-to: ".toggle-line" |
| 21 | assert-css: ( |
| Guillaume Gomez | 457f6c8 | 2022-12-24 08:29:17 +0100 | [diff] [blame] | 22 | ".toggle-line:hover .toggle-line-inner", |
| 23 | {"background-color": |toggle_line_hover_color|}, |
| Guillaume Gomez | 009064f | 2023-01-06 15:18:51 +0100 | [diff] [blame] | 24 | ) |
| Guillaume Gomez | 66bc97c | 2024-04-08 12:14:41 +0200 | [diff] [blame] | 25 | // We put the toggle in the original state. |
| 26 | click: ".more-examples-toggle" |
| Guillaume Gomez | 457f6c8 | 2022-12-24 08:29:17 +0100 | [diff] [blame] | 27 | // Moving cursor away from the toggle line to prevent disrupting next test. |
| Michael Howell | 8511e40 | 2024-11-22 12:58:20 -0700 | [diff] [blame] | 28 | move-cursor-to: "rustdoc-toolbar #search-button" |
| Guillaume Gomez | 009064f | 2023-01-06 15:18:51 +0100 | [diff] [blame] | 29 | }, |
| Guillaume Gomez | 457f6c8 | 2022-12-24 08:29:17 +0100 | [diff] [blame] | 30 | ) |
| 31 | |
| 32 | call-function: ("check-color", { |
| 33 | "theme": "ayu", |
| Guillaume Gomez | 9625fc5 | 2023-08-05 12:47:05 +0200 | [diff] [blame] | 34 | "toggle_line_color": "#999", |
| 35 | "toggle_line_hover_color": "#c5c5c5", |
| Guillaume Gomez | 457f6c8 | 2022-12-24 08:29:17 +0100 | [diff] [blame] | 36 | }) |
| 37 | call-function: ("check-color", { |
| 38 | "theme": "dark", |
| Guillaume Gomez | 9625fc5 | 2023-08-05 12:47:05 +0200 | [diff] [blame] | 39 | "toggle_line_color": "#999", |
| 40 | "toggle_line_hover_color": "#c5c5c5", |
| Guillaume Gomez | 457f6c8 | 2022-12-24 08:29:17 +0100 | [diff] [blame] | 41 | }) |
| 42 | call-function: ("check-color", { |
| 43 | "theme": "light", |
| Guillaume Gomez | 9625fc5 | 2023-08-05 12:47:05 +0200 | [diff] [blame] | 44 | "toggle_line_color": "#ccc", |
| 45 | "toggle_line_hover_color": "#999", |
| Guillaume Gomez | 457f6c8 | 2022-12-24 08:29:17 +0100 | [diff] [blame] | 46 | }) |
| Will Crichton | 212d03d | 2022-12-06 09:59:49 -0800 | [diff] [blame] | 47 | |
| 48 | // Toggling all docs will close additional examples |
| 49 | click: "#toggle-all-docs" |
| 50 | assert-attribute-false: (".more-examples-toggle", {"open": ""}) |
| 51 | |
| 52 | // After re-opening the docs, the additional examples should stay closed |
| 53 | click: "#toggle-all-docs" |
| 54 | assert-attribute-false: (".more-examples-toggle", {"open": ""}) |