Skip to content

Commit

Permalink
Merge pull request webcompat#2444 from karlcow/2437/1
Browse files Browse the repository at this point in the history
Fix webcompat#2437 - Upgrades python ua-parser version to 0.8
  • Loading branch information
karlcow authored May 10, 2018
2 parents 7661d49 + f0b60d3 commit 4c8ff98
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 16 deletions.
2 changes: 1 addition & 1 deletion config/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ nose==1.3.7
pep8==1.7.0
Pillow==4.0.0
requests==2.13.0
ua-parser==0.7.2
ua-parser==0.8
WTForms==2.1
10 changes: 0 additions & 10 deletions tests/functional/index-non-auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,6 @@ registerSuite("Index", {
.end();
},

"reporter addon link is shown"() {
return FunctionalHelpers.openPage(this, url("/"), ".js-hero-title")
.findByCssSelector(".js-addon-link")
.getVisibleText()
.then(function(text) {
assert.include(text, "Download");
})
.end();
},

"form toggles open then closed"() {
return (
FunctionalHelpers.openPage(this, url("/"), ".js-hero-title")
Expand Down
48 changes: 46 additions & 2 deletions tests/unit/test_rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@

# Any request that depends on parsing HTTP Headers (basically anything
# on the index route, will need to include the following: environ_base=headers
headers = {'HTTP_USER_AGENT': ('Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; '
'rv:31.0) Gecko/20100101 Firefox/31.0')}
CHROME_UA = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3425.0 Safari/537.36' # noqa
FIREFOX_UA = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:61.0) Gecko/20100101 Firefox/61.0' # noqa
FIREFOX_AND_UA = 'Mozilla/5.0 (Android; Mobile; rv:61.0) Gecko/61.0 Firefox/61.0' # noqa
OPERA_UA = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.52 Safari/537.36 OPR/15.0.1147.100' # noqa
headers = {'HTTP_USER_AGENT': FIREFOX_UA}


class TestURIContent(unittest.TestCase):
Expand Down Expand Up @@ -69,5 +72,46 @@ def test_user_title_pages(self):
rv = self.app.get('/activity/testuser')
self.assertTrue(title in rv.data)

def test_addon_link(self):
"""An addon link should be in the top navigation bar.
This depends on the user agent string.
"""

# testing Firefox addon
headers = {'HTTP_USER_AGENT': FIREFOX_UA}
rv = self.app.get('/', environ_base=headers)
expected = '<span class="link-text">Download Firefox Add-on</span>'
expected2 = '<use xlink:href="#svg-download2">Firefox addons</use>'
self.assertTrue(expected in rv.data)
self.assertTrue(expected2 in rv.data)
# testing for Firefox Androidpe
headers = {'HTTP_USER_AGENT': FIREFOX_AND_UA}
rv = self.app.get('/', environ_base=headers)
expected = '<span class="link-text">Download Firefox Add-on</span>'
expected2 = '<use xlink:href="#svg-download2">Firefox for Android addons</use>' # noqa
self.assertTrue(expected in rv.data)
self.assertTrue(expected2 in rv.data)
# testing for Chrome
headers = {'HTTP_USER_AGENT': CHROME_UA}
rv = self.app.get('/', environ_base=headers)
expected = '<span class="link-text">Download Chrome Add-on</span>'
expected2 = '<use xlink:href="#svg-download2">Chrome webstore</use>'
self.assertTrue(expected in rv.data)
self.assertTrue(expected2 in rv.data)
# testing for Opera
headers = {'HTTP_USER_AGENT': OPERA_UA}
rv = self.app.get('/', environ_base=headers)
expected = '<span class="link-text">Download Opera Add-on</span>'
expected2 = '<use xlink:href="#svg-download2">Opera Extension</use>'
self.assertTrue(expected in rv.data)
self.assertTrue(expected2 in rv.data)
# testing for unknown browser
headers = {'HTTP_USER_AGENT': 'Punk Cat Space'}
rv = self.app.get('/', environ_base=headers)
expected = '<span class="link-text">Give Feedback</span>'
self.assertTrue(expected in rv.data)


if __name__ == '__main__':
unittest.main()
6 changes: 3 additions & 3 deletions webcompat/templates/nav/addon-links.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<a class="nav-link js-addon-link" href="https://addons.mozilla.org/en-US/android/addon/webcompatcom-mobile-reporter/"
title="Navigate to firefox addon store">
<svg class="icon nav-icon" viewBox="0 0 30 30" role="presentation">
<title> Firefox for Android addons</title>
<use xlink:href="#svg-download2"> Firefox for Android addons</use>
<title>Firefox for Android addons</title>
<use xlink:href="#svg-download2">Firefox for Android addons</use>
</svg>
<span class="link-text">Download Firefox Add-on</span>
</a>
Expand All @@ -38,7 +38,7 @@
title="Navigate to opera addons">
<svg class="icon nav-icon" viewBox="0 0 30 30" role="presentation">
<title>Opera Extension</title>
<use xlink:href="#svg-download2"> Opera Extension</use>
<use xlink:href="#svg-download2">Opera Extension</use>
</svg>
<span class="link-text">Download Opera Add-on</span>
</a>
Expand Down

0 comments on commit 4c8ff98

Please sign in to comment.