implements PR-10f bank composition apply through packer and snapshot refresh
This commit is contained in:
+39
@@ -245,6 +245,45 @@ final class FileSystemPackerWorkspaceServiceTest {
|
||||
assertEquals(1, loader.loadCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
void applyBankCompositionWritesArtifactsAndRefreshesSnapshotWithoutWholeProjectReload() throws Exception {
|
||||
final Path projectRoot = copyFixture("workspaces/managed-basic", tempDir.resolve("apply-bank-composition"));
|
||||
final Path assetRoot = projectRoot.resolve("assets/ui/atlas");
|
||||
Files.writeString(assetRoot.resolve("confirm.png"), "fixture");
|
||||
Files.writeString(assetRoot.resolve("cancel.png"), "fixture");
|
||||
final CountingLoader loader = countingLoader();
|
||||
final FileSystemPackerWorkspaceService service = service(ignored -> { }, loader);
|
||||
|
||||
service.listAssets(new ListAssetsRequest(project(projectRoot)));
|
||||
assertEquals(1, loader.loadCount());
|
||||
|
||||
final var applyResult = service.applyBankComposition(new ApplyBankCompositionRequest(
|
||||
project(projectRoot),
|
||||
AssetReference.forAssetId(1),
|
||||
List.of("cancel.png", "confirm.png")));
|
||||
|
||||
assertTrue(applyResult.success());
|
||||
assertNull(applyResult.errorMessage());
|
||||
assertEquals(1, loader.loadCount());
|
||||
|
||||
final var manifest = MAPPER.readTree(assetRoot.resolve("asset.json").toFile());
|
||||
assertTrue(manifest.path("inputs").isObject());
|
||||
assertTrue(manifest.path("inputs").isEmpty());
|
||||
assertEquals("cancel.png", manifest.path("artifacts").get(0).path("file").asText());
|
||||
assertEquals(0, manifest.path("artifacts").get(0).path("index").asInt());
|
||||
assertEquals("confirm.png", manifest.path("artifacts").get(1).path("file").asText());
|
||||
assertEquals(1, manifest.path("artifacts").get(1).path("index").asInt());
|
||||
|
||||
final var detailsResult = service.getAssetDetails(new GetAssetDetailsRequest(
|
||||
project(projectRoot),
|
||||
AssetReference.forAssetId(1)));
|
||||
assertEquals(PackerOperationStatus.SUCCESS, detailsResult.status());
|
||||
assertEquals(
|
||||
List.of("cancel.png", "confirm.png"),
|
||||
detailsResult.details().bankComposition().selectedFiles().stream().map(file -> file.path()).toList());
|
||||
assertEquals(1, loader.loadCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
void returnsFailureWhenAssetManifestIsMissingOnContractUpdate() throws Exception {
|
||||
final Path projectRoot = copyFixture("workspaces/managed-basic", tempDir.resolve("update-contract-missing-manifest"));
|
||||
|
||||
+27
@@ -80,6 +80,33 @@ final class PackerAssetDetailsServiceTest {
|
||||
.allMatch(file -> !file.displayName().isBlank()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void prefersArtifactsSelectionOrderOverLegacyInputs() throws Exception {
|
||||
final Path projectRoot = copyFixture("workspaces/managed-basic", tempDir.resolve("managed-artifacts-order"));
|
||||
final Path assetRoot = projectRoot.resolve("assets/ui/atlas");
|
||||
final BufferedImage tile = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
|
||||
ImageIO.write(tile, "png", assetRoot.resolve("a.png").toFile());
|
||||
ImageIO.write(tile, "png", assetRoot.resolve("b.png").toFile());
|
||||
final Path manifestPath = assetRoot.resolve("asset.json");
|
||||
|
||||
final ObjectMapper mapper = new ObjectMapper();
|
||||
final ObjectNode manifest = (ObjectNode) mapper.readTree(manifestPath.toFile());
|
||||
final ObjectNode inputs = manifest.putObject("inputs");
|
||||
inputs.putArray("sprites").add("a.png");
|
||||
final var artifacts = manifest.putArray("artifacts");
|
||||
artifacts.addObject().put("file", "b.png").put("index", 0);
|
||||
artifacts.addObject().put("file", "a.png").put("index", 1);
|
||||
mapper.writerWithDefaultPrettyPrinter().writeValue(manifestPath.toFile(), manifest);
|
||||
|
||||
final PackerAssetDetailsService service = service();
|
||||
final var result = service.getAssetDetails(new GetAssetDetailsRequest(project(projectRoot), AssetReference.forAssetId(1)));
|
||||
|
||||
assertEquals(PackerOperationStatus.SUCCESS, result.status());
|
||||
assertEquals(
|
||||
List.of("b.png", "a.png"),
|
||||
result.details().bankComposition().selectedFiles().stream().map(file -> file.path()).toList());
|
||||
}
|
||||
|
||||
@Test
|
||||
void returnsUnregisteredDetailsForValidUnregisteredRootReference() throws Exception {
|
||||
final Path projectRoot = copyFixture("workspaces/orphan-valid", tempDir.resolve("orphan"));
|
||||
|
||||
Reference in New Issue
Block a user