diff --git a/backend/Testing/ApiTests/DeleteProjectTests.cs b/backend/Testing/ApiTests/DeleteProjectTests.cs index d429b9c242..ca8a5f086b 100644 --- a/backend/Testing/ApiTests/DeleteProjectTests.cs +++ b/backend/Testing/ApiTests/DeleteProjectTests.cs @@ -212,7 +212,7 @@ public async Task DeleteProject_DuringSyncInProgress_FwHeadlessReturnsConflict() // Act // wait a bit to ensure the sync is actually in progress await Task.Delay(3000); - await FwHeadlessTestHelpers.TriggerSync(HttpClient, projectId); + await FwHeadlessTestHelpers.EnsureSyncRunningOrQueued(HttpClient, projectId); response = await HttpClient.DeleteAsync($"api/project/{projectId}"); // Assert @@ -344,7 +344,7 @@ public async Task SoftDeleteProject_DuringSyncInProgress_ReturnsGqlError() // Act // wait a bit to ensure the sync is actually in progress await Task.Delay(3000); - await FwHeadlessTestHelpers.TriggerSync(HttpClient, projectId); + await FwHeadlessTestHelpers.EnsureSyncRunningOrQueued(HttpClient, projectId); response = await ExecuteGql($$""" mutation { softDeleteProject(input: { projectId: "{{projectId}}" }) { diff --git a/backend/Testing/FwHeadless/FwHeadlessTestHelpers.cs b/backend/Testing/FwHeadless/FwHeadlessTestHelpers.cs index 3d752fa5ee..6efdbfb3af 100644 --- a/backend/Testing/FwHeadless/FwHeadlessTestHelpers.cs +++ b/backend/Testing/FwHeadless/FwHeadlessTestHelpers.cs @@ -1,3 +1,4 @@ +using System.Net; using System.Net.Http.Json; using LexCore.Sync; using Testing.Fixtures; @@ -23,6 +24,16 @@ public static async Task TriggerSync(HttpClient httpClient, Guid projectId) result.ShouldBeSuccessful(); } + /// + /// Like , but also accepts the 429 FwHeadless returns when a sync is already running. + /// + public static async Task EnsureSyncRunningOrQueued(HttpClient httpClient, Guid projectId) + { + var result = await httpClient.PostAsync($"api/fw-lite/sync/trigger/{projectId}", null); + if (result.StatusCode == HttpStatusCode.TooManyRequests) return; + result.ShouldBeSuccessful(); + } + public static async Task CancelSync(HttpClient httpClient, Guid projectId) { var result = await httpClient.PostAsync($"api/fw-lite/sync/cancel/{projectId}", null);