Skip to content

Commit f451a41

Browse files
Add GUI regression test for non-rust code blocks line numbers
1 parent 54efd13 commit f451a41

File tree

1 file changed

+60
-7
lines changed

1 file changed

+60
-7
lines changed

Diff for: tests/rustdoc-gui/docblock-code-block-line-number.goml

+60-7
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ assert-css: ("#settings", {"display": "block"})
8787

8888
// Then, click the toggle button.
8989
click: "input#line-numbers"
90-
wait-for: 100 // wait-for-false does not exist
90+
wait-for: 100 // FIXME: `wait-for-false` does not exist
9191
assert-false: "pre.example-line-numbers"
9292
assert-local-storage: {"rustdoc-line-numbers": "false" }
9393

@@ -107,6 +107,8 @@ assert-css: (
107107
click: "input#line-numbers"
108108
wait-for: "pre.example-line-numbers"
109109
assert-local-storage: {"rustdoc-line-numbers": "true" }
110+
wait-for: 100 // FIXME: `wait-for-false` does not exist
111+
assert: "pre.example-line-numbers"
110112

111113
// Same check with scraped examples line numbers.
112114
go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html"
@@ -145,9 +147,6 @@ assert-css: (
145147
ALL,
146148
)
147149

148-
// Checking line numbers on scraped code examples.
149-
go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html"
150-
151150
define-function: (
152151
"check-padding",
153152
[path, padding_bottom],
@@ -157,19 +156,19 @@ define-function: (
157156
"padding-bottom": "0px",
158157
"padding-left": "0px",
159158
"padding-right": "0px",
160-
})
159+
}, ALL)
161160
assert-css: (|path| + " .src-line-numbers > pre", {
162161
"padding-top": "14px",
163162
"padding-bottom": |padding_bottom|,
164163
"padding-left": "0px",
165164
"padding-right": "0px",
166-
})
165+
}, ALL)
167166
assert-css: (|path| + " .src-line-numbers > pre > span", {
168167
"padding-top": "0px",
169168
"padding-bottom": "0px",
170169
"padding-left": "8px",
171170
"padding-right": "8px",
172-
})
171+
}, ALL)
173172
},
174173
)
175174

@@ -188,6 +187,35 @@ call-function: ("check-padding", {
188187
"padding_bottom": "14px",
189188
})
190189

190+
define-function: ("check-line-numbers-existence", [], block {
191+
assert-local-storage: {"rustdoc-line-numbers": "true" }
192+
assert-false: ".example-line-numbers"
193+
click: "#settings-menu"
194+
wait-for: "#settings"
195+
196+
// Then, click the toggle button.
197+
click: "input#line-numbers"
198+
wait-for: 100 // FIXME: `wait-for-false` does not exist
199+
assert-local-storage-false: {"rustdoc-line-numbers": "true" }
200+
assert-false: ".example-line-numbers"
201+
// Line numbers should still be there.
202+
assert: ".src-line-numbers"
203+
// Now disabling the setting.
204+
click: "input#line-numbers"
205+
wait-for: 100 // FIXME: `wait-for-false` does not exist
206+
assert-local-storage: {"rustdoc-line-numbers": "true" }
207+
assert-false: ".example-line-numbers"
208+
// Line numbers should still be there.
209+
assert: ".src-line-numbers"
210+
// Closing settings menu.
211+
click: "#settings-menu"
212+
wait-for-css: ("#settings", {"display": "none"})
213+
})
214+
215+
// Checking that turning off the line numbers setting won't remove line numbers from scraped
216+
// examples.
217+
call-function: ("check-line-numbers-existence", {})
218+
191219
// Now checking the line numbers in the source code page.
192220
click: ".src"
193221
assert-css: (".src-line-numbers", {
@@ -202,3 +230,28 @@ assert-css: (".src-line-numbers > a", {
202230
"padding-left": "8px",
203231
"padding-right": "8px",
204232
})
233+
// Checking that turning off the line numbers setting won't remove line numbers.
234+
call-function: ("check-line-numbers-existence", {})
235+
236+
// Now checking that even non-rust code blocks have line numbers generated.
237+
go-to: "file://" + |DOC_PATH| + "/lib2/sub_mod/struct.Foo.html"
238+
assert-local-storage: {"rustdoc-line-numbers": "true" }
239+
assert: ".example-wrap > pre.language-txt"
240+
assert: ".example-wrap > pre.rust"
241+
assert-count: (".example-wrap", 2)
242+
assert-count: (".example-wrap > pre.example-line-numbers", 2)
243+
244+
click: "#settings-menu"
245+
wait-for: "#settings"
246+
247+
// Then, click the toggle button.
248+
click: "input#line-numbers"
249+
wait-for: 100 // FIXME: `wait-for-false` does not exist
250+
assert-local-storage-false: {"rustdoc-line-numbers": "true" }
251+
assert-count: (".example-wrap > pre.example-line-numbers", 0)
252+
253+
// Now turning off the setting.
254+
click: "input#line-numbers"
255+
wait-for: 100 // FIXME: `wait-for-false` does not exist
256+
assert-local-storage: {"rustdoc-line-numbers": "true" }
257+
assert-count: (".example-wrap > pre.example-line-numbers", 2)

0 commit comments

Comments
 (0)