mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-17 10:01:20 -08:00
test(BASE-04): freeze published DOM input and demo baselines
This commit is contained in:
1 parent
9489392905
commit
2b7054d8a5
16 files changed
+3193
-17
No files matched your search
@@ -0,0 +1,37 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
import { domProfile, validateDomReport, verifyFrozenDom } from './dom.mjs'
|
||||
|
||||
test('DOM baseline rejects absent interaction, fake input and wrong media', () => {
|
||||
const frozen = verifyFrozenDom().report
|
||||
for (const mutate of [
|
||||
report => report.checks.pop(),
|
||||
report => report.interactions.find(item => item.code === 'ArrowRight').trusted = false,
|
||||
report => report.interactions.find(item => item.code === 'ArrowRight').afterTime = 0,
|
||||
report => report.interactions.find(item => item.code === 'ArrowRight' && item.target === 'INPUT').afterHotkeys++,
|
||||
report => report.capture.media['video.mp4'] = 'wrong',
|
||||
report => report.unhandled.push('unexpected'),
|
||||
]) {
|
||||
const changed = structuredClone(frozen)
|
||||
mutate(changed)
|
||||
assert.throws(() => validateDomReport(changed))
|
||||
}
|
||||
})
|
||||
|
||||
test('DOM comparison detects class, variable and layout changes without freezing subpixel widths', () => {
|
||||
const frozen = verifyFrozenDom().report
|
||||
const expected = domProfile(frozen)
|
||||
const jitter = structuredClone(frozen)
|
||||
jitter.observations.wide.controls[0].width += 0.01
|
||||
assert.deepEqual(domProfile(jitter), expected)
|
||||
for (const mutate of [
|
||||
report => report.snapshot.tree.attributes.class = 'renamed',
|
||||
report => report.snapshot.cssVariables.pop(),
|
||||
report => report.snapshot.controlAttributes[0].role = 'button',
|
||||
report => report.observations.narrow.controls[0].withinPlayer = false,
|
||||
]) {
|
||||
const changed = structuredClone(frozen)
|
||||
mutate(changed)
|
||||
assert.notDeepEqual(domProfile(changed), expected)
|
||||
}
|
||||
})
|
||||
Reference in new issue
Block a user