test(domain): Ensure custom materials clear texture references when assets are deleted
This commit is contained in:
@@ -33,6 +33,7 @@ import {
|
|||||||
createFoliageLayer,
|
createFoliageLayer,
|
||||||
createFoliagePrototype
|
createFoliagePrototype
|
||||||
} from "../../src/foliage/foliage";
|
} from "../../src/foliage/foliage";
|
||||||
|
import { createCustomMaterialDef } from "../../src/materials/starter-material-library";
|
||||||
|
|
||||||
function createProjectDocumentFixture() {
|
function createProjectDocumentFixture() {
|
||||||
const baseProjectDocument = createEmptyProjectDocument({
|
const baseProjectDocument = createEmptyProjectDocument({
|
||||||
@@ -222,6 +223,45 @@ describe("deleteProjectAssetFromProjectDocument", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("clears custom material texture refs when deleting a referenced image asset", () => {
|
||||||
|
const fixture = createProjectDocumentFixture();
|
||||||
|
const material = createCustomMaterialDef({
|
||||||
|
id: "material-delete-image-ref",
|
||||||
|
textures: {
|
||||||
|
albedo: {
|
||||||
|
assetId: fixture.imageAsset.id
|
||||||
|
},
|
||||||
|
normal: {
|
||||||
|
assetId: fixture.imageAsset.id
|
||||||
|
},
|
||||||
|
roughness: null,
|
||||||
|
metallic: null
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const projectDocument: ProjectDocument = {
|
||||||
|
...fixture.projectDocument,
|
||||||
|
materials: {
|
||||||
|
...fixture.projectDocument.materials,
|
||||||
|
[material.id]: material
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const nextProjectDocument = deleteProjectAssetFromProjectDocument(
|
||||||
|
projectDocument,
|
||||||
|
fixture.imageAsset.id
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(nextProjectDocument.materials[material.id]).toMatchObject({
|
||||||
|
kind: "custom",
|
||||||
|
textures: {
|
||||||
|
albedo: null,
|
||||||
|
normal: null,
|
||||||
|
roughness: null,
|
||||||
|
metallic: null
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("silences sound emitters and removes sound links when deleting an audio asset", () => {
|
it("silences sound emitters and removes sound links when deleting an audio asset", () => {
|
||||||
const fixture = createProjectDocumentFixture();
|
const fixture = createProjectDocumentFixture();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user