Rollup merge of #123515 - GuillaumeGomez:use-include, r=notriddle

Use `include` command to reduce code duplication

Since we updated `browser-ui-test` version, let's make use of the new commands. :)

r? `@notriddle`
This commit is contained in:
Guillaume Gomez 2024-04-05 22:33:30 +02:00 committed by GitHub
commit a074d278d3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
43 changed files with 112 additions and 150 deletions

View File

@ -1,4 +1,5 @@
// This test is to ensure that the anchors (`§`) have the expected color and position. // This test is to ensure that the anchors (`§`) have the expected color and position.
include: "utils.goml"
define-function: ( define-function: (
"check-colors", "check-colors",
@ -8,10 +9,7 @@ define-function: (
// This is needed to ensure that the text color is computed. // This is needed to ensure that the text color is computed.
show-text: true show-text: true
// Setting the theme. call-function: ("switch-theme", {"theme": |theme|})
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
// We reload the page so the local storage settings are being used.
reload:
assert-css: ("#toggle-all-docs", {"color": |main_color|}) assert-css: ("#toggle-all-docs", {"color": |main_color|})
assert-css: (".main-heading h1 a:nth-of-type(1)", {"color": |main_heading_color|}) assert-css: (".main-heading h1 a:nth-of-type(1)", {"color": |main_heading_color|})

View File

@ -2,6 +2,7 @@
// check that the rule isn't applied on other "<code>" elements. // check that the rule isn't applied on other "<code>" elements.
// //
// While we're at it, we also check it for the other themes. // While we're at it, we also check it for the other themes.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"
// If the text isn't displayed, the browser doesn't compute color style correctly... // If the text isn't displayed, the browser doesn't compute color style correctly...
show-text: true show-text: true
@ -10,10 +11,7 @@ define-function: (
"check-colors", "check-colors",
[theme, doc_code_color, doc_inline_code_color], [theme, doc_code_color, doc_inline_code_color],
block { block {
// Set the theme. call-function: ("switch-theme", {"theme": |theme|})
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
// We reload the page so the local storage settings are being used.
reload:
assert-css: (".docblock pre > code", {"color": |doc_code_color|}, ALL) assert-css: (".docblock pre > code", {"color": |doc_code_color|}, ALL)
assert-css: (".docblock > p > code", {"color": |doc_inline_code_color|}, ALL) assert-css: (".docblock > p > code", {"color": |doc_inline_code_color|}, ALL)
}, },

View File

@ -1,4 +1,5 @@
// Checking the colors of the codeblocks tooltips. // Checking the colors of the codeblocks tooltips.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"
show-text: true show-text: true
@ -6,9 +7,7 @@ define-function: (
"check-colors", "check-colors",
[theme, background, color, border], [theme, background, color, border],
block { block {
// Setting the theme. call-function: ("switch-theme", {"theme": |theme|})
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
reload:
// compile_fail block // compile_fail block
assert-css: ( assert-css: (

View File

@ -1,4 +1,5 @@
// Checks that the setting "line numbers" is working as expected. // Checks that the setting "line numbers" is working as expected.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"
// Otherwise, we can't check text color // Otherwise, we can't check text color
@ -13,14 +14,10 @@ define-function: (
[theme, color], [theme, color],
block { block {
// We now set the setting to show the line numbers on code examples. // We now set the setting to show the line numbers on code examples.
set-local-storage: { set-local-storage: {"rustdoc-line-numbers": "true"}
"rustdoc-theme": |theme|, // Page will be reloaded in "switch-theme".
"rustdoc-use-system-theme": "false", call-function: ("switch-theme", {"theme": |theme|})
"rustdoc-line-numbers": "true" // We wait for the line numbers to be added into the DOM by the JS...
}
// We reload to make the line numbers appear and change theme.
reload:
// We wait for them to be added into the DOM by the JS...
wait-for: "pre.example-line-numbers" wait-for: "pre.example-line-numbers"
// If the test didn't fail, it means that it was found! // If the test didn't fail, it means that it was found!
assert-css: ( assert-css: (

View File

@ -1,8 +1,8 @@
// This ensures that the `<details>`/`<summary>` elements are displayed as expected. // This ensures that the `<details>`/`<summary>` elements are displayed as expected.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/details/struct.Details.html" go-to: "file://" + |DOC_PATH| + "/test_docs/details/struct.Details.html"
show-text: true show-text: true
set-local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"} call-function: ("switch-theme", {"theme": "dark"})
reload:
// We first check that the headers in the `.top-doc` doc block still have their // We first check that the headers in the `.top-doc` doc block still have their
// bottom border. // bottom border.

View File

@ -1,4 +1,5 @@
// This test checks the appearance of the tables in the doc comments. // This test checks the appearance of the tables in the doc comments.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/doc_block_table/struct.DocBlockTable.html#method.func" go-to: "file://" + |DOC_PATH| + "/test_docs/doc_block_table/struct.DocBlockTable.html#method.func"
compare-elements-css: (".impl-items .docblock table th", ".top-doc .docblock table th", ["border"]) compare-elements-css: (".impl-items .docblock table th", ".top-doc .docblock table th", ["border"])
@ -8,8 +9,7 @@ define-function: (
"check-colors", "check-colors",
[theme, border_color, zebra_stripe_color], [theme, border_color, zebra_stripe_color],
block { block {
set-local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": |theme|} call-function: ("switch-theme", {"theme": |theme|})
reload:
assert-css: (".top-doc .docblock table tbody tr:nth-child(1)", { assert-css: (".top-doc .docblock table tbody tr:nth-child(1)", {
"background-color": "rgba(0, 0, 0, 0)", "background-color": "rgba(0, 0, 0, 0)",
}) })

View File

@ -1,5 +1,7 @@
// This test check for headings text and background colors for the different themes. // This test check for headings text and background colors for the different themes.
include: "utils.goml"
define-function: ( define-function: (
"check-colors", "check-colors",
[theme, color, code_header_color, focus_background_color, headings_color], [theme, color, code_header_color, focus_background_color, headings_color],
@ -7,8 +9,7 @@ define-function: (
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"
// This is needed so that the text color is computed. // This is needed so that the text color is computed.
show-text: true show-text: true
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} call-function: ("switch-theme", {"theme": |theme|})
reload:
assert-css: ( assert-css: (
".impl", ".impl",
{"color": |color|, "background-color": "rgba(0, 0, 0, 0)"}, {"color": |color|, "background-color": "rgba(0, 0, 0, 0)"},

View File

@ -11,6 +11,7 @@
// 18px 1.125em // 18px 1.125em
// 16px 1rem // 16px 1rem
// 14px 0.875rem // 14px 0.875rem
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html" go-to: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html"
assert-css: (".main-heading h1", {"font-size": "24px"}) assert-css: (".main-heading h1", {"font-size": "24px"})
@ -158,8 +159,8 @@ define-function: (
"check-colors", "check-colors",
[theme, heading_color, small_heading_color, heading_border_color], [theme, heading_color, small_heading_color, heading_border_color],
block { block {
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} call-function: ("switch-theme", {"theme": |theme|})
reload:
assert-css: ( assert-css: (
".top-doc .docblock h2", ".top-doc .docblock h2",
{"color": |heading_color|, "border-bottom": "1px solid " + |heading_border_color|}, {"color": |heading_color|, "border-bottom": "1px solid " + |heading_border_color|},
@ -222,8 +223,7 @@ define-function: (
"check-since-color", "check-since-color",
[theme], [theme],
block { block {
set-local-storage: {"rustdoc-theme": |theme|} call-function: ("switch-theme", {"theme": |theme|})
reload:
assert-css: (".since", {"color": "#808080"}, ALL) assert-css: (".since", {"color": "#808080"}, ALL)
}, },
) )

View File

@ -1,4 +1,5 @@
// This test ensures that opening the help page in its own tab works. // This test ensures that opening the help page in its own tab works.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/help.html" go-to: "file://" + |DOC_PATH| + "/help.html"
set-window-size: (1000, 1000) // Try desktop size first. set-window-size: (1000, 1000) // Try desktop size first.
wait-for: "#help" wait-for: "#help"
@ -19,10 +20,7 @@ define-function: (
"check-colors", "check-colors",
[theme, color, background, box_shadow], [theme, color, background, box_shadow],
block { block {
// Setting the theme. call-function: ("switch-theme", {"theme": |theme|})
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
// We reload the page so the local storage settings are being used.
reload:
assert-css: ("#help kbd", { assert-css: ("#help kbd", {
"color": |color|, "color": |color|,
"background-color": |background|, "background-color": |background|,

View File

@ -1,4 +1,5 @@
// This test checks the highlight colors in the source code pages. // This test checks the highlight colors in the source code pages.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
show-text: true show-text: true
@ -22,8 +23,7 @@ define-function: (
doc_comment, doc_comment,
], ],
block { block {
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} call-function: ("switch-theme", {"theme": |theme|})
reload:
assert-css: ("pre.rust .kw", {"color": |kw|}, ALL) assert-css: ("pre.rust .kw", {"color": |kw|}, ALL)
assert-css: ("pre.rust .kw-2", {"color": |kw2|}, ALL) assert-css: ("pre.rust .kw-2", {"color": |kw2|}, ALL)
assert-css: ("pre.rust .prelude-ty", {"color": |prelude_ty|}, ALL) assert-css: ("pre.rust .prelude-ty", {"color": |prelude_ty|}, ALL)

View File

@ -1,5 +1,7 @@
// This test ensures that the color of the items in the type decl are working as expected. // This test ensures that the color of the items in the type decl are working as expected.
include: "utils.goml"
// We need to disable this check because `trait.impl/test_docs/trait.TraitWithoutGenerics.js` // We need to disable this check because `trait.impl/test_docs/trait.TraitWithoutGenerics.js`
// doesn't exist. // doesn't exist.
fail-on-request-error: false fail-on-request-error: false
@ -21,8 +23,8 @@ define-function: (
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.WithGenerics.html" go-to: "file://" + |DOC_PATH| + "/test_docs/struct.WithGenerics.html"
show-text: true show-text: true
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} call-function: ("switch-theme", {"theme": |theme|})
reload:
assert-css: (".item-decl .code-attribute", {"color": |attr_color|}, ALL) assert-css: (".item-decl .code-attribute", {"color": |attr_color|}, ALL)
assert-css: (".item-decl .trait", {"color": |trait_color|}, ALL) assert-css: (".item-decl .trait", {"color": |trait_color|}, ALL)
// We need to add `code` here because otherwise it would select the parent too. // We need to add `code` here because otherwise it would select the parent too.

View File

@ -1,4 +1,5 @@
// This test checks that comments in item declarations are highlighted. // This test checks that comments in item declarations are highlighted.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/private/enum.Enum.html" go-to: "file://" + |DOC_PATH| + "/test_docs/private/enum.Enum.html"
show-text: true show-text: true
@ -7,8 +8,7 @@ define-function: (
[theme, url, comment_color], [theme, url, comment_color],
block { block {
go-to: |url| go-to: |url|
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} call-function: ("switch-theme", {"theme": |theme|})
reload:
assert-css: (".item-decl .comment", {"color": |comment_color|}, ALL) assert-css: (".item-decl .comment", {"color": |comment_color|}, ALL)
} }
) )

View File

@ -1,14 +1,12 @@
// We check the background color on the jump to definition links in the src code page. // We check the background color on the jump to definition links in the src code page.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/src/link_to_definition/lib.rs.html" go-to: "file://" + |DOC_PATH| + "/src/link_to_definition/lib.rs.html"
define-function: ( define-function: (
"check-background-color", "check-background-color",
[theme, background_color], [theme, background_color],
block { block {
// Set the theme. call-function: ("switch-theme", {"theme": |theme|})
set-local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false" }
// We reload the page so the local storage settings are being used.
reload:
assert-css: ( assert-css: (
"body.src .example-wrap pre.rust a", "body.src .example-wrap pre.rust a",
{"background-color": |background_color|}, {"background-color": |background_color|},

View File

@ -1,4 +1,5 @@
// This test checks links colors. // This test checks links colors.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
// This is needed so that the text color is computed. // This is needed so that the text color is computed.
@ -9,11 +10,7 @@ define-function: (
[theme, mod, macro, struct, enum, trait, fn, type, union, keyword, [theme, mod, macro, struct, enum, trait, fn, type, union, keyword,
sidebar, sidebar_current, sidebar_current_background], sidebar, sidebar_current, sidebar_current_background],
block { block {
set-local-storage: { call-function: ("switch-theme", {"theme": |theme|})
"rustdoc-theme": |theme|,
"rustdoc-use-system-theme": "false",
}
reload:
// Checking results colors. // Checking results colors.
assert-css: (".item-table .mod", {"color": |mod|}, ALL) assert-css: (".item-table .mod", {"color": |mod|}, ALL)
assert-css: (".item-table .macro", {"color": |macro|}, ALL) assert-css: (".item-table .macro", {"color": |macro|}, ALL)

View File

@ -1,4 +1,5 @@
// This test checks the position of the `i` for the notable traits. // This test checks the position of the `i` for the notable traits.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.NotableStructWithLongName.html" go-to: "file://" + |DOC_PATH| + "/test_docs/struct.NotableStructWithLongName.html"
show-text: true show-text: true
// We start with a wide screen. // We start with a wide screen.
@ -128,10 +129,7 @@ define-function: (
// This is needed to ensure that the text color is computed. // This is needed to ensure that the text color is computed.
show-text: true show-text: true
// Setting the theme. call-function: ("switch-theme", {"theme": |theme|})
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
// We reload the page so the local storage settings are being used.
reload:
assert-css: ( assert-css: (
"//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']", "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",

View File

@ -1,4 +1,5 @@
// This test ensures that the "pocket menus" are working as expected. // This test ensures that the "pocket menus" are working as expected.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
// First we check that the help menu doesn't exist yet. // First we check that the help menu doesn't exist yet.
assert-false: "#help-button .popover" assert-false: "#help-button .popover"
@ -33,11 +34,7 @@ define-function: (
"check-popover-colors", "check-popover-colors",
[theme, border_color], [theme, border_color],
block { block {
set-local-storage: { call-function: ("switch-theme", {"theme": |theme|})
"rustdoc-theme": |theme|,
"rustdoc-use-system-theme": "false",
}
reload:
click: "#help-button" click: "#help-button"
assert-css: ( assert-css: (

View File

@ -2,6 +2,7 @@
// Playground. That button is hidden until the user hovers over the code block. // Playground. That button is hidden until the user hovers over the code block.
// This test checks that it is hidden, and that it shows on hover. It also // This test checks that it is hidden, and that it shows on hover. It also
// checks for its color. // checks for its color.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"
show-text: true show-text: true
@ -9,8 +10,7 @@ define-function: (
"check-run-button", "check-run-button",
[theme, color, background, hover_color, hover_background], [theme, color, background, hover_color, hover_background],
block { block {
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} call-function: ("switch-theme", {"theme": |theme|})
reload:
assert-css: (".test-arrow", {"visibility": "hidden"}) assert-css: (".test-arrow", {"visibility": "hidden"})
move-cursor-to: ".example-wrap" move-cursor-to: ".example-wrap"
assert-css: (".test-arrow", { assert-css: (".test-arrow", {

View File

@ -1,4 +1,5 @@
// This test ensures that the correct style is applied to the rust logo in the sidebar. // This test ensures that the correct style is applied to the rust logo in the sidebar.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/staged_api/index.html" go-to: "file://" + |DOC_PATH| + "/staged_api/index.html"
define-function: ( define-function: (
@ -8,14 +9,12 @@ define-function: (
// Going to the doc page. // Going to the doc page.
go-to: "file://" + |DOC_PATH| + "/staged_api/index.html" go-to: "file://" + |DOC_PATH| + "/staged_api/index.html"
// Changing theme. // Changing theme.
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} call-function: ("switch-theme", {"theme": |theme|})
reload:
assert-css: (".rust-logo", {"filter": |filter|}) assert-css: (".rust-logo", {"filter": |filter|})
// Now we check that the non-rust logos don't have a CSS filter set. // Now we check that the non-rust logos don't have a CSS filter set.
go-to: "file://" + |DOC_PATH| + "/huge_logo/index.html" go-to: "file://" + |DOC_PATH| + "/huge_logo/index.html"
// Changing theme on the new page (again...). // Changing theme on the new page (again...).
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} call-function: ("switch-theme", {"theme": |theme|})
reload:
// Check there is no rust logo // Check there is no rust logo
assert-false: ".rust-logo" assert-false: ".rust-logo"
// Check there is no filter. // Check there is no filter.

View File

@ -1,4 +1,5 @@
// Check that scrape example code blocks have the expected colors. // Check that scrape example code blocks have the expected colors.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html" go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html"
show-text: true show-text: true
@ -7,8 +8,7 @@ define-function: (
[theme, highlight, highlight_focus, help_border, help_color, help_hover_border, [theme, highlight, highlight_focus, help_border, help_color, help_hover_border,
help_hover_color], help_hover_color],
block { block {
set-local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false", } call-function: ("switch-theme", {"theme": |theme|})
reload:
wait-for: ".more-examples-toggle" wait-for: ".more-examples-toggle"
assert-css: (".scraped-example .example-wrap .rust span.highlight:not(.focus)", { assert-css: (".scraped-example .example-wrap .rust span.highlight:not(.focus)", {
"background-color": |highlight|, "background-color": |highlight|,
@ -66,8 +66,7 @@ define-function: (
"check-background", "check-background",
[theme, background_color_start, background_color_end], [theme, background_color_start, background_color_end],
block { block {
set-local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false", } call-function: ("switch-theme", {"theme": |theme|})
reload:
assert-css: (".scraped-example:not(.expanded) .code-wrapper::before", { assert-css: (".scraped-example:not(.expanded) .code-wrapper::before", {
"background-image": "linear-gradient(" + |background_color_start| + ", " + "background-image": "linear-gradient(" + |background_color_start| + ", " +
|background_color_end| + ")", |background_color_end| + ")",

View File

@ -1,4 +1,5 @@
// This tests checks that the "scraped examples" toggle is working as expected. // This tests checks that the "scraped examples" toggle is working as expected.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html" go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html"
// Checking the color of the toggle line. // Checking the color of the toggle line.
@ -7,8 +8,7 @@ define-function: (
"check-color", "check-color",
[theme, toggle_line_color, toggle_line_hover_color], [theme, toggle_line_color, toggle_line_hover_color],
block { block {
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} call-function: ("switch-theme", {"theme": |theme|})
reload:
// Clicking "More examples..." will open additional examples // Clicking "More examples..." will open additional examples
assert-attribute-false: (".more-examples-toggle", {"open": ""}) assert-attribute-false: (".more-examples-toggle", {"open": ""})

View File

@ -1,4 +1,5 @@
// Checks that the crate search filtering is handled correctly and changes the results. // Checks that the crate search filtering is handled correctly and changes the results.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=sa'%3Bda'%3Bds" go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=sa'%3Bda'%3Bds"
show-text: true show-text: true
@ -6,11 +7,7 @@ define-function: (
"check-colors", "check-colors",
[theme, error_background], [theme, error_background],
block { block {
// Setting the theme. call-function: ("switch-theme", {"theme": |theme|})
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
// We reload the page so the local storage settings are being used.
reload:
wait-for: "#search .error code" wait-for: "#search .error code"
assert-css: ("#search .error code", {"background-color": |error_background|}) assert-css: ("#search .error code", {"background-color": |error_background|})
} }

View File

@ -1,4 +1,5 @@
// Checks that the crate search filtering is handled correctly and changes the results. // Checks that the crate search filtering is handled correctly and changes the results.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
show-text: true show-text: true
write-into: (".search-input", "test") write-into: (".search-input", "test")
@ -59,8 +60,7 @@ assert-text: (".search-results-title", "Results in all crates", STARTS_WITH)
// Checking the display of the crate filter. // Checking the display of the crate filter.
// We start with the light theme. // We start with the light theme.
set-local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} call-function: ("switch-theme", {"theme": "light"})
reload:
set-timeout: 2000 set-timeout: 2000
wait-for: "#crate-search" wait-for: "#crate-search"

View File

@ -1,4 +1,5 @@
// This test ensures that the elements in ".search-form" have the expected display. // This test ensures that the elements in ".search-form" have the expected display.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
show-text: true show-text: true
@ -9,11 +10,7 @@ define-function: (
menu_button_border, menu_button_a_color, menu_button_a_border_hover, menu_a_color, menu_button_border, menu_button_a_color, menu_button_a_border_hover, menu_a_color,
], ],
block { block {
set-local-storage: { call-function: ("switch-theme", {"theme": |theme|})
"rustdoc-theme": |theme|,
"rustdoc-use-system-theme": "false",
}
reload:
assert-css: ( assert-css: (
".search-input", ".search-input",
{ {

View File

@ -1,4 +1,5 @@
// The goal of this test is to check the color of the "no result" links. // The goal of this test is to check the color of the "no result" links.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/lib2/index.html?search=sdkfskjfsdks" go-to: "file://" + |DOC_PATH| + "/lib2/index.html?search=sdkfskjfsdks"
show-text: true show-text: true
@ -6,9 +7,7 @@ define-function: (
"check-no-result", "check-no-result",
[theme, link, link_hover], [theme, link, link_hover],
block { block {
// Changing theme. call-function: ("switch-theme", {"theme": |theme|})
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
reload:
wait-for: "#results" wait-for: "#results"
assert: ".search-failed.active" assert: ".search-failed.active"
assert-css: ("#results a", {"color": |link|}, ALL) assert-css: ("#results a", {"color": |link|}, ALL)

View File

@ -1,8 +1,8 @@
// Checks that the reexports are present in the search index, can have // Checks that the reexports are present in the search index, can have
// doc aliases and are highligted when their ID is the hash of the page. // doc aliases and are highligted when their ID is the hash of the page.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
set-local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"} call-function: ("switch-theme", {"theme": "dark"})
reload:
// First we check that the reexport has the correct ID and no background color. // First we check that the reexport has the correct ID and no background color.
assert-text: ("//*[@id='reexport.TheStdReexport']", "pub use ::std as TheStdReexport;") assert-text: ("//*[@id='reexport.TheStdReexport']", "pub use ::std as TheStdReexport;")
assert-css: ("//*[@id='reexport.TheStdReexport']", {"background-color": "rgba(0, 0, 0, 0)"}) assert-css: ("//*[@id='reexport.TheStdReexport']", {"background-color": "rgba(0, 0, 0, 0)"})

View File

@ -1,5 +1,6 @@
// The goal of this test is to ensure the color of the text is the one expected. // The goal of this test is to ensure the color of the text is the one expected.
include: "utils.goml"
define-function: ( define-function: (
"check-result-color", "check-result-color",
[result_kind, color, hover_color], [result_kind, color, hover_color],
@ -43,11 +44,7 @@ go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=coo"
show-text: true show-text: true
// Ayu theme // Ayu theme
set-local-storage: { call-function: ("switch-theme", {"theme": "ayu"})
"rustdoc-theme": "ayu",
"rustdoc-use-system-theme": "false",
}
reload:
// Waiting for the search results to appear... // Waiting for the search results to appear...
wait-for: "#search-tabs" wait-for: "#search-tabs"
@ -155,11 +152,7 @@ assert-css: (
) )
// Dark theme // Dark theme
set-local-storage: { call-function: ("switch-theme", {"theme": "dark"})
"rustdoc-theme": "dark",
"rustdoc-use-system-theme": "false",
}
reload:
// Waiting for the search results to appear... // Waiting for the search results to appear...
wait-for: "#search-tabs" wait-for: "#search-tabs"
@ -255,8 +248,7 @@ assert-css: (
) )
// Light theme // Light theme
set-local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} call-function: ("switch-theme", {"theme": "light"})
reload:
// Waiting for the search results to appear... // Waiting for the search results to appear...
wait-for: "#search-tabs" wait-for: "#search-tabs"
@ -360,8 +352,7 @@ define-function: (
"check-alias", "check-alias",
[theme, alias, grey], [theme, alias, grey],
block { block {
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} call-function: ("switch-theme", {"theme": |theme|})
reload:
write-into: (".search-input", "thisisanalias") write-into: (".search-input", "thisisanalias")
// To be SURE that the search will be run. // To be SURE that the search will be run.
press-key: 'Enter' press-key: 'Enter'

View File

@ -1,5 +1,6 @@
// ignore-tidy-linelength // ignore-tidy-linelength
// Checks that the search results have the expected width. // Checks that the search results have the expected width.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
set-window-size: (900, 1000) set-window-size: (900, 1000)
write-into: (".search-input", "test") write-into: (".search-input", "test")
@ -71,8 +72,7 @@ define-function: (
"check-filter", "check-filter",
[theme, border, filter, hover_border, hover_filter], [theme, border, filter, hover_border, hover_filter],
block { block {
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} call-function: ("switch-theme", {"theme": |theme|})
reload:
wait-for: "#crate-search" wait-for: "#crate-search"
assert-css: ("#crate-search", {"border": "1px solid " + |border|}) assert-css: ("#crate-search", {"border": "1px solid " + |border|})
assert-css: ("#crate-search-div::after", {"filter": |filter|}) assert-css: ("#crate-search-div::after", {"filter": |filter|})

View File

@ -1,4 +1,5 @@
// Checking the colors of the search tab headers. // Checking the colors of the search tab headers.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html?search=foo" go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html?search=foo"
show-text: true show-text: true
@ -8,9 +9,7 @@ define-function: (
border_bottom_selected, border_bottom_hover, border_top, border_top_selected, border_bottom_selected, border_bottom_hover, border_top, border_top_selected,
border_top_hover], border_top_hover],
block { block {
// Setting the theme. call-function: ("switch-theme", {"theme": |theme|})
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
reload:
// These two commands are used to be sure the search will be run. // These two commands are used to be sure the search will be run.
focus: ".search-input" focus: ".search-input"

View File

@ -1,5 +1,6 @@
// This test ensures that the settings menu display is working as expected and that // This test ensures that the settings menu display is working as expected and that
// the settings page is also rendered as expected. // the settings page is also rendered as expected.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
show-text: true // needed when we check for colors below. show-text: true // needed when we check for colors below.
// First, we check that the settings page doesn't exist. // First, we check that the settings page doesn't exist.
@ -35,8 +36,7 @@ wait-for: "#alternative-display #search"
assert: "#main-content.hidden" assert: "#main-content.hidden"
// Now let's check the content of the settings menu. // Now let's check the content of the settings menu.
set-local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"} call-function: ("switch-theme", {"theme": "dark"})
reload:
click: "#settings-menu" click: "#settings-menu"
wait-for: "#settings" wait-for: "#settings"

View File

@ -1,4 +1,5 @@
// This test checks links colors in sidebar before and after hover. // This test checks links colors in sidebar before and after hover.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"
// This is needed so that the text color is computed. // This is needed so that the text color is computed.
@ -13,8 +14,7 @@ define-function: (
type_hover_background, keyword, keyword_hover, keyword_hover_background, type_hover_background, keyword, keyword_hover, keyword_hover_background,
], ],
block { block {
set-local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false" } call-function: ("switch-theme", {"theme": |theme|})
reload:
// Struct // Struct
assert-css: ( assert-css: (
".sidebar .block.struct li:not(.current) a", ".sidebar .block.struct li:not(.current) a",

View File

@ -1,6 +1,7 @@
// This test ensure that the sidebar isn't "hidden" on mobile but instead moved out of the viewport. // This test ensure that the sidebar isn't "hidden" on mobile but instead moved out of the viewport.
// This is especially important for devices for "text-first" content (like for users with // This is especially important for devices for "text-first" content (like for users with
// sight issues). // sight issues).
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"
// Switching to "mobile view" by reducing the width to 600px. // Switching to "mobile view" by reducing the width to 600px.
set-window-size: (600, 600) set-window-size: (600, 600)
@ -59,7 +60,7 @@ define-function: (
"check-colors", "check-colors",
[theme, color, background], [theme, color, background],
block { block {
set-local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": |theme|} call-function: ("switch-theme", {"theme": |theme|})
reload: reload:
// Open the sidebar menu. // Open the sidebar menu.

View File

@ -1,4 +1,5 @@
// This test ensures that the elements in the sidebar are displayed correctly. // This test ensures that the elements in the sidebar are displayed correctly.
include: "utils.goml"
javascript: false javascript: false
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
// Since the javascript is disabled, there shouldn't be a toggle. // Since the javascript is disabled, there shouldn't be a toggle.
@ -34,8 +35,7 @@ define-function: (
theme, color, color_hover, background, background_hover, background_toggle, theme, color, color_hover, background, background_hover, background_toggle,
], ],
block { block {
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} call-function: ("switch-theme", {"theme": |theme|})
reload:
wait-for-css: (".src .sidebar > *", {"visibility": "visible"}) wait-for-css: (".src .sidebar > *", {"visibility": "visible"})
assert-css: ( assert-css: (
"#src-sidebar details[open] > .files a.selected", "#src-sidebar details[open] > .files a.selected",

View File

@ -1,5 +1,6 @@
// The goal of this test is to ensure that the sidebar is working as expected in the source // The goal of this test is to ensure that the sidebar is working as expected in the source
// code pages. // code pages.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
show-text: true show-text: true
@ -8,11 +9,7 @@ define-function: (
"check-colors", "check-colors",
[theme, color, background_color], [theme, color, background_color],
block { block {
set-local-storage: { call-function: ("switch-theme", {"theme": |theme|})
"rustdoc-theme": |theme|,
"rustdoc-use-system-theme": "false",
}
reload:
// Checking results colors. // Checking results colors.
assert-css: (".src .sidebar", { assert-css: (".src .sidebar", {
"color": |color|, "color": |color|,

View File

@ -1,4 +1,5 @@
// Checks multiple things on the sidebar display (width of its elements, colors, etc). // Checks multiple things on the sidebar display (width of its elements, colors, etc).
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
assert-property: (".sidebar", {"clientWidth": "200"}) assert-property: (".sidebar", {"clientWidth": "200"})
show-text: true show-text: true
@ -8,11 +9,7 @@ define-function: (
"check-colors", "check-colors",
[theme, color, background_color], [theme, color, background_color],
block { block {
set-local-storage: { call-function: ("switch-theme", {"theme": |theme|})
"rustdoc-theme": |theme|,
"rustdoc-use-system-theme": "false",
}
reload:
// Checking results colors. // Checking results colors.
assert-css: (".sidebar", { assert-css: (".sidebar", {
"color": |color|, "color": |color|,
@ -46,9 +43,7 @@ call-function: (
} }
) )
set-local-storage: {"rustdoc-theme": "light"} call-function: ("switch-theme", {"theme": "light"})
// We reload the page so the local storage settings are being used.
reload:
assert-text: (".sidebar > .sidebar-crate > h2 > a", "test_docs") assert-text: (".sidebar > .sidebar-crate > h2 > a", "test_docs")
// Crate root has no "location" element // Crate root has no "location" element

View File

@ -1,4 +1,5 @@
// Checks that the interactions with the source code pages are working as expected. // Checks that the interactions with the source code pages are working as expected.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
show-text: true show-text: true
// Check that we can click on the line number. // Check that we can click on the line number.
@ -23,8 +24,7 @@ define-function: (
"check-colors", "check-colors",
[theme, color, background_color, highlight_color, highlight_background_color], [theme, color, background_color, highlight_color, highlight_background_color],
block { block {
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} call-function: ("switch-theme", {"theme": |theme|})
reload:
assert-css: ( assert-css: (
".src-line-numbers > a:not(.line-highlighted)", ".src-line-numbers > a:not(.line-highlighted)",
{"color": |color|, "background-color": |background_color|}, {"color": |color|, "background-color": |background_color|},

View File

@ -1,12 +1,13 @@
// All stability badges should have rounded corners and colored backgrounds. // All stability badges should have rounded corners and colored backgrounds.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
show-text: true show-text: true
define-function: ( define-function: (
"check-badge", "check-badge",
[theme, background, color], [theme, background, color],
block { block {
set-local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": |theme|}
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
call-function: ("switch-theme", {"theme": |theme|})
assert: ".docblock .stab" assert: ".docblock .stab"
assert: ".item-table .stab" assert: ".item-table .stab"
assert-css: (".stab", { assert-css: (".stab", {

View File

@ -1,4 +1,5 @@
// Check that the targeted element has the expected styles. // Check that the targeted element has the expected styles.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/lib2/struct.Foo.html#method.a_method" go-to: "file://" + |DOC_PATH| + "/lib2/struct.Foo.html#method.a_method"
show-text: true show-text: true
@ -9,8 +10,7 @@ define-function: (
"check-style", "check-style",
[theme, background, border], [theme, background, border],
block { block {
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} call-function: ("switch-theme", {"theme": |theme|})
reload:
assert-css: ("#method\.a_method:target", { assert-css: ("#method\.a_method:target", {
"background-color": |background|, "background-color": |background|,
"border-right": "3px solid " + |border|, "border-right": "3px solid " + |border|,

View File

@ -1,7 +1,7 @@
// Ensures that the theme change is working as expected. // Ensures that the theme change is working as expected.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
set-local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": "dark"} call-function: ("switch-theme", {"theme": "dark"})
reload:
store-value: (background_light, "white") store-value: (background_light, "white")
store-value: (background_dark, "#353535") store-value: (background_dark, "#353535")
@ -68,8 +68,7 @@ assert: "#preferred-light-theme.setting-line.hidden"
// Ensures that the custom theme feature is working as expected. // Ensures that the custom theme feature is working as expected.
go-to: "file://" + |DOC_PATH| + "/theme_css/index.html" go-to: "file://" + |DOC_PATH| + "/theme_css/index.html"
set-local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": "dark"} call-function: ("switch-theme", {"theme": "dark"})
reload:
store-value: (background_light, "white") store-value: (background_light, "white")
store-value: (background_dark, "#353535") store-value: (background_dark, "#353535")

View File

@ -1,12 +1,10 @@
// Ensures that the theme is working when going back in history. // Ensures that the theme is working when going back in history.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
// Set the theme to dark. // Set the theme to dark.
set-local-storage: { call-function: ("switch-theme", {"theme": "dark"})
"rustdoc-theme": "dark",
"rustdoc-use-system-theme": "false",
}
// We reload the page so the local storage settings are being used.
reload:
assert-css: ("body", { "background-color": "#353535" }) assert-css: ("body", { "background-color": "#353535" })
assert-local-storage: { "rustdoc-theme": "dark" } assert-local-storage: { "rustdoc-theme": "dark" }

View File

@ -1,4 +1,5 @@
// Checks that the documentation toggles have the correct position, style and work as expected. // Checks that the documentation toggles have the correct position, style and work as expected.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
assert-attribute: ("#main-content > details.top-doc", {"open": ""}) assert-attribute: ("#main-content > details.top-doc", {"open": ""})
assert-text: ("#toggle-all-docs", "[]") assert-text: ("#toggle-all-docs", "[]")
@ -51,10 +52,7 @@ define-function: (
"check-color", "check-color",
[theme, filter], [theme, filter],
block { block {
// Setting the theme. call-function: ("switch-theme", {"theme": |theme|})
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
// We reload the page so the local storage settings are being used.
reload:
assert-css: ("details.toggle > summary::before", { assert-css: ("details.toggle > summary::before", {
"opacity": "0.5", "opacity": "0.5",

View File

@ -1,4 +1,5 @@
// Check position and color of the `<sup>` for unsafe elements. // Check position and color of the `<sup>` for unsafe elements.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
// If the text isn't displayed, the browser doesn't compute color style correctly... // If the text isn't displayed, the browser doesn't compute color style correctly...
show-text: true show-text: true
@ -15,10 +16,7 @@ define-function: (
// `color` is the expected color of the `<sup>` element. // `color` is the expected color of the `<sup>` element.
[theme, color], [theme, color],
block { block {
// Set the theme. call-function: ("switch-theme", {"theme": |theme|})
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
// We reload the page so the local storage settings are being used.
reload:
assert-css: (".item-name sup", {"color": |color|}) assert-css: (".item-name sup", {"color": |color|})
}, },
) )

View File

@ -0,0 +1,11 @@
// This file contains code to be re-used by other tests.
define-function: (
"switch-theme",
[theme],
block {
// Set the theme.
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
// We reload the page so the local storage settings are being used.
reload:
},
)

View File

@ -1,4 +1,5 @@
// Test to check that the "warning blocks" are displayed as expected. // Test to check that the "warning blocks" are displayed as expected.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"
show-text: true show-text: true
@ -7,8 +8,7 @@ define-function: (
"check-warning", "check-warning",
[theme, color, border_color], [theme, color, border_color],
block { block {
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} call-function: ("switch-theme", {"theme": |theme|})
reload:
// The IDs are added directly into the DOM to make writing this test easier. // The IDs are added directly into the DOM to make writing this test easier.
assert-css: ("#doc-warning-1", { assert-css: ("#doc-warning-1", {