Browse Source

chore(tests): Don't snapshot test txt versions of emails (#8349)

Ben Vinegar 6 years ago
parent
commit
31bd7ed345

+ 22 - 1
tests/acceptance/test_emails.py

@@ -1,6 +1,9 @@
 from __future__ import absolute_import
 
+import os.path
+
 from six.moves.urllib.parse import urlencode
+from os.path import join, dirname
 
 from sentry.testutils import AcceptanceTestCase
 
@@ -31,6 +34,18 @@ EMAILS = (
 )
 
 
+def read_txt_email_fixture(name):
+    # "sso unlinked without password"
+    # => "sso_unlinked_without_password.txt"
+    filename = name.replace(' ', '_') + '.txt'
+    path = join(dirname(__file__), os.pardir, 'fixtures', 'emails', filename)
+
+    fixture = None
+    with open(path, 'r') as f:
+        fixture = f.read()
+    return fixture
+
+
 class EmailTestCase(AcceptanceTestCase):
     def setUp(self):
         super(EmailTestCase, self).setUp()
@@ -48,10 +63,16 @@ class EmailTestCase(AcceptanceTestCase):
 
     def test_emails(self):
         for url, name in EMAILS:
+            # HTML output is captured as a snapshot
             self.browser.get(self.build_url(url, 'html'))
             self.browser.wait_until('#preview')
             self.browser.snapshot('{} email html'.format(name))
 
+            # Text output is asserted against static fixture files
             self.browser.get(self.build_url(url, 'txt'))
             self.browser.wait_until('#preview')
-            self.browser.snapshot('{} email txt'.format(name))
+            elem = self.browser.find_element_by_css_selector('#preview pre')
+            text_src = elem.get_attribute('innerHTML')
+
+            fixture_src = read_txt_email_fixture(name)
+            assert fixture_src == text_src

+ 49 - 0
tests/fixtures/emails/alert.txt

@@ -0,0 +1,49 @@
+Details
+-------
+
+http://example.com/link
+
+
+Suspect Commits
+---------------
+
+* feat: Do something to raven/base.py
+  1b17483 - dcramer@gmail.com
+
+
+Tags
+----
+
+* logger = javascript
+* environment = prod
+* level = error
+* device = Other
+
+
+Stacktrace
+-----------
+
+
+
+
+Template
+-----------
+
+
+
+
+Request
+-----------
+
+
+
+
+User
+-----------
+
+
+
+
+
+
+Unsubscribe: javascript:alert("This is a preview page, what did you expect to happen?");

+ 13 - 0
tests/fixtures/emails/assigned.txt

@@ -0,0 +1,13 @@
+# Assigned
+
+foo@example.com assigned an issue to foo@example.com
+
+
+## Issue Details
+
+ornare elit pulvinar nisl integer cum ad massa
+
+http://testserver/organization/project/issues/1/
+
+
+Unsubscribe: javascript:alert("This is a preview page, what did you expect to happen?");

+ 13 - 0
tests/fixtures/emails/assigned_self.txt

@@ -0,0 +1,13 @@
+# Assigned
+
+foo@example.com assigned an issue to themselves
+
+
+## Issue Details
+
+ornare elit pulvinar nisl integer cum ad massa
+
+http://testserver/organization/project/issues/1/
+
+
+Unsubscribe: javascript:alert("This is a preview page, what did you expect to happen?");

+ 26 - 0
tests/fixtures/emails/digest.txt

@@ -0,0 +1,26 @@
+Notifications for example
+June 8, 2016, 7:25 a.m. UTC to July 4, 2016, 2:11 p.m. UTC
+
+Rule #1
+
+* CursusError: nibh curabitur (9729 events, 5901 users)
+  http://testserver/example/example/issues/9/
+
+* CuraeError: pulvinar fames suspendisse erat integer ad magna (7555 events, 4549 users)
+  http://testserver/example/example/issues/15/
+
+* erat pellentesque enim imperdiet tortor (3180 events, 276 users)
+  http://testserver/example/example/issues/16/
+
+* NecVivamusError: consequat ipsum proin gravida inceptos scelerisque inceptos iaculis libero vulputate (2824 events, 1188 users)
+  http://testserver/example/example/issues/14/
+
+* LectusDapibusTacitiError: semper porta curae luctus fermentum molestie praesent ac auctor (2358 events, 7906 users)
+  http://testserver/example/example/issues/2/
+
+* VelTorquentError: porttitor praesent ridiculus (562 events, 8950 users)
+  http://testserver/example/example/issues/13/
+
+
+
+Unsubscribe: javascript:alert("This is a preview page, what did you expect to happen?");

+ 8 - 0
tests/fixtures/emails/invalid_identity.txt

@@ -0,0 +1,8 @@
+Action Required
+---------------
+
+An identity with a third party service provider (dummy) failed to authenticate and has been removed.
+
+You will need to associate your account with dummy to continue using the integration.
+
+http://testserver/account/settings/social/associate/dummy/

+ 9 - 0
tests/fixtures/emails/invitation.txt

@@ -0,0 +1,9 @@
+Welcome to Sentry
+
+Your teammates over at Example have already been using Sentry without you, but the good news is that you've been invited to join them.
+
+Join your team by visiting the following url:
+
+    http://testserver/accept/1/None/
+
+If you'd like to learn more about Sentry before diving head-first, check out our website, https://sentry.io/

+ 20 - 0
tests/fixtures/emails/mfa_added.txt

@@ -0,0 +1,20 @@
+Security Notice
+---------------
+
+An authenticator has been added to your Sentry account.
+
+
+Details
+-------
+
+Account: foo@example.com
+IP: 127.0.0.1
+When: Jan. 20, 2017, 9:39 p.m. UTC
+
+Authenticator: U2F (Universal 2nd Factor)
+
+
+Don't recognize this activity?
+------------------------------
+
+If you didn't trigger this action, we recommend you immediately review your account security, including changing your password. If you determine that this activity is malicious please contact .

+ 20 - 0
tests/fixtures/emails/mfa_removed.txt

@@ -0,0 +1,20 @@
+Security Notice
+---------------
+
+An authenticator has been removed from your Sentry account.
+
+
+Details
+-------
+
+Account: foo@example.com
+IP: 127.0.0.1
+When: Jan. 20, 2017, 9:39 p.m. UTC
+
+Authenticator: U2F (Universal 2nd Factor)
+
+
+Don't recognize this activity?
+------------------------------
+
+If you didn't trigger this action, we recommend you immediately review your account security, including changing your password. If you determine that this activity is malicious please contact .

+ 14 - 0
tests/fixtures/emails/note.txt

@@ -0,0 +1,14 @@
+# New Comment
+
+foo@example.com left a new comment:
+
+metus volutpat
+
+
+## Details
+
+ornare elit pulvinar nisl integer cum ad massa
+
+http://testserver/organization/project/issues/1/activity/
+
+Unsubscribe: javascript:alert("This is a preview page, what did you expect to happen?");

Some files were not shown because too many files changed in this diff