Skip to content

Commit

Permalink
Merge branch 'MAS-129_121__112_Daily_Email' of github.com:nice-digita…
Browse files Browse the repository at this point in the history
…l/MAS into MAS-129_121__112_Daily_Email
  • Loading branch information
ediblecode committed Jan 16, 2020
2 parents a367366 + a8b6683 commit e18952a
Show file tree
Hide file tree
Showing 7 changed files with 241 additions and 47 deletions.
42 changes: 42 additions & 0 deletions lambda/MAS.Tests/Feeds/daily-items-2020-01-01.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[
{
"_id": "5daf1aa18a34d4bb8405b5e0",
"slug": "testing-789",
"source": {
"_id": "5de526fc43e373581b7810c8",
"oldEPiServerId": 2,
"title": "ACP Journal Club",
"__v": 0
},
"shortSummary": "testing",
"resourceLinks": "http://localhost:3010/keystone/items",
"url": "https://www.nhs.uk/",
"title": "Wonder Drug",
"__v": 0,
"comment": "<p>A</p>",
"publicationDate": "2019-11-25T13:48:36.000Z",
"createdDate": "2019-10-22T15:05:05.927Z",
"specialities": [
{
"_id": "5e0e4331200a585f718e1ee5",
"key": "be1c2e2f-745e-4a82-b5aa-d4cef4d31a1b",
"title": "Anaesthesia and pain",
"__v": 0
},
{
"_id": "5e0e4331200a58dead8e1ee8",
"key": "53fc67a4-46d8-4171-9447-7fcf216c8749",
"title": "Complementary and alternative therapies",
"__v": 0
}
],
"evidenceType": {
"_id": "5df7abf383138898ee1f67ef",
"title": "Safety alerts",
"key": "mas_evidence_types:Safety%20alerts",
"oldEPiServerId": 778708,
"__v": 0
},
"isInitial": false
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

<h2>DailyEmail</h2>


<div class='evidenceType'>
<strong>Safety alerts</strong>

<div class='item'>
Wonder Drug
<br>
ACP Journal Club
<br>
Anaesthesia and pain | Complementary and alternative therapies
<br>
testing
<br>
<a href='https://www.medicinesresources.nhs.uk/testing-789'>SPS Comment</a>
</div>
</div>

28 changes: 28 additions & 0 deletions lambda/MAS.Tests/IntegrationTests/DailyEmailTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,33 @@ public async void EmailBodyHtmlMatchesApprovedForSingleItem()

bodyHtml.ShouldMatchApproved();
}

[Fact]
public async void EmailBodyHtmlMatchesApprovedForSingleItemWithSpecificDate()
{
// Arrange
var fakeMailService = new Mock<IMailService>();

string bodyHtml = string.Empty;
fakeMailService.Setup(s => s.CreateAndSendDailyAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>()))
.Callback<string, string, string>((subject, previewText, body) => bodyHtml = body)
.ReturnsAsync("1234");

var client = WithImplementation(fakeMailService.Object).CreateClient();

AppSettings.CMSConfig.DailyItemsPath = "/daily-items-{0}.json";

// Act
var response = await client.PutAsync("/api/mail/daily?date=01-01-2020", null);

// Assert
response.StatusCode.ShouldBe(System.Net.HttpStatusCode.OK);

var responseText = await response.Content.ReadAsStringAsync();
responseText.ShouldBe("1234");

bodyHtml.ShouldMatchApproved();
}

}
}
5 changes: 5 additions & 0 deletions lambda/MAS.Tests/MAS.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,9 @@
<ItemGroup>
<ProjectReference Include="..\MAS\MAS.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="Feeds\daily-items-2020-01-01.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion lambda/MAS/Controllers/MailController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public MailController(IMailService mailService, IContentService contentService,
_logger = logger;
}

//PUT api/mail/daily
//PUT api/mail/daily?date=01-01-2020
[HttpPut("daily")]
public async Task<IActionResult> PutMailAsync(DateTime? date = null)
{
Expand Down
160 changes: 141 additions & 19 deletions lambda/MAS/Views/DailyEmail.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,154 @@
//Layout = "~/Views/Shared/_EmailLayout.cshtml";
var groupedItems = Model.GroupBy(x => x.EvidenceType.Title).ToList();
var specialitiesList = Model.SelectMany(x => x.Specialities).Select(x => x.Title).ToList();
var specialitiesAsString = String.Join(',', specs);
}

<h2>DailyEmail</h2>

<table class="row article-border article-mec">
<tbody>
<tr>
<th class="small-12 large-12 columns first last">
<table>
<tbody>
<tr>
<th>
<p>
*|INTERESTED:Daily specialities of interest:@specialitiesAsString|*
Articles that match your chosen specialities today
*|ELSE|*
No articles match your chosen specialities today
*|END:INTERESTED|*
- <a href="#abc">Edit your subscription</a>
</p>
</th>
<th class="expander"></th>
</tr>
</tbody>
</table>
</th>
</tr>
</tbody>
</table>


@foreach (var group in groupedItems)
{
var evidenceType = group.Key;

@:*|INTERESTED:Daily specialities of interest:specialitiesAsString|*
<table class="spacer-heading">
<tbody>
<tr>
<td height="16px" style="font-size:16px;line-height:16px;">
<h3 class="article-heading">evidenceType</h3>
</td>
</tr>
</tbody>
</table>

@foreach (var item in group)
{
@:*|INTERESTED:Daily specialities of interest:specialitiesAsString|*
<table class="row article-border">
<tbody>
<tr>
<th class="small-12 large-12 columns first last">
<table>
<tbody>
<tr>
<th>
<h4 class="h4 article-title"><a class="article-link" href="#">@item.Title</a></h4>
<p class="article-description">@item.ShortSummary</p>
<p class="article-description"><a class="article-link-subtle standard-link" href="https://www.medicinesresources.nhs.uk/@item.Slug">Read SPS commentary</a></p>
<p class="article-tags">
<span class="source-tag">@item.Source.Title</span>
@foreach (var spec in item.Specialities)
{
<span class="specialism-tag">@spec.Title</span>
}
</p>
</th>
<th class="expander"></th>
</tr>
</tbody>
</table>
</th>
</tr>
</tbody>
</table>
@:*|END:INTERESTED|*
}
@:*|END:INTERESTED|*
}

