summaryrefslogtreecommitdiffstats
path: root/tests/rustdoc-gui/search-filter.goml
blob: d739471a625a423439e48fe5f0bb71c4ce282d55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// Checks that the crate search filtering is handled correctly and changes the results.
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
show-text: true
write: (".search-input", "test")
// To be SURE that the search will be run.
press-key: 'Enter'
// Waiting for the search results to appear...
wait-for: "#search-tabs"
assert-text: ("#results .externcrate", "test_docs")

wait-for: "#crate-search"
// We now want to change the crate filter.
click: "#crate-search"
// We select "lib2" option then press enter to change the filter.
press-key: "ArrowDown"
press-key: "ArrowDown"
press-key: "ArrowDown"
press-key: "ArrowDown"
press-key: "ArrowDown"
press-key: "Enter"
// Waiting for the search results to appear...
wait-for: "#search-tabs"
assert-document-property: ({"URL": "&filter-crate="}, CONTAINS)
// We check that there is no more "test_docs" appearing.
assert-false: "#results .externcrate"
// We also check that "lib2" is the filter crate.
assert-property: ("#crate-search", {"value": "lib2"})

// Now we check that leaving the search results and putting them back keeps the
// crate filtering.
press-key: "Escape"
wait-for-css: ("#main-content", {"display": "block"})
focus: ".search-input"
wait-for-css: ("#main-content", {"display": "none"})
// We check that there is no more "test_docs" appearing.
assert-false: "#results .externcrate"
assert-property: ("#crate-search", {"value": "lib2"})

// Selecting back "All crates"
click: "#crate-search"
press-key: "ArrowUp"
press-key: "ArrowUp"
press-key: "ArrowUp"
press-key: "ArrowUp"
press-key: "ArrowUp"
press-key: "Enter"
// Waiting for the search results to appear...
wait-for: "#search-tabs"
assert-property: ("#crate-search", {"value": "all crates"})

// Checking that the URL parameter is taken into account for crate filtering.
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=test&filter-crate=lib2"
wait-for: "#crate-search"
assert-property: ("#crate-search", {"value": "lib2"})
assert-false: "#results .externcrate"

// Checking that the text for the "title" is correct (the "all crates" comes from the "<select>").
assert-text: (".search-results-title", "Results in all crates", STARTS_WITH)

// Checking the display of the crate filter.
// We start with the light theme.
set-local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"}
reload:

set-timeout: 2000
wait-for: "#crate-search"
assert-css: ("#crate-search", {
    "border": "1px solid rgb(224, 224, 224)",
    "color": "rgb(0, 0, 0)",
    "background-color": "rgb(255, 255, 255)",
})

// We now check the dark theme.
click: "#settings-menu"
wait-for: "#settings"
click: "#theme-dark"
wait-for-css: ("#crate-search", {
    "border": "1px solid rgb(224, 224, 224)",
    "color": "rgb(221, 221, 221)",
    "background-color": "rgb(53, 53, 53)",
})

// And finally we check the ayu theme.
click: "#theme-ayu"
wait-for-css: ("#crate-search", {
    "border": "1px solid rgb(92, 103, 115)",
    "color": "rgb(255, 255, 255)",
    "background-color": "rgb(15, 20, 25)",
})