-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
web: web page search box doesn't work for regex searches #3867
Comments
Good catch; that seems like a good thing to fix! My honest feeling here is that this is probably not worth writing a test for. I think it would be pretty annoying to test a combination of JavaScript and Python, and especially so to test something actually running in a browser. Tests are nice to have, certainly, but in some circumstances they are just not worth the hassle. 😃 |
Thanks for the advice Adrian. I will be including a couple of tests for the underlying (JSON) web API operations. These currently work but it doesn't do any harm to have sometests to make sure they don't get broken in the future. Unless I can think of an easy (and reliable) way to add a test for the JS code I will leave it out. Tests which are flaky, or break due to harmless other changes, tend to make things harder instead of easier! |
This has got a bit more complex. There are two related but different bugs, both in
I have a simple fix which just does not do replacement 1 if the query also includes To be honest, I am not convinced of the value of doing replacement 1 at all. It seems to be intended to allow path specifications to always use A possibly related question is that explicitly trying to query on paths doesn't seem to work very well anywhere in beets! At the command line, Anyway, I am not trying to open up a larger can of worms. But I am trying to work out whether to include my limited fix to stop replacement 1 in queries including |
Wow, that is pretty nasty! I think you're right about the reason why replacement 1 exists, and the original idea to allow queries like
No—path queries get handled specially so they query entire directory names instead of substring matches. So Line 53 in 3e82613
And here's the somewhat high-level documentation: |
Thanks for the hint. I checked the git log for My proposed change (to stop doing the \ substitution if a field match is happening - i.e. a I suspect the real fix is to undo both replacements. My guess is that there are a tiny number of people using either feature and they could easily change to a world without them. But that might mean code changes for existing users so is not desirable. My new proposal is to change replacement 1 so it does not apply to regex queries (which are much more likely to use An alternative is to deprecate but maintain the current syntax and introduce a new query format which does not do manipulation on It would be good to hear from @nmeum if they are still around. |
Great. Changing things just for queries that contain |
As discussed in bug beetbox#3867, backslash replacement in query strings is a bit of a hack but it is useful (see beetbox#3566 and beetbox#3567 for more discussion). However, it breaks many regular expressions so this patch stops the replacement if the query term contains '::', indicating it is a regex match. This commit fixes beetbox#3867. Signed-off-by: Graham R. Cobb <g+beets@cobb.uk.net>
bugfix beetbox#3867. Signed-off-by: Graham R. Cobb <g+beets@cobb.uk.net>
Signed-off-by: Graham R. Cobb <g+beets@cobb.uk.net>
When I opened this issue I thought the problem was in the web page javascript but I later determined there was an underlying problem in the web plugin code. I have submitted a PR with a fix for that. I propose that if that PR is accepted, this bug should be closed, rather than going on further. I will then open a new bug if needed, if there is still a problem in the web page javascript when I return to that. (I am trying to make various improvements in that, which I will raise as a feature request soon). But first there is a separate small but important feature I would like to work on - I will propose that later today or tomorrow. I hope that is OK. |
The fix #3869 now passes CI tests even on Windows (no changes to the code, just to the tests to provide better test objects on Windows). If/when you are happy to include that PR I believe this can be marked fixed. On to the readonly feature, but that may be tomorrow. |
Problem
This is not a problem in the web API itself, but in the web pages which provide the simple web user interface.
Bringing up the web interface and entering a query such as
somefield::.
never returns any results.The problem is that the web page ends up double URI encoding the search before passing it to GET /item/query.
I have a fix (in
static/beets.js
) which I can submit once the current PR is done.However, I have no idea how to create a test for this as it would mean starting the webserver, submitting an HTTP request and checking the resulting (complex) HTML. Does anyone have any example of doing that in the beets pytest environment? I know very little python and nothing about pytest but I may be able to steal a similar test if one exists!
EDIT: Actually, it is the last step - parsing and checking the resulting HTML which is hard (the rest is what the tests already do - but they are dealing with JSON responses, not HTML responses). Does anyone have any tools or examples of checking HTML responses? Or do I just do some simple string searches and hope nothing changes too much to change the page in the future?
The text was updated successfully, but these errors were encountered: