Fix curation after quick parse
This commit is contained in:
@@ -135,8 +135,8 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
<button type="button" class="btn btn-link" @onclick="OnEdit" disabled="@(IsSaving)">Edit</button>
|
||||
<button type="button" class="btn-ritual" @onclick="OnMarkCurated" disabled="@(IsSaving)">
|
||||
<button type="button" class="btn btn-link" @onclick="OnEdit" disabled="@(IsSaving || IsReparsing)">Edit</button>
|
||||
<button type="button" class="btn-ritual" @onclick="OnMarkCurated" disabled="@(IsSaving || IsReparsing)">
|
||||
@(IsSaving ? "Saving..." : "Mark as Curated")
|
||||
</button>
|
||||
}
|
||||
|
||||
@@ -424,7 +424,9 @@ public sealed class LookupService(
|
||||
result.RawAffixText = NormalizeOptionalText(request.RawAffixText);
|
||||
result.ParseStatus = request.ParseStatus.Trim();
|
||||
result.ParsedJson = CriticalCellEditorSnapshot.FromRequest(request).ToJson();
|
||||
result.IsCurated = hasEdits ? false : request.IsCurated;
|
||||
result.IsCurated = hasEdits && result.IsCurated
|
||||
? false
|
||||
: request.IsCurated;
|
||||
|
||||
ReplaceBaseEffects(dbContext, result, request.Effects);
|
||||
ReplaceBranches(dbContext, result, request.Branches);
|
||||
|
||||
@@ -106,6 +106,72 @@ public sealed class LookupServiceCurationIntegrationTests
|
||||
Assert.Equal("Edited description after curation.", reopenedResponse.DescriptionText);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Lookup_service_allows_marking_uncurated_reparsed_content_as_curated()
|
||||
{
|
||||
var databasePath = CreateEmptyDatabasePath();
|
||||
var repositoryRoot = CreateTemporaryRepositoryRoot();
|
||||
var locator = new CriticalImportArtifactLocator(new TestHostEnvironment(Path.Combine(repositoryRoot, "src", "RolemasterDb.App")));
|
||||
|
||||
await SeedCriticalResultAsync(databasePath, "slash/cells/source-cell.png", 2);
|
||||
WriteSourceImage(repositoryRoot, "slash/cells/source-cell.png");
|
||||
|
||||
var lookupService = new LookupService(CreateDbContextFactory(databasePath), locator);
|
||||
var resultId = await GetResultIdAsync(databasePath);
|
||||
|
||||
var initialResponse = await lookupService.GetCriticalCellEditorAsync("slash", resultId);
|
||||
Assert.NotNull(initialResponse);
|
||||
Assert.False(initialResponse!.IsCurated);
|
||||
|
||||
var reparsedResponse = await lookupService.ReparseCriticalCellAsync(
|
||||
"slash",
|
||||
resultId,
|
||||
new CriticalCellUpdateRequest(
|
||||
initialResponse.RawCellText,
|
||||
"Edited quick parse input.",
|
||||
initialResponse.DescriptionText,
|
||||
initialResponse.RawAffixText,
|
||||
initialResponse.ParseStatus,
|
||||
initialResponse.ParsedJson,
|
||||
initialResponse.IsCurated,
|
||||
initialResponse.IsDescriptionOverridden,
|
||||
initialResponse.IsRawAffixTextOverridden,
|
||||
initialResponse.AreEffectsOverridden,
|
||||
initialResponse.AreBranchesOverridden,
|
||||
initialResponse.Effects,
|
||||
initialResponse.Branches));
|
||||
|
||||
Assert.NotNull(reparsedResponse);
|
||||
Assert.False(reparsedResponse!.IsCurated);
|
||||
|
||||
var curatedResponse = await lookupService.UpdateCriticalCellAsync(
|
||||
"slash",
|
||||
resultId,
|
||||
new CriticalCellUpdateRequest(
|
||||
reparsedResponse.RawCellText,
|
||||
reparsedResponse.QuickParseInput,
|
||||
reparsedResponse.DescriptionText,
|
||||
reparsedResponse.RawAffixText,
|
||||
reparsedResponse.ParseStatus,
|
||||
reparsedResponse.ParsedJson,
|
||||
true,
|
||||
reparsedResponse.IsDescriptionOverridden,
|
||||
reparsedResponse.IsRawAffixTextOverridden,
|
||||
reparsedResponse.AreEffectsOverridden,
|
||||
reparsedResponse.AreBranchesOverridden,
|
||||
reparsedResponse.Effects,
|
||||
reparsedResponse.Branches));
|
||||
|
||||
Assert.NotNull(curatedResponse);
|
||||
Assert.True(curatedResponse!.IsCurated);
|
||||
Assert.Equal("Edited quick parse input.", curatedResponse.QuickParseInput);
|
||||
|
||||
var reopenedResponse = await lookupService.GetCriticalCellEditorAsync("slash", resultId);
|
||||
Assert.NotNull(reopenedResponse);
|
||||
Assert.True(reopenedResponse!.IsCurated);
|
||||
Assert.Equal("Edited quick parse input.", reopenedResponse.QuickParseInput);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Lookup_service_resolves_source_image_paths_only_when_artifacts_exist()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user