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