Skip to content

Commit 560413c

Browse files
committed
Fixes webcompat#1412: Add page titles and tests for them
1 parent 0d04b81 commit 560413c

10 files changed

+62
-1
lines changed

tests/test_rendering.py

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# This Source Code Form is subject to the terms of the Mozilla Public
4+
# License, v. 2.0. If a copy of the MPL was not distributed with this
5+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
7+
'''Tests for our URI endpoints' rendering.'''
8+
9+
import os.path
10+
import sys
11+
import unittest
12+
13+
# Add webcompat module to import path
14+
sys.path.append(os.path.realpath(os.pardir))
15+
import webcompat # nopep8
16+
17+
# Any request that depends on parsing HTTP Headers (basically anything
18+
# on the index route, will need to include the following: environ_base=headers
19+
headers = {'HTTP_USER_AGENT': ('Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; '
20+
'rv:31.0) Gecko/20100101 Firefox/31.0')}
21+
22+
23+
class TestURLs(unittest.TestCase):
24+
def setUp(self):
25+
webcompat.app.config['TESTING'] = True
26+
self.app = webcompat.app.test_client()
27+
28+
def tearDown(self):
29+
pass
30+
31+
def test_titles(self):
32+
'''Page title format for different URIs.'''
33+
issueNum = '1000'
34+
defaultTitle = 'Web Compatibility'
35+
website_uris = [
36+
('/', defaultTitle),
37+
('/about', 'About'),
38+
('/contributors', 'Contributors'),
39+
('/tools/cssfixme', 'CSS Fix Me'),
40+
('/issues/' + issueNum, 'Issue #' + issueNum),
41+
('/issues', 'Issues'),
42+
('issues/new', 'New Issue'),
43+
('/privacy', 'Privacy Policy'),
44+
('/404', defaultTitle)
45+
]
46+
for uri, title in website_uris:
47+
rv = self.app.get(uri, environ_base=headers)
48+
expected = '<title>{title} | webcompat.com</title>'.format(
49+
title=title)
50+
self.assertTrue(expected in rv.data)
51+
52+
if __name__ == '__main__':
53+
unittest.main()

webcompat/templates/about.html

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{% extends "layout.html" %}
2+
{% block title %}About{% endblock %}
23
{% block body %}
34
{% include "shared/nav.html" %}
45
<main class="wc-UIContent" role="main">

webcompat/templates/contributors.html

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{% extends "layout.html" %}
2+
{% block title %}Contributors{% endblock %}
23
{% block body %}
34
<div>
45
{% include "shared/nav.html" %}

webcompat/templates/cssfixme.html

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{% extends "layout.html" %}
2+
{% block title %}CSS Fix Me{% endblock %}
23
{% block body %}
34
{% include "shared/nav.html" %}
45
<main class="wc-UIContent" role="main">

webcompat/templates/issue.html

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{% extends "layout.html" %}
2+
{% block title %}Issue #{{ number }}{% endblock %}
23
{% block body %}
34
{% include "shared/nav.html" %}
45
<main class="wc-UISection wc-UISection--backgroundColor" role="main">

webcompat/templates/layout.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html lang="en">
33
<head>
4-
<title>webcompat.com</title>
4+
<title>{% block title %}Web Compatibility{% endblock %} | webcompat.com</title>
55
<meta charset="utf-8">
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
77
<meta name="description" content="Open source community for web compatibility. Report bugs from websites or for browsers and help us move the web forward.">

webcompat/templates/list-issue.html

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{% extends "layout.html" %}
2+
{% block title %}Issues{% endblock %}
23
{% block body %}
34
<div class="wc-SearchIssue js-SearchIssue" data-username="{{ session.username }}">
45
{% include "shared/nav.html" %}

webcompat/templates/new-issue.html

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{%- extends "layout.html" -%}
2+
{% block title %}New Issue{% endblock %}
23
{%- block body -%}
34
{% include "topbar.html" %}
45
<main role="main">

webcompat/templates/privacy.html

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{% extends "layout.html" %}
2+
{% block title %}Privacy Policy{% endblock %}
23
{% block body %}
34
{% include "shared/nav.html" %}
45
<main class="wc-UIContent" role="main">

webcompat/templates/user-activity.html

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{% extends "layout.html" %}
2+
{% block title %}{{user}}'s Activity{% endblock %}
23
{% block body %}
34
{% include "shared/nav.html" %}
45
<main role="main">

0 commit comments

Comments
 (0)