// Checks that the setting "line numbers" is working as expected. include: "utils.goml" go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" // We check that without this setting, there is no line number displayed. assert-false: "pre.example-line-numbers" // All corners should be rounded. assert-css: ( ".example-wrap .rust", { "border-top-left-radius": "6px", "border-bottom-left-radius": "6px", "border-top-right-radius": "6px", "border-bottom-right-radius": "6px", }, ALL, ) // We set the setting to show the line numbers on code examples. set-local-storage: {"rustdoc-line-numbers": "true"} reload: // We wait for the line numbers to be added into the DOM by the JS... wait-for: "pre.example-line-numbers" // Otherwise, we can't check text color show-text: true // Let's now check some CSS properties... define-function: ( "check-colors", [theme, color], block { // Page will be reloaded in "switch-theme". call-function: ("switch-theme", {"theme": |theme|}) // If the test didn't fail, it means that it was found! assert-css: ( "pre.example-line-numbers", { "color": |color|, "margin": "0px", "padding": "14px 8px", "text-align": "right", // There should not be a radius on the right of the line numbers. "border-top-left-radius": "6px", "border-bottom-left-radius": "6px", "border-top-right-radius": "0px", "border-bottom-right-radius": "0px", }, ALL, ) // There should not be a radius on the left of the line numbers. assert-css: ("pre.example-line-numbers + .rust", { "border-top-left-radius": "0px", "border-bottom-left-radius": "0px", "border-top-right-radius": "6px", "border-bottom-right-radius": "6px", }) }, ) call-function: ("check-colors", { "theme": "ayu", "color": "#5c6773", }) call-function: ("check-colors", { "theme": "dark", "color": "#3b91e2", }) call-function: ("check-colors", { "theme": "light", "color": "#c67e2d", }) // The first code block has two lines so let's check its `
` elements lists both of them. assert-text: ("pre.example-line-numbers", "1\n2") // Now, try changing the setting dynamically. We'll turn it off, using the settings menu, // and make sure it goes away. // First, open the settings menu. click: "#settings-menu" wait-for: "#settings" assert-css: ("#settings", {"display": "block"}) // Then, click the toggle button. click: "input#line-numbers" wait-for: 100 // wait-for-false does not exist assert-false: "pre.example-line-numbers" assert-local-storage: {"rustdoc-line-numbers": "false" } // Check that the rounded corners are back. assert-css: ( ".example-wrap .rust", { "border-top-left-radius": "6px", "border-bottom-left-radius": "6px", "border-top-right-radius": "6px", "border-bottom-right-radius": "6px", }, ALL, ) // Finally, turn it on again. click: "input#line-numbers" wait-for: "pre.example-line-numbers" assert-local-storage: {"rustdoc-line-numbers": "true" } // Same check with scraped examples line numbers. go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html" assert-css: ( ".scraped-example .src-line-numbers > pre", { // There should not be a radius on the right of the line numbers. "border-top-left-radius": "6px", "border-bottom-left-radius": "6px", "border-top-right-radius": "0px", "border-bottom-right-radius": "0px", }, ALL, ) assert-css: ( ".scraped-example .src-line-numbers", { // There should not be a radius on the right of the line numbers. "border-top-left-radius": "6px", "border-bottom-left-radius": "6px", "border-top-right-radius": "0px", "border-bottom-right-radius": "0px", }, ALL, ) assert-css: ( ".scraped-example .rust", { // There should not be a radius on the left of the code. "border-top-left-radius": "0px", "border-bottom-left-radius": "0px", "border-top-right-radius": "6px", "border-bottom-right-radius": "6px", }, ALL, )