refactor: add unit tests for bookmarklet #280
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Contributes to #262.
What does this PR do / solve?
As mention in #262 following the reduction of our YouTube API quota, we need to make several changes to the bookmarklet in order to save some quota while keeping a good user experience. E.g. track titles should be extracted from the page instead of queried from YouTube API.
As these changes are quite structural and may introduce bugs in the bookmarklet, and as we don't have time to test it manually after each change, it's time to refactor the code in order to make that code testable by automated unit tests.
This PR is the first step of that refactor: it makes the bookmarklet loadable from Node.js.
Overview of changes
See the diff, and disable the display of whitespace changes.
detectTracks({ window, ui, urlDetectors })
,makeFileDetector()
andmakeStreamDetector(players)
How to test this PR?
$ nvm use $ node_modules/.bin/mocha test/unit/bookmarklet-tests.js $ docker-compose up --build -d $ npm run docker:seed && node_modules/.bin/wdio wdio.conf.js
Also, you can test the bookmarklet manually, from your web browser, by following the instructions provided in the unit test file: https://github.com/openwhyd/openwhyd/pull/280/files?diff=split&w=1#diff-c8dc146d6906e24b2298327e5628d90aR23