forked from longtao.wu/droboticflow
104 lines
3.8 KiB
JavaScript
104 lines
3.8 KiB
JavaScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import {
|
|
buildBrowserPlayableVideoURL,
|
|
isObjectStorageContentURL,
|
|
isHumanEvidenceContentURL,
|
|
isPackageContentURL,
|
|
isRunArtifactContentURL,
|
|
isSourceDataContentURL,
|
|
} from "../../src/lib/video-preview.js";
|
|
|
|
test("recognizes source data content urls", () => {
|
|
assert.equal(
|
|
isSourceDataContentURL("/api/source-data/collections/run-1/BJ_001/content?relativePath=DJI_001%2FDJI_0001_D.mp4"),
|
|
true,
|
|
);
|
|
assert.equal(isSourceDataContentURL("https://example.com/video.mp4"), false);
|
|
});
|
|
|
|
test("recognizes package content urls", () => {
|
|
assert.equal(
|
|
isPackageContentURL("/api/packages/run-1/DJI_0001_D_clip001_package/content?relativePath=DJI_0001_D_clip001.mp4"),
|
|
true,
|
|
);
|
|
assert.equal(isPackageContentURL("https://example.com/video.mp4"), false);
|
|
});
|
|
|
|
test("recognizes object storage content urls", () => {
|
|
assert.equal(
|
|
isObjectStorageContentURL(
|
|
"/api/object-storage/content?connectionId=storage-1&bucket=datastorage&key=demo%2Fvideo.mp4",
|
|
),
|
|
true,
|
|
);
|
|
assert.equal(isObjectStorageContentURL("https://example.com/video.mp4"), false);
|
|
});
|
|
|
|
test("recognizes run artifact content urls", () => {
|
|
assert.equal(isRunArtifactContentURL("/api/runs/run-1/artifacts/artifact-video/content"), true);
|
|
assert.equal(isRunArtifactContentURL("/api/runs/run-1/lineage"), false);
|
|
assert.equal(isRunArtifactContentURL("https://example.com/video.mp4"), false);
|
|
});
|
|
|
|
test("recognizes role-scoped human evidence content urls", () => {
|
|
assert.equal(
|
|
isHumanEvidenceContentURL("/api/plugins/human-loop/items/item-1/evidence/headpose-render/content"),
|
|
true,
|
|
);
|
|
assert.equal(isHumanEvidenceContentURL("/api/plugins/human-loop/items/item-1"), false);
|
|
});
|
|
|
|
test("adds browser transcode flag for source data video previews", () => {
|
|
assert.equal(
|
|
buildBrowserPlayableVideoURL(
|
|
"/api/source-data/collections/run-1/BJ_001/content?relativePath=DJI_001%2FDJI_0001_D.mp4",
|
|
),
|
|
"/api/source-data/collections/run-1/BJ_001/content?relativePath=DJI_001%2FDJI_0001_D.mp4&transcode=browser",
|
|
);
|
|
});
|
|
|
|
test("adds browser transcode flag for package video previews", () => {
|
|
assert.equal(
|
|
buildBrowserPlayableVideoURL(
|
|
"/api/packages/run-1/DJI_0001_D_clip001_package/content?relativePath=DJI_0001_D_clip001.mp4",
|
|
),
|
|
"/api/packages/run-1/DJI_0001_D_clip001_package/content?relativePath=DJI_0001_D_clip001.mp4&transcode=browser",
|
|
);
|
|
});
|
|
|
|
test("adds browser transcode flag for object storage video previews", () => {
|
|
assert.equal(
|
|
buildBrowserPlayableVideoURL(
|
|
"/api/object-storage/content?connectionId=storage-1&bucket=datastorage&key=demo%2Fvideo.mp4",
|
|
),
|
|
"/api/object-storage/content?connectionId=storage-1&bucket=datastorage&key=demo%2Fvideo.mp4&transcode=browser",
|
|
);
|
|
});
|
|
|
|
test("adds browser transcode flag for run artifact video previews", () => {
|
|
assert.equal(
|
|
buildBrowserPlayableVideoURL("/api/runs/run-1/artifacts/artifact-video/content"),
|
|
"/api/runs/run-1/artifacts/artifact-video/content?transcode=browser",
|
|
);
|
|
});
|
|
|
|
test("adds browser transcode flag for reviewed prelabel evidence", () => {
|
|
const url = "/api/plugins/human-loop/items/item-1/evidence/headpose-render/content";
|
|
assert.equal(buildBrowserPlayableVideoURL(url), `${url}?transcode=browser`);
|
|
});
|
|
|
|
test("does not duplicate browser transcode flag", () => {
|
|
assert.equal(
|
|
buildBrowserPlayableVideoURL(
|
|
"/api/source-data/collections/run-1/BJ_001/content?relativePath=DJI_001%2FDJI_0001_D.mp4&transcode=browser",
|
|
),
|
|
"/api/source-data/collections/run-1/BJ_001/content?relativePath=DJI_001%2FDJI_0001_D.mp4&transcode=browser",
|
|
);
|
|
});
|
|
|
|
test("leaves non source data urls untouched", () => {
|
|
assert.equal(buildBrowserPlayableVideoURL("https://example.com/preview.mp4"), "https://example.com/preview.mp4");
|
|
});
|