diff options
author | Vitaly Takmazov | 2019-07-04 14:31:22 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2019-07-04 14:31:22 +0300 |
commit | 79a9f1509c4430f6e65c67e41098ef7aaa227c3f (patch) | |
tree | 8938ab6702c1ce855d4320c715ae09688872b5a8 /src/test | |
parent | 52d88dd00b260c54ba90ab52e283b5b1b1ba851d (diff) |
Render email using templates
* do not include tracking pixel in pm
* reorganize snapshots layout
* reconfigure pebble to not trim anything
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/java/com/juick/server/tests/ServerTests.java | 36 | ||||
-rw-r--r-- | src/test/resources/snapshots/activity/testfollow.json (renamed from src/test/resources/mocks/activity/testfollow.json) | 0 | ||||
-rw-r--r-- | src/test/resources/snapshots/activity/testuser.json (renamed from src/test/resources/mocks/activity/testuser.json) | 0 | ||||
-rw-r--r-- | src/test/resources/snapshots/email/private.html | 10 | ||||
-rw-r--r-- | src/test/resources/snapshots/email/subscription.html | 10 | ||||
-rw-r--r-- | src/test/resources/snapshots/email/subscription.txt | 5 |
6 files changed, 59 insertions, 2 deletions
diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java index 4c72913e..de742447 100644 --- a/src/test/java/com/juick/server/tests/ServerTests.java +++ b/src/test/java/com/juick/server/tests/ServerTests.java @@ -28,6 +28,7 @@ import com.gargoylesoftware.htmlunit.html.DomElement; import com.gargoylesoftware.htmlunit.html.HtmlPage; import com.jayway.jsonpath.JsonPath; import com.juick.*; +import com.juick.formatters.PlainTextFormatter; import com.juick.model.AnonymousUser; import com.juick.model.CommandResult; import com.juick.model.PrivateChats; @@ -218,10 +219,16 @@ public class ServerTests { @Inject private Profile profileController; - @Value("classpath:mocks/activity/testuser.json") + @Value("classpath:snapshots/activity/testuser.json") private Resource testuserResponse; - @Value("classpath:mocks/activity/testfollow.json") + @Value("classpath:snapshots/activity/testfollow.json") private Resource testfollowRequest; + @Value("classpath:snapshots/email/subscription.html") + private Resource testSubscriptionHtmlEmail; + @Value("classpath:snapshots/email/private.html") + private Resource testPrivateHtmlEmail; + @Value("classpath:snapshots/email/subscription.txt") + private Resource testSubscriptionTextEmail; @Value("classpath:static/av-96.png") private Resource defaultAvatar; @Value("classpath:cmyk.jpg") @@ -241,6 +248,8 @@ public class ServerTests { @Inject private KeystoreManager testKeystoreManager; + @Inject + private EmailManager emailManager; @Inject private ApplicationEventPublisher applicationEventPublisher; @@ -2121,4 +2130,27 @@ public class ServerTests { .findFirst().orElseThrow(IllegalStateException::new); assertThat(rareTagStats.getUsageCount(), is(1)); } + private String getSnapshot(Resource resource) throws IOException { + return IOUtils.toString(resource.getInputStream(), StandardCharsets.UTF_8); + } + @Test + public void emailTemplatesTest() throws IOException { + String plainText = emailManager.renderPlaintext("yo", "https://localhost/m/1").orElseThrow(); + assertThat(plainText, is(getSnapshot(testSubscriptionTextEmail))); + User demo = MockUtils.mockUser(45, ugnichName, ugnichPassword); + Message html = MockUtils.mockMessage(56, demo, "yo"); + String htmlText = emailManager.renderHtml( + MessageUtils.formatHtml(html), + PlainTextFormatter.formatUrl(html), + html, "12345") + .orElseThrow(); + assertThat(htmlText, is(getSnapshot(testSubscriptionHtmlEmail))); + html.setMid(0); + String htmlPM = emailManager.renderHtml( + MessageUtils.formatHtml(html), + PlainTextFormatter.formatUrl(html), + html, "12345") + .orElseThrow(); + assertThat(htmlPM, is(getSnapshot(testPrivateHtmlEmail))); + } } diff --git a/src/test/resources/mocks/activity/testfollow.json b/src/test/resources/snapshots/activity/testfollow.json index e308e52e..e308e52e 100644 --- a/src/test/resources/mocks/activity/testfollow.json +++ b/src/test/resources/snapshots/activity/testfollow.json diff --git a/src/test/resources/mocks/activity/testuser.json b/src/test/resources/snapshots/activity/testuser.json index 95fc2aa9..95fc2aa9 100644 --- a/src/test/resources/mocks/activity/testuser.json +++ b/src/test/resources/snapshots/activity/testuser.json diff --git a/src/test/resources/snapshots/email/private.html b/src/test/resources/snapshots/email/private.html new file mode 100644 index 00000000..fee506c7 --- /dev/null +++ b/src/test/resources/snapshots/email/private.html @@ -0,0 +1,10 @@ +<b>@ugnich:</b></br/><i></i><br/>yo<br /> +<br /> +<br /> +-- +<br /> +You are receiving this because you are subscribed to this user, discussion, tag or mentioned. +Reply to this email directly or <a href="https://juick.com/pm/inbox"> + view it</a> on Juick. +<br /> +<a href="https://juick.com/settings?hash=12345">Configure or disable notifications</a>
\ No newline at end of file diff --git a/src/test/resources/snapshots/email/subscription.html b/src/test/resources/snapshots/email/subscription.html new file mode 100644 index 00000000..c75360ed --- /dev/null +++ b/src/test/resources/snapshots/email/subscription.html @@ -0,0 +1,10 @@ +<b>@ugnich:</b></br/><i></i><br/>yo<br /> +<br /> +<br /> +-- +<br /> +You are receiving this because you are subscribed to this user, discussion, tag or mentioned. +Reply to this email directly or <a href="https://juick.com/m/56"> + <img src="https://api.juick.com/thread/mark_read/56-0.gif?hash=12345" />view it</a> on Juick. +<br /> +<a href="https://juick.com/settings?hash=12345">Configure or disable notifications</a>
\ No newline at end of file diff --git a/src/test/resources/snapshots/email/subscription.txt b/src/test/resources/snapshots/email/subscription.txt new file mode 100644 index 00000000..57967c4b --- /dev/null +++ b/src/test/resources/snapshots/email/subscription.txt @@ -0,0 +1,5 @@ +yo + +-- +You are receiving this because you are subscribed to this user, discussion, tag or mentioned. +Reply to this email directly or view it on Juick: https://localhost/m/1
\ No newline at end of file |