Release Timeline Studio v0.6.0
This commit is contained in:
1 parent
2ebcf6a673
commit
fecf450037
57 files changed
+2790
-197
No files matched your search
@@ -1,5 +1,57 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
test("linked 2x source audio exports at half duration without doubling pitch", async ({ page }) => {
|
||||
test.setTimeout(180_000);
|
||||
await page.goto("/");
|
||||
const result = await page.evaluate(async () => {
|
||||
const { exportOfflineVideo, } = await import("/src/lib/offlineVideoExport.js");
|
||||
const { exportBrowserVideo } = await import("/src/lib/media.js");
|
||||
const canvas = document.createElement("canvas"); canvas.width = 160; canvas.height = 90;
|
||||
const context = canvas.getContext("2d"); context.fillStyle = "#18253d"; context.fillRect(0, 0, 160, 90);
|
||||
const image = canvas.toDataURL("image/png");
|
||||
const sampleRate = 48_000; const frames = sampleRate * 2;
|
||||
const wav = new ArrayBuffer(44 + frames * 2); const view = new DataView(wav);
|
||||
const write = (offset, value) => [...value].forEach((char, index) => view.setUint8(offset + index, char.charCodeAt(0)));
|
||||
write(0, "RIFF"); view.setUint32(4, 36 + frames * 2, true); write(8, "WAVEfmt ");
|
||||
view.setUint32(16, 16, true); view.setUint16(20, 1, true); view.setUint16(22, 1, true);
|
||||
view.setUint32(24, sampleRate, true); view.setUint32(28, sampleRate * 2, true);
|
||||
view.setUint16(32, 2, true); view.setUint16(34, 16, true); write(36, "data"); view.setUint32(40, frames * 2, true);
|
||||
for (let index = 0; index < frames; index += 1) view.setInt16(44 + index * 2, Math.sin(index / sampleRate * Math.PI * 2 * 440) * 12000, true);
|
||||
const sourceAudio = new Blob([wav], { type: "audio/wav" });
|
||||
const options = {
|
||||
imageSrc: image, visualType: "image", visualSegments: [{ id: "image", src: image, type: "image", duration: 1 }],
|
||||
voiceAudioSegments: [], sourceAudioBlob: sourceAudio,
|
||||
sourceAudioSegments: [{ id: "linked", start: 0, duration: 1, sourceStart: 0, sourceDuration: 2, playbackRate: 2 }],
|
||||
sourceAudioVolume: 1, musicBlob: null, text: "", captionSegments: [], duration: 1,
|
||||
ratio: { width: 16, height: 9 }, fitMode: "cover", filter: "none", captionsEnabled: false,
|
||||
captionSize: 12, captionStyle: {}, captionReferenceSize: { width: 160, height: 90 }, stickerSegments: [],
|
||||
exportSettings: { codec: "vp9", width: 160, height: 90, frameRate: 24, videoBitsPerSecond: 800_000 },
|
||||
};
|
||||
const [offline, compatibility] = await Promise.all([
|
||||
exportOfflineVideo(options),
|
||||
exportBrowserVideo(options),
|
||||
]);
|
||||
const audioContext = new AudioContext();
|
||||
const inspect = async (blob) => {
|
||||
const decoded = await audioContext.decodeAudioData((await blob.arrayBuffer()).slice(0));
|
||||
const samples = decoded.getChannelData(0); const start = Math.floor(samples.length * 0.2); const end = Math.floor(samples.length * 0.8);
|
||||
let crossings = 0;
|
||||
for (let index = start + 1; index < end; index += 1) if (samples[index - 1] <= 0 && samples[index] > 0) crossings += 1;
|
||||
return { duration: decoded.duration, frequency: crossings / ((end - start) / decoded.sampleRate), samples: decoded.length };
|
||||
};
|
||||
const inspected = { offline: await inspect(offline.blob), compatibility: await inspect(compatibility.blob) };
|
||||
await audioContext.close();
|
||||
return inspected;
|
||||
});
|
||||
for (const exported of [result.offline, result.compatibility]) {
|
||||
expect(exported.duration).toBeGreaterThan(0.9);
|
||||
expect(exported.duration).toBeLessThan(1.1);
|
||||
expect(exported.frequency).toBeGreaterThan(420);
|
||||
expect(exported.frequency).toBeLessThan(460);
|
||||
expect(exported.samples).toBeGreaterThan(40_000);
|
||||
}
|
||||
});
|
||||
|
||||
test("offline export restores enabled embedded video audio when no separated source track exists", async ({ page }) => {
|
||||
test.setTimeout(180_000);
|
||||
await page.goto("/");
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
const ONE_PIXEL_PNG = Buffer.from(
|
||||
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAusB9Y9ZQmcAAAAASUVORK5CYII=",
|
||||
"base64",
|
||||
);
|
||||
|
||||
function createSilentWav(durationSeconds = 2) {
|
||||
const sampleRate = 8_000;
|
||||
const sampleCount = Math.round(sampleRate * durationSeconds);
|
||||
const buffer = Buffer.alloc(44 + sampleCount * 2);
|
||||
buffer.write("RIFF", 0);
|
||||
buffer.writeUInt32LE(buffer.length - 8, 4);
|
||||
buffer.write("WAVEfmt ", 8);
|
||||
buffer.writeUInt32LE(16, 16);
|
||||
buffer.writeUInt16LE(1, 20);
|
||||
buffer.writeUInt16LE(1, 22);
|
||||
buffer.writeUInt32LE(sampleRate, 24);
|
||||
buffer.writeUInt32LE(sampleRate * 2, 28);
|
||||
buffer.writeUInt16LE(2, 32);
|
||||
buffer.writeUInt16LE(16, 34);
|
||||
buffer.write("data", 36);
|
||||
buffer.writeUInt32LE(sampleCount * 2, 40);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
test("mobile Music action opens direct clip properties and exposes real speed control", async ({ page }, testInfo) => {
|
||||
await page.setViewportSize({ width: 412, height: 915 });
|
||||
await page.addInitScript(() => {
|
||||
localStorage.clear();
|
||||
localStorage.setItem("ai-voiceover-ui-language", "zh");
|
||||
});
|
||||
await page.goto("/");
|
||||
|
||||
const input = page.locator('input[type="file"][multiple]');
|
||||
await input.setInputFiles({ name: "visual.png", mimeType: "image/png", buffer: ONE_PIXEL_PNG });
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(page.locator(".image-clip")).toBeVisible();
|
||||
|
||||
await page.getByText("媒体", { exact: true }).last().click();
|
||||
await input.setInputFiles({ name: "music-speed.wav", mimeType: "audio/wav", buffer: createSilentWav(2) });
|
||||
await page.getByRole("button", { name: "添加到音乐轨" }).click();
|
||||
|
||||
const musicClip = page.locator(".audio-clip.is-music").first();
|
||||
await expect(musicClip).toBeVisible();
|
||||
await musicClip.click();
|
||||
const clipActions = page.locator(".timeline-mobile-clip-actions");
|
||||
await expect(clipActions).toBeVisible();
|
||||
await clipActions.getByRole("button", { name: "音频" }).click();
|
||||
|
||||
const propertySheet = page.locator(".voice-panel.is-audio-clip-context");
|
||||
await expect(propertySheet).toBeVisible();
|
||||
await expect(page.locator(".mobile-sheet-nav strong")).toHaveText("音频片段属性");
|
||||
await expect(page.locator(".mobile-sheet-nav [role='tab']")).toHaveCount(0);
|
||||
await expect(propertySheet.getByText("播放速度", { exact: true })).toBeVisible();
|
||||
await expect(page.locator(".timeline-mobile-clip-actions")).toBeVisible();
|
||||
await expect(page.locator(".media-panel")).toBeHidden();
|
||||
|
||||
const durationBefore = await musicClip.locator(".audio-clip-duration").getAttribute("data-compact-duration");
|
||||
await propertySheet.getByRole("button", { name: "2×", exact: true }).click();
|
||||
await expect(propertySheet.locator(".audio-property-slider em").filter({ hasText: "2×" })).toBeVisible();
|
||||
await expect(musicClip.locator(".audio-clip-duration")).toHaveAttribute("data-compact-duration", "1.0s");
|
||||
expect(durationBefore).not.toBe("1.0s");
|
||||
await expect(page.locator(".timeline-mobile-clip-actions")).toBeVisible();
|
||||
await page.screenshot({ path: testInfo.outputPath("mobile-music-direct-properties-2x.png") });
|
||||
|
||||
await page.locator(".mobile-sheet-close").click();
|
||||
await expect(propertySheet).toBeHidden();
|
||||
await expect(page.locator(".timeline-mobile-clip-actions")).toBeVisible();
|
||||
});
|
||||
@@ -0,0 +1,32 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
test("mobile large-canvas close does not click through to the topbar", async ({ page }) => {
|
||||
await page.setViewportSize({ width: 412, height: 915 });
|
||||
await page.addInitScript(() => localStorage.setItem("ai-voiceover-ui-language", "zh"));
|
||||
await page.goto("/");
|
||||
|
||||
await page.getByRole("button", { name: "大画布预览与编辑" }).click();
|
||||
const dialog = page.getByRole("dialog", { name: "大画布编辑" });
|
||||
await expect(dialog).toBeVisible();
|
||||
|
||||
const closeButton = dialog.locator(".focus-preview-close");
|
||||
const closeBox = await closeButton.boundingBox();
|
||||
if (!closeBox) throw new Error("Large-canvas close button is unavailable");
|
||||
|
||||
const client = await page.context().newCDPSession(page);
|
||||
await client.send("Emulation.setTouchEmulationEnabled", { enabled: true, maxTouchPoints: 1 });
|
||||
const touchPoint = {
|
||||
id: 1,
|
||||
x: closeBox.x + closeBox.width / 2,
|
||||
y: closeBox.y + closeBox.height / 2,
|
||||
radiusX: 6,
|
||||
radiusY: 6,
|
||||
force: 1,
|
||||
};
|
||||
await client.send("Input.dispatchTouchEvent", { type: "touchStart", touchPoints: [touchPoint] });
|
||||
await expect(dialog).toBeVisible();
|
||||
await client.send("Input.dispatchTouchEvent", { type: "touchEnd", touchPoints: [] });
|
||||
|
||||
await expect(dialog).toBeHidden();
|
||||
await expect(page.locator(".settings-panel")).toHaveCount(0);
|
||||
});
|
||||
@@ -0,0 +1,57 @@
|
||||
import { execFileSync } from "node:child_process";
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
test("mobile linked source audio follows video speed and can be separated again after deletion", async ({ page }, testInfo) => {
|
||||
test.setTimeout(180_000);
|
||||
const videoPath = testInfo.outputPath("mobile-video-with-audio.webm");
|
||||
execFileSync("ffmpeg", [
|
||||
"-hide_banner", "-loglevel", "error", "-y",
|
||||
"-f", "lavfi", "-i", "color=c=#244b68:s=320x180:d=1.2",
|
||||
"-f", "lavfi", "-i", "sine=frequency=440:sample_rate=44100:duration=1.2",
|
||||
"-c:v", "libvpx-vp9", "-b:v", "300k", "-pix_fmt", "yuv420p", "-c:a", "libopus", "-shortest",
|
||||
videoPath,
|
||||
]);
|
||||
|
||||
await page.setViewportSize({ width: 412, height: 915 });
|
||||
await page.addInitScript(() => {
|
||||
localStorage.clear();
|
||||
localStorage.setItem("ai-voiceover-ui-language", "zh");
|
||||
});
|
||||
await page.goto("/");
|
||||
await page.locator('input[type="file"][multiple]').setInputFiles(videoPath);
|
||||
await page.keyboard.press("Escape");
|
||||
|
||||
const visualClip = page.locator(".image-clip").first();
|
||||
await expect(visualClip).toBeVisible();
|
||||
await expect(visualClip.locator(".image-clip-duration")).toHaveText("00:01");
|
||||
await visualClip.click();
|
||||
|
||||
const actionBar = page.locator(".timeline-mobile-clip-actions");
|
||||
const separateAudio = actionBar.getByText("分离音频", { exact: true });
|
||||
await expect(actionBar).toBeVisible();
|
||||
await expect(separateAudio).toBeVisible();
|
||||
await separateAudio.click();
|
||||
|
||||
await expect(page.locator(".source-track")).toBeVisible({ timeout: 120_000 });
|
||||
await expect(page.locator(".audio-clip.is-source").first()).toBeVisible({ timeout: 120_000 });
|
||||
await expect(actionBar.getByText("分离音频", { exact: true })).toHaveCount(0);
|
||||
await expect(visualClip).toBeVisible();
|
||||
|
||||
await visualClip.click();
|
||||
await actionBar.getByText("编辑", { exact: true }).click();
|
||||
await page.getByRole("tab", { name: "变速", exact: true }).click();
|
||||
await page.locator(".visual-speed-presets").getByText("2×", { exact: true }).click();
|
||||
await expect(page.locator(".visual-speed-summary")).toContainText("0.60s");
|
||||
await expect(page.locator(".visual-speed-hint")).toHaveText("画面原声已同步");
|
||||
await expect(page.locator(".audio-clip.is-source .audio-clip-duration")).toHaveText("00:00.60");
|
||||
|
||||
await page.locator(".mobile-sheet-close").click();
|
||||
const sourceClip = page.locator(".audio-clip.is-source");
|
||||
await sourceClip.click();
|
||||
await actionBar.locator("button.is-danger").click();
|
||||
await expect(sourceClip).toHaveCount(0);
|
||||
await expect(page.locator(".source-track")).toHaveCount(0);
|
||||
|
||||
await visualClip.click();
|
||||
await expect(actionBar.getByText("分离音频", { exact: true })).toBeVisible();
|
||||
});
|
||||
@@ -0,0 +1,50 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
test("mobile sticker clip exposes direct properties, copy, and delete actions", async ({ page }) => {
|
||||
await page.setViewportSize({ width: 412, height: 915 });
|
||||
await page.addInitScript(() => {
|
||||
localStorage.clear();
|
||||
localStorage.setItem("ai-voiceover-ui-language", "zh");
|
||||
});
|
||||
await page.goto("/");
|
||||
|
||||
await page.locator(".tool-rail").getByRole("button", { name: "贴纸" }).click();
|
||||
await page.getByRole("button", { name: "热度火焰" }).click();
|
||||
await page.getByRole("button", { name: "添加贴纸" }).click();
|
||||
|
||||
const stickerClip = page.locator(".sticker-segment");
|
||||
await expect(stickerClip).toBeVisible();
|
||||
await stickerClip.click();
|
||||
|
||||
const actions = page.locator(".timeline-mobile-clip-actions");
|
||||
await expect(actions).toBeVisible();
|
||||
await expect(actions.getByRole("button")).toHaveCount(4);
|
||||
await expect(actions.getByRole("button", { name: "返回" })).toBeVisible();
|
||||
await expect(actions.getByRole("button", { name: "属性" })).toBeVisible();
|
||||
await expect(actions.getByRole("button", { name: "复制" })).toBeVisible();
|
||||
await expect(actions.getByRole("button", { name: "删除" })).toBeVisible();
|
||||
await expect(actions.getByRole("button", { name: "分割" })).toHaveCount(0);
|
||||
|
||||
await actions.getByRole("button", { name: "属性" }).click();
|
||||
const properties = page.locator(".voice-panel.is-sticker-context");
|
||||
await expect(properties).toBeVisible();
|
||||
await expect(page.locator(".mobile-sheet-nav strong")).toHaveText("贴纸属性");
|
||||
await expect(page.locator(".mobile-sheet-nav [role='tab']")).toHaveCount(0);
|
||||
await expect(properties.getByText("不透明度", { exact: true })).toBeVisible();
|
||||
await expect(actions).toBeVisible();
|
||||
|
||||
await page.locator(".mobile-sheet-close").click();
|
||||
await expect(properties).toBeHidden();
|
||||
await expect(actions).toBeVisible();
|
||||
|
||||
await actions.getByRole("button", { name: "删除" }).click();
|
||||
await expect(stickerClip).toHaveCount(0);
|
||||
await expect(page.locator(".sticker-track")).toHaveCount(0);
|
||||
});
|
||||
|
||||
test("desktop sticker selection keeps the mobile action bar hidden", async ({ page }) => {
|
||||
await page.setViewportSize({ width: 1280, height: 900 });
|
||||
await page.addInitScript(() => localStorage.setItem("ai-voiceover-ui-language", "zh"));
|
||||
await page.goto("/");
|
||||
await expect(page.locator(".timeline-mobile-clip-actions")).toHaveCount(0);
|
||||
});
|
||||
@@ -0,0 +1,256 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
const ONE_PIXEL_PNG = Buffer.from(
|
||||
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAusB9Y9ZQmcAAAAASUVORK5CYII=",
|
||||
"base64",
|
||||
);
|
||||
|
||||
function createSilentWav(durationSeconds = 1) {
|
||||
const sampleRate = 8_000;
|
||||
const sampleCount = Math.round(sampleRate * durationSeconds);
|
||||
const buffer = Buffer.alloc(44 + sampleCount * 2);
|
||||
buffer.write("RIFF", 0);
|
||||
buffer.writeUInt32LE(buffer.length - 8, 4);
|
||||
buffer.write("WAVEfmt ", 8);
|
||||
buffer.writeUInt32LE(16, 16);
|
||||
buffer.writeUInt16LE(1, 20);
|
||||
buffer.writeUInt16LE(1, 22);
|
||||
buffer.writeUInt32LE(sampleRate, 24);
|
||||
buffer.writeUInt32LE(sampleRate * 2, 28);
|
||||
buffer.writeUInt16LE(2, 32);
|
||||
buffer.writeUInt16LE(16, 34);
|
||||
buffer.write("data", 36);
|
||||
buffer.writeUInt32LE(sampleCount * 2, 40);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
async function readTimelineState(page) {
|
||||
return page.evaluate(() => {
|
||||
const labels = Array.from(document.querySelectorAll(".ruler-tick.is-major"))
|
||||
.map((tick) => tick.textContent?.trim() || "")
|
||||
.filter(Boolean)
|
||||
.map((label) => {
|
||||
const [minutes, seconds] = label.split(":");
|
||||
return Number(minutes) * 60 + Number(seconds);
|
||||
})
|
||||
.filter(Number.isFinite)
|
||||
.sort((a, b) => a - b);
|
||||
const steps = labels.slice(1).map((value, index) => value - labels[index]).filter((value) => value > 0);
|
||||
return {
|
||||
currentTime: Number(document.querySelector(".scrubber")?.value || 0),
|
||||
labelStep: steps.length ? Math.min(...steps) : null,
|
||||
trackWidth: document.querySelector(".track-scroll")?.getBoundingClientRect().width || 0,
|
||||
scrollLeft: document.querySelector(".tracks")?.scrollLeft || 0,
|
||||
geometryTime: (() => {
|
||||
const track = document.querySelector(".track-scroll")?.getBoundingClientRect();
|
||||
const viewport = document.querySelector(".tracks")?.getBoundingClientRect();
|
||||
const duration = Number(document.querySelector(".scrubber")?.max || 0);
|
||||
if (!track || !viewport || !duration) return 0;
|
||||
return Math.max(0, Math.min(duration, ((viewport.left + viewport.width / 2 - track.left) / track.width) * duration));
|
||||
})(),
|
||||
zoomText: document.querySelector("[data-testid='timeline-zoom-readout']")?.textContent || "",
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
test("mobile pinch zoom keeps the visible frame and ruler scale stable on release", async ({ page }, testInfo) => {
|
||||
await page.setViewportSize({ width: 412, height: 915 });
|
||||
await page.addInitScript(() => localStorage.setItem("ai-voiceover-ui-language", "zh"));
|
||||
await page.goto("/");
|
||||
await page.locator('input[type="file"][multiple]').setInputFiles({
|
||||
name: "pinch-fixture.png",
|
||||
mimeType: "image/png",
|
||||
buffer: ONE_PIXEL_PNG,
|
||||
});
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(page.locator(".image-clip")).toBeVisible();
|
||||
|
||||
const tracks = page.locator(".tracks");
|
||||
await tracks.evaluate((element) => {
|
||||
element.scrollLeft = Math.min(120, element.scrollWidth - element.clientWidth);
|
||||
element.dispatchEvent(new Event("scroll", { bubbles: true }));
|
||||
});
|
||||
await page.waitForTimeout(80);
|
||||
|
||||
const box = await tracks.boundingBox();
|
||||
if (!box) throw new Error("Timeline tracks are not visible");
|
||||
const centerX = box.x + box.width / 2;
|
||||
const centerY = box.y + Math.min(60, box.height / 2);
|
||||
const cdp = await page.context().newCDPSession(page);
|
||||
await cdp.send("Emulation.setTouchEmulationEnabled", { enabled: true, maxTouchPoints: 2 });
|
||||
const touchPoint = (id, x) => ({ id, x, y: centerY, radiusX: 6, radiusY: 6, force: 1 });
|
||||
|
||||
const before = await readTimelineState(page);
|
||||
await page.screenshot({ path: testInfo.outputPath("01-before-pinch.png") });
|
||||
await cdp.send("Input.dispatchTouchEvent", {
|
||||
type: "touchStart",
|
||||
touchPoints: [touchPoint(1, centerX - 45), touchPoint(2, centerX + 45)],
|
||||
});
|
||||
const frameStates = [];
|
||||
for (let distance = 55; distance <= 105; distance += 10) {
|
||||
await cdp.send("Input.dispatchTouchEvent", {
|
||||
type: "touchMove",
|
||||
touchPoints: [touchPoint(1, centerX - distance), touchPoint(2, centerX + distance)],
|
||||
});
|
||||
await page.waitForTimeout(20);
|
||||
frameStates.push({ distance: distance * 2, state: await readTimelineState(page) });
|
||||
}
|
||||
const visibleBeforeRelease = await readTimelineState(page);
|
||||
await page.screenshot({ path: testInfo.outputPath("02-visible-before-release.png") });
|
||||
await cdp.send("Input.dispatchTouchEvent", { type: "touchEnd", touchPoints: [] });
|
||||
await page.waitForTimeout(100);
|
||||
const afterRelease = await readTimelineState(page);
|
||||
await page.screenshot({ path: testInfo.outputPath("03-after-release.png") });
|
||||
|
||||
expect(visibleBeforeRelease.trackWidth).toBeGreaterThan(before.trackWidth);
|
||||
expect(visibleBeforeRelease.trackWidth / before.trackWidth).toBeCloseTo(210 / 90, 1);
|
||||
for (const frame of frameStates) {
|
||||
expect(frame.state.trackWidth / before.trackWidth).toBeCloseTo(frame.distance / 90, 1);
|
||||
expect(frame.state.geometryTime).toBeCloseTo(before.geometryTime, 2);
|
||||
}
|
||||
expect(afterRelease.trackWidth).toBeCloseTo(visibleBeforeRelease.trackWidth, 0);
|
||||
expect(afterRelease.currentTime).toBeCloseTo(visibleBeforeRelease.currentTime, 2);
|
||||
expect(afterRelease.labelStep).toBe(before.labelStep);
|
||||
expect(afterRelease.labelStep).toBe(visibleBeforeRelease.labelStep);
|
||||
expect(afterRelease.zoomText).toBe(visibleBeforeRelease.zoomText);
|
||||
});
|
||||
|
||||
test("desktop timeline keeps its existing draggable playhead behavior", async ({ page }) => {
|
||||
await page.setViewportSize({ width: 1280, height: 900 });
|
||||
await page.addInitScript(() => localStorage.setItem("ai-voiceover-ui-language", "zh"));
|
||||
await page.goto("/");
|
||||
await expect(page.locator(".playhead")).toHaveCSS("cursor", "ew-resize");
|
||||
await expect(page.locator(".mobile-fixed-playhead")).toBeHidden();
|
||||
});
|
||||
|
||||
test("mobile trackpad wheel zoom uses pixels and does not jump when committed", async ({ page }) => {
|
||||
await page.setViewportSize({ width: 412, height: 915 });
|
||||
await page.addInitScript(() => localStorage.setItem("ai-voiceover-ui-language", "zh"));
|
||||
await page.goto("/");
|
||||
await page.locator('input[type="file"][multiple]').setInputFiles({
|
||||
name: "wheel-pinch-fixture.png",
|
||||
mimeType: "image/png",
|
||||
buffer: ONE_PIXEL_PNG,
|
||||
});
|
||||
await page.keyboard.press("Escape");
|
||||
const clip = page.locator(".image-clip");
|
||||
await expect(clip).toBeVisible();
|
||||
const box = await clip.boundingBox();
|
||||
if (!box) throw new Error("Timeline clip is unavailable");
|
||||
const before = await readTimelineState(page);
|
||||
const deltaY = -40;
|
||||
await clip.dispatchEvent("wheel", {
|
||||
deltaY,
|
||||
deltaX: 0,
|
||||
deltaMode: 0,
|
||||
ctrlKey: true,
|
||||
clientX: box.x + box.width / 2,
|
||||
clientY: box.y + box.height / 2,
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
});
|
||||
await page.waitForTimeout(32);
|
||||
const during = await readTimelineState(page);
|
||||
await page.waitForTimeout(260);
|
||||
const committed = await readTimelineState(page);
|
||||
|
||||
expect(during.trackWidth / before.trackWidth).toBeCloseTo(Math.exp(40 * 0.00056), 2);
|
||||
expect(committed.trackWidth).toBeCloseTo(during.trackWidth, 0);
|
||||
expect(committed.geometryTime).toBeCloseTo(before.geometryTime, 2);
|
||||
expect(committed.currentTime).toBeCloseTo(before.currentTime, 2);
|
||||
});
|
||||
|
||||
test("mobile pinch beginning on a voiceover never moves the timed clip", async ({ page }) => {
|
||||
await page.setViewportSize({ width: 412, height: 915 });
|
||||
await page.addInitScript(() => localStorage.setItem("ai-voiceover-ui-language", "zh"));
|
||||
await page.goto("/");
|
||||
const input = page.locator('input[type="file"][multiple]');
|
||||
await input.setInputFiles({
|
||||
name: "pinch-fixture.png",
|
||||
mimeType: "image/png",
|
||||
buffer: ONE_PIXEL_PNG,
|
||||
});
|
||||
await page.keyboard.press("Escape");
|
||||
await page.getByText("媒体", { exact: true }).last().click();
|
||||
await input.setInputFiles({
|
||||
name: "voice-pinch.wav",
|
||||
mimeType: "audio/wav",
|
||||
buffer: createSilentWav(),
|
||||
});
|
||||
await page.getByRole("button", { name: "添加到配音轨" }).click();
|
||||
|
||||
const clip = page.locator(".audio-clip:not(.is-source):not(.is-music)").first();
|
||||
await expect(clip).toBeVisible();
|
||||
const tracks = page.locator(".tracks");
|
||||
await page.getByRole("button", { name: "放大" }).click();
|
||||
await page.getByRole("button", { name: "放大" }).click();
|
||||
await page.waitForTimeout(180);
|
||||
await tracks.evaluate((element) => {
|
||||
element.scrollLeft = Math.min(80, element.scrollWidth - element.clientWidth);
|
||||
element.dispatchEvent(new Event("scroll", { bubbles: true }));
|
||||
});
|
||||
await page.waitForTimeout(80);
|
||||
const clipBox = await clip.boundingBox();
|
||||
const tracksBox = await tracks.boundingBox();
|
||||
if (!clipBox || !tracksBox) throw new Error("Voiceover timeline geometry is unavailable");
|
||||
const startLeft = await clip.evaluate((element) => element.style.left);
|
||||
const startWidth = await clip.evaluate((element) => element.style.width);
|
||||
const startState = await readTimelineState(page);
|
||||
const y = tracksBox.y + Math.min(62, tracksBox.height / 3);
|
||||
const firstX = tracksBox.x + tracksBox.width / 2 - 45;
|
||||
const secondX = Math.min(tracksBox.x + tracksBox.width - 12, firstX + 90);
|
||||
const cdp = await page.context().newCDPSession(page);
|
||||
await cdp.send("Emulation.setTouchEmulationEnabled", { enabled: true, maxTouchPoints: 2 });
|
||||
const touchPoint = (id, x) => ({ id, x, y, radiusX: 6, radiusY: 6, force: 1 });
|
||||
await cdp.send("Input.dispatchTouchEvent", {
|
||||
type: "touchStart",
|
||||
touchPoints: [touchPoint(1, firstX)],
|
||||
});
|
||||
await cdp.send("Input.dispatchTouchEvent", {
|
||||
type: "touchMove",
|
||||
touchPoints: [touchPoint(1, firstX + 8)],
|
||||
});
|
||||
await cdp.send("Input.dispatchTouchEvent", {
|
||||
type: "touchStart",
|
||||
touchPoints: [touchPoint(1, firstX + 8), touchPoint(2, secondX)],
|
||||
});
|
||||
const handoffState = await readTimelineState(page);
|
||||
const midpoint = (firstX + secondX) / 2;
|
||||
for (let progress = 0; progress <= 0.65; progress += 0.13) {
|
||||
await cdp.send("Input.dispatchTouchEvent", {
|
||||
type: "touchMove",
|
||||
touchPoints: [
|
||||
touchPoint(1, firstX + (midpoint - firstX) * progress),
|
||||
touchPoint(2, secondX + (midpoint - secondX) * progress),
|
||||
],
|
||||
});
|
||||
await page.waitForTimeout(18);
|
||||
}
|
||||
await page.waitForTimeout(32);
|
||||
const visibleBeforeRelease = {
|
||||
timeline: await readTimelineState(page),
|
||||
clip: await clip.boundingBox(),
|
||||
};
|
||||
await cdp.send("Input.dispatchTouchEvent", { type: "touchEnd", touchPoints: [] });
|
||||
await page.waitForTimeout(100);
|
||||
const afterRelease = {
|
||||
timeline: await readTimelineState(page),
|
||||
clip: await clip.boundingBox(),
|
||||
};
|
||||
await page.waitForTimeout(450);
|
||||
const afterMomentumWindow = {
|
||||
timeline: await readTimelineState(page),
|
||||
clip: await clip.boundingBox(),
|
||||
};
|
||||
|
||||
expect(visibleBeforeRelease.timeline.trackWidth).toBeLessThan(startState.trackWidth);
|
||||
expect(afterRelease.timeline.trackWidth).toBeCloseTo(visibleBeforeRelease.timeline.trackWidth, 0);
|
||||
expect(afterRelease.timeline.currentTime).toBeCloseTo(handoffState.currentTime, 2);
|
||||
expect(afterRelease.timeline.currentTime).toBeCloseTo(visibleBeforeRelease.timeline.currentTime, 2);
|
||||
expect(afterRelease.clip?.x).toBeCloseTo(visibleBeforeRelease.clip?.x || 0, 0);
|
||||
expect(afterRelease.clip?.width).toBeCloseTo(visibleBeforeRelease.clip?.width || 0, 0);
|
||||
expect(afterMomentumWindow.timeline.currentTime).toBeCloseTo(afterRelease.timeline.currentTime, 2);
|
||||
expect(afterMomentumWindow.clip?.x).toBeCloseTo(afterRelease.clip?.x || 0, 0);
|
||||
expect(await clip.evaluate((element) => element.style.left)).toBe(startLeft);
|
||||
expect(await clip.evaluate((element) => element.style.width)).toBe(startWidth);
|
||||
});
|
||||
@@ -0,0 +1,35 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
const ONE_PIXEL_PNG = Buffer.from(
|
||||
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAusB9Y9ZQmcAAAAASUVORK5CYII=",
|
||||
"base64",
|
||||
);
|
||||
|
||||
test("mobile Visuals lock blocks destructive clip actions until unlocked", async ({ page }) => {
|
||||
await page.setViewportSize({ width: 412, height: 915 });
|
||||
await page.addInitScript(() => localStorage.setItem("ai-voiceover-ui-language", "zh"));
|
||||
await page.goto("/");
|
||||
await page.locator('input[type="file"][multiple]').setInputFiles({
|
||||
name: "locked-visual.png",
|
||||
mimeType: "image/png",
|
||||
buffer: ONE_PIXEL_PNG,
|
||||
});
|
||||
await page.keyboard.press("Escape");
|
||||
|
||||
const clip = page.locator(".image-clip");
|
||||
const lock = page.locator('.track-labels > div').first().locator('button[aria-pressed]');
|
||||
await expect(clip).toBeVisible();
|
||||
await expect(lock).toHaveAttribute("aria-pressed", "false");
|
||||
await lock.click();
|
||||
await expect(lock).toHaveAttribute("aria-pressed", "true");
|
||||
|
||||
await clip.click();
|
||||
await page.locator(".timeline-mobile-clip-actions .is-danger").click();
|
||||
await expect(clip).toBeVisible();
|
||||
|
||||
await lock.click();
|
||||
await expect(lock).toHaveAttribute("aria-pressed", "false");
|
||||
await clip.click();
|
||||
await page.locator(".timeline-mobile-clip-actions .is-danger").click();
|
||||
await expect(clip).toHaveCount(0);
|
||||
});
|
||||
@@ -0,0 +1,53 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
test("same-asset sticker instances remain independent during cross-subtrack drag", async ({ page }) => {
|
||||
await page.setViewportSize({ width: 1280, height: 900 });
|
||||
await page.addInitScript(() => {
|
||||
localStorage.clear();
|
||||
localStorage.setItem("ai-voiceover-ui-language", "zh");
|
||||
});
|
||||
await page.goto("/");
|
||||
|
||||
const project = {
|
||||
format: "timeline-studio-project",
|
||||
project: {
|
||||
script: "",
|
||||
captionSegments: [],
|
||||
selectedStickerId: "trend-spark",
|
||||
stickerSegments: [
|
||||
{ id: "spark-a", stickerId: "trend-spark", name: "闪光爆点", src: "/assets/stickers/trend-spark.png", start: 5, duration: 3, lane: 0 },
|
||||
{ id: "spark-b", stickerId: "trend-spark", name: "闪光爆点", src: "/assets/stickers/trend-spark.png", start: 5, duration: 3, lane: 1 },
|
||||
{ id: "flame", stickerId: "trend-flame", name: "热度火焰", src: "/assets/stickers/trend-flame.png", start: 0, duration: 4, lane: 2 },
|
||||
],
|
||||
},
|
||||
};
|
||||
await page.locator(".project-file-input").setInputFiles({
|
||||
name: "sticker-lanes.timeline",
|
||||
mimeType: "application/json",
|
||||
buffer: Buffer.from(JSON.stringify(project)),
|
||||
});
|
||||
|
||||
await expect(page.locator(".sticker-track")).toHaveCount(3);
|
||||
const moving = page.locator('[data-timeline-segment-id="spark-b"]');
|
||||
const untouched = page.locator('[data-timeline-segment-id="spark-a"]');
|
||||
const thirdLane = page.locator('[data-sticker-lane-index="2"]');
|
||||
await expect(moving).toBeVisible();
|
||||
const movingBox = await moving.boundingBox();
|
||||
const thirdLaneBox = await thirdLane.boundingBox();
|
||||
if (!movingBox || !thirdLaneBox) throw new Error("Sticker subtracks are unavailable");
|
||||
|
||||
await page.mouse.move(movingBox.x + movingBox.width / 2, movingBox.y + movingBox.height / 2);
|
||||
await page.mouse.down();
|
||||
await page.mouse.move(movingBox.x + movingBox.width / 2 + 8, thirdLaneBox.y + thirdLaneBox.height / 2, { steps: 6 });
|
||||
|
||||
await expect(thirdLane.getByTestId("sticker-drop-preview")).toBeVisible();
|
||||
await expect(moving).toHaveClass(/is-timeline-dragging/);
|
||||
await expect(page.locator('[data-sticker-lane-index="1"] [data-timeline-segment-id="spark-b"]')).toHaveCount(1);
|
||||
await page.mouse.up();
|
||||
|
||||
await expect(page.getByTestId("sticker-drop-preview")).toHaveCount(0);
|
||||
await expect(thirdLane.locator('[data-timeline-segment-id="spark-b"]')).toHaveCount(1);
|
||||
await expect(page.locator('[data-timeline-segment-id="spark-b"]')).toHaveCount(1);
|
||||
await expect(page.locator('[data-timeline-segment-id="spark-a"]')).toHaveCount(1);
|
||||
await expect(untouched).toHaveAttribute("data-timeline-segment-id", "spark-a");
|
||||
});
|
||||
Reference in new issue
Block a user