66 lines
2.6 KiB
JavaScript
66 lines
2.6 KiB
JavaScript
import test from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import { readFile } from 'node:fs/promises'
|
|
import path from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
import { validateAssetBuildManifest } from '../scripts/asset-build-manifest.mjs'
|
|
|
|
const testDirectory = path.dirname(fileURLToPath(import.meta.url))
|
|
const pipelineDirectory = path.resolve(testDirectory, '..')
|
|
const workspace = path.resolve(pipelineDirectory, '..')
|
|
|
|
const readManifest = async (name) => JSON.parse(await readFile(
|
|
path.join(pipelineDirectory, 'manifests', name),
|
|
'utf8',
|
|
))
|
|
|
|
test('长页面背景只由一份清单拥有六张正式输出', async () => {
|
|
const manifest = await readManifest('page-backgrounds-v3.json')
|
|
validateAssetBuildManifest(manifest, workspace)
|
|
|
|
assert.equal(manifest.family, 'page-backgrounds-v3')
|
|
assert.deepEqual(
|
|
manifest.assets.map(({ id }) => id),
|
|
[
|
|
'genealogy-page-background-long',
|
|
'tree-page-background-long',
|
|
'family-page-background-long',
|
|
'records-page-background-long',
|
|
'notification-page-background-long',
|
|
'profile-page-background-long',
|
|
],
|
|
)
|
|
assert.equal(manifest.assets[0].processing.mode, 'opaque-resize')
|
|
for (const asset of manifest.assets.slice(1)) {
|
|
assert.equal(asset.processing.mode, 'opaque-cover-crop')
|
|
}
|
|
})
|
|
|
|
test('G01 空态边框拥有独立的暖金边框提取清单', async () => {
|
|
const manifest = await readManifest('g01-state-frame-v3.json')
|
|
validateAssetBuildManifest(manifest, workspace)
|
|
|
|
assert.equal(manifest.family, 'g01-state-frame-v3')
|
|
assert.equal(manifest.assets.length, 1)
|
|
assert.equal(manifest.assets[0].id, 'g01-empty-panel-frame')
|
|
assert.equal(manifest.assets[0].processing.mode, 'warm-gold-frame-extract')
|
|
assert.equal(manifest.assets[0].processing.borderBand, 110)
|
|
})
|
|
|
|
test('新构建入口不再保留候选构建和 Sharp 专用命令', async () => {
|
|
const packageJson = JSON.parse(await readFile(path.join(pipelineDirectory, 'package.json'), 'utf8'))
|
|
assert.equal(
|
|
packageJson.scripts['build:page-backgrounds'],
|
|
'node scripts/build-raster-assets.mjs design-pipeline/manifests/page-backgrounds-v3.json',
|
|
)
|
|
assert.equal(
|
|
packageJson.scripts['build:g01-state-frame'],
|
|
'node scripts/build-raster-assets.mjs design-pipeline/manifests/g01-state-frame-v3.json',
|
|
)
|
|
assert.equal(packageJson.scripts['build:g01-background-candidates'], undefined)
|
|
assert.equal(packageJson.scripts['build:module-page-backgrounds'], undefined)
|
|
assert.equal(packageJson.scripts['build:g01-empty-frame'], undefined)
|
|
assert.equal(packageJson.dependencies?.sharp, undefined)
|
|
})
|