Add/update tests for --extend-css option

This commit is contained in:
Guillaume Gomez 2023-04-12 15:17:33 +02:00
parent bf6582e0cc
commit 6bc6ea7a3e
9 changed files with 29 additions and 2 deletions

View file

@ -1064,6 +1064,8 @@ fn run(self, builder: &Builder<'_>) {
cargo.env("RUSTDOCFLAGS", "-Zunstable-options --generate-link-to-definition");
} else if entry.file_name() == "scrape_examples" {
cargo.arg("-Zrustdoc-scrape-examples");
} else if entry.file_name() == "extend_css" {
cargo.env("RUSTDOCFLAGS", &format!("--extend-css extra.css"));
}
builder.run(&mut cargo);
}

View file

@ -0,0 +1,5 @@
// Test to ensure that the `--extend-css` option is working as expected.
go-to: "file://" + |DOC_PATH| + "/extend_css/index.html"
show-text: true
// The text from the `.extend` element should be red.
assert-css: (".extend", {"color": "rgb(255, 0, 0)"})

View file

@ -16,6 +16,7 @@ press-key: "ArrowDown"
press-key: "ArrowDown"
press-key: "ArrowDown"
press-key: "ArrowDown"
press-key: "ArrowDown"
press-key: "Enter"
// Waiting for the search results to appear...
wait-for: "#search-tabs"
@ -41,6 +42,7 @@ press-key: "ArrowUp"
press-key: "ArrowUp"
press-key: "ArrowUp"
press-key: "ArrowUp"
press-key: "ArrowUp"
press-key: "Enter"
// Waiting for the search results to appear...
wait-for: "#search-tabs"

View file

@ -73,7 +73,7 @@ assert: "//*[@class='dir-entry' and @open]/*[text()='sub_mod']"
// Only "another_folder" should be "open" in "lib2".
assert: "//*[@class='dir-entry' and not(@open)]/*[text()='another_mod']"
// All other trees should be collapsed.
assert-count: ("//*[@id='source-sidebar']/details[not(text()='lib2') and not(@open)]", 8)
assert-count: ("//*[@id='source-sidebar']/details[not(text()='lib2') and not(@open)]", 9)
// We now switch to mobile mode.
set-window-size: (600, 600)

View file

@ -102,7 +102,7 @@ assert: ".source-sidebar-expanded"
// We check that the first entry of the sidebar is collapsed
assert-property: ("#source-sidebar details:first-of-type", {"open": "false"})
assert-text: ("#source-sidebar details:first-of-type > summary", "http")
assert-text: ("#source-sidebar details:first-of-type > summary", "extend_css")
// We now click on it.
click: "#source-sidebar details:first-of-type > summary"
assert-property: ("#source-sidebar details:first-of-type", {"open": "true"})

View file

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "extend_css"
version = "0.1.0"

View file

@ -0,0 +1,7 @@
[package]
name = "extend_css"
version = "0.1.0"
edition = "2018"
[lib]
path = "lib.rs"

View file

@ -0,0 +1,3 @@
.extend {
color: red !important;
}

View file

@ -0,0 +1 @@
//! <div class="extend">text in red</div>