forked from longtao.wu/droboticflow
76 lines
2.6 KiB
JavaScript
76 lines
2.6 KiB
JavaScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import {
|
|
buildBrowserPlayableVideoURL,
|
|
isObjectStorageContentURL,
|
|
isPackageContentURL,
|
|
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("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("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");
|
|
});
|