Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"dependencies": {
"browser-ui-test": "^0.23.0",
"browser-ui-test": "^0.23.1",
"es-check": "^9.4.4",
"eslint": "^8.57.1",
"typescript": "^5.8.3"
Expand Down
11 changes: 6 additions & 5 deletions tests/rustdoc-gui/copy-code.goml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Checks that the "copy code" button is not triggering JS error and its display
// isn't broken.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"

define-function: (
Expand Down Expand Up @@ -47,15 +48,15 @@ assert: |copy_height| > 0 && |copy_width| > 0

// First we ensure that the clipboard is empty.
assert-clipboard: ""

// We make the line numbers appear.
click: "rustdoc-toolbar .settings-menu"
wait-for-css: ("#settings", {"display": "block"})
// We make the line numbers appear.
call-function: ("open-settings-menu", {})
click: "#line-numbers"
wait-for-local-storage: {"rustdoc-line-numbers": "true" }

// We close the settings menu.
click: "rustdoc-toolbar .settings-menu"
wait-for-css-false: ("#settings", {"display": "block"})
call-function: ("close-settings-menu", {})

// We ensure that there are actually line numbers generated in the DOM.
assert-text: (".example-wrap pre.rust code span[data-nosnippet]", "1")
// We make the copy button appear.
Expand Down
7 changes: 3 additions & 4 deletions tests/rustdoc-gui/font-serif-change.goml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Ensures that the font serif change is working as expected.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"

// By default, it should be the serif fonts.
Expand All @@ -8,8 +9,7 @@ assert-css: ("body", {"font-family": |serif_font|})
assert-css: ("p code", {"font-family": |serif_code_font|})

// We now switch to the sans serif font
click: "main .settings-menu"
wait-for: "#sans-serif-fonts"
call-function: ("open-settings-menu", {})
click: "#sans-serif-fonts"

store-value: (font, '"Fira Sans", sans-serif')
Expand All @@ -23,8 +23,7 @@ assert-css: ("body", {"font-family": |font|})
assert-css: ("p code", {"font-family": |code_font|})

// We switch back to the serif font
click: "main .settings-menu"
wait-for: "#sans-serif-fonts"
call-function: ("open-settings-menu", {})
click: "#sans-serif-fonts"

assert-css: ("body", {"font-family": |serif_font|})
Expand Down
11 changes: 5 additions & 6 deletions tests/rustdoc-gui/notable-trait.goml
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ call-function: ("check-notable-tooltip-position", {
"i_x": 528,
})

go-to: "file://" + |DOC_PATH| + "/test_docs/struct.NotableStructWithLongName.html"
// This is needed to ensure that the text color is computed.
show-text: true

// Now check the colors.
define-function: (
"check-colors",
[theme, header_color, content_color, type_color, trait_color, link_color],
block {
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.NotableStructWithLongName.html"
// This is needed to ensure that the text color is computed.
show-text: true

call-function: ("switch-theme", {"theme": |theme|})

assert-css: (
Expand Down Expand Up @@ -251,7 +251,6 @@ reload:
assert-count: ("//*[@class='tooltip popover']", 0)
click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']"
assert-count: ("//*[@class='tooltip popover']", 1)
click: "rustdoc-toolbar .settings-menu a"
wait-for: "#settings"
call-function: ("open-settings-menu", {})
assert-count: ("//*[@class='tooltip popover']", 0)
assert-false: "#method\.create_an_iterator_from_read .tooltip:focus"
6 changes: 2 additions & 4 deletions tests/rustdoc-gui/search-filter.goml
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,15 @@ assert-css: ("#crate-search", {
})

// We now check the dark theme.
click: "rustdoc-toolbar .settings-menu"
wait-for: "#settings"
click: "#theme-dark"
call-function: ("switch-theme", {"theme": "dark"})
wait-for-css: ("#crate-search", {
"border": "1px solid #e0e0e0",
"color": "#ddd",
"background-color": "#353535",
})

// And finally we check the ayu theme.
click: "#theme-ayu"
call-function: ("switch-theme", {"theme": "ayu"})
wait-for-css: ("#crate-search", {
"border": "1px solid #5c6773",
"color": "#c5c5c5",
Expand Down
5 changes: 3 additions & 2 deletions tests/rustdoc-gui/setting-auto-hide-content-large-items.goml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// This test ensures that the "Auto-hide item contents for large items" setting is working as
// expected.

include: "utils.goml"

// We need to disable this check because `trait.impl/test_docs/trait.Iterator.js` doesn't exist.
fail-on-request-error: false

Expand All @@ -9,8 +11,7 @@ define-function: (
[storage_value, setting_attribute_value, toggle_attribute_value],
block {
assert-local-storage: {"rustdoc-auto-hide-large-items": |storage_value|}
click: "rustdoc-toolbar .settings-menu"
wait-for: "#settings"
call-function: ("open-settings-menu", {})
assert-property: ("#auto-hide-large-items", {"checked": |setting_attribute_value|})
assert-attribute: (".item-decl .type-contents-toggle", {"open": |toggle_attribute_value|})
}
Expand Down
5 changes: 3 additions & 2 deletions tests/rustdoc-gui/setting-auto-hide-item-methods-docs.goml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
// This test ensures that the "Auto-hide item methods' documentation" setting is working as
// expected.

include: "utils.goml"

define-function: (
"check-setting",
[storage_value, setting_attribute_value, toggle_attribute_value],
block {
assert-local-storage: {"rustdoc-auto-hide-method-docs": |storage_value|}
click: "rustdoc-toolbar .settings-menu"
wait-for: "#settings"
call-function: ("open-settings-menu", {})
assert-property: ("#auto-hide-method-docs", {"checked": |setting_attribute_value|})
assert-attribute: (".toggle.method-toggle", {"open": |toggle_attribute_value|})
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// Checks that the setting "auto hide trait implementations" is working as expected.

include: "utils.goml"

define-function: (
"check-setting",
[storage_value, setting_attribute_value, toggle_attribute_value],
block {
assert-local-storage: {"rustdoc-auto-hide-trait-implementations": |storage_value|}
click: "rustdoc-toolbar .settings-menu"
wait-for: "#settings"
call-function: ("open-settings-menu", {})
assert-property: ("#auto-hide-trait-implementations", {"checked": |setting_attribute_value|})
assert-attribute: ("#trait-implementations-list > details", {"open": |toggle_attribute_value|}, ALL)
}
Expand Down
11 changes: 6 additions & 5 deletions tests/rustdoc-gui/setting-go-to-only-result.goml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
// Checks that the setting "Directly go to item in search if there is only one result " is working as expected.
// Checks that the setting "Directly go to item in search if there is only one result " is working
// as expected.

include: "utils.goml"

define-function: (
"check-setting",
[storage_value, setting_attribute_value],
block {
assert-local-storage: {"rustdoc-go-to-only-result": |storage_value|}
click: "rustdoc-toolbar .settings-menu"
wait-for: "#settings"
call-function: ("open-settings-menu", {})
assert-property: ("#go-to-only-result", {"checked": |setting_attribute_value|})
}
)
Expand All @@ -25,8 +27,7 @@ wait-for: "#search"
assert-document-property: ({"URL": "/lib2/index.html"}, CONTAINS)

// Now we change its value.
click: "rustdoc-toolbar .settings-menu"
wait-for: "#settings"
call-function: ("open-settings-menu", {})
click: "#go-to-only-result"
assert-local-storage: {"rustdoc-go-to-only-result": "true"}

Expand Down
14 changes: 5 additions & 9 deletions tests/rustdoc-gui/settings.goml
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
// This test ensures that the settings menu display is working as expected and that
// the settings page is also rendered as expected.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
show-text: true // needed when we check for colors below.
// First, we check that the settings page doesn't exist.
assert-false: "#settings"
// We now click on the settings button.
click: "rustdoc-toolbar .settings-menu"
wait-for: "#settings"
call-function: ("open-settings-menu", {})
assert-css: ("#settings", {"display": "block"})

// Store the line margin to compare with the settings.html later.
store-css: (".setting-line", {"margin": setting_line_margin})

// Let's close it by clicking on the same button.
click: "rustdoc-toolbar .settings-menu"
wait-for-css: ("#settings", {"display": "none"})
call-function: ("close-settings-menu", {})

// Let's check that pressing "ESCAPE" is closing it.
click: "rustdoc-toolbar .settings-menu"
Expand All @@ -28,8 +26,7 @@ write: "test"
// To be SURE that the search will be run.
press-key: 'Enter'
wait-for: "#alternative-display #search"
click: "rustdoc-toolbar .settings-menu"
wait-for-css: ("#settings", {"display": "block"})
call-function: ("open-settings-menu", {})
// Ensure that the search is still displayed.
wait-for: "#alternative-display #search"
assert: "#main-content.hidden"
Expand All @@ -41,8 +38,7 @@ set-local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"
// We reload the page so the local storage settings are being used.
reload:

click: "rustdoc-toolbar .settings-menu"
wait-for: "#settings"
call-function: ("open-settings-menu", {})

// We check that the "Use system theme" is disabled.
assert-property: ("#theme-system-preference", {"checked": "false"})
Expand Down
13 changes: 1 addition & 12 deletions tests/rustdoc-gui/sidebar-mobile.goml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ define-function: (
"check-colors",
[theme, color, background],
block {
call-function: ("switch-theme-mobile", {"theme": |theme|})
reload:
call-function: ("switch-theme", {"theme": |theme|})

// Open the sidebar menu.
click: ".sidebar-menu-toggle"
Expand All @@ -86,13 +85,3 @@ call-function: ("check-colors", {
"color": "#c5c5c5",
"background": "#14191f",
})
call-function: ("check-colors", {
"theme": "dark",
"color": "#ddd",
"background": "#505050",
})
call-function: ("check-colors", {
"theme": "light",
"color": "black",
"background": "#F5F5F5",
})
7 changes: 3 additions & 4 deletions tests/rustdoc-gui/sidebar-resize-close-popover.goml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Checks sidebar resizing close the Settings popover
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
assert-property: (".sidebar", {"clientWidth": "199"})
show-text: true
click: "rustdoc-toolbar .settings-menu"
wait-for: "#settings"
call-function: ("open-settings-menu", {})
assert-css: ("#settings", {"display": "block"})
// normal resizing
drag-and-drop: ((205, 100), (185, 100))
Expand All @@ -12,8 +12,7 @@ assert-css: ("#settings", {"display": "none"})

// Now same thing, but for source code
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
click: "rustdoc-toolbar .settings-menu"
wait-for: "#settings"
call-function: ("open-settings-menu", {})
assert-css: ("#settings", {"display": "block"})
assert-property: (".sidebar", {"clientWidth": "49"})
drag-and-drop: ((52, 100), (185, 100))
Expand Down
4 changes: 2 additions & 2 deletions tests/rustdoc-gui/sidebar-resize-setting.goml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Checks sidebar resizing stays synced with the setting
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
assert-property: (".sidebar", {"clientWidth": "199"})
show-text: true

// Verify that the "hide" option is unchecked
click: "rustdoc-toolbar .settings-menu"
wait-for: "#settings"
call-function: ("open-settings-menu", {})
assert-css: ("#settings", {"display": "block"})
assert-property: ("#hide-sidebar", {"checked": "false"})
press-key: "Escape"
Expand Down
7 changes: 3 additions & 4 deletions tests/rustdoc-gui/source-code-wrapping.goml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// 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"
show-text: true
set-window-size: (1000, 1000)
Expand All @@ -13,8 +14,7 @@ define-function: (
)

store-size: (".rust code", {"width": width, "height": height})
click: "main .settings-menu"
wait-for: "#settings"
call-function: ("open-settings-menu", {})
call-function: ("click-code-wrapping", {"expected": "true"})
wait-for-size-false: (".rust code", {"width": |width|, "height": |height|})
store-size: (".rust code", {"width": new_width, "height": new_height})
Expand All @@ -28,8 +28,7 @@ assert-size: (".rust code", {"width": |width|, "height": |height|})

// Now let's check in docs code examples.
go-to: "file://" + |DOC_PATH| + "/test_docs/trait_bounds/index.html"
click: "main .settings-menu"
wait-for: "#settings"
call-function: ("open-settings-menu", {})

store-property: (".example-wrap .rust code", {"scrollWidth": rust_width, "scrollHeight": rust_height})
store-property: (".example-wrap .language-text code", {"scrollWidth": txt_width, "scrollHeight": txt_height})
Expand Down
10 changes: 2 additions & 8 deletions tests/rustdoc-gui/theme-change.goml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ store-value: (background_light, "white")
store-value: (background_dark, "#353535")
store-value: (background_ayu, "#0f1419")

click: "rustdoc-toolbar .settings-menu"
wait-for: "#theme-ayu"
call-function: ("open-settings-menu", {})
click: "#theme-ayu"
// should be the ayu theme so let's check the color.
wait-for-css: ("body", { "background-color": |background_ayu| })
Expand All @@ -22,10 +21,6 @@ click: "#theme-dark"
wait-for-css: ("body", { "background-color": |background_dark| })
assert-local-storage: { "rustdoc-theme": "dark" }

set-local-storage: {
"rustdoc-preferred-light-theme": "light",
"rustdoc-preferred-dark-theme": "light",
}
go-to: "file://" + |DOC_PATH| + "/settings.html"

wait-for: "#settings"
Expand Down Expand Up @@ -75,8 +70,7 @@ store-value: (background_dark, "#353535")
store-value: (background_ayu, "#0f1419")
store-value: (background_custom_theme, "red")

click: "rustdoc-toolbar .settings-menu"
wait-for: "#theme-ayu"
call-function: ("open-settings-menu", {})
click: "#theme-ayu"
// should be the ayu theme so let's check the color.
wait-for-css: ("body", { "background-color": |background_ayu| })
Expand Down
7 changes: 3 additions & 4 deletions tests/rustdoc-gui/theme-defaults.goml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Ensure that the theme picker always starts with the actual defaults.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
click: "rustdoc-toolbar .settings-menu"
wait-for: "#theme-system-preference"
call-function: ("open-settings-menu", {})
assert: "#theme-system-preference:checked"
assert: "#preferred-light-theme-light:checked"
assert: "#preferred-dark-theme-dark:checked"
Expand All @@ -16,8 +16,7 @@ set-local-storage: {
"rustdoc-theme": "ayu"
}
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
click: "rustdoc-toolbar .settings-menu"
wait-for: "#theme-system-preference"
call-function: ("open-settings-menu", {})
assert: "#theme-system-preference:checked"
assert: "#preferred-light-theme-light:checked"
assert-false: "#preferred-dark-theme-dark:checked"
Expand Down
Loading
Loading