From 933b3e969619b4a64adf2f1e0cc1565b216655f3 Mon Sep 17 00:00:00 2001 From: Thomas Rittson <31796059+eliykat@users.noreply.github.com> Date: Tue, 27 Aug 2024 08:48:14 +1000 Subject: [PATCH] Fix flaky OrganizationService tests (#4686) Subscription update tests were not fixing the current maxAutoscaleSeats value. Autodata could sometimes make it the same as the new value, so the update code wouldn't be triggered and the test would fail --- .../Services/OrganizationServiceTests.cs | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/test/Core.Test/AdminConsole/Services/OrganizationServiceTests.cs b/test/Core.Test/AdminConsole/Services/OrganizationServiceTests.cs index 61ae727f7c..48042f3773 100644 --- a/test/Core.Test/AdminConsole/Services/OrganizationServiceTests.cs +++ b/test/Core.Test/AdminConsole/Services/OrganizationServiceTests.cs @@ -1829,22 +1829,28 @@ OrganizationUserInvite invite, SutProvider sutProvider) [Theory] [PaidOrganizationCustomize(CheckedPlanType = PlanType.EnterpriseAnnually)] - [BitAutoData("Cannot set max seat autoscaling below seat count", 1, 0, 2)] - [BitAutoData("Cannot set max seat autoscaling below seat count", 4, -1, 6)] - public async Task Enterprise_UpdateSubscription_BadInputThrows(string expectedMessage, - int? maxAutoscaleSeats, int seatAdjustment, int? currentSeats, Organization organization, SutProvider sutProvider) - => await UpdateSubscription_BadInputThrows(expectedMessage, maxAutoscaleSeats, seatAdjustment, currentSeats, organization, sutProvider); + [BitAutoData("Cannot set max seat autoscaling below seat count", 1, 0, 2, 2)] + [BitAutoData("Cannot set max seat autoscaling below seat count", 4, -1, 6, 6)] + public async Task Enterprise_UpdateMaxSeatAutoscaling_BadInputThrows(string expectedMessage, + int? maxAutoscaleSeats, int seatAdjustment, int? currentSeats, int? currentMaxAutoscaleSeats, + Organization organization, SutProvider sutProvider) + => await UpdateSubscription_BadInputThrows(expectedMessage, maxAutoscaleSeats, seatAdjustment, currentSeats, + currentMaxAutoscaleSeats, organization, sutProvider); [Theory] [FreeOrganizationCustomize] - [BitAutoData("Your plan does not allow seat autoscaling", 10, 0, null)] - public async Task Free_UpdateSubscription_BadInputThrows(string expectedMessage, - int? maxAutoscaleSeats, int seatAdjustment, int? currentSeats, Organization organization, SutProvider sutProvider) - => await UpdateSubscription_BadInputThrows(expectedMessage, maxAutoscaleSeats, seatAdjustment, currentSeats, organization, sutProvider); + [BitAutoData("Your plan does not allow seat autoscaling", 10, 0, null, null)] + public async Task Free_UpdateMaxSeatAutoscaling_BadInputThrows(string expectedMessage, + int? maxAutoscaleSeats, int seatAdjustment, int? currentSeats, int? currentMaxAutoscaleSeats, + Organization organization, SutProvider sutProvider) + => await UpdateSubscription_BadInputThrows(expectedMessage, maxAutoscaleSeats, seatAdjustment, currentSeats, + currentMaxAutoscaleSeats, organization, sutProvider); private async Task UpdateSubscription_BadInputThrows(string expectedMessage, - int? maxAutoscaleSeats, int seatAdjustment, int? currentSeats, Organization organization, SutProvider sutProvider) + int? maxAutoscaleSeats, int seatAdjustment, int? currentSeats, int? currentMaxAutoscaleSeats, + Organization organization, SutProvider sutProvider) { organization.Seats = currentSeats; + organization.MaxAutoscaleSeats = currentMaxAutoscaleSeats; sutProvider.GetDependency().GetByIdAsync(organization.Id).Returns(organization); var exception = await Assert.ThrowsAsync(() => sutProvider.Sut.UpdateSubscription(organization.Id,