From 893cc8338494c823029648cd111331472a632cbf Mon Sep 17 00:00:00 2001 From: Liam Crossley Date: Wed, 11 Dec 2024 16:00:32 +0000 Subject: [PATCH 1/5] Added "See details" to saved search email for NHS vacancies --- .../Models/SavedSearchApiRequest.cs | 3 + .../EmailTemplateBuilderTests.cs | 58 ++++++++++++++++++- .../PostSendSavedSearchNotificationCommand.cs | 2 + .../GetSavedSearchesQueryResult.cs | 2 + .../EmailTemplates/EmailTemplateBuilder.cs | 4 +- .../Responses/GetVacanciesResponse.cs | 3 + 6 files changed, 69 insertions(+), 3 deletions(-) diff --git a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.Api/Models/SavedSearchApiRequest.cs b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.Api/Models/SavedSearchApiRequest.cs index 910d25a324..dfcf63dc17 100644 --- a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.Api/Models/SavedSearchApiRequest.cs +++ b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.Api/Models/SavedSearchApiRequest.cs @@ -33,6 +33,8 @@ public class Vacancy public string? TrainingCourse { get; set; } public double? Distance { get; set; } + + public string? VacancySource { get; set; } } public class Address { @@ -105,6 +107,7 @@ public PostSendSavedSearchNotificationCommand MapToCommand(SavedSearchApiRequest TrainingCourse = vacancy.TrainingCourse, VacancyReference = vacancy.VacancyReference, Wage = vacancy.Wage, + VacancySource = vacancy.VacancySource, Address = new PostSendSavedSearchNotificationCommand.Address { AddressLine1 = vacancy.Address.AddressLine1, diff --git a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.UnitTests/Domain/EmailTemplates/EmailTemplateBuilderTests.cs b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.UnitTests/Domain/EmailTemplates/EmailTemplateBuilderTests.cs index 296af0a517..c1d0a01a2d 100644 --- a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.UnitTests/Domain/EmailTemplates/EmailTemplateBuilderTests.cs +++ b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.UnitTests/Domain/EmailTemplates/EmailTemplateBuilderTests.cs @@ -1,4 +1,5 @@ using FluentAssertions; +using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers; using NUnit.Framework; using SFA.DAS.FindApprenticeshipJobs.Application.Commands.SavedSearch.SendNotification; using SFA.DAS.FindApprenticeshipJobs.Domain.EmailTemplates; @@ -164,7 +165,8 @@ public void GetSavedSearchVacanciesSnippet_Should_Return_Correct_Snippet() Distance = 10, TrainingCourse = "Software Engineering", Wage = "�30,000", - ClosingDate = "2022-12-31" + ClosingDate = "2022-12-31", + VacancySource = "FAA" } }; @@ -240,7 +242,59 @@ ABC Company // Assert snippet.Should().Be(expectedSnippet); } - + + [Test] + public void GetSavedSearchVacanciesSnippet_Should_Return_Correct_Snippet_With_Training_Course_Set_To_See_Details_On_Nhs_When_Vacancy_Source_Is_Nhs() + { + // Arrange + var environmentHelper = new EmailEnvironmentHelper("test") + { + VacancyDetailsUrl = "https://example.com/vacancy/{vacancy-reference}" + }; + + var vacancies = new List + { + new() + { + Title = "Mental Health Nurse", + VacancyReference = "12345", + EmployerName = "NHS Jobs", + Address = new PostSendSavedSearchNotificationCommand.Address + { + AddressLine1 = "123 Main St", + Postcode = "12345" + }, + Distance = 10, + TrainingCourse = "", + Wage = "�30,000", + ClosingDate = "2022-12-31", + VacancySource = "NHS" + } + }; + + const string expectedSnippet = """ + + #[Mental Health Nurse](https://example.com/vacancy/12345) + NHS Jobs + 123 Main St, 12345 + + * Distance: 10 miles + * Training course: See more details on NHS Jobs + * Annual wage: �30,000 + + 2022-12-31 + + --- + + """; + + // Act + var snippet = EmailTemplateBuilder.GetSavedSearchVacanciesSnippet(environmentHelper, vacancies, true); + + // Assert + snippet.Should().Be(expectedSnippet); + } + private static object[] _titleTestCases = [ new object?[] { "Foo", new Dictionary {{1, "Route 1"},{2,"Route 2"}}, new Dictionary {{1, "Level 1"}, {2, "Level 2"}}, null, true, "Foo in all of England" }, diff --git a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Commands/SavedSearch/SendNotification/PostSendSavedSearchNotificationCommand.cs b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Commands/SavedSearch/SendNotification/PostSendSavedSearchNotificationCommand.cs index d7f8c4b8c6..51fa8ed6a9 100644 --- a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Commands/SavedSearch/SendNotification/PostSendSavedSearchNotificationCommand.cs +++ b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Commands/SavedSearch/SendNotification/PostSendSavedSearchNotificationCommand.cs @@ -46,6 +46,8 @@ public class Vacancy public string? TrainingCourse { get; set; } public double? Distance { get; set; } + + public string? VacancySource { get; set; } } public class Address diff --git a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Queries/SavedSearch/GetSavedSearches/GetSavedSearchesQueryResult.cs b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Queries/SavedSearch/GetSavedSearches/GetSavedSearchesQueryResult.cs index 9cb749e1aa..f53b264f79 100644 --- a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Queries/SavedSearch/GetSavedSearches/GetSavedSearchesQueryResult.cs +++ b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Queries/SavedSearch/GetSavedSearches/GetSavedSearchesQueryResult.cs @@ -33,6 +33,7 @@ public class ApprenticeshipVacancy public string? ClosingDate { get; set; } public string? TrainingCourse { get; set; } public decimal? Distance { get; set; } + public string? VacancySource { get; set; } public static implicit operator ApprenticeshipVacancy(GetVacanciesListItem source) { @@ -47,6 +48,7 @@ public static implicit operator ApprenticeshipVacancy(GetVacanciesListItem sourc Address = source.VacancyAddress, TrainingCourse = $"{source.CourseTitle} (level {source.CourseLevel})", Distance = source.Distance.HasValue ? Math.Round(source.Distance.Value, 1) : null, + VacancySource = source.VacancySource, }; } } diff --git a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Domain/EmailTemplates/EmailTemplateBuilder.cs b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Domain/EmailTemplates/EmailTemplateBuilder.cs index 49e344f32e..cb43a9aabb 100644 --- a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Domain/EmailTemplates/EmailTemplateBuilder.cs +++ b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Domain/EmailTemplates/EmailTemplateBuilder.cs @@ -81,7 +81,9 @@ public static string GetSavedSearchVacanciesSnippet( sb.AppendLine($"* Distance: {vacancy.Distance} miles"); } - sb.AppendLine($"* Training course: {vacancy.TrainingCourse}"); + var trainingCourseText = (vacancy.VacancySource == "NHS") ? "See more details on NHS Jobs" : vacancy.TrainingCourse; + + sb.AppendLine($"* Training course: {trainingCourseText}"); sb.AppendLine($"* Annual wage: {vacancy.Wage}"); sb.AppendLine(); diff --git a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/InnerApi/Responses/GetVacanciesResponse.cs b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/InnerApi/Responses/GetVacanciesResponse.cs index 12b94e6bd7..5824226e72 100644 --- a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/InnerApi/Responses/GetVacanciesResponse.cs +++ b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/InnerApi/Responses/GetVacanciesResponse.cs @@ -51,6 +51,9 @@ public class GetVacanciesListItem [JsonPropertyName("standardLevel")] public int CourseLevel { get; set; } + + [JsonPropertyName("vacancySource")] + public string VacancySource { get; set; } } public class VacancyAddress From 0a8a1ed8081a92d0c9b959894d2bd9f17b861634 Mon Sep 17 00:00:00 2001 From: Liam Crossley Date: Thu, 12 Dec 2024 12:14:20 +0000 Subject: [PATCH 2/5] Amended wage text displayed in email search alerts --- .../Models/SavedSearchApiRequest.cs | 3 - .../EmailTemplateBuilderTests.cs | 76 +++++++++++++++++-- .../PostSendSavedSearchNotificationCommand.cs | 4 + .../GetSavedSearchesQueryResult.cs | 4 + .../EmailTemplates/EmailTemplateBuilder.cs | 8 +- .../Responses/GetVacanciesResponse.cs | 6 ++ 6 files changed, 90 insertions(+), 11 deletions(-) diff --git a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.Api/Models/SavedSearchApiRequest.cs b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.Api/Models/SavedSearchApiRequest.cs index dfcf63dc17..910d25a324 100644 --- a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.Api/Models/SavedSearchApiRequest.cs +++ b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.Api/Models/SavedSearchApiRequest.cs @@ -33,8 +33,6 @@ public class Vacancy public string? TrainingCourse { get; set; } public double? Distance { get; set; } - - public string? VacancySource { get; set; } } public class Address { @@ -107,7 +105,6 @@ public PostSendSavedSearchNotificationCommand MapToCommand(SavedSearchApiRequest TrainingCourse = vacancy.TrainingCourse, VacancyReference = vacancy.VacancyReference, Wage = vacancy.Wage, - VacancySource = vacancy.VacancySource, Address = new PostSendSavedSearchNotificationCommand.Address { AddressLine1 = vacancy.Address.AddressLine1, diff --git a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.UnitTests/Domain/EmailTemplates/EmailTemplateBuilderTests.cs b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.UnitTests/Domain/EmailTemplates/EmailTemplateBuilderTests.cs index c1d0a01a2d..1a14d1e8a5 100644 --- a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.UnitTests/Domain/EmailTemplates/EmailTemplateBuilderTests.cs +++ b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.UnitTests/Domain/EmailTemplates/EmailTemplateBuilderTests.cs @@ -178,7 +178,7 @@ ABC Company * Distance: 10 miles * Training course: Software Engineering - * Annual wage: �30,000 + * Wage: �30,000 a year 2022-12-31 @@ -228,7 +228,7 @@ ABC Company 123 Main St, 12345 * Training course: Software Engineering - * Annual wage: �30,000 + * Wage: �30,000 a year 2022-12-31 @@ -243,8 +243,68 @@ ABC Company snippet.Should().Be(expectedSnippet); } - [Test] - public void GetSavedSearchVacanciesSnippet_Should_Return_Correct_Snippet_With_Training_Course_Set_To_See_Details_On_Nhs_When_Vacancy_Source_Is_Nhs() + [TestCase("Competitive", "", "Competitive")] + [TestCase("", "month", "�30,000 a year")] + [TestCase("", "hour", "�30,000 a year")] + public void GetSavedSearchVacanciesSnippet_Should_Return_Snippet_With_Correct_Wage_Text_For_Faa_VacancySource_And_Different_WageTypes( + string wagetype, string wageUnit, string expectedWageText) + { + // Arrange + var environmentHelper = new EmailEnvironmentHelper("test") + { + VacancyDetailsUrl = "https://example.com/vacancy/{vacancy-reference}" + }; + + var vacancies = new List + { + new() + { + Title = "Software Developer", + VacancyReference = "12345", + EmployerName = "ABC Company", + Address = new PostSendSavedSearchNotificationCommand.Address + { + AddressLine1 = "123 Main St", + Postcode = "12345" + }, + Distance = 10, + TrainingCourse = "Software Engineering", + Wage = "�30,000", + ClosingDate = "2022-12-31", + VacancySource = "FAA", + WageUnit = wageUnit, + WageType = wagetype + } + }; + + string expectedSnippet = $""" + + #[Software Developer](https://example.com/vacancy/12345) + ABC Company + 123 Main St, 12345 + + * Distance: 10 miles + * Training course: Software Engineering + * Wage: {expectedWageText} + + 2022-12-31 + + --- + + """; + + // Act + var snippet = EmailTemplateBuilder.GetSavedSearchVacanciesSnippet(environmentHelper, vacancies, true); + + // Assert + snippet.Should().Be(expectedSnippet); + } + + [TestCase("Competitive", "", "Depends on experience")] + [TestCase("", "month", "�30,000 a month")] + [TestCase("", "hour", "�30,000 an hour")] + public void GetSavedSearchVacanciesSnippet_Should_Return_Snippet_With_Correct_Wage_Text_For_Nhs_VacancySource_And_Different_WageTypes( + string wagetype, string wageUnit, string expectedWageText) { // Arrange var environmentHelper = new EmailEnvironmentHelper("test") @@ -268,11 +328,13 @@ public void GetSavedSearchVacanciesSnippet_Should_Return_Correct_Snippet_With_Tr TrainingCourse = "", Wage = "�30,000", ClosingDate = "2022-12-31", - VacancySource = "NHS" + VacancySource = "NHS", + WageUnit = wageUnit, + WageType = wagetype } }; - const string expectedSnippet = """ + string expectedSnippet = $""" #[Mental Health Nurse](https://example.com/vacancy/12345) NHS Jobs @@ -280,7 +342,7 @@ NHS Jobs * Distance: 10 miles * Training course: See more details on NHS Jobs - * Annual wage: �30,000 + * Wage: {expectedWageText} 2022-12-31 diff --git a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Commands/SavedSearch/SendNotification/PostSendSavedSearchNotificationCommand.cs b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Commands/SavedSearch/SendNotification/PostSendSavedSearchNotificationCommand.cs index 51fa8ed6a9..ceab7b0991 100644 --- a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Commands/SavedSearch/SendNotification/PostSendSavedSearchNotificationCommand.cs +++ b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Commands/SavedSearch/SendNotification/PostSendSavedSearchNotificationCommand.cs @@ -41,6 +41,10 @@ public class Vacancy public string? Wage { get; set; } + public string? WageUnit { get; set; } + + public string? WageType { get; set; } + public string? ClosingDate { get; set; } public string? TrainingCourse { get; set; } diff --git a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Queries/SavedSearch/GetSavedSearches/GetSavedSearchesQueryResult.cs b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Queries/SavedSearch/GetSavedSearches/GetSavedSearchesQueryResult.cs index f53b264f79..d6affef43d 100644 --- a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Queries/SavedSearch/GetSavedSearches/GetSavedSearchesQueryResult.cs +++ b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Queries/SavedSearch/GetSavedSearches/GetSavedSearchesQueryResult.cs @@ -30,6 +30,8 @@ public class ApprenticeshipVacancy public string? EmployerName { get; set; } public Address Address { get; set; } = null!; public string? Wage { get; set; } + public string? WageUnit { get; set; } + public string? WageType { get; set; } public string? ClosingDate { get; set; } public string? TrainingCourse { get; set; } public decimal? Distance { get; set; } @@ -45,6 +47,8 @@ public static implicit operator ApprenticeshipVacancy(GetVacanciesListItem sourc Title = source.Title, EmployerName = source.EmployerName, Wage = source.WageText, + WageUnit = source.WageUnit, + WageType = source.WageType, Address = source.VacancyAddress, TrainingCourse = $"{source.CourseTitle} (level {source.CourseLevel})", Distance = source.Distance.HasValue ? Math.Round(source.Distance.Value, 1) : null, diff --git a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Domain/EmailTemplates/EmailTemplateBuilder.cs b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Domain/EmailTemplates/EmailTemplateBuilder.cs index cb43a9aabb..48098b6514 100644 --- a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Domain/EmailTemplates/EmailTemplateBuilder.cs +++ b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Domain/EmailTemplates/EmailTemplateBuilder.cs @@ -83,8 +83,14 @@ public static string GetSavedSearchVacanciesSnippet( var trainingCourseText = (vacancy.VacancySource == "NHS") ? "See more details on NHS Jobs" : vacancy.TrainingCourse; + var wageText = + (vacancy.WageType == "Competitive") ? + ((vacancy.VacancySource == "NHS") ? "Depends on experience" : vacancy.WageType) : + (vacancy.VacancySource == "NHS") ? + vacancy.Wage + ((vacancy.WageUnit == "hour") ? " an " : " a ") + vacancy.WageUnit : vacancy.Wage + " a year"; + sb.AppendLine($"* Training course: {trainingCourseText}"); - sb.AppendLine($"* Annual wage: {vacancy.Wage}"); + sb.AppendLine($"* Wage: {wageText}"); sb.AppendLine(); sb.AppendLine($"{vacancy.ClosingDate}"); diff --git a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/InnerApi/Responses/GetVacanciesResponse.cs b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/InnerApi/Responses/GetVacanciesResponse.cs index 5824226e72..14424b068f 100644 --- a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/InnerApi/Responses/GetVacanciesResponse.cs +++ b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/InnerApi/Responses/GetVacanciesResponse.cs @@ -37,6 +37,12 @@ public class GetVacanciesListItem [JsonPropertyName("wageText")] public string WageText { get; set; } + [JsonPropertyName("wageUnit")] + public string WageUnit { get; set; } + + [JsonPropertyName("wageType")] + public string WageType { get; set; } + [JsonPropertyName("address")] public VacancyAddress VacancyAddress { get; set; } From f91c59c46cd551d11f3654c3802e995a4756b55d Mon Sep 17 00:00:00 2001 From: Liam Crossley Date: Fri, 13 Dec 2024 15:00:40 +0000 Subject: [PATCH 3/5] Amended URL for NHS vacancies in search alerts --- .../EmailTemplateBuilderTests.cs | 22 ++++++++-------- .../EmailTemplates/EmailEnvironmentHelper.cs | 2 ++ .../EmailTemplates/EmailTemplateBuilder.cs | 26 ++++++++++++------- 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.UnitTests/Domain/EmailTemplates/EmailTemplateBuilderTests.cs b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.UnitTests/Domain/EmailTemplates/EmailTemplateBuilderTests.cs index 1a14d1e8a5..65ce7cf431 100644 --- a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.UnitTests/Domain/EmailTemplates/EmailTemplateBuilderTests.cs +++ b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.UnitTests/Domain/EmailTemplates/EmailTemplateBuilderTests.cs @@ -164,7 +164,7 @@ public void GetSavedSearchVacanciesSnippet_Should_Return_Correct_Snippet() }, Distance = 10, TrainingCourse = "Software Engineering", - Wage = "�30,000", + Wage = "£30,000", ClosingDate = "2022-12-31", VacancySource = "FAA" } @@ -178,7 +178,7 @@ ABC Company * Distance: 10 miles * Training course: Software Engineering - * Wage: �30,000 a year + * Wage: £30,000 a year 2022-12-31 @@ -216,7 +216,7 @@ public void GetSavedSearchVacanciesSnippet_Should_Return_Correct_Snippet_With_No }, Distance = 10, TrainingCourse = "Software Engineering", - Wage = "�30,000", + Wage = "£30,000", ClosingDate = "2022-12-31" } }; @@ -228,7 +228,7 @@ ABC Company 123 Main St, 12345 * Training course: Software Engineering - * Wage: �30,000 a year + * Wage: £30,000 a year 2022-12-31 @@ -244,8 +244,8 @@ ABC Company } [TestCase("Competitive", "", "Competitive")] - [TestCase("", "month", "�30,000 a year")] - [TestCase("", "hour", "�30,000 a year")] + [TestCase("", "month", "£30,000 a year")] + [TestCase("", "hour", "£30,000 a year")] public void GetSavedSearchVacanciesSnippet_Should_Return_Snippet_With_Correct_Wage_Text_For_Faa_VacancySource_And_Different_WageTypes( string wagetype, string wageUnit, string expectedWageText) { @@ -269,7 +269,7 @@ public void GetSavedSearchVacanciesSnippet_Should_Return_Snippet_With_Correct_Wa }, Distance = 10, TrainingCourse = "Software Engineering", - Wage = "�30,000", + Wage = "£30,000", ClosingDate = "2022-12-31", VacancySource = "FAA", WageUnit = wageUnit, @@ -301,15 +301,15 @@ ABC Company } [TestCase("Competitive", "", "Depends on experience")] - [TestCase("", "month", "�30,000 a month")] - [TestCase("", "hour", "�30,000 an hour")] + [TestCase("", "month", "£30,000 a month")] + [TestCase("", "hour", "£30,000 an hour")] public void GetSavedSearchVacanciesSnippet_Should_Return_Snippet_With_Correct_Wage_Text_For_Nhs_VacancySource_And_Different_WageTypes( string wagetype, string wageUnit, string expectedWageText) { // Arrange var environmentHelper = new EmailEnvironmentHelper("test") { - VacancyDetailsUrl = "https://example.com/vacancy/{vacancy-reference}" + VacancyDetailsUrl = "https://example.com/vacancy/nhs/{vacancy-reference}" }; var vacancies = new List @@ -326,7 +326,7 @@ public void GetSavedSearchVacanciesSnippet_Should_Return_Snippet_With_Correct_Wa }, Distance = 10, TrainingCourse = "", - Wage = "�30,000", + Wage = "£30,000", ClosingDate = "2022-12-31", VacancySource = "NHS", WageUnit = wageUnit, diff --git a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Domain/EmailTemplates/EmailEnvironmentHelper.cs b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Domain/EmailTemplates/EmailEnvironmentHelper.cs index dd5cb1b86d..383832a664 100644 --- a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Domain/EmailTemplates/EmailEnvironmentHelper.cs +++ b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Domain/EmailTemplates/EmailEnvironmentHelper.cs @@ -19,6 +19,8 @@ public class EmailEnvironmentHelper(string environmentName) public string VacancyDetailsUrl { get; set; } = $"{GetBaseUrl(environmentName)}apprenticeship/{{vacancy-reference}}"; + public string VacancyDetailsNhsUrl { get; set; } = + $"{GetBaseUrl(environmentName)}apprenticeship/nhs/{{vacancy-reference}}"; private static string GetBaseUrl(string environmentName) { diff --git a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Domain/EmailTemplates/EmailTemplateBuilder.cs b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Domain/EmailTemplates/EmailTemplateBuilder.cs index 48098b6514..b8a27725b0 100644 --- a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Domain/EmailTemplates/EmailTemplateBuilder.cs +++ b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Domain/EmailTemplates/EmailTemplateBuilder.cs @@ -66,8 +66,24 @@ public static string GetSavedSearchVacanciesSnippet( foreach (var vacancy in vacancies) { + string? trainingCourseText; + string? wageText; + sb.AppendLine(); - sb.AppendLine($"#[{vacancy.Title}]({environmentHelper.VacancyDetailsUrl.Replace("{vacancy-reference}", vacancy.VacancyReference)})"); + if (vacancy.VacancySource == "NHS") + { + sb.AppendLine($"#[{vacancy.Title}]({environmentHelper.VacancyDetailsNhsUrl.Replace("{vacancy-reference}", vacancy.VacancyReference)})"); + trainingCourseText = "See more details on NHS Jobs"; + wageText = (vacancy.WageType == "Competitive") ? + "Depends on experience" : + vacancy.Wage + ((vacancy.WageUnit == "hour") ? " an " : " a ") + vacancy.WageUnit; + } + else + { + sb.AppendLine($"#[{vacancy.Title}]({environmentHelper.VacancyDetailsUrl.Replace("{vacancy-reference}", vacancy.VacancyReference)})"); + trainingCourseText = vacancy.TrainingCourse; + wageText = (vacancy.WageType == "Competitive") ? vacancy.WageType : vacancy.Wage + " a year"; + } sb.AppendLine(vacancy.EmployerName); sb.AppendLine(!string.IsNullOrEmpty(vacancy.Address.AddressLine4) ? $"{vacancy.Address.AddressLine4}, {vacancy.Address.Postcode}" : !string.IsNullOrEmpty(vacancy.Address.AddressLine3) ? $"{vacancy.Address.AddressLine3}, {vacancy.Address.Postcode}" : @@ -80,14 +96,6 @@ public static string GetSavedSearchVacanciesSnippet( { sb.AppendLine($"* Distance: {vacancy.Distance} miles"); } - - var trainingCourseText = (vacancy.VacancySource == "NHS") ? "See more details on NHS Jobs" : vacancy.TrainingCourse; - - var wageText = - (vacancy.WageType == "Competitive") ? - ((vacancy.VacancySource == "NHS") ? "Depends on experience" : vacancy.WageType) : - (vacancy.VacancySource == "NHS") ? - vacancy.Wage + ((vacancy.WageUnit == "hour") ? " an " : " a ") + vacancy.WageUnit : vacancy.Wage + " a year"; sb.AppendLine($"* Training course: {trainingCourseText}"); sb.AppendLine($"* Wage: {wageText}"); From 5a49814ccbd3f1e036bfd85dcd0fbe6951ee51ce Mon Sep 17 00:00:00 2001 From: Liam Crossley Date: Fri, 13 Dec 2024 15:28:56 +0000 Subject: [PATCH 4/5] Corrected EmailTemplateBuilderTests --- .../Domain/EmailTemplates/EmailTemplateBuilderTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.UnitTests/Domain/EmailTemplates/EmailTemplateBuilderTests.cs b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.UnitTests/Domain/EmailTemplates/EmailTemplateBuilderTests.cs index 65ce7cf431..6b50a2ec2c 100644 --- a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.UnitTests/Domain/EmailTemplates/EmailTemplateBuilderTests.cs +++ b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.UnitTests/Domain/EmailTemplates/EmailTemplateBuilderTests.cs @@ -336,7 +336,7 @@ public void GetSavedSearchVacanciesSnippet_Should_Return_Snippet_With_Correct_Wa string expectedSnippet = $""" - #[Mental Health Nurse](https://example.com/vacancy/12345) + #[Mental Health Nurse](https://example.com/vacancy/nhs/12345) NHS Jobs 123 Main St, 12345 From a47b5588b0465a3716bef3184c524f77986064a2 Mon Sep 17 00:00:00 2001 From: Liam Crossley Date: Fri, 13 Dec 2024 15:39:12 +0000 Subject: [PATCH 5/5] Amended test arrangement --- .../Domain/EmailTemplates/EmailTemplateBuilderTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.UnitTests/Domain/EmailTemplates/EmailTemplateBuilderTests.cs b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.UnitTests/Domain/EmailTemplates/EmailTemplateBuilderTests.cs index 6b50a2ec2c..ac21a2fe51 100644 --- a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.UnitTests/Domain/EmailTemplates/EmailTemplateBuilderTests.cs +++ b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.UnitTests/Domain/EmailTemplates/EmailTemplateBuilderTests.cs @@ -309,7 +309,7 @@ public void GetSavedSearchVacanciesSnippet_Should_Return_Snippet_With_Correct_Wa // Arrange var environmentHelper = new EmailEnvironmentHelper("test") { - VacancyDetailsUrl = "https://example.com/vacancy/nhs/{vacancy-reference}" + VacancyDetailsNhsUrl = "https://example.com/vacancy/nhs/{vacancy-reference}" }; var vacancies = new List