Merge pull request #2586 from ehuss/fix-search-subchapter
Fix search not showing in sub-directories
This commit is contained in:
commit
105d836fbc
2 changed files with 35 additions and 2 deletions
|
|
@ -468,12 +468,12 @@ window.search = window.search || {};
|
||||||
showResults(true);
|
showResults(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
fetch('{{ resource "searchindex.json" }}')
|
fetch(path_to_root + '{{ resource "searchindex.json" }}')
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(json => init(json))
|
.then(json => init(json))
|
||||||
.catch(error => { // Try to load searchindex.js if fetch failed
|
.catch(error => { // Try to load searchindex.js if fetch failed
|
||||||
var script = document.createElement('script');
|
var script = document.createElement('script');
|
||||||
script.src = '{{ resource "searchindex.js" }}';
|
script.src = path_to_root + '{{ resource "searchindex.js" }}';
|
||||||
script.onload = () => init(window.search);
|
script.onload = () => init(window.search);
|
||||||
document.head.appendChild(script);
|
document.head.appendChild(script);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
33
tests/gui/search.goml
Normal file
33
tests/gui/search.goml
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
// This tests basic search behavior.
|
||||||
|
|
||||||
|
// We disable the requests checks because `searchindex.json` will always fail
|
||||||
|
// locally (due to CORS), but the searchindex.js will succeed.
|
||||||
|
fail-on-request-error: false
|
||||||
|
go-to: |DOC_PATH| + "index.html"
|
||||||
|
|
||||||
|
define-function: (
|
||||||
|
"open-search",
|
||||||
|
[],
|
||||||
|
block {
|
||||||
|
assert-css: ("#search-wrapper", {"display": "none"})
|
||||||
|
press-key: 'S'
|
||||||
|
wait-for-css-false: ("#search-wrapper", {"display": "none"})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
call-function: ("open-search", {})
|
||||||
|
assert-text: ("#searchresults-header", "")
|
||||||
|
write: "strikethrough"
|
||||||
|
wait-for-text: ("#searchresults-header", "2 search results for 'strikethrough':")
|
||||||
|
// Close the search display
|
||||||
|
press-key: 'Escape'
|
||||||
|
wait-for-css: ("#search-wrapper", {"display": "none"})
|
||||||
|
// Reopening the search should show the last value
|
||||||
|
call-function: ("open-search", {})
|
||||||
|
assert-text: ("#searchresults-header", "2 search results for 'strikethrough':")
|
||||||
|
// Navigate to a sub-chapter
|
||||||
|
go-to: "./individual/strikethrough.html"
|
||||||
|
assert-text: ("#searchresults-header", "")
|
||||||
|
call-function: ("open-search", {})
|
||||||
|
write: "strikethrough"
|
||||||
|
wait-for-text: ("#searchresults-header", "2 search results for 'strikethrough':")
|
||||||
Loading…
Add table
Reference in a new issue