Improved harness - with card selection
This commit is contained in:
@@ -63,12 +63,30 @@ test('advertised optional-mask failures reject loading and clean up every succes
|
||||
}
|
||||
})
|
||||
|
||||
test('runtime catalog validation accepts missing/valid optional URLs and rejects malformed text-mask fields', () => {
|
||||
const catalog = { schemaVersion: 1, cards: [asset], errors: [] }
|
||||
test('runtime catalog validation accepts complete artifact variants and rejects malformed text-mask fields', () => {
|
||||
const artifactAsset = {
|
||||
artwork: '/__card_asset/BP-002-david/high/normal/card.png',
|
||||
mask: '/__card_asset/BP-002-david/high/normal/finish-mask.png',
|
||||
revision: 'test', width: 2000, height: 2800,
|
||||
}
|
||||
const resolutions = ['low', 'med', 'high']
|
||||
const printings = ['normal', 'borderless', 'textless', 'boundless']
|
||||
const variants = Object.fromEntries(resolutions.map(resolution => [resolution,
|
||||
Object.fromEntries(printings.map(printing => [printing, { ...artifactAsset,
|
||||
artwork: `/__card_asset/BP-002-david/${resolution}/${printing}/card.png`,
|
||||
mask: `/__card_asset/BP-002-david/${resolution}/${printing}/finish-mask.png`,
|
||||
}]))
|
||||
]))
|
||||
const card = { cardId: 'BP-002', title: 'David', rarity: 'Blessed', folderName: 'BP-002-david',
|
||||
acceptedRevision: 'accepted', variants }
|
||||
const catalog = { schemaVersion: 2, cards: [card], errors: [] }
|
||||
assert.deepEqual(validateCardCatalog(catalog), catalog)
|
||||
const masked = { ...catalog, cards: [{ ...asset, textMask: '/card-art/test-text-mask.png?v=revision' }] }
|
||||
const masked = structuredClone(catalog)
|
||||
masked.cards[0].variants.high.normal.textMask = '/__card_asset/BP-002-david/high/normal/text-mask.png'
|
||||
assert.deepEqual(validateCardCatalog(masked), masked)
|
||||
for (const textMask of [null, 1, false, '', '/reference/text.png', 'https://example.com/text.png']) {
|
||||
assert.throws(() => validateCardCatalog({ ...catalog, cards: [{ ...asset, textMask }] }), /invalid format/)
|
||||
const malformed = structuredClone(catalog)
|
||||
malformed.cards[0].variants.high.normal.textMask = textMask
|
||||
assert.throws(() => validateCardCatalog(malformed), /invalid format/)
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user