From f451a410e34c15befefdfed3195442f0de6ec052 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 21 Sep 2024 17:00:42 +0200 Subject: [PATCH] Add GUI regression test for non-rust code blocks line numbers --- .../docblock-code-block-line-number.goml | 67 +++++++++++++++++-- 1 file changed, 60 insertions(+), 7 deletions(-) diff --git a/tests/rustdoc-gui/docblock-code-block-line-number.goml b/tests/rustdoc-gui/docblock-code-block-line-number.goml index fed916ac246..53f756dfcd6 100644 --- a/tests/rustdoc-gui/docblock-code-block-line-number.goml +++ b/tests/rustdoc-gui/docblock-code-block-line-number.goml @@ -87,7 +87,7 @@ assert-css: ("#settings", {"display": "block"}) // Then, click the toggle button. click: "input#line-numbers" -wait-for: 100 // wait-for-false does not exist +wait-for: 100 // FIXME: `wait-for-false` does not exist assert-false: "pre.example-line-numbers" assert-local-storage: {"rustdoc-line-numbers": "false" } @@ -107,6 +107,8 @@ assert-css: ( click: "input#line-numbers" wait-for: "pre.example-line-numbers" assert-local-storage: {"rustdoc-line-numbers": "true" } +wait-for: 100 // FIXME: `wait-for-false` does not exist +assert: "pre.example-line-numbers" // Same check with scraped examples line numbers. go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html" @@ -145,9 +147,6 @@ assert-css: ( ALL, ) -// Checking line numbers on scraped code examples. -go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html" - define-function: ( "check-padding", [path, padding_bottom], @@ -157,19 +156,19 @@ define-function: ( "padding-bottom": "0px", "padding-left": "0px", "padding-right": "0px", - }) + }, ALL) assert-css: (|path| + " .src-line-numbers > pre", { "padding-top": "14px", "padding-bottom": |padding_bottom|, "padding-left": "0px", "padding-right": "0px", - }) + }, ALL) assert-css: (|path| + " .src-line-numbers > pre > span", { "padding-top": "0px", "padding-bottom": "0px", "padding-left": "8px", "padding-right": "8px", - }) + }, ALL) }, ) @@ -188,6 +187,35 @@ call-function: ("check-padding", { "padding_bottom": "14px", }) +define-function: ("check-line-numbers-existence", [], block { + assert-local-storage: {"rustdoc-line-numbers": "true" } + assert-false: ".example-line-numbers" + click: "#settings-menu" + wait-for: "#settings" + + // Then, click the toggle button. + click: "input#line-numbers" + wait-for: 100 // FIXME: `wait-for-false` does not exist + assert-local-storage-false: {"rustdoc-line-numbers": "true" } + assert-false: ".example-line-numbers" + // Line numbers should still be there. + assert: ".src-line-numbers" + // Now disabling the setting. + click: "input#line-numbers" + wait-for: 100 // FIXME: `wait-for-false` does not exist + assert-local-storage: {"rustdoc-line-numbers": "true" } + assert-false: ".example-line-numbers" + // Line numbers should still be there. + assert: ".src-line-numbers" + // Closing settings menu. + click: "#settings-menu" + wait-for-css: ("#settings", {"display": "none"}) +}) + +// Checking that turning off the line numbers setting won't remove line numbers from scraped +// examples. +call-function: ("check-line-numbers-existence", {}) + // Now checking the line numbers in the source code page. click: ".src" assert-css: (".src-line-numbers", { @@ -202,3 +230,28 @@ assert-css: (".src-line-numbers > a", { "padding-left": "8px", "padding-right": "8px", }) +// Checking that turning off the line numbers setting won't remove line numbers. +call-function: ("check-line-numbers-existence", {}) + +// Now checking that even non-rust code blocks have line numbers generated. +go-to: "file://" + |DOC_PATH| + "/lib2/sub_mod/struct.Foo.html" +assert-local-storage: {"rustdoc-line-numbers": "true" } +assert: ".example-wrap > pre.language-txt" +assert: ".example-wrap > pre.rust" +assert-count: (".example-wrap", 2) +assert-count: (".example-wrap > pre.example-line-numbers", 2) + +click: "#settings-menu" +wait-for: "#settings" + +// Then, click the toggle button. +click: "input#line-numbers" +wait-for: 100 // FIXME: `wait-for-false` does not exist +assert-local-storage-false: {"rustdoc-line-numbers": "true" } +assert-count: (".example-wrap > pre.example-line-numbers", 0) + +// Now turning off the setting. +click: "input#line-numbers" +wait-for: 100 // FIXME: `wait-for-false` does not exist +assert-local-storage: {"rustdoc-line-numbers": "true" } +assert-count: (".example-wrap > pre.example-line-numbers", 2)