Skip to content

Commit

Permalink
Merge branch 'selenium-tests'
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgaya committed May 16, 2021
2 parents f828ad1 + 2d91e55 commit c6e18ca
Show file tree
Hide file tree
Showing 10 changed files with 2,679 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Version 1.3

- Add per-domain settings for deduplicating by thumbnail
- Automate basic browser tests using Selenium
- Minor fixes/improvements

## Version 1.2
Expand Down
3 changes: 3 additions & 0 deletions chrome.jq
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@
"48": "icons/icon48.png",
"128": "icons/icon128.png"
})

# Chrome emits a spurious warning about browser_specific_settings
| del(.browser_specific_settings)
6 changes: 6 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
"description": "Hide duplicate posts on pre-redesign Reddit.",
"homepage_url": "https://nickgaya.github.io/rededup/",

"browser_specific_settings": {
"gecko": {
"id": "{68f0c654-5a3d-423b-b846-2b3ab68d05dd}"
}
},

"icons": {
"48": "icons/icon.svg",
"96": "icons/icon.svg"
Expand Down
10 changes: 8 additions & 2 deletions rededup.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,10 @@ async function getLinkInfo(thing, pageType, settings) {
if (settings.showHashValues) {
const hashElt = document.createElement('code');
hashElt.textContent = bufToHex(linkInfo.thumbnailHash);
getTagline(thing, pageType).append(' [', hashElt, ']');
const spanElt = document.createElement('span');
spanElt.classList.add('rededup-hash');
spanElt.append(' [', hashElt, ']');
getTagline(thing, pageType).append(spanElt);
}
} catch (error) {
console.warn("Failed to get thumbnail hash", thumbnailImg,
Expand Down Expand Up @@ -267,6 +270,7 @@ class DupRecord {
this.countElt = document.createElement('span');
this.countElt.textContent = '0 duplicates';
this.linkElt = document.createElement('a');
this.linkElt.classList.add('rededup-toggle');
this.linkElt.textContent = this.showDuplicates ? 'hide' : 'show';
this.linkElt.href = '#';
const dupRecord = this;
Expand All @@ -281,7 +285,9 @@ class DupRecord {
return false;
});
this.taglineElt = document.createElement('span');
this.taglineElt.append(' (', this.countElt, ' — ', this.linkElt, ')');
this.taglineElt.classList.add('rededup-tagline');
this.taglineElt.append(
' (', this.countElt, ' \u2014 ', this.linkElt, ')');
const tagline = getTagline(this.links[0], pageType);
tagline.append(this.taglineElt);
}
Expand Down
14 changes: 7 additions & 7 deletions testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,17 @@ These tests use specific posts to verify the deduplication functionality.

2. Deduplicate by URL

1. Navigate to https://old.reddit.com/by_id/t3_jyu5b2,t3_jysgvx,t3_jyu73g.
1. Navigate to https://old.reddit.com/by_id/t3_jyu5b2,t3_jysgvx,t3_jywerx.

2. Verify that posts are collated as expected.

* Post order should be jyu5b2, jyu73g, jysgvx.
* Post order should be jyu5b2, jywerx, jysgvx.
* jyu5b2 should have "(1 duplicate — show)" at end of tagline.
* jyu73g should be hidden.
* jywerx should be hidden.

3. Verify that show/hide link works as expected.

4. Deduplicate by URL (crosspost)
3. Deduplicate by URL (crosspost)

1. Navigate to https://old.reddit.com/by_id/t3_jyu5b2,t3_jyvuiz.

Expand All @@ -136,16 +136,16 @@ These tests use specific posts to verify the deduplication functionality.

4. Deduplicate multiple

1. Navigate to https://old.reddit.com/by_id/t3_jrjed7,t3_jysgvx,t3_jyu5b2,t3_jrqhj4,t3_jo1qwh,t3_jyu73g,t3_jri2y8,t3_jyvuiz.
1. Navigate to https://old.reddit.com/by_id/t3_jrjed7,t3_jysgvx,t3_jyu5b2,t3_jrqhj4,t3_jo1qwh,t3_jywerx,t3_jri2y8,t3_jyvuiz.

2. Verify that posts are collated as expected.

* Post order should be jrjed7, jrqhj4, jri2y8, jysgvx, jyu5b2, jyu73g,
* Post order should be jrjed7, jrqhj4, jri2y8, jysgvx, jyu5b2, jywerx,
jyvuiz, jo1qwh.
* jrjed7 should have "(2 duplicates — show)" at end of tagline.
* jrqhj4 and jri2y8 should be hidden.
* jyu5b2 should have "(2 duplicates — show)" at end of tagline.
* jyu73g and jyvuiz should be hidden.
* jywerx and jyvuiz should be hidden.

3. Verify that both show/hide links work as expected.

Expand Down
2 changes: 2 additions & 0 deletions tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
geckodriver.log
node_modules/
12 changes: 12 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Selenium tests

These tests are written using Node.js and Selenium. They require Firefox and
gecko-webdriver to be installed on your system.

To run the tests:

export REDEDUP_PATH=../artifacts/rededup-<version>-fx.zip
npm test

By default, the tests run in "headless" mode. To enable the browser GUI, you
can set the environment variable `BROWSER_GUI=true`.
Loading

0 comments on commit c6e18ca

Please sign in to comment.