mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-25 08:01:20 -08:00
test(BASE-05): capture published distribution and type consumers
This commit is contained in:
1 parent
2b7054d8a5
commit
c7a375e146
21 files changed
+5079
-28
No files matched your search
@@ -0,0 +1,36 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { validatePublishedCapture } from './api.mjs'
|
||||
import { hash, refactorDir } from './releases.mjs'
|
||||
|
||||
export function validateSsr(report) {
|
||||
assert.equal(report.kind, 'ssr')
|
||||
validatePublishedCapture(report, 'ssr')
|
||||
assert.deepEqual(report.errors, [])
|
||||
assert.deepEqual(report.unhandled, [])
|
||||
assert.deepEqual(report.checks, ['SSR.browser-reuses-player', 'SSR.browser-reuses-video', 'SSR.browser-ready', 'SSR.browser-plugin', 'SSR.browser-cleanup'].map(id => ({ id, passed: true })))
|
||||
assert.equal(report.capture.media['video.mp4'], hash(fs.readFileSync(path.resolve(refactorDir, '../docs/assets/sample/video.mp4'))))
|
||||
assert(report.observations.videoWidth > 0 && report.observations.duration > 0)
|
||||
assert.equal(report.observations.serverMarker, 'preserved')
|
||||
}
|
||||
export function ssrProfile(report) {
|
||||
return { checks: report.checks, observations: report.observations }
|
||||
}
|
||||
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
||||
const frozen = JSON.parse(fs.readFileSync(path.join(refactorDir, 'baselines/ssr.json'), 'utf8'))
|
||||
validateSsr(frozen.report)
|
||||
const index = process.argv.indexOf('--compare')
|
||||
if (index !== -1) {
|
||||
assert(process.argv[index + 1], '--compare requires a report path')
|
||||
const report = JSON.parse(fs.readFileSync(process.argv[index + 1], 'utf8'))
|
||||
validateSsr(report)
|
||||
assert.deepEqual(ssrProfile(report), ssrProfile(frozen.report))
|
||||
console.log('Published browser template reuse matches SSR baseline')
|
||||
}
|
||||
else {
|
||||
assert(process.argv.slice(2).every(arg => arg === '--check'), 'Use --check or --compare <report>')
|
||||
console.log('Frozen browser SSR evidence verified; browser was not rerun')
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user