From a62972239b3cfe701c1f8d32652889cb9aa6c04f Mon Sep 17 00:00:00 2001 From: wiiiii123 Date: Tue, 21 Apr 2026 02:08:20 +0700 Subject: [PATCH] test(editor): expand auto clip guard coverage --- src/components/video-editor/types.test.ts | 60 ++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/src/components/video-editor/types.test.ts b/src/components/video-editor/types.test.ts index e7054d61..1d4412f1 100644 --- a/src/components/video-editor/types.test.ts +++ b/src/components/video-editor/types.test.ts @@ -25,7 +25,7 @@ describe("extendAutoFullTrackClip", () => { ).toBeNull(); }); - it("does not change multi-clip timelines or non-growing durations", () => { + it("does not change multi-clip timelines", () => { expect( extendAutoFullTrackClip( [ @@ -37,6 +37,9 @@ describe("extendAutoFullTrackClip", () => { 10_000, ), ).toBeNull(); + }); + + it("does not change clips when the duration does not grow", () => { expect( extendAutoFullTrackClip( [{ id: "clip-1", startMs: 0, endMs: 8_000, speed: 1 }], @@ -46,4 +49,59 @@ describe("extendAutoFullTrackClip", () => { ), ).toBeNull(); }); + + it("does not change clips when the auto-created clip id is missing", () => { + expect( + extendAutoFullTrackClip( + [{ id: "clip-1", startMs: 0, endMs: 5_000, speed: 1 }], + null, + 5_000, + 8_000, + ), + ).toBeNull(); + }); + + it("does not change clips when the previous auto-created end time is missing", () => { + expect( + extendAutoFullTrackClip( + [{ id: "clip-1", startMs: 0, endMs: 5_000, speed: 1 }], + "clip-1", + null, + 8_000, + ), + ).toBeNull(); + }); + + it("does not change clips when the reported duration shrinks", () => { + expect( + extendAutoFullTrackClip( + [{ id: "clip-1", startMs: 0, endMs: 8_000, speed: 1 }], + "clip-1", + 8_000, + 7_000, + ), + ).toBeNull(); + }); + + it("does not change clips when the tracked clip id no longer matches", () => { + expect( + extendAutoFullTrackClip( + [{ id: "clip-1", startMs: 0, endMs: 5_000, speed: 1 }], + "clip-2", + 5_000, + 8_000, + ), + ).toBeNull(); + }); + + it("does not change clips when the clip no longer starts at zero", () => { + expect( + extendAutoFullTrackClip( + [{ id: "clip-1", startMs: 250, endMs: 5_000, speed: 1 }], + "clip-1", + 5_000, + 8_000, + ), + ).toBeNull(); + }); });