TST: Add a test to check that assets don't block themselves

This commit is contained in:
bananarama92 2025-03-06 00:35:57 +01:00
parent d513a867d7
commit 8313c56a5c
No known key found for this signature in database
GPG key ID: ECBC951D6255A50F

View file

@ -1279,6 +1279,30 @@ function testDrawCallbacks(assets, window) {
}
}
/**
* @param {readonly Asset[]} assets
* @param {Record<ExtendedArchetype, Record<string, AssetArchetypeData>>} extendedDataRecords
*/
function testSelfBlock(assets, extendedDataRecords) {
for (const asset of assets) {
/** @type {readonly AssetGroupName[]} */
const blocks = asset.Block ?? [];
if (blocks.includes(asset.Group.Name)) {
error(`${asset.Group.Name}:${asset.Name}: item must not block its own group`);
}
/** @type {Record<string, ExtendedItemOption[]>} */
const extendedOptions = getExtendedOptions(asset, extendedDataRecords);
for (const [extendedName, options] of Object.entries(extendedOptions)) {
/** @type {readonly AssetGroupName[]} */
const extendedBlocks = options.flatMap(o => o.Property?.Block ?? []);
if (extendedBlocks.includes(asset.Group.Name)) {
error(`${asset.Group.Name}:${asset.Name}:${extendedName} extended item must not block its own group`);
}
}
}
}
/**
* Strigify and parse the passed object to get the correct Array and Object prototypes, because VM uses different ones.
* This unfortunately results in Functions being lost and replaced with a dummy function
@ -1512,4 +1536,5 @@ function sanitizeVMOutput(input) {
testHasPreview(assetList);
testAssetHasPNG(assetList, extendedItemSuperRecord, poseRecord);
testSetPose(assetList, pose);
testSelfBlock(assetList, extendedItemSuperRecord);
})();