]> git.lizzy.rs Git - rust.git/blob - src/test/rustdoc-gui/search-filter.goml
Rollup merge of #100367 - fmease:fix-100365, r=compiler-errors
[rust.git] / src / test / rustdoc-gui / search-filter.goml
1 // Checks that the crate search filtering is handled correctly and changes the results.
2 goto: file://|DOC_PATH|/test_docs/index.html
3 show-text: true
4 write: (".search-input", "test")
5 // To be SURE that the search will be run.
6 press-key: 'Enter'
7 // Waiting for the search results to appear...
8 wait-for: "#titles"
9 assert-text: ("#results .externcrate", "test_docs")
10
11 wait-for: "#crate-search"
12 // We now want to change the crate filter.
13 click: "#crate-search"
14 // We select "lib2" option then press enter to change the filter.
15 press-key: "ArrowDown"
16 press-key: "ArrowDown"
17 press-key: "Enter"
18 // Waiting for the search results to appear...
19 wait-for: "#titles"
20 assert-document-property: ({"URL": "&filter-crate="}, CONTAINS)
21 // We check that there is no more "test_docs" appearing.
22 assert-false: "#results .externcrate"
23 // We also check that "lib2" is the filter crate.
24 assert-property: ("#crate-search", {"value": "lib2"})
25
26 // Now we check that leaving the search results and putting them back keeps the
27 // crate filtering.
28 press-key: "Escape"
29 wait-for-css: ("#main-content", {"display": "block"})
30 focus: ".search-input"
31 wait-for-css: ("#main-content", {"display": "none"})
32 // We check that there is no more "test_docs" appearing.
33 assert-false: "#results .externcrate"
34 assert-property: ("#crate-search", {"value": "lib2"})
35
36 // Selecting back "All crates"
37 click: "#crate-search"
38 press-key: "ArrowUp"
39 press-key: "ArrowUp"
40 press-key: "Enter"
41 // Waiting for the search results to appear...
42 wait-for: "#titles"
43 assert-property: ("#crate-search", {"value": "all crates"})
44
45 // Checking that the URL parameter is taken into account for crate filtering.
46 goto: file://|DOC_PATH|/test_docs/index.html?search=test&filter-crate=lib2
47 wait-for: "#crate-search"
48 assert-property: ("#crate-search", {"value": "lib2"})
49 assert-false: "#results .externcrate"
50
51 // Checking that the text for the "title" is correct (the "all crates" comes from the "<select>").
52 assert-text: (".search-results-title", "Results in all crates", STARTS_WITH)
53
54 // Checking the display of the crate filter.
55 // We start with the light theme.
56 local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"}
57 reload:
58
59 timeout: 2000
60 wait-for: "#crate-search"
61 assert-css: ("#crate-search", {
62     "border": "1px solid rgb(224, 224, 224)",
63     "color": "rgb(0, 0, 0)",
64     "background-color": "rgb(255, 255, 255)",
65 })
66
67 // We now check the dark theme.
68 click: "#settings-menu"
69 wait-for: "#settings"
70 click: "#theme-dark"
71 wait-for-css: ("#crate-search", {
72     "border": "1px solid rgb(210, 210, 210)",
73     "color": "rgb(221, 221, 221)",
74     "background-color": "rgb(53, 53, 53)",
75 })
76
77 // And finally we check the ayu theme.
78 click: "#theme-ayu"
79 wait-for-css: ("#crate-search", {
80     "border": "1px solid rgb(92, 103, 115)",
81     "color": "rgb(255, 255, 255)",
82     "background-color": "rgb(15, 20, 25)",
83 })