Skip to content
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

Fixes #2453 - Changes regex to fix progressive label filtering #2496

Merged
merged 2 commits into from
Jun 22, 2018

Conversation

laghee
Copy link
Contributor

@laghee laghee commented Jun 15, 2018

This PR fixes issue #2453

Proposed PR background

Progressive label filtering was broken, seemingly because of something wonky in the regex. I simplified the regex used in editor.js to escape special characters in label titles. I only included currently used special characters, so if future label titles involve anything other than /, ., (, ), /s, -, &, and :, this will need to be updated.


@laghee laghee requested review from miketaylr and karlcow June 15, 2018 18:58
Copy link
Member

@miketaylr miketaylr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

I think in the future we will want to restrict possible chars in labels further, but this seems good.

Can we add a functional test for this so it doesn't regress in the future? Something like:

  1. go to issue 100
  2. open the label filter widget
  3. type test-label
  4. assert we get expected number of results

https://github.com/webcompat/webcompat.com/blob/master/tests/functional/labels-auth.js is a good place for that test.

we may need to update a fixture file or 2, that will be something to investigate if things are failing for you unexpectedly:

https://github.com/webcompat/webcompat.com/tree/master/tests/fixtures/api/issues

@laghee
Copy link
Contributor Author

laghee commented Jun 18, 2018

OK, will do. 👍

@laghee
Copy link
Contributor Author

laghee commented Jun 21, 2018

@miketaylr I'm not totally clear on fixtures, so I can't figure out if I'm doing something goofy or if there's something amiss in the way the fixtures are set up:

  • running the server in test mode serves the labels fixture (where there is no test-label value, so I substituted status-tacos ... obviously)
  • all of the labels are hidden (have style="display: none;") when status-tacos is entered into the search field
  • entering s matches only status-sitewait
  • entering tacos matches only status-tacos
  • entering i matches 4 -- closed-invalid, browser-ie, status-imported, internet-explorer 🤔

Does this sound like the fix isn't working after all, or does something need to be tweaked in the testing environment?

@miketaylr
Copy link
Member

OK, let's see.

When looking at a normal issue (non-fixture):

screen shot 2018-06-21 at 12 22 22 pm

If i type s, I get 2 labels.

When looking at fixture data, I get one:

screen shot 2018-06-21 at 12 22 59 pm

It seems like we're matching on the first letter after status-... this seems expected, I think?

So if you search for status-tacos, it won't match because it's looking for status-status-tacos. Does that make sense? If I were writing a test, I would search for tacos instead, then do assertions, etc.

issues.LabelList = Backbone.Model.extend({
handles all the matching around "namespaces"... I think. It's been a while. :)

@laghee
Copy link
Contributor Author

laghee commented Jun 22, 2018

Wait, so status isn't part of the actual label text? Ahhhhhhh, OK. And I suppose that's true for closed and browser, too? Now I get it.

Sorry, @miketaylr , my bad -- even setting the tests to run in non-headless, I couldn't see the labels themselves or get the inspector to run, so I just assumed everything after label was displayed text (along the lines of status: add to changelog). 🤦‍♀️ (Now that I go back and look at the live labels with the inspector, I see it's the same there, which totally slipped past me.)

New commit incoming ...

Edit: OK, I'm not re-running these in case you wanted to check out the error, but the tests were passing locally. Let me know if I messed up and it's not the usual problem, though.

@TravisBuddy
Copy link

Travis tests have failed

Hey @laghee,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

1st Build

npm run test:js -- --reporters="runner" --firefoxBinary=`which firefox`
> webcompat@ test:js /home/travis/build/webcompat/webcompat.com
> node ./tests/functional/_intern.js "--reporters=runner" "--firefoxBinary=/home/travis/firefox-58.0/firefox/firefox"

Error: 
        ======================================================
        Oops, something went wrong. Try restarting the server.
        Open another terminal and window type:
        npm run start:test
        or
        python run.py -t
        ======================================================
        
  at ClientRequest.<anonymous>  <tests/functional/lib/setup.js:55:9>
  at emitOne  <events.js:116:13>
  at ClientRequest.emit  <events.js:211:7>
  at Socket.socketErrorListener  <_http_client.js:387:9>
  at emitOne  <events.js:116:13>
  at Socket.emit  <events.js:211:7>
  at emitErrorNT  <internal/streams/destroy.js:64:8>
something bad happened inside intern.run()
{ Error: 
        ======================================================
        Oops, something went wrong. Try restarting the server.
        Open another terminal and window type:
        npm run start:test
        or
        python run.py -t
        ======================================================
        
    at ClientRequest.<anonymous> (/home/travis/build/webcompat/webcompat.com/tests/functional/lib/setup.js:55:9)
    at emitOne (events.js:116:13)
    at ClientRequest.emit (events.js:211:7)
    at Socket.socketErrorListener (_http_client.js:387:9)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at emitErrorNT (internal/streams/destroy.js:64:8)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9) reported: true }
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! webcompat@ test:js: `node ./tests/functional/_intern.js "--reporters=runner" "--firefoxBinary=/home/travis/firefox-58.0/firefox/firefox"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the webcompat@ test:js script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/travis/.npm/_logs/2018-06-22T09_18_06_134Z-debug.log

@miketaylr
Copy link
Member

OK, travis is super busted, let's do this manually:

npm run test:js -- --functionalSuites=tests/functional/labels-auth.js

✓ firefox on darwin 17.6.0 - Labels (auth) - Label editor opens then closes (clicks)
✓ firefox on darwin 17.6.0 - Labels (auth) - Label editor opens then closes (key events)
✓ firefox on darwin 17.6.0 - Labels (auth) - Clicking outside label editor closes it
✓ firefox on darwin 17.6.0 - Labels (auth) - Clicking close button actually closes it
✓ firefox on darwin 17.6.0 - Labels (auth) - Label editor filters label list based on entered text
✓ chrome 67.0.3396.87 on Mac OS X - Labels (auth) - Label editor opens then closes (clicks)
✓ chrome 67.0.3396.87 on Mac OS X - Labels (auth) - Label editor opens then closes (key events)
✓ chrome 67.0.3396.87 on Mac OS X - Labels (auth) - Clicking outside label editor closes it
✓ chrome 67.0.3396.87 on Mac OS X - Labels (auth) - Clicking close button actually closes it
✓ chrome 67.0.3396.87 on Mac OS X - Labels (auth) - Label editor filters label list based on entered text

node
Tunnel: Ready

Total: [✓✓✓✓✓✓✓✓✓✓] 10/10
Passed: 10  Failed: 0   Skipped: 0

Fx:         [✓✓✓✓✓] 5/5
Chr 67 Mac: [✓✓✓✓✓] 5/5
it started, yay!

Copy link
Member

@miketaylr miketaylr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

.type("tacos")
.end()
.sleep(1000)
.findAllByXpath(

This comment was marked as abuse.

This comment was marked as abuse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants