Merge pull request #7752 from elsa-workflows/sfmskywalker-fix-flaky-payload-test

Fix flaky PublishEvent payload assertion
This commit is contained in:
Sipke Schoorstra 2026-06-23 01:28:50 +02:00 committed by GitHub
commit 883a184c2e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 3 deletions

View file

@ -11,8 +11,6 @@
<packageSourceMapping>
<packageSource key="NuGet official package source">
<package pattern="*" />
</packageSource>
<packageSource key="cshells-feedz">
<package pattern="CShells" />
<package pattern="CShells.*" />
</packageSource>

View file

@ -1,3 +1,4 @@
using System.Linq;
using System.Text.Json;
using Elsa.Common.Models;
using Elsa.Testing.Shared;
@ -74,10 +75,25 @@ public class PublishEventTests : AppComponentTest
// Verify the payload structure and content
using var payloadDocument = JsonDocument.Parse(JsonSerializer.Serialize(receivedPayload));
Assert.True(payloadDocument.RootElement.TryGetProperty("Status", out var status), "Received payload should contain a Status property");
Assert.True(TryGetProperty(payloadDocument.RootElement, "Status", out var status), "Received payload should contain a Status property");
Assert.Equal("Shipped", status.GetString());
}
private static bool TryGetProperty(JsonElement element, string propertyName, out JsonElement property)
{
var candidate = element.EnumerateObject()
.Where(candidate => candidate.Name.Equals(propertyName, StringComparison.OrdinalIgnoreCase))
.FirstOrDefault();
if (candidate.Value.ValueKind == JsonValueKind.Undefined)
{
property = default;
return false;
}
property = candidate.Value;
return true;
}
private async Task<WorkflowInstance> GetSingleWorkflowInstanceAsync(string definitionId, string correlationId, int timeoutMs = 5000)
{
var tcs = new TaskCompletionSource<WorkflowInstance>();