-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[tests] JavaScript: extract searchindex.js-format test fixtures. #12102
[tests] JavaScript: extract searchindex.js-format test fixtures. #12102
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
This turned out to be less code than I expected, so I've bundled it in here too, but could separate it again if that's easier for review/understanding. |
This comment was marked as outdated.
This comment was marked as outdated.
Which is the reverse of what I'm doing on the test suite where the PRs are huge. So don't worry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! I left a few comments which are mostly just nits.
* ~~~~~~~~~~~~~~~~ | ||
* | ||
* This script contains the language-specific data used by searchtools.js, | ||
* namely the list of stopwords, stemmer, scorer and splitter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comments in this file seem a little misleading? This is really just test scaffolding AFAICT
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mm, yep - this is an interesting case - it's an evaluated copy of a template file from the basic theme. That's me attempting to make the JavaScript test environment realistic, but it is duplicative (and a bit confusing).
tests/js/roots/multiterm/index.rst
Outdated
Main Page | ||
========= | ||
|
||
Welcome to the... main page! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would personally use this opportunity to add a bit of context about what this file tests.
tests/js/roots/partial/index.rst
Outdated
sphinx_utils module | ||
=================== | ||
|
||
Useful utilities. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same, I would personally use this opportunity to add a bit of context about what this file tests.
function loadFixture(name) { | ||
req = new XMLHttpRequest(); | ||
req.open("GET", `base/tests/js/fixtures/${name}`, false); | ||
req.send(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing you used XMLHttpRequest()
because you want to make a synchronous? Should probably add a comment about that.
Apparently using XMLHttpRequest this way is discouraged and might be deprecated at some point, but they've been saying that since 2014. 😉 It's probably fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, that's good to know :) Yep; we don't want the test to proceed until the fixture has definitely loaded -- I'm inclined to use a straightforward (even if seemingly dated) approach here.
…te_js_fixtures.py'
…nstead of comparing their sha256 hash values.
Thank you @wlach for the code review! I've left a couple of not-entirely-resolved items open, and let me know what you think of the adjustments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good from my perspective! Obviously you'll need a committer to approve/land.
@picnixz Could you take a look at this? I think it makes sense to merge this before proceeding with any more work on the search system. I reviewed it a couple weeks ago and all looks good to me (not to say I'm infallible but that's gotta count for something) |
Lucky you that I've submitted my thesis and have more free time! |
… query terms items.
…n invoking sphinx command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me it's fine now (modulo this small suggestion but we can just decide later).
… of reading them from an iterator at test-time. Co-authored-by: Bénédikt Tran <[email protected]>
Once you're done, just ping me and I'll merge it ! |
Thanks @picnixz - all done with those changes, so I think this is ready for merge. |
Thank you! |
Feature or Bugfix
Purpose
index
data in the JavaScript HTML search tests to match the format emitted by the Sphinx (Python) HTML builder.Detail
searchindex.js
is a JavaScript code file that runsSearch.setIndex(...)
with the contents of the index as an argument.karma
HTTP server andeval
it.searchindex.js
fixture content does not match the existing fixture files.Relates