*|INTERESTED:Send me everything from the Medicines Awareness Daily service:Send me everything|*
<table class="row article-border article-mec">
<tbody>
<tr>
<th class="small-12 large-12 columns first last">
<table>
<tbody>
<tr>
<th>
<p>
All articles from Medicines awareness services: Daily edition
</p>
</th>
<th class="expander"></th>
</tr>
</tbody>
</table>
</th>
</tr>
</tbody>
</table>

@foreach (var group in groupedItems)
{
var evidenceType = group.Key;

<div class='evidenceType'>
<strong>@evidenceType</strong>

@foreach (var item in group)
{
<div class='item'>
@item.Title
<br>
@item.Source.Title
<br>
@String.Join(" | ", item.Specialities.Select(x => x.Title))
<br>
@item.ShortSummary
<br>
<a href='https://www.medicinesresources.nhs.uk/@item.Slug'>SPS Comment</a>
</div>
}
</div>
<table class="spacer-heading">
<tbody>
<tr>
<td height="16px" style="font-size:16px;line-height:16px;">
<h3 class="article-heading">evidenceType</h3>
</td>
</tr>
</tbody>
</table>

@foreach (var item in group)
{
<table class="row article-border">
<tbody>
<tr>
<th class="small-12 large-12 columns first last">
<table>
<tbody>
<tr>
<th>
<h4 class="h4 article-title"><a class="article-link" href="#">@item.Title</a></h4>
<p class="article-description">@item.ShortSummary</p>
<p class="article-description"><a class="article-link-subtle standard-link" href="https://www.medicinesresources.nhs.uk/@item.Slug">Read SPS commentary</a></p>
<p class="article-tags">
<span class="source-tag">@item.Source.Title</span>
@foreach (var spec in item.Specialities)
{
<span class="specialism-tag">@spec.Title</span>
}
</p>
</th>
<th class="expander"></th>
</tr>
</tbody>
</table>
</th>
</tr>
</tbody>
</table>
}
}
*|END:INTERESTED|*

31 changes: 4 additions & 27 deletions mailchimp-templates/daily.html
Original file line number Diff line number Diff line change
Expand Up @@ -2389,6 +2389,9 @@
.footer-link{
color:#393939;
}
.standard-link{
color:#0000CD;
}
</style></head>
<body>
<!-- -->
Expand Down Expand Up @@ -2491,33 +2494,7 @@ <h2 class="emailsubheader">The very latest current awareness and evidence-based
</tr>
</tbody>
</table>
<p class="text-center footer-text">Share this email<br>
</p>
<center>
<table align="center" class="menu float-center">
<tr>
<td>
<table>
<tr>
<th class="menu-item float-center">
<a href="undefined"><img src="https://nice-digital.github.io/NICE.Design/MAS/img/twitter-logo.png" alt=""></a>
</th>
<th class="menu-item float-center">
<a href="undefined"><img src="https://nice-digital.github.io/NICE.Design/MAS/img/linkedin-logo.png" alt=""></a>
</th>
<th class="menu-item float-center">
<a href="undefined"><img src="https://nice-digital.github.io/NICE.Design/MAS/img/facebook-logo.png" alt=""></a>
</th>
<th class="menu-item float-center">
<a href="undefined"><img src="https://nice-digital.github.io/NICE.Design/MAS/img/Email-logo.png" alt=""></a>
</th>
</tr>
</table>
</td>
</tr>
</table>
</center>
<p class="text-center footer-text">Copyright 2019 © National Institute for Health Care Excellence. All rights reserved.<br>Our mailing address is: Level 1A, City Tower, Piccadilly Plaza, Manchester, M1 4BT <br>Add us to your address book<br><a href="#" class="footer-link">Update your preferences</a> or <a href="#" class="footer-link">unsubscribe from list</a>
<p class="text-center footer-text">Copyright 2020 © National Institute for Health Care Excellence. All rights reserved.<br>Our mailing address is: Level 1A, City Tower, Piccadilly Plaza, Manchester, M1 4BT <br>Add us to your address book<br><a href="#" class="footer-link">Update your preferences</a> or <a href="#" class="footer-link">unsubscribe from list</a>
</p>
</th>
<th class="expander"></th>
Expand Down

2 comments on commit e18952a

@NICE-TeamCity
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TeamCity MAS / MAS Build 1.1.0.576 outcome was FAILURE
Summary: Artifacts size 179.9 KB is 95% different from 3.6 MB in build #1.1.0.557-r893BC73; exit code 1 (Step: Set build number (Command Line)) (new) Build time: 00:00:12

@NICE-TeamCity
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TeamCity MAS / MAS Build 1.1.0.577-MAS-129_121__112_Dai outcome was FAILURE
Summary: Tests failed: 1 (1 new), passed: 8; artifacts size 187.2 KB is 95% different from 3.6 MB in build #1.1.0.557-r893BC73 Build time: 00:00:42

Failed tests

api/items.test.js: items should return the found item as json with whitelist of fields: <no details avaliable>

Please sign in to comment.