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

refactor: add unit tests for bookmarklet #280

Merged
merged 3 commits into from
Mar 12, 2020
Merged

Conversation

adrienjoly
Copy link
Member

@adrienjoly adrienjoly commented Mar 12, 2020

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.

  • export detectTracks({ window, ui, urlDetectors }), makeFileDetector() and makeStreamDetector(players)
  • bump to bookmarklet v2.4 (from v2.3)
  • add a first unit test

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

=> make it work from Node.js
@adrienjoly adrienjoly changed the title refact: add unit tests for bookmarklet refactor: add unit tests for bookmarklet Mar 12, 2020
@adrienjoly adrienjoly self-assigned this Mar 12, 2020
@adrienjoly adrienjoly added this to 📥 Inbox / ideas in Development via automation Mar 12, 2020
@adrienjoly adrienjoly merged commit 5122189 into master Mar 12, 2020
Development automation moved this from 📥 Inbox / ideas to ✔️ Done / pending QA Mar 12, 2020
@adrienjoly adrienjoly deleted the refact/bookmarklet branch March 12, 2020 10:17
adrienjoly added a commit that referenced this pull request Mar 12, 2020
Contributes to #262. Follow up of #280.

## What does this PR do / solve?

As mentioned 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 second step of that refactor: it enables adaptive metadata enrichment for the page itself (e.g. youtube track page), while preventing duplicates in the results.

## Overview of changes

See the diff, and disable the display of whitespace changes.

- add `detectYouTubePageTrack()`
- group ui calls
- bump to bookmarklet v2.5 (from v2.4)
- add unit tests

## How to test this PR?

```sh
$ 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.
adrienjoly pushed a commit that referenced this pull request Mar 12, 2020
## [1.26.1](v1.26.0...v1.26.1) (2020-03-12)

### Bug Fixes

* **bookmarklet:** refactor bookmarklet and add tests for [#262](#262) ([#281](#281)) ([957afec](957afec)), closes [#280](#280)
@adrienjoly adrienjoly moved this from ✔️ Done / pending QA to 🌲 In production in Development Mar 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development
  
🌲 In production
Development

Successfully merging this pull request may close these issues.

None yet

1 participant