test(ambilight): [PKG-AMBILIGHT-05] checkpoint installed canvas combinations

This commit is contained in:
Harvey Zhao committed 2026-09-14 17:50:38 +08:00
1 parent e7f31b6fc8
commit 765ddb816f
19 files changed
+1032 -85

No files matched your search

+32 -1
View File
@@ -1,11 +1,42 @@
import assert from 'node:assert/strict'
import fs from 'node:fs'
import path from 'node:path'
import process from 'node:process'
// eslint-disable-next-line test/no-import-node-test -- This fixture exercises the repository's Node test runner.
import { test } from 'node:test'
import { checkFiles, publishedConsumer } from '../scripts/package-check.mjs'
import { checkFiles, checkPackages, publishedConsumer } from '../scripts/package-check.mjs'
import { removeConsumer, runtimeConsumer } from '../scripts/package-consumer.mjs'
import { emitterContracts } from './contracts/emitter.js'
import { ambilightCandidate } from './helpers/ambilight.js'
import { canvasCandidate } from './helpers/canvas.js'
test('Additional browser packages cannot be mistaken for full release consumer acceptance', async () => {
await assert.rejects(checkPackages({ release: true, include: ['artplayer-plugin-ambilight'] }), /not full release acceptance/)
})
test('Explicit installed plugin maps never fall back to source or frozen workspace', async () => {
const keys = ['ARTPLAYER_BROWSER_ARTIFACTS', 'ARTPLAYER_AMBILIGHT_BASELINE', 'ARTPLAYER_CANVAS_BASELINE']
const previous = Object.fromEntries(keys.map(key => [key, process.env[key]]))
try {
process.env.ARTPLAYER_BROWSER_ARTIFACTS = path.resolve('refactor/.cache/absent-installed-plugin-map.json')
assert(!fs.existsSync(process.env.ARTPLAYER_BROWSER_ARTIFACTS))
delete process.env.ARTPLAYER_AMBILIGHT_BASELINE
delete process.env.ARTPLAYER_CANVAS_BASELINE
await assert.rejects(ambilightCandidate(), { code: 'ENOENT' })
await assert.rejects(canvasCandidate(), { code: 'ENOENT' })
process.env.ARTPLAYER_AMBILIGHT_BASELINE = '1'
process.env.ARTPLAYER_CANVAS_BASELINE = '1'
await assert.rejects(ambilightCandidate(), /cannot use the frozen workspace/)
await assert.rejects(canvasCandidate(), /cannot use the frozen workspace/)
}
finally {
for (const key of keys) {
if (previous[key] === undefined)
delete process.env[key]
else process.env[key] = previous[key]
}
}
})
test('Package checks reject missing files, missing wildcard exports and internal configuration', () => {
const manifest = { name: 'fixture', main: './dist/main.js', module: './dist/main.mjs', types: './types/main.d.ts', legacy: './dist/legacy.js', exports: { '.': './dist/main.js', './lang/*': './dist/lang/*.js' } }