diff --git a/src/main/resources/freemarker/new-study-digest.ftl b/src/main/resources/freemarker/new-study-digest.ftl
index 74e0fc37ee..5af6e7c76e 100644
--- a/src/main/resources/freemarker/new-study-digest.ftl
+++ b/src/main/resources/freemarker/new-study-digest.ftl
@@ -1,45 +1,56 @@
<#assign pageTitle="DUOS - New data in DUOS today!">
<#assign greetingHtml="Dear ${userName},">
+<#-- Email clients require inline CSS, so the shared declarations are defined once and reused. -->
+<#assign bodyTextStyle="font-family: 'Montserrat', sans-serif; font-size: 16px; color: #1F3B50; line-height: 25px;">
+<#assign headerCellStyle="font-family: 'Montserrat', sans-serif; font-style: italic; font-size: 15px; color: #00609f; border-bottom: 1px solid #cccccc; padding: 5px;">
+<#assign dataCellStyle="font-family: 'Montserrat', sans-serif; color: #1F3B50; border-bottom: 1px solid #cccccc; padding: 5px; vertical-align: top;">
+<#assign linkStyle="text-decoration: none; font-family: 'Montserrat', sans-serif; color: #00609F; font-weight: 600;">
+<#assign badgeStyle="display: inline-block; padding: 1px 10px; border: 1px solid #cde1f0; border-radius: 12px; background-color: #eaf2f9; font-family: 'Montserrat', sans-serif; font-size: 13px; line-height: 20px; color: #00609F; white-space: nowrap;">
<#include "/freemarker/header.ftl">
- |
- The studies below were registered in DUOS today! Click the Study link to view the study and its datasets, or go to the DUOS Data Library to view all studies.
+ |
+ The studies below were registered in DUOS today! Click the Study link to view the study and its datasets, or go to the DUOS Data Library to view all studies.
|
+ <#if newStudies?has_content>
-
- <#if newStudies?has_content>
-
-
-
- | Study Name |
- Access Type(s) |
- Number of Datasets |
-
-
-
- <#list newStudies as item>
-
- |
- ${item.name()}
- |
-
- <#list item.accessTypes()?split(",") as accessType>${accessType?trim?cap_first}<#sep>, #list>
- |
-
- ${item.datasetCount()}
- |
-
- #list>
-
-
- #if>
+ |
+ <#if newStudies?size == 1>1 new study was<#else>${newStudies?size} new studies were#if> registered today.
|
- |
-
-
+ |
+
+
+
+ | Study Name |
+ Access Type(s) |
+ Number of Datasets |
+
+
+
+ <#list newStudies as item>
+
+ |
+ ${item.name()}
+ |
+
+ <#list item.accessTypes()?split(",") as accessType>
+ ${accessType?trim?cap_first}
+ #list>
+ |
+
+ ${item.datasetCount()}
+ |
+
+ #list>
+
+
+ |
+
+ #if>
+
+ |
The DUOS team
|
diff --git a/src/test/java/org/broadinstitute/consent/http/mail/message/NewStudyDigestMessageTest.java b/src/test/java/org/broadinstitute/consent/http/mail/message/NewStudyDigestMessageTest.java
index 184a13e860..38053d92e5 100644
--- a/src/test/java/org/broadinstitute/consent/http/mail/message/NewStudyDigestMessageTest.java
+++ b/src/test/java/org/broadinstitute/consent/http/mail/message/NewStudyDigestMessageTest.java
@@ -65,8 +65,36 @@ void testNewStudyDigestMessage() throws Exception {
rendered.document().body().html(),
containsString(urlStringPattern.formatted(serverUrl, record2.id(), record2.name())));
- // Assert display-formatted access types from template
- assertThat(rendered.document().body().html(), containsString("Controlled, External"));
- assertThat(rendered.document().body().html(), containsString("Open"));
+ // Assert display-formatted access types from template, rendered as one badge per type
+ assertEquals(
+ List.of("Controlled", "External", "Open"),
+ rendered.document().select(".access-type-badge").eachText());
+
+ // Assert the summary count line is present and pluralized for multiple studies
+ assertEquals(
+ "2 new studies were registered today.",
+ getElementTextById(rendered.document(), "newStudyCount"));
+
+ // Assert dataset counts are bare numbers, right-aligned under the column heading
+ var datasetCounts = rendered.document().select(".dataset-count");
+ assertEquals(List.of("1", "2"), datasetCounts.eachText());
+ datasetCounts.forEach(
+ cell -> assertThat(cell.attr("style"), containsString("text-align: right")));
+ }
+
+ @Test
+ void testNewStudyDigestMessage_SingleStudyCountIsSingular() throws Exception {
+ List newStudies =
+ List.of(new StudyDatasetCountRecord("My only new study", 3, "open", 1));
+ User user = new User();
+ user.setDisplayName("Test User");
+ var message = new NewStudyDigestMessage(user, newStudies, "My reference id");
+
+ var rendered = renderTemplate(message, "http://localhost:8080/");
+
+ assertEquals(
+ "1 new study was registered today.",
+ getElementTextById(rendered.document(), "newStudyCount"));
+ assertEquals(List.of("1"), rendered.document().select(".dataset-count").eachText());
}
}