Add rustdoc GUI test to ensure that the "hide deprecated items" setting is working as expected

This commit is contained in:
Guillaume Gomez 2026-01-14 00:45:39 +01:00
parent 4ded6397b3
commit 9f965bcf76
3 changed files with 136 additions and 2 deletions

View file

@ -0,0 +1,83 @@
// Test that the "hide deprecated" setting is correctly handled.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/lib2/deprecated/index.html"
// There should be two deprecated items listed on the module page:
// `DeprecatedStruct` and `DeprecatedTrait`.
assert-count: ("dt.deprecated", 2)
// `DeprecatedStruct` and `DeprecatedTrait` should be displayed for now.
assert-css: ("dt.deprecated", {"display": "block"}, ALL)
// We enable the "hide deprecated items" setting.
call-function: ("open-settings-menu", {})
click: "#hide-deprecated-items"
// None of them should be displayed anymore.
wait-for-css: ("dt.deprecated", {"display": "none"}, ALL)
// We disable the setting.
click: "#hide-deprecated-items"
// All of them should be displayed back.
wait-for-css: ("dt.deprecated", {"display": "block"}, ALL)
// Now we go to a trait with a deprecated method and a deprecated associated const.
go-to: "file://" + |DOC_PATH| + "/lib2/deprecated/trait.NormalTrait.html"
// There should be two deprecated items.
assert-count: ("details.deprecated", 2)
// They should be displayed for now.
assert-css: ("details.deprecated", {"display": "block"}, ALL)
// We enable the "hide deprecated items" setting.
call-function: ("open-settings-menu", {})
click: "#hide-deprecated-items"
// They shouldn't be displayed anymore.
wait-for-css: ("details.deprecated", {"display": "none"}, ALL)
// We disable the setting.
click: "#hide-deprecated-items"
// All of them should be displayed back.
wait-for-css: ("details.deprecated", {"display": "block"}, ALL)
// We now go to a struct with a deprecated method which implements a deprecated trait and a trait
// with deprecated associated items.
go-to: "file://" + |DOC_PATH| + "/lib2/deprecated/struct.NonDeprecatedStruct.html"
// There should be five deprecated items (six minus one "future" deprecated)...
assert-count: ("details.deprecated", 5)
// One of which being a deprecated impl because the trait itself is deprecated.
assert-count: ("details.implementors-toggle.deprecated", 1)
// And another has `since = "TBD"` and should NOT have the `deprecated` class.
assert: "details:not(.deprecated) #method\.future_deprecated_fn"
// They should all be displayed for now.
assert-css: ("details.deprecated", {"display": "block"}, ALL)
// We enable the "hide deprecated items" setting.
call-function: ("open-settings-menu", {})
click: "#hide-deprecated-items"
// They shouldn't be displayed anymore.
wait-for-css: ("details.deprecated", {"display": "none"}, ALL)
// We disable the setting.
click: "#hide-deprecated-items"
// All of them should be displayed back.
wait-for-css: ("details.deprecated", {"display": "block"}, ALL)
// And now we check with the search results.
call-function: ("perform-search", {"query": "deprecated::depr"})
// There should at least 7 results.
store-count: ("#results ul.search-results.active > a", nb_search_results)
assert: |nb_search_results| >= 7
// There should be at least 5 deprecated items.
store-count: ("#results ul.search-results.active > a.deprecated", nb_deprecated_results)
assert: |nb_search_results| >= 5
// Deprecated items should all be displayed.
assert-css: ("#results ul.search-results.active > a.deprecated", {"display": "grid"}, ALL)
// We enable the "hide deprecated items" setting.
call-function: ("open-settings-menu", {})
click: "#hide-deprecated-items"
// None of them should be displayed anymore.
wait-for-css: ("#results ul.search-results.active > a.deprecated", {"display": "none"}, ALL)

View file

@ -368,3 +368,46 @@ impl std::ops::Deref for Derefer {
&self.0
}
}
pub mod deprecated {
#[deprecated(since = "1.26.0", note = "deprecated")]
pub struct DeprecatedStruct;
pub struct NonDeprecatedStruct;
pub trait NormalTrait {
#[deprecated(since = "1.26.0", note = "deprecated")]
/// doc
const X: usize = 12;
#[deprecated(since = "1.26.0", note = "deprecated")]
/// doc
fn normal_deprecated_fn();
}
#[deprecated(since = "1.26.0", note = "deprecated")]
pub trait DeprecatedTrait {
fn depr_deprecated_fn();
}
impl NonDeprecatedStruct {
#[deprecated(since = "1.26.0", note = "deprecated")]
/// doc
pub fn deprecated_fn() {}
/// doc
pub fn non_deprecated_fn() {}
#[deprecated(since = "TBD", note = "deprecated")]
/// doc
pub fn future_deprecated_fn() {}
}
impl NormalTrait for NonDeprecatedStruct {
fn normal_deprecated_fn() {}
}
impl DeprecatedTrait for NonDeprecatedStruct {
fn depr_deprecated_fn() {}
}
}

View file

@ -60,8 +60,8 @@ define-function: (
)
define-function: (
"perform-search",
[query],
"open-search",
[],
block {
// Block requests with doubled `//`.
// Amazon S3 doesn't support them, but other web hosts do,
@ -72,6 +72,14 @@ define-function: (
// Perform search
click: "#search-button"
wait-for: ".search-input"
}
)
define-function: (
"perform-search",
[query],
block {
call-function: ("open-search", {})
write-into: (".search-input", |query|)
press-key: 'Enter'
// wait for the search to start