From ee0653a9a84b34831749c1a872fbf09e533c1faa Mon Sep 17 00:00:00 2001 From: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> Date: Tue, 2 Dec 2025 16:26:37 +0000 Subject: [PATCH] fix tests --- src/Speckle.Sdk/Api/GraphQL/Inputs/IngestInputs.cs | 13 ++++++++++--- .../Api/GraphQL/Resources/SubscriptionResource.cs | 14 +++++++++++--- .../GraphQL/Resources/SubscriptionResourceTests.cs | 6 ++++-- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/Speckle.Sdk/Api/GraphQL/Inputs/IngestInputs.cs b/src/Speckle.Sdk/Api/GraphQL/Inputs/IngestInputs.cs index 8fd9db80..4fff6936 100644 --- a/src/Speckle.Sdk/Api/GraphQL/Inputs/IngestInputs.cs +++ b/src/Speckle.Sdk/Api/GraphQL/Inputs/IngestInputs.cs @@ -1,4 +1,5 @@ -using Speckle.Sdk.Api.GraphQL.Enums; +using Speckle.Newtonsoft.Json; +using Speckle.Sdk.Api.GraphQL.Enums; namespace Speckle.Sdk.Api.GraphQL.Inputs; @@ -38,8 +39,14 @@ public record ModelIngestionCancelledInput(string ingestionId, string projectId, public record ProjectModelIngestionSubscriptionInput( string projectId, ModelIngestionReference ingestionReference, - ProjectModelIngestionUpdatedMessageType messageType -); + [property: JsonIgnore] ProjectModelIngestionUpdatedMessageType messageType +) +{ + // The Newtonsoft serializer is setup to handle SCREAMING_CASE enums. + // But the API requires the enum to look exactly like they are + [JsonProperty(nameof(messageType))] + public string serializedType => messageType.ToString(); +} /// /// @oneOf i.e. server expects either or , but not both. diff --git a/src/Speckle.Sdk/Api/GraphQL/Resources/SubscriptionResource.cs b/src/Speckle.Sdk/Api/GraphQL/Resources/SubscriptionResource.cs index 4b38a449..9a014cff 100644 --- a/src/Speckle.Sdk/Api/GraphQL/Resources/SubscriptionResource.cs +++ b/src/Speckle.Sdk/Api/GraphQL/Resources/SubscriptionResource.cs @@ -222,14 +222,22 @@ public sealed class SubscriptionResource : IDisposable { //language=graphql const string QUERY = """ - subscription IngestionUpdated( - $input: ProjectModelIngestionSubscriptionInput! - ) { + subscription IngestionUpdated($input: ProjectModelIngestionSubscriptionInput!) { data: projectModelIngestionUpdated(input: $input) { modelIngestion { id createdAt updatedAt + modelId + cancellationRequested + statusData { + ... on HasModelIngestionStatus { + status + } + ... on HasProgressMessage { + progressMessage + } + } } type } diff --git a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/SubscriptionResourceTests.cs b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/SubscriptionResourceTests.cs index da015ec4..8cdfea1c 100644 --- a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/SubscriptionResourceTests.cs +++ b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/SubscriptionResourceTests.cs @@ -11,7 +11,7 @@ namespace Speckle.Sdk.Tests.Integration.API.GraphQL.Resources; public class SubscriptionResourceTests : IAsyncLifetime { #if DEBUG - private const int WAIT_PERIOD = 3000; // WSL is slow AF, so for local runs, we're being extra generous + private const int WAIT_PERIOD = 4000; // WSL is slow AF, so for local runs, we're being extra generous #else private const int WAIT_PERIOD = 400; // For CI runs, a much smaller wait time is acceptable #endif @@ -143,7 +143,8 @@ public class SubscriptionResourceTests : IAsyncLifetime new(_testModel.id, _testProject.id, "", new(".NET test", "0.0.0", null, null)) ); TaskCompletionSource tcs = new(); - using var sub = Sut.CreateProjectModelIngestionCancellationRequestedSubscription(_testProject.id, ingestion.id); + + using var sub = Sut.CreateProjectModelIngestionCancellationRequestedSubscription(ingestion.id, _testProject.id); sub.Listeners += (_, message) => tcs.SetResult(message); await Task.Delay(WAIT_PERIOD); // Give time to subscription to be setup @@ -153,6 +154,7 @@ public class SubscriptionResourceTests : IAsyncLifetime var subscriptionMessage = await tcs.Task; subscriptionMessage.Should().NotBeNull(); + subscriptionMessage.type.Should().Be(ProjectModelIngestionUpdatedMessageType.cancellationRequested); subscriptionMessage.modelIngestion.id.Should().Be(ingestion.id); } }