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