-
Notifications
You must be signed in to change notification settings - Fork 203
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 #1412: Add titles to pages #1419
Conversation
f070fe1
to
4a69072
Compare
@heatherbooker I'm about to board a plane. |
ahah ok @karlcow thx for the heads up! ^^ safe trip! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the pull request.
Please make the changes and rebase it once done. :) If you don't know how to do it I will gladly explain.
tests/functional/issues-non-auth.js
Outdated
@@ -101,6 +101,15 @@ define([ | |||
assert.notInclude(className, "wc-Comment-content-nsfw--display"); | |||
}) | |||
.end(); | |||
}, | |||
|
|||
"Issue page title matches actual issue number": function() { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
webcompat/templates/layout.html
Outdated
@@ -1,7 +1,7 @@ | |||
<!DOCTYPE html> | |||
<html lang="en"> | |||
<head> | |||
<title>webcompat.com</title> | |||
<title>{% block title %}{% endblock %}webcompat.com</title> |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
just putting this here, because I was experimenting in testing with the python side. #!/usr/bin/env python
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
'''Tests for our URL endpoints.'''
import os.path
import sys
import unittest
# Add webcompat module to import path
sys.path.append(os.path.realpath(os.pardir))
import webcompat # nopep8
# 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')}
class TestURLs(unittest.TestCase):
def setUp(self):
webcompat.app.config['TESTING'] = True
self.app = webcompat.app.test_client()
def tearDown(self):
pass
def test_home(self):
'''Page title format for different URIs.'''
website_uris = [
('/about', 'About'),
('/contributors', 'Contributors'),
('/tools/cssfixme', 'CSS Fix Me'),
('/issues/1000', 'Issue #1000'),
('/issues', 'Issues'),
('/issues/new', 'New Issue'),
('/privacy', 'Privacy Policy')]
for uri, title in website_uris:
rv = self.app.get(uri, environ_base=headers)
expected = '<title>{title} | webcompat.com</title>'.format(
title=title)
self.assertTrue(expected in rv.data)
if __name__ == '__main__':
unittest.main() With the results: nosetests -v tests/test_rendering.py
# Page title format for different URIs. ... ok
#
# ----------------------------------------------------------------------
# Ran 1 test in 0.181s
#
# OK |
My feeling on why it should be on the python side more than the JS side (functional tests) is that these titles do not require any actions from the user. It's really generated by the application. So it probably should be in the unit tests. @heatherbooker What do you think about it? |
@karlcow Hm gotcha, I don't have a lot of experience testing but looking through the tests that does make sense to have it in unit tests. Oh actually except for testing And would you rather see these tests in a separate file Last q - why the |
4a69072
to
dde8462
Compare
Sorry for the late answer
This should be done in python too, but is a bit more complicated. because it requires to mock the circumstances of the template.
Yup in a different file than test_urls.py
This is PEP8 E402. You can see the difference in between the lines here. The why it's not everywhere is that we started to clean it up little by little when we are editing the files. But not necessary systematically for the whole project as it is not a bug, but more cosmetics. Hope it helps. |
dde8462
to
fc628e5
Compare
Hey @karlcow , my apologies for the delay! I've been fiddling with testing the I know you linked to the route in views.py and it has g.user and session['username'] but I haven't been able to figure it out! :( I don't see anything similar in the other python test files involving actually mocking being logged in. Here is the code. If you could point me in the right direction I would really appreciate it! :) |
me too. I'm almost there but it's indeed a bit complex. What I propose is that you send the pull request without /activity/username test. And we open a subsequent new issue for this specific test. In that way we do not block your contributions and we can address this specific test later on. |
fc628e5
to
560413c
Compare
Okie doke @karlcow , done :) (Phew, it makes me feel better to know that you too find it a bit complex!) |
And here's a new issue for it - #1428 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot. Good work.
Fixes #1412 .
Also adds titles to all other possible pages (ie not humans.txt!)