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/java/com/juick | |
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/java/com/juick')
-rw-r--r-- | src/test/java/com/juick/server/tests/ServerTests.java | 36 |
1 files changed, 34 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))); + } } |