Skip to content

Commit e96cf47

Browse files
committed
Fix adversarial review findings: strengthen assertions and remove brittle checks
- Strengthen DueDate assertion to verify actual value (not just non-null) - Remove trailing comma substring checks that could false-fail on string content (JsonDocument.Parse already validates JSON syntax) - Replace non-deterministic if/else in cross-format test with deterministic assertion - Rename test to match actual behavior (zero candidates, not parse error)
1 parent e325d76 commit e96cf47

File tree

3 files changed

+11
-28
lines changed

3 files changed

+11
-28
lines changed

backend/tests/Taskdeck.Application.Tests/Services/BoardJsonExportImportRoundTripTests.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public async Task RoundTrip_FullBoard_PreservesAllData()
128128

129129
var exportedCard2 = exportDto.Cards.First(c => c.Title == "Add dashboard");
130130
exportedCard2.Labels.Should().ContainSingle(l => l.Name == "Feature");
131-
exportedCard2.DueDate.Should().NotBeNull("due date should be preserved");
131+
exportedCard2.DueDate.Should().BeCloseTo(dueDate, TimeSpan.FromSeconds(1), "due date value should be preserved");
132132
}
133133

134134
[Fact]
@@ -533,12 +533,8 @@ public async Task RoundTrip_ExportJsonIsValidParsableJson()
533533
var json = exportResult.Value;
534534
json.Should().NotBeNullOrWhiteSpace();
535535

536-
// Should not have trailing commas
537-
json.Should().NotContain(",]");
538-
json.Should().NotContain(",}");
539-
540-
// Should parse without exceptions
541-
var doc = JsonDocument.Parse(json);
536+
// Parsing validates JSON syntax (including rejecting trailing commas)
537+
using var doc = JsonDocument.Parse(json);
542538
doc.Should().NotBeNull();
543539
doc.RootElement.ValueKind.Should().Be(JsonValueKind.Object);
544540
}

backend/tests/Taskdeck.Application.Tests/Services/CrossFormatImportIntegrityTests.cs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class CrossFormatImportIntegrityTests
2323
};
2424

2525
[Fact]
26-
public void BoardJsonExport_FedAsCsvPayload_ProducesParseError()
26+
public void BoardJsonExport_FedAsCsvPayload_ProducesZeroCandidates()
2727
{
2828
// Create a board JSON export payload
2929
var now = DateTimeOffset.UtcNow;
@@ -46,20 +46,11 @@ public void BoardJsonExport_FedAsCsvPayload_ProducesParseError()
4646

4747
var result = _csvAdapter.Parse(request);
4848

49-
// The CSV parser should either fail or produce zero useful candidates
50-
// because JSON is not valid CSV (the header row won't match expected columns)
51-
if (result.IsSuccess)
52-
{
53-
// If it parses at all, it should not produce meaningful candidates
54-
// since JSON keys don't map to expected CSV column aliases
55-
result.Value.Candidates.Should().BeEmpty(
56-
"JSON payload should not produce valid CSV candidates");
57-
}
58-
else
59-
{
60-
// Alternatively, the parser may reject it outright
61-
result.ErrorCode.Should().NotBeNull();
62-
}
49+
// JSON is technically parseable as single-column CSV (the "{" line becomes the header),
50+
// but no recognized column aliases exist, so zero candidates are produced.
51+
result.IsSuccess.Should().BeTrue("JSON is syntactically parseable as degenerate CSV");
52+
result.Value.Candidates.Should().BeEmpty(
53+
"JSON payload should not produce valid CSV candidates because no column aliases match");
6354
}
6455

6556
[Fact]

backend/tests/Taskdeck.Application.Tests/Services/GdprDataExportRoundTripTests.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,10 @@ public async Task ExportUserData_AllSectionsPopulated_ProducesValidJson()
120120
var json = JsonSerializer.Serialize(export, JsonOptions);
121121
json.Should().NotBeNullOrWhiteSpace();
122122

123-
// Parse and verify structure
124-
var doc = JsonDocument.Parse(json);
123+
// Parsing validates JSON syntax (including rejecting trailing commas)
124+
using var doc = JsonDocument.Parse(json);
125125
doc.RootElement.ValueKind.Should().Be(JsonValueKind.Object);
126126

127-
// No trailing commas or invalid JSON
128-
json.Should().NotContain(",]");
129-
json.Should().NotContain(",}");
130-
131127
// Verify the export can be deserialized back
132128
var deserialized = JsonSerializer.Deserialize<UserDataExportDto>(json, JsonOptions);
133129
deserialized.Should().NotBeNull();

0 commit comments

Comments
 (0)