@nodaro/shared 3.61.0 → 3.63.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-4KYLNTR7.cjs → chunk-2PU3AGGS.cjs} +27 -4
- package/dist/chunk-2PU3AGGS.cjs.map +1 -0
- package/dist/{chunk-43TGSZRJ.js → chunk-2QKF7M2Z.js} +3 -3
- package/dist/{chunk-43TGSZRJ.js.map → chunk-2QKF7M2Z.js.map} +1 -1
- package/dist/{chunk-B6BG3LV2.js → chunk-34QLPTSA.js} +3 -3
- package/dist/{chunk-B6BG3LV2.js.map → chunk-34QLPTSA.js.map} +1 -1
- package/dist/chunk-3K24DWOH.js +453 -0
- package/dist/chunk-3K24DWOH.js.map +1 -0
- package/dist/{chunk-IRQ3SPX7.js → chunk-4DVWXEB6.js} +23 -4
- package/dist/chunk-4DVWXEB6.js.map +1 -0
- package/dist/{chunk-ZES6EZC4.js → chunk-4MMZD63H.js} +3 -3
- package/dist/{chunk-ZES6EZC4.js.map → chunk-4MMZD63H.js.map} +1 -1
- package/dist/{chunk-MQZRQ5LM.cjs → chunk-63H4C56Q.cjs} +8 -8
- package/dist/{chunk-MQZRQ5LM.cjs.map → chunk-63H4C56Q.cjs.map} +1 -1
- package/dist/{chunk-IVXSNW2B.cjs → chunk-6BZC2ZHC.cjs} +18 -332
- package/dist/chunk-6BZC2ZHC.cjs.map +1 -0
- package/dist/{chunk-M3SXUUWC.cjs → chunk-6FQBKI2A.cjs} +4 -11
- package/dist/chunk-6FQBKI2A.cjs.map +1 -0
- package/dist/{chunk-673E4KYC.js → chunk-6M563QE6.js} +134 -8
- package/dist/chunk-6M563QE6.js.map +1 -0
- package/dist/chunk-6TGB7ECA.cjs +48 -0
- package/dist/chunk-6TGB7ECA.cjs.map +1 -0
- package/dist/{chunk-XUJC6GHE.cjs → chunk-6XUG4L7X.cjs} +6 -6
- package/dist/{chunk-XUJC6GHE.cjs.map → chunk-6XUG4L7X.cjs.map} +1 -1
- package/dist/{chunk-XZKFZMRT.cjs → chunk-77WU3V3J.cjs} +6 -6
- package/dist/{chunk-XZKFZMRT.cjs.map → chunk-77WU3V3J.cjs.map} +1 -1
- package/dist/{chunk-ZFJN23V4.cjs → chunk-A2PX5IRC.cjs} +4 -4
- package/dist/{chunk-ZFJN23V4.cjs.map → chunk-A2PX5IRC.cjs.map} +1 -1
- package/dist/{chunk-ZDBPQBAA.js → chunk-AE3AAJ4O.js} +3 -3
- package/dist/{chunk-ZDBPQBAA.js.map → chunk-AE3AAJ4O.js.map} +1 -1
- package/dist/chunk-ALRXY4QH.cjs +13 -0
- package/dist/chunk-ALRXY4QH.cjs.map +1 -0
- package/dist/{chunk-UARGJ5IZ.js → chunk-BMJVKYVB.js} +56 -12
- package/dist/chunk-BMJVKYVB.js.map +1 -0
- package/dist/{chunk-6XVHYD5R.js → chunk-CLAKSLXF.js} +4 -9
- package/dist/chunk-CLAKSLXF.js.map +1 -0
- package/dist/chunk-CTANEPMY.js +61 -0
- package/dist/chunk-CTANEPMY.js.map +1 -0
- package/dist/chunk-CZ5IQB3L.js +42 -0
- package/dist/chunk-CZ5IQB3L.js.map +1 -0
- package/dist/{chunk-WGKAOUEQ.cjs → chunk-D34K455O.cjs} +3 -2
- package/dist/chunk-D34K455O.cjs.map +1 -0
- package/dist/chunk-EPXGG27L.js +331 -0
- package/dist/chunk-EPXGG27L.js.map +1 -0
- package/dist/{chunk-3M4BNKFJ.cjs → chunk-F6WGGYQW.cjs} +167 -3
- package/dist/chunk-F6WGGYQW.cjs.map +1 -0
- package/dist/{chunk-7FCTCWHD.js → chunk-FXGNRYQQ.js} +3 -3
- package/dist/{chunk-7FCTCWHD.js.map → chunk-FXGNRYQQ.js.map} +1 -1
- package/dist/{chunk-ZNM2LW3D.cjs → chunk-GMBDLNLD.cjs} +105 -56
- package/dist/chunk-GMBDLNLD.cjs.map +1 -0
- package/dist/{chunk-NJVOJXBS.cjs → chunk-GSKLPI3J.cjs} +104 -49
- package/dist/chunk-GSKLPI3J.cjs.map +1 -0
- package/dist/{chunk-EWS2VFO4.js → chunk-HBXF6RUU.js} +4 -4
- package/dist/{chunk-EWS2VFO4.js.map → chunk-HBXF6RUU.js.map} +1 -1
- package/dist/{chunk-MOMFX32D.js → chunk-HWQ2SYNA.js} +194 -325
- package/dist/chunk-HWQ2SYNA.js.map +1 -0
- package/dist/{chunk-SCMTN57Y.js → chunk-IY3Y462W.js} +3 -3
- package/dist/{chunk-SCMTN57Y.js.map → chunk-IY3Y462W.js.map} +1 -1
- package/dist/{chunk-ZZGQRRN7.js → chunk-KCZHQH2O.js} +6 -306
- package/dist/chunk-KCZHQH2O.js.map +1 -0
- package/dist/{chunk-XROE3CAS.cjs → chunk-KHH54GRP.cjs} +120 -79
- package/dist/chunk-KHH54GRP.cjs.map +1 -0
- package/dist/{chunk-FVVD6XY2.js → chunk-KL6GAYTT.js} +13 -4
- package/dist/chunk-KL6GAYTT.js.map +1 -0
- package/dist/{chunk-FVII3KHN.js → chunk-KMGCHV6O.js} +163 -4
- package/dist/chunk-KMGCHV6O.js.map +1 -0
- package/dist/{chunk-FMXFHJWX.cjs → chunk-L2TVY6XN.cjs} +4 -4
- package/dist/{chunk-FMXFHJWX.cjs.map → chunk-L2TVY6XN.cjs.map} +1 -1
- package/dist/{chunk-FQXRYPCX.cjs → chunk-LH72PQO2.cjs} +505 -68
- package/dist/chunk-LH72PQO2.cjs.map +1 -0
- package/dist/chunk-LMAQUR55.cjs +506 -0
- package/dist/chunk-LMAQUR55.cjs.map +1 -0
- package/dist/{chunk-F5YEMSNK.cjs → chunk-M5OCFGHF.cjs} +571 -30
- package/dist/chunk-M5OCFGHF.cjs.map +1 -0
- package/dist/{chunk-VOWJCUMR.js → chunk-MD4XHED4.js} +3 -3
- package/dist/{chunk-VOWJCUMR.js.map → chunk-MD4XHED4.js.map} +1 -1
- package/dist/chunk-N5HH46JF.cjs +68 -0
- package/dist/chunk-N5HH46JF.cjs.map +1 -0
- package/dist/{chunk-G4XWVWRI.js → chunk-NIAFR5EE.js} +5 -4
- package/dist/chunk-NIAFR5EE.js.map +1 -0
- package/dist/{chunk-CF4S4N5X.js → chunk-O2QOBA6Q.js} +2 -2
- package/dist/{chunk-CF4S4N5X.js.map → chunk-O2QOBA6Q.js.map} +1 -1
- package/dist/{chunk-4GGLKRYI.cjs → chunk-O6TBB4IF.cjs} +2 -2
- package/dist/{chunk-4GGLKRYI.cjs.map → chunk-O6TBB4IF.cjs.map} +1 -1
- package/dist/{chunk-SWVGHAYO.js → chunk-O7RZRUMZ.js} +110 -74
- package/dist/chunk-O7RZRUMZ.js.map +1 -0
- package/dist/{chunk-LLOIAGFB.js → chunk-OV3JTKBY.js} +449 -51
- package/dist/chunk-OV3JTKBY.js.map +1 -0
- package/dist/{chunk-A3FHTSLB.js → chunk-PSKZKLDG.js} +550 -31
- package/dist/chunk-PSKZKLDG.js.map +1 -0
- package/dist/{chunk-VB2ARGQ6.js → chunk-RGNHHIMN.js} +3 -3
- package/dist/chunk-RGNHHIMN.js.map +1 -0
- package/dist/chunk-SMOO5FAH.js +10 -0
- package/dist/chunk-SMOO5FAH.js.map +1 -0
- package/dist/{chunk-5XRRENHD.cjs → chunk-TM5JYSJF.cjs} +170 -17
- package/dist/chunk-TM5JYSJF.cjs.map +1 -0
- package/dist/{chunk-PONP5J5E.cjs → chunk-V24EPI5N.cjs} +13 -3
- package/dist/chunk-V24EPI5N.cjs.map +1 -0
- package/dist/{chunk-RQ4F3AJH.cjs → chunk-V5EEQR2U.cjs} +21 -21
- package/dist/{chunk-RQ4F3AJH.cjs.map → chunk-V5EEQR2U.cjs.map} +1 -1
- package/dist/chunk-WZVIBAKN.cjs +351 -0
- package/dist/chunk-WZVIBAKN.cjs.map +1 -0
- package/dist/{chunk-5M43XMRB.cjs → chunk-X5BAFW3Q.cjs} +8 -8
- package/dist/{chunk-5M43XMRB.cjs.map → chunk-X5BAFW3Q.cjs.map} +1 -1
- package/dist/{chunk-RUHKBEFF.js → chunk-XBTYGQ6Z.js} +63 -10
- package/dist/chunk-XBTYGQ6Z.js.map +1 -0
- package/dist/{chunk-JHTT2V4A.cjs → chunk-XGGZWA4A.cjs} +118 -52
- package/dist/chunk-XGGZWA4A.cjs.map +1 -0
- package/dist/{chunk-5I4T4QR5.cjs → chunk-XGVJGNZW.cjs} +5 -5
- package/dist/{chunk-5I4T4QR5.cjs.map → chunk-XGVJGNZW.cjs.map} +1 -1
- package/dist/{chunk-7ARKVJTN.cjs → chunk-Y35JQPT6.cjs} +228 -383
- package/dist/chunk-Y35JQPT6.cjs.map +1 -0
- package/dist/{chunk-AFQFGZN7.cjs → chunk-Y4GCJJPF.cjs} +8 -6
- package/dist/chunk-Y4GCJJPF.cjs.map +1 -0
- package/dist/{chunk-C77F4ZTL.js → chunk-YUER7TJG.js} +3 -3
- package/dist/{chunk-C77F4ZTL.js.map → chunk-YUER7TJG.js.map} +1 -1
- package/dist/{chunk-HGI2VKIV.js → chunk-YX6TFX7H.js} +67 -14
- package/dist/chunk-YX6TFX7H.js.map +1 -0
- package/dist/{chunk-TWF2OSH4.cjs → chunk-ZPE2ZTJ4.cjs} +4 -4
- package/dist/{chunk-TWF2OSH4.cjs.map → chunk-ZPE2ZTJ4.cjs.map} +1 -1
- package/dist/entries/apps.cjs +44 -44
- package/dist/entries/apps.js +9 -9
- package/dist/entries/credits.cjs +286 -153
- package/dist/entries/credits.d.cts +254 -5
- package/dist/entries/credits.d.ts +254 -5
- package/dist/entries/credits.js +14 -9
- package/dist/entries/entities.cjs +188 -143
- package/dist/entries/entities.d.cts +122 -1
- package/dist/entries/entities.d.ts +122 -1
- package/dist/entries/entities.js +2 -1
- package/dist/entries/llm-models.cjs +77 -57
- package/dist/entries/llm-models.d.cts +85 -5
- package/dist/entries/llm-models.d.ts +85 -5
- package/dist/entries/llm-models.js +2 -2
- package/dist/entries/media.cjs +92 -87
- package/dist/entries/media.d.cts +19 -1
- package/dist/entries/media.d.ts +19 -1
- package/dist/entries/media.js +3 -2
- package/dist/entries/model-catalog.cjs +211 -103
- package/dist/entries/model-catalog.d.cts +135 -19
- package/dist/entries/model-catalog.d.ts +135 -19
- package/dist/entries/model-catalog.js +5 -5
- package/dist/entries/models.cjs +504 -295
- package/dist/entries/models.d.cts +71 -4
- package/dist/entries/models.d.ts +71 -4
- package/dist/entries/models.js +7 -6
- package/dist/entries/nodes.cjs +249 -233
- package/dist/entries/nodes.d.cts +35 -6
- package/dist/entries/nodes.d.ts +35 -6
- package/dist/entries/nodes.js +10 -10
- package/dist/entries/pipeline.cjs +152 -152
- package/dist/entries/pipeline.d.cts +3 -2
- package/dist/entries/pipeline.d.ts +3 -2
- package/dist/entries/pipeline.js +3 -3
- package/dist/entries/runtime-config.cjs +29 -29
- package/dist/entries/runtime-config.d.cts +10 -7
- package/dist/entries/runtime-config.d.ts +10 -7
- package/dist/entries/runtime-config.js +1 -1
- package/dist/entries/social.cjs +177 -177
- package/dist/entries/social.js +2 -2
- package/dist/entries/types.d.cts +8 -0
- package/dist/entries/types.d.ts +8 -0
- package/dist/entries/ugc.cjs +71 -71
- package/dist/entries/ugc.js +4 -4
- package/dist/entries/video.cjs +316 -208
- package/dist/entries/video.d.cts +490 -99
- package/dist/entries/video.d.ts +490 -99
- package/dist/entries/video.js +8 -4
- package/dist/entries/workflow.cjs +102 -102
- package/dist/entries/workflow.d.cts +5 -4
- package/dist/entries/workflow.d.ts +5 -4
- package/dist/entries/workflow.js +2 -2
- package/dist/{gpt-image-2-6-BeZdT-pW.d.cts → gpt-image-2-6-jIRQBRag.d.cts} +6 -0
- package/dist/{gpt-image-2-6-BeZdT-pW.d.ts → gpt-image-2-6-jIRQBRag.d.ts} +6 -0
- package/dist/index.cjs +2727 -2092
- package/dist/index.d.cts +11 -11
- package/dist/index.d.ts +11 -11
- package/dist/index.js +30 -27
- package/dist/{model-catalog-BgSvskgY.d.ts → model-catalog-C_Eo35tL.d.cts} +158 -14
- package/dist/{model-catalog-BgSvskgY.d.cts → model-catalog-C_Eo35tL.d.ts} +158 -14
- package/dist/{model-constants-DHd9jwQ7.d.cts → model-constants-Bg4ccSQb.d.ts} +427 -34
- package/dist/{model-constants-DHd9jwQ7.d.ts → model-constants-DWcxOmaY.d.cts} +427 -34
- package/package.json +1 -1
- package/src/__tests__/credit-identifiers.test.ts +29 -0
- package/src/__tests__/extend-providers.test.ts +194 -0
- package/src/__tests__/fixtures/mask-composite-quote-parity.json +118 -0
- package/src/__tests__/fixtures/root-exports.baseline.json +68 -0
- package/src/__tests__/gpt-image-2-6-formats.test.ts +4 -1
- package/src/__tests__/grok-video-15-catalog.test.ts +189 -0
- package/src/__tests__/gvp-supported-providers.test.ts +32 -4
- package/src/__tests__/lip-sync-audio-rate.test.ts +74 -0
- package/src/__tests__/lip-sync-levers.test.ts +31 -0
- package/src/__tests__/llm-models.test.ts +132 -3
- package/src/__tests__/llm-price-key.test.ts +152 -1
- package/src/__tests__/minimax-h3-image.test.ts +140 -0
- package/src/__tests__/model-makers.test.ts +49 -11
- package/src/__tests__/model-tree.test.ts +13 -0
- package/src/__tests__/nemotron-transcribe-pricing.test.ts +61 -0
- package/src/__tests__/normalize-node-params.test.ts +25 -0
- package/src/__tests__/pixverse-v6-max-catalog.test.ts +271 -0
- package/src/__tests__/prompt-length-limits.test.ts +4 -0
- package/src/__tests__/retired-video-provider.test.ts +15 -5
- package/src/__tests__/seedance-25-catalog-modes.test.ts +1 -1
- package/src/__tests__/seedance-task-type.test.ts +188 -0
- package/src/__tests__/seedream-5-5.test.ts +117 -0
- package/src/__tests__/transcribe-capabilities.test.ts +39 -2
- package/src/__tests__/transcribe-preflight.test.ts +50 -1
- package/src/__tests__/unit-contract-compose.test.ts +27 -1
- package/src/__tests__/unit-contracts.test.ts +20 -6
- package/src/__tests__/upscale-factors.test.ts +107 -0
- package/src/__tests__/video-audio-capability.test.ts +35 -6
- package/src/__tests__/video-character-refs.test.ts +20 -2
- package/src/__tests__/video-collapse-parity.test.ts +19 -0
- package/src/__tests__/video-overlay-geometry.test.ts +68 -0
- package/src/__tests__/video-overlay-layer-plan.test.ts +3 -4
- package/src/__tests__/video-overlay-layouts.test.ts +529 -0
- package/src/__tests__/video-overlay-pricing.test.ts +61 -0
- package/src/__tests__/video-overlay-validate.test.ts +128 -0
- package/src/__tests__/video-overlay-wired-kind.test.ts +207 -0
- package/src/__tests__/video-overlay.test.ts +280 -194
- package/src/__tests__/video-ref-limits.test.ts +2 -1
- package/src/__tests__/video-reference-only.test.ts +6 -2
- package/src/__tests__/video-resolution-billed-as-named.test.ts +30 -0
- package/src/__tests__/video-start-frame-only.test.ts +98 -0
- package/src/__tests__/video-upscale-params.test.ts +62 -0
- package/src/__tests__/wired-character-names.test.ts +220 -0
- package/src/catalog-projection.ts +8 -0
- package/src/credit-estimators/index.ts +18 -0
- package/src/credit-estimators/nemotron-transcribe.ts +87 -0
- package/src/credit-estimators/video-overlay.ts +70 -0
- package/src/credit-identifiers.ts +183 -16
- package/src/entity-image-url.ts +21 -0
- package/src/entries/credits.ts +26 -1
- package/src/entries/entities.ts +14 -0
- package/src/entries/llm-models.ts +6 -0
- package/src/entries/model-catalog.ts +44 -1
- package/src/entries/models.ts +69 -0
- package/src/entries/nodes.ts +4 -0
- package/src/entries/video.ts +7 -1
- package/src/freecut-protocol.ts +8 -0
- package/src/generated/unit-contracts.ts +8 -1
- package/src/gpt-image-2-6.ts +6 -0
- package/src/input-image-pricing.ts +76 -0
- package/src/lip-sync-levers.ts +56 -0
- package/src/lip-sync-pricing.ts +91 -1
- package/src/llm-models.ts +249 -4
- package/src/mask-composite.ts +11 -0
- package/src/minimax-h3-image.ts +61 -0
- package/src/model-catalog.ts +604 -40
- package/src/model-constants.ts +860 -55
- package/src/model-tree.ts +2 -1
- package/src/nodaro-video-upscale.ts +48 -0
- package/src/node-default-mappings.ts +15 -2
- package/src/node-execution-state.ts +4 -3
- package/src/normalize-node-params.ts +49 -1
- package/src/producer-types.ts +23 -1
- package/src/runtime-config/contract.ts +10 -7
- package/src/seedance-draft.ts +2 -1
- package/src/seedance-task-type.ts +37 -0
- package/src/seedream-5-5.ts +45 -0
- package/src/transcribe-preflight.ts +58 -7
- package/src/unit-contract-compose.ts +4 -1
- package/src/upscale-factors.ts +111 -0
- package/src/video-character-refs.ts +7 -4
- package/src/video-duration.ts +9 -0
- package/src/video-overlay-geometry.ts +99 -0
- package/src/video-overlay-input.ts +25 -0
- package/src/video-overlay-layout-ids.ts +48 -0
- package/src/video-overlay-layouts.ts +315 -0
- package/src/video-overlay-validate.ts +223 -0
- package/src/video-overlay-video-layers.ts +304 -0
- package/src/video-overlay.ts +165 -297
- package/src/video-ui-defaults.ts +11 -7
- package/src/video-upscale-params.ts +67 -0
- package/src/wired-character-names.ts +202 -0
- package/dist/chunk-3M4BNKFJ.cjs.map +0 -1
- package/dist/chunk-4KYLNTR7.cjs.map +0 -1
- package/dist/chunk-5XRRENHD.cjs.map +0 -1
- package/dist/chunk-673E4KYC.js.map +0 -1
- package/dist/chunk-6XVHYD5R.js.map +0 -1
- package/dist/chunk-7ARKVJTN.cjs.map +0 -1
- package/dist/chunk-7WGKP3EU.js +0 -23
- package/dist/chunk-7WGKP3EU.js.map +0 -1
- package/dist/chunk-A3FHTSLB.js.map +0 -1
- package/dist/chunk-AFQFGZN7.cjs.map +0 -1
- package/dist/chunk-F5YEMSNK.cjs.map +0 -1
- package/dist/chunk-FQXRYPCX.cjs.map +0 -1
- package/dist/chunk-FVII3KHN.js.map +0 -1
- package/dist/chunk-FVVD6XY2.js.map +0 -1
- package/dist/chunk-G4XWVWRI.js.map +0 -1
- package/dist/chunk-HGI2VKIV.js.map +0 -1
- package/dist/chunk-IRQ3SPX7.js.map +0 -1
- package/dist/chunk-IVXSNW2B.cjs.map +0 -1
- package/dist/chunk-JHTT2V4A.cjs.map +0 -1
- package/dist/chunk-KHZAQGRP.js +0 -17
- package/dist/chunk-KHZAQGRP.js.map +0 -1
- package/dist/chunk-LLOIAGFB.js.map +0 -1
- package/dist/chunk-M3SXUUWC.cjs.map +0 -1
- package/dist/chunk-MOMFX32D.js.map +0 -1
- package/dist/chunk-NCOGGRRP.cjs +0 -27
- package/dist/chunk-NCOGGRRP.cjs.map +0 -1
- package/dist/chunk-NJVOJXBS.cjs.map +0 -1
- package/dist/chunk-PONP5J5E.cjs.map +0 -1
- package/dist/chunk-RUHKBEFF.js.map +0 -1
- package/dist/chunk-SWVGHAYO.js.map +0 -1
- package/dist/chunk-UARGJ5IZ.js.map +0 -1
- package/dist/chunk-VB2ARGQ6.js.map +0 -1
- package/dist/chunk-WGKAOUEQ.cjs.map +0 -1
- package/dist/chunk-XROE3CAS.cjs.map +0 -1
- package/dist/chunk-ZLDFPVVI.cjs +0 -19
- package/dist/chunk-ZLDFPVVI.cjs.map +0 -1
- package/dist/chunk-ZNM2LW3D.cjs.map +0 -1
- package/dist/chunk-ZZGQRRN7.js.map +0 -1
|
@@ -0,0 +1,529 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest"
|
|
2
|
+
import {
|
|
3
|
+
VIDEO_OVERLAY_LAYOUT_IDS,
|
|
4
|
+
isVideoOverlayLayoutId,
|
|
5
|
+
videoOverlayLayoutNeedsAspect,
|
|
6
|
+
videoOverlayLayoutNeedsVideoLayer,
|
|
7
|
+
videoOverlayLayoutPlacesBase,
|
|
8
|
+
} from "../video-overlay-layout-ids.js"
|
|
9
|
+
import {
|
|
10
|
+
VIDEO_OVERLAY_ASPECT_BOUNDS,
|
|
11
|
+
VIDEO_OVERLAY_PIP_INSET,
|
|
12
|
+
VIDEO_OVERLAY_PIP_WIDTH,
|
|
13
|
+
clampVideoOverlayAspect,
|
|
14
|
+
evenVideoOverlayRect,
|
|
15
|
+
expandVideoOverlayLayout,
|
|
16
|
+
firstVideoLayerIndex,
|
|
17
|
+
placeVideoOverlayVideos,
|
|
18
|
+
resolveVideoOverlayBaseRect,
|
|
19
|
+
resolveVideoOverlayStackRects,
|
|
20
|
+
} from "../video-overlay-layouts.js"
|
|
21
|
+
import {
|
|
22
|
+
VIDEO_OVERLAY_ERROR_CODES,
|
|
23
|
+
VIDEO_OVERLAY_OUTPUT_ASPECTS,
|
|
24
|
+
assembleVideoOverlayRequest,
|
|
25
|
+
expandVideoOverlayLayer,
|
|
26
|
+
videoOverlayCompositionKey,
|
|
27
|
+
type ExpandedVideoOverlayRequest,
|
|
28
|
+
type VideoOverlayBox,
|
|
29
|
+
type VideoOverlayLayerInput,
|
|
30
|
+
} from "../video-overlay.js"
|
|
31
|
+
import { resolveVideoOverlayGeometry, videoOverlayCanvas, type VideoOverlayCanvas } from "../video-overlay-geometry.js"
|
|
32
|
+
import { formatVideoOverlayError, validateVideoOverlayRequest, type VideoOverlayIssue, type VideoOverlayValidationInput } from "../video-overlay-validate.js"
|
|
33
|
+
|
|
34
|
+
const V = "https://cdn.example/v.mp4"
|
|
35
|
+
const I = "https://cdn.example/i.png"
|
|
36
|
+
const BOX: VideoOverlayBox = { anchor: "center", x: 0, y: 10, width: 80, height: 40, fit: "cover" }
|
|
37
|
+
const videoLayer: VideoOverlayLayerInput = { videoUrl: V, start: 0 }
|
|
38
|
+
const imageLayer: VideoOverlayLayerInput = { imageUrl: I, start: 0 }
|
|
39
|
+
const codeOf = (body: VideoOverlayValidationInput) => {
|
|
40
|
+
const r = validateVideoOverlayRequest(body)
|
|
41
|
+
return r.ok ? "ok" : r.code
|
|
42
|
+
}
|
|
43
|
+
/** First video layers the validator refuses: each must reach it unrepaired by a layout. */
|
|
44
|
+
const malformedFirstVideoLayers: VideoOverlayLayerInput[] = [
|
|
45
|
+
{ videoUrl: V, start: 0, anchor: "center", width: 500 },
|
|
46
|
+
{ videoUrl: V, start: 0, width: 50 },
|
|
47
|
+
{ videoUrl: V, start: 0, anchor: "middle", width: 30 } as unknown as VideoOverlayLayerInput,
|
|
48
|
+
{ videoUrl: V, start: 0, anchor: "center", width: 30, height: 0 },
|
|
49
|
+
{ videoUrl: V, start: 0, anchor: "center", width: 30, fit: "stretch" } as unknown as VideoOverlayLayerInput,
|
|
50
|
+
{ videoUrl: V, start: 0, animate: "yes" } as unknown as VideoOverlayLayerInput,
|
|
51
|
+
{ videoUrl: V, start: 0, opacity: 5 },
|
|
52
|
+
{ videoUrl: V, start: -1 },
|
|
53
|
+
{ videoUrl: V, imageUrl: I, start: 0 },
|
|
54
|
+
{ videoUrl: V, start: 0, sound: { volume: 2 } },
|
|
55
|
+
]
|
|
56
|
+
const stack = resolveVideoOverlayStackRects
|
|
57
|
+
const CANVASES = VIDEO_OVERLAY_OUTPUT_ASPECTS.map((a) => videoOverlayCanvas(null, a)!)
|
|
58
|
+
const ASPECTS = [16 / 9, 9 / 16, 1, 4 / 3, 21 / 9, 4 / 5, 1920 / 1080, 720 / 1280]
|
|
59
|
+
const SHAPE_TABLE: Array<readonly [VideoOverlayCanvas, number, number]> = CANVASES.flatMap((c) =>
|
|
60
|
+
ASPECTS.flatMap((a) => ASPECTS.map((b) => [c, a, b] as const)),
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
describe("layout ids", () => {
|
|
64
|
+
it("are the five named layouts", () => {
|
|
65
|
+
expect(VIDEO_OVERLAY_LAYOUT_IDS).toEqual(["video-bottom", "video-top", "stack-whole", "stack-filled", "pip"])
|
|
66
|
+
expect(isVideoOverlayLayoutId("pip")).toBe(true)
|
|
67
|
+
expect(isVideoOverlayLayoutId("stack")).toBe(false)
|
|
68
|
+
expect(isVideoOverlayLayoutId(null)).toBe(false)
|
|
69
|
+
})
|
|
70
|
+
it("every layout but pip needs an output aspect; stacks and pip need a video layer; only the stacks place the base themselves", () => {
|
|
71
|
+
expect(VIDEO_OVERLAY_LAYOUT_IDS.filter(videoOverlayLayoutNeedsAspect)).toEqual(["video-bottom", "video-top", "stack-whole", "stack-filled"])
|
|
72
|
+
expect(VIDEO_OVERLAY_LAYOUT_IDS.filter(videoOverlayLayoutNeedsVideoLayer)).toEqual(["stack-whole", "stack-filled", "pip"])
|
|
73
|
+
expect(VIDEO_OVERLAY_LAYOUT_IDS.filter(videoOverlayLayoutPlacesBase)).toEqual(["stack-whole", "stack-filled"])
|
|
74
|
+
})
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
describe("resolveVideoOverlayStackRects", () => {
|
|
78
|
+
it("two 16:9 on 9:16", () =>
|
|
79
|
+
expect(stack("stack-whole", { w: 1080, h: 1920 }, 16 / 9, 16 / 9)).toEqual({
|
|
80
|
+
top: { left: 0, top: 354, width: 1080, height: 606 },
|
|
81
|
+
bottom: { left: 0, top: 960, width: 1080, height: 606 },
|
|
82
|
+
}))
|
|
83
|
+
it("different shapes centre the pair", () =>
|
|
84
|
+
expect(stack("stack-whole", { w: 1080, h: 1920 }, 16 / 9, 1)).toEqual({
|
|
85
|
+
top: { left: 0, top: 117, width: 1080, height: 606 },
|
|
86
|
+
bottom: { left: 0, top: 723, width: 1080, height: 1080 },
|
|
87
|
+
}))
|
|
88
|
+
it("shrinks together when too tall", () =>
|
|
89
|
+
expect(stack("stack-whole", { w: 1080, h: 1080 }, 16 / 9, 16 / 9)).toEqual({
|
|
90
|
+
top: { left: 60, top: 0, width: 960, height: 540 },
|
|
91
|
+
bottom: { left: 60, top: 540, width: 960, height: 540 },
|
|
92
|
+
}))
|
|
93
|
+
it("filled splits with no gap on an odd half", () =>
|
|
94
|
+
expect(stack("stack-filled", { w: 1080, h: 1350 }, 16 / 9, 16 / 9)).toEqual({
|
|
95
|
+
top: { left: 0, top: 0, width: 1080, height: 674 },
|
|
96
|
+
bottom: { left: 0, top: 674, width: 1080, height: 676 },
|
|
97
|
+
}))
|
|
98
|
+
it("the join is exact for every shape", () => {
|
|
99
|
+
for (const [c, a, b] of SHAPE_TABLE) {
|
|
100
|
+
const r = stack("stack-whole", c, a, b)
|
|
101
|
+
expect(r.top.top + r.top.height).toBe(r.bottom.top)
|
|
102
|
+
}
|
|
103
|
+
})
|
|
104
|
+
it("whole: both the same width, even sizes, inside the canvas, equal room above and below (±1 px)", () => {
|
|
105
|
+
for (const [c, a, b] of SHAPE_TABLE) {
|
|
106
|
+
const { top, bottom } = stack("stack-whole", c, a, b)
|
|
107
|
+
expect(top.width).toBe(bottom.width)
|
|
108
|
+
expect(top.left).toBe(bottom.left)
|
|
109
|
+
for (const r of [top, bottom]) {
|
|
110
|
+
expect(r.width % 2).toBe(0)
|
|
111
|
+
expect(r.height % 2).toBe(0)
|
|
112
|
+
expect(r.left).toBeGreaterThanOrEqual(0)
|
|
113
|
+
expect(r.top).toBeGreaterThanOrEqual(0)
|
|
114
|
+
expect(r.left + r.width).toBeLessThanOrEqual(c.w)
|
|
115
|
+
expect(r.top + r.height).toBeLessThanOrEqual(c.h)
|
|
116
|
+
}
|
|
117
|
+
const below = c.h - (bottom.top + bottom.height)
|
|
118
|
+
expect(Math.abs(below - top.top)).toBeLessThanOrEqual(1)
|
|
119
|
+
}
|
|
120
|
+
})
|
|
121
|
+
it("filled: the two halves cover the whole canvas, whatever the sources' shapes", () => {
|
|
122
|
+
for (const c of CANVASES) {
|
|
123
|
+
const { top, bottom } = stack("stack-filled", c, 16 / 9, 9 / 16)
|
|
124
|
+
expect(top).toMatchObject({ left: 0, top: 0, width: c.w })
|
|
125
|
+
expect(bottom).toMatchObject({ left: 0, top: top.height, width: c.w })
|
|
126
|
+
expect(top.height + bottom.height).toBe(c.h)
|
|
127
|
+
}
|
|
128
|
+
})
|
|
129
|
+
it("an unreadable aspect reads as square, as in the layer geometry", () => {
|
|
130
|
+
expect(stack("stack-whole", { w: 1080, h: 1920 }, Number.NaN, 0)).toEqual(stack("stack-whole", { w: 1080, h: 1920 }, 1, 1))
|
|
131
|
+
})
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
describe("resolveVideoOverlayBaseRect — a placed base sits flush on its anchored edge", () => {
|
|
135
|
+
const PORTRAIT = { w: 1080, h: 1920 }
|
|
136
|
+
const edge = (anchor: "bottom" | "top"): VideoOverlayBox => ({ anchor, x: 0, y: 0, width: 100, fit: "contain" })
|
|
137
|
+
it("a 16:9 base against the bottom of 9:16", () =>
|
|
138
|
+
expect(resolveVideoOverlayBaseRect(PORTRAIT, edge("bottom"), 16 / 9)).toEqual({ left: 0, top: 1314, width: 1080, height: 606 }))
|
|
139
|
+
it("a 16:9 base against the top of 9:16", () =>
|
|
140
|
+
expect(resolveVideoOverlayBaseRect(PORTRAIT, edge("top"), 16 / 9)).toEqual({ left: 0, top: 0, width: 1080, height: 606 }))
|
|
141
|
+
it("cover with an explicit height fills the box exactly", () => {
|
|
142
|
+
expect(resolveVideoOverlayBaseRect(PORTRAIT, { anchor: "center", x: 0, y: 0, width: 100, height: 50, fit: "cover" }, 16 / 9)).toEqual({ left: 0, top: 480, width: 1080, height: 960 })
|
|
143
|
+
expect(resolveVideoOverlayBaseRect(PORTRAIT, { anchor: "bottom", x: 0, y: 0, width: 100, height: 50, fit: "cover" }, 16 / 9)).toEqual({ left: 0, top: 960, width: 1080, height: 960 })
|
|
144
|
+
})
|
|
145
|
+
it("offsets move it in % of the canvas", () =>
|
|
146
|
+
expect(resolveVideoOverlayBaseRect(PORTRAIT, { ...edge("bottom"), y: -10 }, 16 / 9)).toEqual({ left: 0, top: 1122, width: 1080, height: 606 }))
|
|
147
|
+
it("its size is the layer geometry's drawn size (same clamp, same even rounding)", () => {
|
|
148
|
+
const boxes: VideoOverlayBox[] = [edge("bottom"), BOX, { anchor: "top-left", x: 4, y: 4, width: 30, fit: "contain" }, { anchor: "center", x: 0, y: 0, width: 100, fit: "contain" }]
|
|
149
|
+
for (const c of CANVASES) {
|
|
150
|
+
for (const box of boxes) {
|
|
151
|
+
for (const aspect of ASPECTS) {
|
|
152
|
+
const { drawn } = resolveVideoOverlayGeometry(c, box, aspect)
|
|
153
|
+
const r = resolveVideoOverlayBaseRect(c, box, aspect)
|
|
154
|
+
expect([r.width, r.height]).toEqual([drawn.width, drawn.height])
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
})
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
describe("clampVideoOverlayAspect — a probed video's aspect, bounded before any geometry", () => {
|
|
162
|
+
it("keeps every aspect inside [1/8, 8] as it is", () => {
|
|
163
|
+
expect(VIDEO_OVERLAY_ASPECT_BOUNDS).toEqual([1 / 8, 8])
|
|
164
|
+
for (const a of [16 / 9, 9 / 16, 1, 1 / 8, 8]) expect(clampVideoOverlayAspect(a)).toBe(a)
|
|
165
|
+
})
|
|
166
|
+
it("clamps a wider or taller one to the bound", () => {
|
|
167
|
+
expect(clampVideoOverlayAspect(20)).toBe(8)
|
|
168
|
+
expect(clampVideoOverlayAspect(1 / 1000)).toBe(1 / 8)
|
|
169
|
+
})
|
|
170
|
+
it("reads an unusable one as square, as the layer geometry does", () => {
|
|
171
|
+
for (const a of [Number.NaN, 0, -2, Number.POSITIVE_INFINITY]) expect(clampVideoOverlayAspect(a)).toBe(1)
|
|
172
|
+
})
|
|
173
|
+
it("a stack of clamped aspects never leaves the canvas, whatever the probes said", () => {
|
|
174
|
+
const EXTREMES = [1 / 1000, 1 / 9, 1 / 8, 1, 8, 9, 1000]
|
|
175
|
+
for (const c of CANVASES) {
|
|
176
|
+
for (const a of EXTREMES) {
|
|
177
|
+
for (const b of EXTREMES) {
|
|
178
|
+
const { top, bottom } = stack("stack-whole", c, clampVideoOverlayAspect(a), clampVideoOverlayAspect(b))
|
|
179
|
+
for (const r of [top, bottom]) {
|
|
180
|
+
expect(r.left).toBeGreaterThanOrEqual(0)
|
|
181
|
+
expect(r.top).toBeGreaterThanOrEqual(0)
|
|
182
|
+
expect(r.left + r.width).toBeLessThanOrEqual(c.w)
|
|
183
|
+
expect(r.top + r.height).toBeLessThanOrEqual(c.h)
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
})
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
describe("evenVideoOverlayRect — what the render draws, since overlay snaps odd offsets to even", () => {
|
|
192
|
+
it("floors an odd left and top to even, as overlay does on yuv420", () => {
|
|
193
|
+
expect(evenVideoOverlayRect({ left: 371, top: 117, width: 606, height: 1080 })).toEqual({ left: 370, top: 116, width: 606, height: 1080 })
|
|
194
|
+
})
|
|
195
|
+
it("floors a negative odd offset down too (overlay clears the low bit)", () => {
|
|
196
|
+
expect(evenVideoOverlayRect({ left: -61, top: -1, width: 1200, height: 676 })).toEqual({ left: -62, top: -2, width: 1200, height: 676 })
|
|
197
|
+
})
|
|
198
|
+
it("floors an odd size to even", () => {
|
|
199
|
+
expect(evenVideoOverlayRect({ left: 0, top: 0, width: 607, height: 341 })).toEqual({ left: 0, top: 0, width: 606, height: 340 })
|
|
200
|
+
})
|
|
201
|
+
it("returns an even rect by reference", () => {
|
|
202
|
+
const r = { left: 0, top: 1314, width: 1080, height: 606 }
|
|
203
|
+
expect(evenVideoOverlayRect(r)).toBe(r)
|
|
204
|
+
})
|
|
205
|
+
it("keeps a stack's join exact: both tops move by the same pixel", () => {
|
|
206
|
+
for (const [c, a, b] of SHAPE_TABLE) {
|
|
207
|
+
const r = stack("stack-whole", c, a, b)
|
|
208
|
+
const top = evenVideoOverlayRect(r.top)
|
|
209
|
+
const bottom = evenVideoOverlayRect(r.bottom)
|
|
210
|
+
expect(top.top + top.height).toBe(bottom.top)
|
|
211
|
+
expect(top.top % 2).toBe(0)
|
|
212
|
+
}
|
|
213
|
+
})
|
|
214
|
+
it("16:9 above 1:1 on 9:16 draws at 116 and 722", () => {
|
|
215
|
+
const r = stack("stack-whole", { w: 1080, h: 1920 }, 16 / 9, 1)
|
|
216
|
+
expect([evenVideoOverlayRect(r.top).top, evenVideoOverlayRect(r.bottom).top]).toEqual([116, 722])
|
|
217
|
+
})
|
|
218
|
+
})
|
|
219
|
+
|
|
220
|
+
describe("firstVideoLayerIndex — the lowest video layer by render order", () => {
|
|
221
|
+
it("skips image layers and follows zIndex", () => {
|
|
222
|
+
const layers: VideoOverlayLayerInput[] = [
|
|
223
|
+
{ imageUrl: I, start: 0, slot: 1 },
|
|
224
|
+
{ videoUrl: V, start: 0, slot: 2, zIndex: 50 },
|
|
225
|
+
{ videoUrl: V, start: 0, slot: 3 },
|
|
226
|
+
]
|
|
227
|
+
expect(firstVideoLayerIndex(layers)).toBe(2)
|
|
228
|
+
expect(firstVideoLayerIndex(layers.slice(0, 2))).toBe(1)
|
|
229
|
+
})
|
|
230
|
+
it("-1 with no video layer, and for anything that is not a list", () => {
|
|
231
|
+
expect(firstVideoLayerIndex([imageLayer, null, undefined])).toBe(-1)
|
|
232
|
+
expect(firstVideoLayerIndex([])).toBe(-1)
|
|
233
|
+
expect(firstVideoLayerIndex(null)).toBe(-1)
|
|
234
|
+
})
|
|
235
|
+
})
|
|
236
|
+
|
|
237
|
+
describe("expandVideoOverlayLayout — a layout writes the boxes", () => {
|
|
238
|
+
it("video-bottom writes the base box", () =>
|
|
239
|
+
expect(expandVideoOverlayLayout({ layout: "video-bottom", outputAspect: "9:16", layers: [] }).baseBox).toEqual({ anchor: "bottom", x: 0, y: 0, width: 100, fit: "contain" }))
|
|
240
|
+
it("video-top writes the base box", () =>
|
|
241
|
+
expect(expandVideoOverlayLayout({ layout: "video-top", outputAspect: "9:16", layers: [] }).baseBox).toEqual({ anchor: "top", x: 0, y: 0, width: 100, fit: "contain" }))
|
|
242
|
+
it("pip puts the first video in its corner", () =>
|
|
243
|
+
expect(expandVideoOverlayLayout({ layout: "pip", layers: [{ videoUrl: V, start: 0, corner: "top-left" }] }).layers[0]).toMatchObject({
|
|
244
|
+
anchor: "top-left",
|
|
245
|
+
x: 4,
|
|
246
|
+
y: 4,
|
|
247
|
+
width: 30,
|
|
248
|
+
fit: "contain",
|
|
249
|
+
animate: false,
|
|
250
|
+
}))
|
|
251
|
+
it("an explicit base box wins over the layout", () =>
|
|
252
|
+
expect(expandVideoOverlayLayout({ layout: "video-bottom", baseBox: BOX, layers: [] }).baseBox).toEqual(BOX))
|
|
253
|
+
|
|
254
|
+
it("pip defaults to bottom-right, 30 % wide, 4 % in, and replaces the layer's box, height and preset tag", () => {
|
|
255
|
+
expect([VIDEO_OVERLAY_PIP_WIDTH, VIDEO_OVERLAY_PIP_INSET]).toEqual([30, 4])
|
|
256
|
+
const layer: VideoOverlayLayerInput = {
|
|
257
|
+
videoUrl: V, start: 1, end: 9, slot: 2, sound: { volume: 0.5 }, opacity: 0.8,
|
|
258
|
+
preset: "card", anchor: "center", x: 0, y: -4, width: 78, height: 60, fit: "cover", animate: true,
|
|
259
|
+
}
|
|
260
|
+
const out = expandVideoOverlayLayout({ layout: "pip", layers: [imageLayer, layer] })
|
|
261
|
+
expect(out.layers[0]).toBe(imageLayer)
|
|
262
|
+
expect(out.layers[1]).toEqual({
|
|
263
|
+
videoUrl: V, start: 1, end: 9, slot: 2, sound: { volume: 0.5 }, opacity: 0.8,
|
|
264
|
+
anchor: "bottom-right", x: -4, y: -4, width: 30, fit: "contain", animate: false,
|
|
265
|
+
})
|
|
266
|
+
expect(out.baseBox).toBeUndefined()
|
|
267
|
+
})
|
|
268
|
+
it("pip places the lowest video layer only", () => {
|
|
269
|
+
const layers: VideoOverlayLayerInput[] = [{ videoUrl: V, start: 0, slot: 1, zIndex: 9 }, { videoUrl: V, start: 0, slot: 2 }]
|
|
270
|
+
const out = expandVideoOverlayLayout({ layout: "pip", layers })
|
|
271
|
+
expect(out.layers[0]).toBe(layers[0])
|
|
272
|
+
expect(out.layers[1]).toMatchObject({ anchor: "bottom-right", width: 30 })
|
|
273
|
+
})
|
|
274
|
+
it("stack layouts leave every box unset and turn the first video layer's animation off", () => {
|
|
275
|
+
for (const layout of ["stack-whole", "stack-filled"] as const) {
|
|
276
|
+
const layers: VideoOverlayLayerInput[] = [imageLayer, { videoUrl: V, start: 0, animate: true }]
|
|
277
|
+
const out = expandVideoOverlayLayout({ layout, outputAspect: "9:16", layers })
|
|
278
|
+
expect(out.baseBox).toBeUndefined()
|
|
279
|
+
expect(out.layers[0]).toBe(imageLayer)
|
|
280
|
+
expect(out.layers[1]).toEqual({ videoUrl: V, start: 0, animate: false })
|
|
281
|
+
}
|
|
282
|
+
})
|
|
283
|
+
it("an explicit base box gets the layer's trailing defaults (x 0, y 0, fit contain); a partial one is left for the validator", () => {
|
|
284
|
+
expect(expandVideoOverlayLayout({ baseBox: { anchor: "bottom", width: 100 }, layers: [] }).baseBox).toEqual({ anchor: "bottom", width: 100, x: 0, y: 0, fit: "contain" })
|
|
285
|
+
expect(expandVideoOverlayLayout({ baseBox: { anchor: "top", width: 50, height: null }, layers: [] }).baseBox).toEqual({ anchor: "top", width: 50, x: 0, y: 0, fit: "contain" })
|
|
286
|
+
const partial = { width: 50 }
|
|
287
|
+
expect(expandVideoOverlayLayout({ baseBox: partial, layers: [] }).baseBox).toBe(partial)
|
|
288
|
+
})
|
|
289
|
+
it("returns the request by reference when there is nothing to write, and is idempotent", () => {
|
|
290
|
+
const plain = { layers: [imageLayer], outputAspect: "9:16" }
|
|
291
|
+
expect(expandVideoOverlayLayout(plain)).toBe(plain)
|
|
292
|
+
const unknown = { layout: "stack", layers: [videoLayer] }
|
|
293
|
+
expect(expandVideoOverlayLayout(unknown)).toBe(unknown)
|
|
294
|
+
const noVideo = { layout: "pip", layers: [imageLayer] }
|
|
295
|
+
expect(expandVideoOverlayLayout(noVideo)).toBe(noVideo)
|
|
296
|
+
for (const layout of VIDEO_OVERLAY_LAYOUT_IDS) {
|
|
297
|
+
const once = expandVideoOverlayLayout({ layout, outputAspect: "9:16", layers: [imageLayer, { videoUrl: V, start: 0, corner: "top-right" }] })
|
|
298
|
+
expect(expandVideoOverlayLayout(once)).toBe(once)
|
|
299
|
+
}
|
|
300
|
+
})
|
|
301
|
+
it("never mutates its input", () => {
|
|
302
|
+
const layer = Object.freeze({ videoUrl: V, start: 0, animate: true })
|
|
303
|
+
const req = Object.freeze({ layout: "pip", baseBox: Object.freeze({ anchor: "bottom", width: 100 }), layers: Object.freeze([layer]) })
|
|
304
|
+
const out = expandVideoOverlayLayout(req)
|
|
305
|
+
expect(out).not.toBe(req)
|
|
306
|
+
expect(req.layers[0]).toEqual({ videoUrl: V, start: 0, animate: true })
|
|
307
|
+
expect(req.baseBox).toEqual({ anchor: "bottom", width: 100 })
|
|
308
|
+
})
|
|
309
|
+
})
|
|
310
|
+
|
|
311
|
+
describe("validateVideoOverlayRequest — the base box and layouts", () => {
|
|
312
|
+
it("refuses a stack with no aspect", () => expect(codeOf({ layout: "stack-whole", layers: [videoLayer] })).toBe("layout_needs_aspect"))
|
|
313
|
+
it("refuses a stack with no video layer", () => expect(codeOf({ layout: "stack-whole", outputAspect: "9:16", layers: [imageLayer] })).toBe("layout_needs_video_layer"))
|
|
314
|
+
it("refuses a base box with no aspect", () => expect(codeOf({ baseBox: BOX, layers: [imageLayer] })).toBe("base_box_needs_aspect"))
|
|
315
|
+
|
|
316
|
+
it("the three codes are in the list", () => {
|
|
317
|
+
expect(VIDEO_OVERLAY_ERROR_CODES).toEqual(expect.arrayContaining(["base_box_needs_aspect", "layout_needs_aspect", "layout_needs_video_layer"]))
|
|
318
|
+
})
|
|
319
|
+
it("each layout's needs, and nothing more", () => {
|
|
320
|
+
expect(codeOf({ layout: "pip", layers: [videoLayer] })).toBe("ok")
|
|
321
|
+
expect(codeOf({ layout: "pip", outputAspect: "9:16", layers: [imageLayer] })).toBe("layout_needs_video_layer")
|
|
322
|
+
expect(codeOf({ layout: "video-bottom", layers: [imageLayer] })).toBe("layout_needs_aspect")
|
|
323
|
+
expect(codeOf({ layout: "video-top", outputAspect: "9:16", layers: [imageLayer] })).toBe("ok")
|
|
324
|
+
expect(codeOf({ layout: "stack-filled", outputAspect: "1:1", layers: [imageLayer, videoLayer] })).toBe("ok")
|
|
325
|
+
expect(codeOf({ baseBox: BOX, outputAspect: "4:5", layers: [imageLayer] })).toBe("ok")
|
|
326
|
+
})
|
|
327
|
+
it("a base box follows the layer rule: anchor and width, every present field in range", () => {
|
|
328
|
+
const fail = (baseBox: unknown) => validateVideoOverlayRequest({ outputAspect: "9:16", layers: [imageLayer], baseBox: baseBox as VideoOverlayBox }) as VideoOverlayIssue
|
|
329
|
+
const incomplete = fail({ width: 50 })
|
|
330
|
+
expect(incomplete).toEqual({ ok: false, code: "incomplete_box", params: { field: "baseBox" } })
|
|
331
|
+
expect(formatVideoOverlayError(incomplete)).toBe("baseBox needs an anchor and a width")
|
|
332
|
+
expect(fail({}).code).toBe("incomplete_box")
|
|
333
|
+
expect(fail("bottom").code).toBe("incomplete_box")
|
|
334
|
+
const wide = fail({ anchor: "bottom", width: 101 })
|
|
335
|
+
expect(wide).toEqual({ ok: false, code: "field_out_of_bounds", params: { field: "baseBox.width", allowed: "1..100" } })
|
|
336
|
+
expect(formatVideoOverlayError(wide)).toBe("baseBox.width is out of range (allowed: 1..100)")
|
|
337
|
+
expect(fail({ anchor: "middle", width: 50 }).params.field).toBe("baseBox.anchor")
|
|
338
|
+
expect(fail({ anchor: "bottom", width: 50, fit: "stretch" }).params.field).toBe("baseBox.fit")
|
|
339
|
+
expect(validateVideoOverlayRequest({ outputAspect: "9:16", layers: [imageLayer], baseBox: { anchor: "bottom", width: 50, height: null } })).toEqual({ ok: true })
|
|
340
|
+
})
|
|
341
|
+
it("an unknown layout is refused, not ignored", () => {
|
|
342
|
+
const r = validateVideoOverlayRequest({ outputAspect: "9:16", layers: [videoLayer], layout: "stack" }) as VideoOverlayIssue
|
|
343
|
+
expect(r).toEqual({ ok: false, code: "field_out_of_bounds", params: { field: "layout", allowed: VIDEO_OVERLAY_LAYOUT_IDS.join(", ") } })
|
|
344
|
+
})
|
|
345
|
+
it("an empty layout reads as absent, like null", () => {
|
|
346
|
+
expect(codeOf({ outputAspect: "9:16", layers: [imageLayer], layout: "" })).toBe("ok")
|
|
347
|
+
expect(codeOf({ layers: [imageLayer], layout: null })).toBe("ok")
|
|
348
|
+
})
|
|
349
|
+
it("a stack layout with a base box is refused: the stack places the base itself", () => {
|
|
350
|
+
for (const layout of ["stack-whole", "stack-filled"] as const) {
|
|
351
|
+
const r = validateVideoOverlayRequest({ layout, baseBox: BOX, outputAspect: "9:16", layers: [videoLayer] }) as VideoOverlayIssue
|
|
352
|
+
expect(r).toEqual({ ok: false, code: "layout_conflicts_base_box", params: { layout } })
|
|
353
|
+
expect(formatVideoOverlayError(r)).toBe("A stack layout places the base itself — remove baseBox or choose Custom")
|
|
354
|
+
}
|
|
355
|
+
expect(VIDEO_OVERLAY_ERROR_CODES).toContain("layout_conflicts_base_box")
|
|
356
|
+
})
|
|
357
|
+
it("the edge layouts and pip still take an explicit base box", () => {
|
|
358
|
+
for (const layout of ["video-bottom", "video-top", "pip"] as const) {
|
|
359
|
+
expect(codeOf({ layout, baseBox: BOX, outputAspect: "9:16", layers: [videoLayer] })).toBe("ok")
|
|
360
|
+
}
|
|
361
|
+
})
|
|
362
|
+
it("renders the three refusals in English", () => {
|
|
363
|
+
const text = (body: VideoOverlayValidationInput) => formatVideoOverlayError(validateVideoOverlayRequest(body) as VideoOverlayIssue)
|
|
364
|
+
expect(text({ baseBox: BOX, layers: [imageLayer] })).toBe("baseBox needs an outputAspect")
|
|
365
|
+
expect(text({ layout: "stack-whole", layers: [videoLayer] })).toBe("layout stack-whole needs an outputAspect")
|
|
366
|
+
expect(text({ layout: "pip", layers: [imageLayer] })).toBe("layout pip needs a video layer — set videoUrl on a layer or connect a video to a layer's handle")
|
|
367
|
+
})
|
|
368
|
+
it("the verdict is the same before and after the layout expansion", () => {
|
|
369
|
+
const cases: VideoOverlayValidationInput[] = [
|
|
370
|
+
{ layout: "video-bottom", layers: [imageLayer] },
|
|
371
|
+
{ layout: "video-top", outputAspect: "9:16", layers: [imageLayer] },
|
|
372
|
+
{ layout: "stack-whole", layers: [videoLayer] },
|
|
373
|
+
{ layout: "stack-filled", outputAspect: "9:16", layers: [imageLayer] },
|
|
374
|
+
{ layout: "pip", layers: [imageLayer] },
|
|
375
|
+
{ layout: "pip", layers: [{ videoUrl: V, start: 0, sound: { volume: 2 } }] },
|
|
376
|
+
{ layout: "video-bottom", baseBox: { width: 50 }, outputAspect: "9:16", layers: [imageLayer] },
|
|
377
|
+
{ baseBox: { anchor: "bottom", width: 100 }, layers: [imageLayer] },
|
|
378
|
+
{ baseBox: { anchor: "bottom", width: 100 }, outputAspect: "9:16", layers: [imageLayer] },
|
|
379
|
+
{ layout: "stack", outputAspect: "9:16", layers: [videoLayer] },
|
|
380
|
+
{ layout: "stack-whole", baseBox: { anchor: "bottom", width: 100 }, outputAspect: "9:16", layers: [videoLayer] },
|
|
381
|
+
{ layout: "stack-filled", baseBox: { width: 50 }, layers: [imageLayer] },
|
|
382
|
+
{ layout: "", outputAspect: "9:16", layers: [imageLayer] },
|
|
383
|
+
// A malformed first video layer is refused before the expansion, so it must be refused after it too:
|
|
384
|
+
// the layout never repairs a layer the validator would refuse.
|
|
385
|
+
...malformedFirstVideoLayers.map((layer) => ({ layout: "pip", layers: [imageLayer, layer] })),
|
|
386
|
+
...malformedFirstVideoLayers.map((layer) => ({ layout: "stack-whole", outputAspect: "9:16", layers: [layer] })),
|
|
387
|
+
...malformedFirstVideoLayers.map((layer) => ({ layout: "stack-filled", outputAspect: "9:16", layers: [layer] })),
|
|
388
|
+
]
|
|
389
|
+
for (const body of cases) {
|
|
390
|
+
const expanded = expandVideoOverlayLayout({ ...body, layers: body.layers ?? [] })
|
|
391
|
+
expect([body, validateVideoOverlayRequest(expanded)]).toEqual([body, validateVideoOverlayRequest(body)])
|
|
392
|
+
}
|
|
393
|
+
})
|
|
394
|
+
it("a first video layer the validator refuses is left as it is (by reference), for every layout that places it", () => {
|
|
395
|
+
for (const layer of malformedFirstVideoLayers) {
|
|
396
|
+
for (const layout of ["pip", "stack-whole", "stack-filled"] as const) {
|
|
397
|
+
const req = { layout, outputAspect: "9:16", layers: [layer] }
|
|
398
|
+
expect([layer, expandVideoOverlayLayout(req)]).toEqual([layer, req])
|
|
399
|
+
expect(expandVideoOverlayLayout(req)).toBe(req)
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
})
|
|
403
|
+
it("the same holds through the real assembly (pip with a 500 %-wide video layer)", () => {
|
|
404
|
+
const r = assembleVideoOverlayRequest({
|
|
405
|
+
videoUrl: "v",
|
|
406
|
+
data: { layout: "pip", layers: [{ start: 0, anchor: "center", width: 500 }] },
|
|
407
|
+
wiredImageUrls: [V],
|
|
408
|
+
wiredVideoSlots: new Set([1]),
|
|
409
|
+
})
|
|
410
|
+
const before = validateVideoOverlayRequest(r)
|
|
411
|
+
expect(before).toMatchObject({ ok: false, code: "field_out_of_bounds", slot: 1, params: { field: "width" } })
|
|
412
|
+
expect(validateVideoOverlayRequest(expandVideoOverlayLayout(r))).toEqual(before)
|
|
413
|
+
})
|
|
414
|
+
})
|
|
415
|
+
|
|
416
|
+
describe("assembleVideoOverlayRequest — baseBox and layout ride as stored", () => {
|
|
417
|
+
it("both reach the request; absent, they add no key", () => {
|
|
418
|
+
const r = assembleVideoOverlayRequest({ videoUrl: "v", data: { layers: [imageLayer], outputAspect: "9:16", baseBox: BOX, layout: "video-bottom" }, wiredImageUrls: [] })
|
|
419
|
+
expect(r).toMatchObject({ baseBox: BOX, layout: "video-bottom" })
|
|
420
|
+
const plain = assembleVideoOverlayRequest({ videoUrl: "v", data: { layers: [imageLayer], baseBox: null, layout: null }, wiredImageUrls: [] })
|
|
421
|
+
expect(Object.keys(plain).sort()).toEqual(["layers", "videoUrl"])
|
|
422
|
+
})
|
|
423
|
+
it("a malformed base box or an unknown layout reaches the validator, which refuses it on both engines", () => {
|
|
424
|
+
const box = assembleVideoOverlayRequest({ videoUrl: "v", data: { layers: [imageLayer], outputAspect: "9:16", baseBox: { width: 50 } }, wiredImageUrls: [] })
|
|
425
|
+
expect(validateVideoOverlayRequest(box)).toMatchObject({ ok: false, code: "incomplete_box", params: { field: "baseBox" } })
|
|
426
|
+
const layout = assembleVideoOverlayRequest({ videoUrl: "v", data: { layers: [imageLayer], outputAspect: "9:16", layout: "stack" }, wiredImageUrls: [] })
|
|
427
|
+
expect(validateVideoOverlayRequest(layout)).toMatchObject({ ok: false, code: "field_out_of_bounds", params: { field: "layout" } })
|
|
428
|
+
})
|
|
429
|
+
it("a stored base box loses its null fields — read as absent everywhere — so the REST route, which takes no null, accepts the canvas run", () => {
|
|
430
|
+
const stored = { anchor: "bottom", x: 0, y: null, width: 100, height: null, fit: "contain" } as const
|
|
431
|
+
const r = assembleVideoOverlayRequest({ videoUrl: "v", data: { layers: [imageLayer], outputAspect: "9:16", baseBox: stored }, wiredImageUrls: [] })
|
|
432
|
+
expect(r.baseBox).toEqual({ anchor: "bottom", x: 0, width: 100, fit: "contain" })
|
|
433
|
+
expect(validateVideoOverlayRequest(r)).toEqual(validateVideoOverlayRequest({ ...r, baseBox: stored }))
|
|
434
|
+
// A box with no null field rides by reference; a non-object still reaches the validator as stored.
|
|
435
|
+
expect(assembleVideoOverlayRequest({ videoUrl: "v", data: { layers: [imageLayer], baseBox: BOX }, wiredImageUrls: [] }).baseBox).toBe(BOX)
|
|
436
|
+
const odd = assembleVideoOverlayRequest({ videoUrl: "v", data: { layers: [imageLayer], outputAspect: "9:16", baseBox: "top" as never }, wiredImageUrls: [] })
|
|
437
|
+
expect(odd.baseBox).toBe("top")
|
|
438
|
+
expect(validateVideoOverlayRequest(odd)).toMatchObject({ ok: false, code: "incomplete_box", params: { field: "baseBox" } })
|
|
439
|
+
})
|
|
440
|
+
it("a node storing an empty layout assembles with no layout and validates", () => {
|
|
441
|
+
const r = assembleVideoOverlayRequest({ videoUrl: "v", data: { layers: [imageLayer], layout: "" }, wiredImageUrls: [] })
|
|
442
|
+
expect(Object.keys(r).sort()).toEqual(["layers", "videoUrl"])
|
|
443
|
+
expect(validateVideoOverlayRequest(r)).toEqual({ ok: true })
|
|
444
|
+
})
|
|
445
|
+
it("a wired video slot satisfies a layout that needs a video layer", () => {
|
|
446
|
+
const r = assembleVideoOverlayRequest({
|
|
447
|
+
videoUrl: "v",
|
|
448
|
+
data: { layers: [], outputAspect: "9:16", layout: "stack-whole" },
|
|
449
|
+
wiredImageUrls: [V],
|
|
450
|
+
wiredVideoSlots: new Set([1]),
|
|
451
|
+
})
|
|
452
|
+
expect(validateVideoOverlayRequest(r)).toEqual({ ok: true })
|
|
453
|
+
})
|
|
454
|
+
it("an assembled request expands and is still an assembled request (what the worker calls)", () => {
|
|
455
|
+
const r = assembleVideoOverlayRequest({ videoUrl: "v", data: { layers: [], layout: "pip" }, wiredImageUrls: [V], wiredVideoSlots: new Set([1]) })
|
|
456
|
+
const out: ExpandedVideoOverlayRequest = expandVideoOverlayLayout(r)
|
|
457
|
+
expect(out.layers[0]).toMatchObject({ videoUrl: V, slot: 1, anchor: "bottom-right", x: -4, y: -4, width: 30, animate: false })
|
|
458
|
+
expect(validateVideoOverlayRequest(out)).toEqual({ ok: true })
|
|
459
|
+
})
|
|
460
|
+
})
|
|
461
|
+
|
|
462
|
+
describe("videoOverlayCompositionKey — the base box and the layout", () => {
|
|
463
|
+
const base = { baseUrl: "https://x/base.mp4", sources: [I], data: { layers: [{ start: 1 }], outputAspect: "9:16" } }
|
|
464
|
+
const key = videoOverlayCompositionKey(base)
|
|
465
|
+
it("unset (absent, undefined, null, or an empty layout) keeps today's key", () => {
|
|
466
|
+
expect(videoOverlayCompositionKey({ ...base, data: { ...base.data, baseBox: null, layout: undefined } })).toBe(key)
|
|
467
|
+
expect(videoOverlayCompositionKey({ ...base, data: { ...base.data, layout: "" } })).toBe(key)
|
|
468
|
+
expect(JSON.parse(key)).toHaveLength(6)
|
|
469
|
+
})
|
|
470
|
+
it("changes with the base box and with the layout, and is canonical in the box's key order", () => {
|
|
471
|
+
const withBox = videoOverlayCompositionKey({ ...base, data: { ...base.data, baseBox: BOX } })
|
|
472
|
+
const withLayout = videoOverlayCompositionKey({ ...base, data: { ...base.data, layout: "video-bottom" } })
|
|
473
|
+
const otherBox = videoOverlayCompositionKey({ ...base, data: { ...base.data, baseBox: { ...BOX, y: 20 } } })
|
|
474
|
+
expect(new Set([key, withBox, withLayout, otherBox]).size).toBe(4)
|
|
475
|
+
const reordered: VideoOverlayBox = { fit: "cover", height: 40, width: 80, y: 10, x: 0, anchor: "center" }
|
|
476
|
+
expect(videoOverlayCompositionKey({ ...base, data: { ...base.data, baseBox: reordered } })).toBe(withBox)
|
|
477
|
+
})
|
|
478
|
+
it("a wired plan and a layout stay distinguishable", () => {
|
|
479
|
+
const plan = videoOverlayCompositionKey({ ...base, planLayers: [] })
|
|
480
|
+
const both = videoOverlayCompositionKey({ ...base, planLayers: [], data: { ...base.data, layout: "pip" } })
|
|
481
|
+
expect(new Set([key, plan, both]).size).toBe(3)
|
|
482
|
+
})
|
|
483
|
+
})
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* Where the base and every video layer draw — the ONE placement the worker
|
|
487
|
+
* renders with and the canvas preview draws with, so the two cannot disagree.
|
|
488
|
+
*/
|
|
489
|
+
describe("placeVideoOverlayVideos — the base and the video layers, as the render draws them", () => {
|
|
490
|
+
const PORTRAIT = { w: 1080, h: 1920 }
|
|
491
|
+
const layer = (box: Partial<VideoOverlayBox> = {}) => expandVideoOverlayLayer({ videoUrl: V, start: 0, anchor: "center", width: 50, ...box })
|
|
492
|
+
const at = (r: { readonly left: number; readonly top: number; readonly width: number; readonly height: number }) => [r.left, r.top, r.width, r.height]
|
|
493
|
+
|
|
494
|
+
it("stack-whole: the base above, the first video layer below, both contain — 16:9 over 1:1 on 9:16 at y 116 and 722", () => {
|
|
495
|
+
const p = placeVideoOverlayVideos({ canvas: PORTRAIT, layout: "stack-whole", baseAspect: 16 / 9, firstVideo: 1, videos: [{ index: 1, layer: layer(), aspect: 1 }] })
|
|
496
|
+
expect(p.basePlacement).toEqual({ drawn: { left: 0, top: 116, width: 1080, height: 606 }, fit: "contain" })
|
|
497
|
+
expect(p.layers.get(1)).toEqual({ drawn: { left: 0, top: 722, width: 1080, height: 1080 }, fit: "contain" })
|
|
498
|
+
})
|
|
499
|
+
it("stack-whole: two 16:9 come out at 1080x606, 354 px above and below", () => {
|
|
500
|
+
const p = placeVideoOverlayVideos({ canvas: PORTRAIT, layout: "stack-whole", baseAspect: 16 / 9, firstVideo: 0, videos: [{ index: 0, layer: layer(), aspect: 16 / 9 }] })
|
|
501
|
+
expect(at(p.basePlacement!.drawn)).toEqual([0, 354, 1080, 606])
|
|
502
|
+
expect(at(p.layers.get(0)!.drawn)).toEqual([0, 960, 1080, 606])
|
|
503
|
+
})
|
|
504
|
+
it("stack-filled: both halves cover, whatever fit the layer stores; its own box is not read", () => {
|
|
505
|
+
const p = placeVideoOverlayVideos({ canvas: PORTRAIT, layout: "stack-filled", baseAspect: 16 / 9, firstVideo: 0, videos: [{ index: 0, layer: layer({ fit: "contain", width: 10 }), aspect: 16 / 9 }] })
|
|
506
|
+
expect(p.basePlacement).toEqual({ drawn: { left: 0, top: 0, width: 1080, height: 960 }, fit: "cover" })
|
|
507
|
+
expect(p.layers.get(0)).toEqual({ drawn: { left: 0, top: 960, width: 1080, height: 960 }, fit: "cover" })
|
|
508
|
+
})
|
|
509
|
+
it("a base box (video-bottom) places the base flush on its edge at its own fit; a video layer draws at its own box, rounded to even", () => {
|
|
510
|
+
const req = expandVideoOverlayLayout({ layout: "video-bottom", layers: [] })
|
|
511
|
+
const p = placeVideoOverlayVideos({ canvas: PORTRAIT, baseBox: req.baseBox, baseAspect: 16 / 9, firstVideo: 0, videos: [{ index: 0, layer: layer({ anchor: "top-left", x: 3, y: 3, width: 33 }), aspect: 4 / 3 }] })
|
|
512
|
+
expect(p.basePlacement).toEqual({ drawn: { left: 0, top: 1314, width: 1080, height: 606 }, fit: "contain" })
|
|
513
|
+
const own = resolveVideoOverlayGeometry(PORTRAIT, layer({ anchor: "top-left", x: 3, y: 3, width: 33 }), 4 / 3).drawn
|
|
514
|
+
expect(p.layers.get(0)).toEqual({ drawn: evenVideoOverlayRect(own), fit: "contain" })
|
|
515
|
+
expect(p.layers.get(0)!.drawn.left % 2).toBe(0)
|
|
516
|
+
})
|
|
517
|
+
it("no layout and no base box: the base is not placed (drawn as before)", () => {
|
|
518
|
+
const p = placeVideoOverlayVideos({ canvas: PORTRAIT, baseAspect: 16 / 9, firstVideo: 0, videos: [{ index: 0, layer: layer(), aspect: 16 / 9 }] })
|
|
519
|
+
expect(p.basePlacement).toBeUndefined()
|
|
520
|
+
})
|
|
521
|
+
it("holds every aspect inside the bounds before placing (a 1:1000 sliver is placed as 1:8)", () => {
|
|
522
|
+
const args = (aspect: number) => ({ canvas: PORTRAIT, layout: "stack-whole", baseAspect: aspect, firstVideo: 0, videos: [{ index: 0, layer: layer(), aspect }] })
|
|
523
|
+
expect(placeVideoOverlayVideos(args(1 / 1000))).toEqual(placeVideoOverlayVideos(args(1 / 8)))
|
|
524
|
+
expect(placeVideoOverlayVideos(args(Number.NaN))).toEqual(placeVideoOverlayVideos(args(1)))
|
|
525
|
+
})
|
|
526
|
+
it("a stack whose first video layer is not among the videos is a caller bug", () => {
|
|
527
|
+
expect(() => placeVideoOverlayVideos({ canvas: PORTRAIT, layout: "stack-whole", baseAspect: 1, firstVideo: 2, videos: [] })).toThrow(/stacked layer 2/)
|
|
528
|
+
})
|
|
529
|
+
})
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest"
|
|
2
|
+
import {
|
|
3
|
+
VIDEO_OVERLAY_PRICING,
|
|
4
|
+
VIDEO_OVERLAY_REMEASURE_SLACK_SEC,
|
|
5
|
+
videoOverlayBaseTooLong,
|
|
6
|
+
videoOverlayCreditId,
|
|
7
|
+
videoOverlayVideoUnits,
|
|
8
|
+
} from "../credit-estimators/video-overlay.js"
|
|
9
|
+
import { VIDEO_OVERLAY_VIDEO_MAX_BASE_SEC } from "../video-overlay.js"
|
|
10
|
+
|
|
11
|
+
describe("Video Overlay pricing", () => {
|
|
12
|
+
it("an image-only run is the flat row; a run with a video layer is the per-5-second row", () => {
|
|
13
|
+
expect(videoOverlayCreditId(false)).toBe("video-overlay")
|
|
14
|
+
expect(videoOverlayCreditId(true)).toBe("video-overlay:video")
|
|
15
|
+
expect(VIDEO_OVERLAY_PRICING.IMAGE_CREDIT_ID).toBe("video-overlay")
|
|
16
|
+
expect(VIDEO_OVERLAY_PRICING.VIDEO_CREDIT_ID).toBe("video-overlay:video")
|
|
17
|
+
expect(VIDEO_OVERLAY_PRICING.UNIT_SEC).toBe(5)
|
|
18
|
+
expect(VIDEO_OVERLAY_PRICING.MAX_BASE_SEC).toBe(VIDEO_OVERLAY_VIDEO_MAX_BASE_SEC)
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it("one unit per started 5 seconds of the base, at least one", () => {
|
|
22
|
+
expect(videoOverlayVideoUnits(0.5)).toBe(1)
|
|
23
|
+
expect(videoOverlayVideoUnits(5)).toBe(1)
|
|
24
|
+
expect(videoOverlayVideoUnits(5.5)).toBe(2)
|
|
25
|
+
expect(videoOverlayVideoUnits(10)).toBe(2)
|
|
26
|
+
expect(videoOverlayVideoUnits(23)).toBe(5)
|
|
27
|
+
expect(videoOverlayVideoUnits(60)).toBe(12)
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
it("a cut a hair past a whole second is priced as that second (the clip rule)", () => {
|
|
31
|
+
expect(videoOverlayVideoUnits(10.012)).toBe(2)
|
|
32
|
+
expect(videoOverlayVideoUnits(60.04)).toBe(12)
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it("an unknown length is quoted at the 60 s cap — 12 units, never below a run", () => {
|
|
36
|
+
expect(videoOverlayVideoUnits(undefined)).toBe(12)
|
|
37
|
+
expect(videoOverlayVideoUnits(null)).toBe(12)
|
|
38
|
+
expect(videoOverlayVideoUnits(Number.NaN)).toBe(12)
|
|
39
|
+
expect(videoOverlayVideoUnits(0)).toBe(12)
|
|
40
|
+
expect(videoOverlayVideoUnits(-3)).toBe(12)
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
it("a length past the cap counts the cap (such a base is refused before anything is reserved)", () => {
|
|
44
|
+
expect(videoOverlayVideoUnits(61)).toBe(12)
|
|
45
|
+
expect(videoOverlayVideoUnits(600)).toBe(12)
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it("the cap reads the priced seconds: 60.04 s is in, 60.06 s and 61 s are out", () => {
|
|
49
|
+
expect(videoOverlayBaseTooLong(10)).toBe(false)
|
|
50
|
+
expect(videoOverlayBaseTooLong(60)).toBe(false)
|
|
51
|
+
expect(videoOverlayBaseTooLong(60.04)).toBe(false)
|
|
52
|
+
expect(videoOverlayBaseTooLong(60.06)).toBe(true)
|
|
53
|
+
expect(videoOverlayBaseTooLong(61)).toBe(true)
|
|
54
|
+
})
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
describe("the worker's re-measure slack", () => {
|
|
58
|
+
it("is half a second, on the seconds", () => {
|
|
59
|
+
expect(VIDEO_OVERLAY_REMEASURE_SLACK_SEC).toBe(0.5)
|
|
60
|
+
})
|
|
61
|
+
})
|