Skip to content

Commit

Permalink
VIH-10350 - Decommission obsolete feature flags (#159)
Browse files Browse the repository at this point in the history
* removed feature toggle service

* Update values.dev.template.yaml

* removed launchdarkly package

* Update ParticipantEmailNotificationsController.cs

* test removed

* Update ParticipantEmailNotificationsController.cs

* reinstated feature toggle service

* Update values.dev.template.yaml
  • Loading branch information
marcogagliardi authored Sep 12, 2024
1 parent 9b24f5d commit aab67eb
Show file tree
Hide file tree
Showing 15 changed files with 27 additions and 414 deletions.
12 changes: 0 additions & 12 deletions NotificationApi/NotificationApi.Common/Util/FeatureToggles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ namespace NotificationApi.Common.Util
{
public interface IFeatureToggles
{
bool UsePostMay2023Template();
}

public class FeatureToggles : IFeatureToggles
{
private readonly ILdClient _ldClient;
private readonly Context _context;
private const string LdUser = "vh-notification-api";
private const string NewNotifyTemplatesToggleKey = "notify-post-may-2023-templates";

public FeatureToggles(string sdkKey, string environmentName)
{
Expand All @@ -25,15 +23,5 @@ public FeatureToggles(string sdkKey, string environmentName)
_context = Context.Builder(LdUser).Name(environmentName).Build();
_ldClient = new LdClient(config);
}

public bool UsePostMay2023Template()
{
if (!_ldClient.Initialized)
{
throw new InvalidOperationException("LaunchDarkly client not initialized");
}

return _ldClient.BoolVariation(NewNotifyTemplatesToggleKey, _context);
}
}
}
2 changes: 1 addition & 1 deletion NotificationApi/NotificationApi.Common/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -706,4 +706,4 @@
}
}
}
}
}
8 changes: 8 additions & 0 deletions NotificationApi/NotificationApi.Contract/packages.lock.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
{
"version": 1,
"dependencies": {
".NETStandard,Version=v2.1": {
"SonarAnalyzer.CSharp": {
"type": "Direct",
"requested": "[9.24.0.89429, )",
"resolved": "9.24.0.89429",
"contentHash": "Ozk4LVpLNHhd+mmYKiG/WYtUUBZFknpkRy5JwTq4YfmT2wPA16vev5s/42urrN27ZV+01Kb5aYKJt3EI+5jPdw=="
}
},
"net8.0": {
"SonarAnalyzer.CSharp": {
"type": "Direct",
Expand Down
2 changes: 1 addition & 1 deletion NotificationApi/NotificationApi.DAL/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -1408,4 +1408,4 @@
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
using NotificationApi.Common.Util;
using Testing.Common.Stubs;

namespace NotificationApi.IntegrationTests.Api.ParticipantNotifications
{
public class SendParticipantMultiDayHearingConfirmationForExistingUserEmailTests : ApiTest
{
private AsyncNotificationClientStub _notifyStub;
private FeatureTogglesStub _featureToggleStub;

[SetUp]
public void Setup()
{
var scope = Application.Services.GetRequiredService<IServiceScopeFactory>().CreateScope();
_notifyStub = scope.ServiceProvider.GetRequiredService<IAsyncNotificationClient>() as AsyncNotificationClientStub;
_notifyStub!.SentEmails.Clear();
_featureToggleStub = Application.Services.GetService(typeof(IFeatureToggles)) as FeatureTogglesStub;
_featureToggleStub!.UseNew2023Templates = false;
}


Expand Down Expand Up @@ -91,43 +86,6 @@ public async Task should_send_a_multi_day_confirmation_email_for_a_judiciary_jud
).Should().BeTrue();
}

[Test]
public async Task should_send_a_multi_day_confirmation_email_for_a_non_judiciary_judge()
{
// arrange
var request = new ExistingUserMultiDayHearingConfirmationRequest
{
RoleName = RoleNames.Judge,
Name = $"{Faker.Name.FullName()}",
DisplayName = "Judge Fudge",
CaseNumber = $"{Faker.RandomNumber.Next()}",
CaseName = $"{Faker.RandomNumber.Next()}",
HearingId = Guid.NewGuid(),
ParticipantId = Guid.NewGuid(),
ContactEmail = $"{Guid.NewGuid()}@intautomation.com",
Username = $"{Guid.NewGuid()}@intautomation.com",
ScheduledDateTime = DateTime.UtcNow.AddDays(1),
TotalDays = 3
};

// act
using var client = Application.CreateClient();
var result = await client.PostAsync(
ApiUriFactory.ParticipantNotificationEndpoints.SendParticipantMultiDayHearingConfirmationForExistingUserEmail, RequestBody.Set(request));

// assert
result.IsSuccessStatusCode.Should().BeTrue(result.Content.ReadAsStringAsync().Result);

var notifications = await TestDataManager.GetNotifications(request.HearingId.Value,
request.ParticipantId.Value, Domain.Enums.NotificationType.HearingConfirmationJudgeMultiDay,
request.ContactEmail);
notifications.Count.Should().Be(1);
_notifyStub.SentEmails.Count.Should().Be(1);
_notifyStub.SentEmails.Exists(x => x.EmailAddress == request.ContactEmail
&& x.ExternalRefId == notifications[0].ExternalId
).Should().BeTrue();
}

[Test]
public async Task should_send_a_multi_day_confirmation_email_for_a_judiciary_judge()
{
Expand Down Expand Up @@ -166,48 +124,9 @@ public async Task should_send_a_multi_day_confirmation_email_for_a_judiciary_jud
}

[Test]
public async Task should_send_a_multi_day_confirmation_email_for_a_representative_feature_toggle_off()
{
// arrange
_featureToggleStub!.UseNew2023Templates = false;
var request = new ExistingUserMultiDayHearingConfirmationRequest
{
RoleName = RoleNames.Representative,
Name = $"{Faker.Name.FullName()}",
CaseNumber = $"{Faker.RandomNumber.Next()}",
CaseName = $"{Faker.RandomNumber.Next()}",
HearingId = Guid.NewGuid(),
ParticipantId = Guid.NewGuid(),
ContactEmail = $"{Guid.NewGuid()}@intautomation.com",
Username = $"{Guid.NewGuid()}@intautomation.com",
ScheduledDateTime = DateTime.UtcNow.AddDays(1),
Representee = $"{Faker.Name.FullName()}",
TotalDays = 3
};

// act
using var client = Application.CreateClient();
var result = await client.PostAsync(
ApiUriFactory.ParticipantNotificationEndpoints.SendParticipantMultiDayHearingConfirmationForExistingUserEmail, RequestBody.Set(request));

// assert
result.IsSuccessStatusCode.Should().BeTrue(result.Content.ReadAsStringAsync().Result);

var notifications = await TestDataManager.GetNotifications(request.HearingId.Value,
request.ParticipantId.Value, Domain.Enums.NotificationType.HearingConfirmationRepresentativeMultiDay,
request.ContactEmail);
notifications.Count.Should().Be(1);
_notifyStub.SentEmails.Count.Should().Be(1);
_notifyStub.SentEmails.Exists(x => x.EmailAddress == request.ContactEmail
&& x.ExternalRefId == notifications[0].ExternalId
).Should().BeTrue();
}

[Test]
public async Task should_send_a_multi_day_confirmation_email_for_a_representative_feature_toggle_on()
public async Task should_send_a_multi_day_confirmation_email_for_a_representative()
{
// arrange
_featureToggleStub!.UseNew2023Templates = true;
var request = new ExistingUserMultiDayHearingConfirmationRequest
{
RoleName = RoleNames.Representative,
Expand Down Expand Up @@ -242,46 +161,8 @@ public async Task should_send_a_multi_day_confirmation_email_for_a_representativ
}

[Test]
public async Task should_send_a_multi_day_confirmation_email_for_a_lip_feature_toggle_off()
{
// arrange
_featureToggleStub!.UseNew2023Templates = false;
var request = new ExistingUserMultiDayHearingConfirmationRequest
{
RoleName = RoleNames.Individual,
Name = $"{Faker.Name.FullName()}",
CaseNumber = $"{Faker.RandomNumber.Next()}",
CaseName = $"{Faker.RandomNumber.Next()}",
HearingId = Guid.NewGuid(),
ParticipantId = Guid.NewGuid(),
ContactEmail = $"{Guid.NewGuid()}@intautomation.com",
Username = $"{Guid.NewGuid()}@intautomation.com",
ScheduledDateTime = DateTime.UtcNow.AddDays(1),
TotalDays = 3
};

// act
using var client = Application.CreateClient();
var result = await client.PostAsync(
ApiUriFactory.ParticipantNotificationEndpoints.SendParticipantMultiDayHearingConfirmationForExistingUserEmail, RequestBody.Set(request));

// assert
result.IsSuccessStatusCode.Should().BeTrue(result.Content.ReadAsStringAsync().Result);

var notifications = await TestDataManager.GetNotifications(request.HearingId.Value, request.ParticipantId.Value,
Domain.Enums.NotificationType.HearingConfirmationLipMultiDay,
request.ContactEmail);
notifications.Count.Should().Be(1);
_notifyStub.SentEmails.Count.Should().Be(1);
_notifyStub.SentEmails.Exists(x => x.EmailAddress == request.ContactEmail
&& x.ExternalRefId == notifications[0].ExternalId
).Should().BeTrue();
}

[Test]
public async Task should_send_a_multi_day_confirmation_email_for_a_lip_feature_toggle_on()
public async Task should_send_a_multi_day_confirmation_email_for_a_lip()
{
_featureToggleStub!.UseNew2023Templates = true;
// arrange
var request = new ExistingUserMultiDayHearingConfirmationRequest
{
Expand Down
Loading

0 comments on commit aab67eb

Please sign in to comment.