Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backend/Testing/ApiTests/DeleteProjectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Comment thread
myieye marked this conversation as resolved.
Resolved
response = await HttpClient.DeleteAsync($"api/project/{projectId}");

// Assert
Expand Down Expand Up @@ -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}}" }) {
Expand Down
11 changes: 11 additions & 0 deletions backend/Testing/FwHeadless/FwHeadlessTestHelpers.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Net;
using System.Net.Http.Json;
using LexCore.Sync;
using Testing.Fixtures;
Expand All @@ -23,6 +24,16 @@ public static async Task TriggerSync(HttpClient httpClient, Guid projectId)
result.ShouldBeSuccessful();
}

/// <summary>
/// Like <see cref="TriggerSync"/>, but also accepts the 429 FwHeadless returns when a sync is already running.
/// </summary>
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);
Expand Down
Loading