mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-10-30 09:16:55 +00:00
feat(studio): a host undo key paints a still-saving move back at once (#4894)
* feat(studio): let a host's undo key paint a still-saving move back at once * test(studio): prove the public revert from a .ts test and drop the export comment * test(studio): a failing revert check cannot leave an edit pending, and a second revert paints nothing * test(studio): load the package index once at collection, not inside the revert test
This commit is contained in:
@@ -148,6 +148,7 @@ export type {
|
||||
// A host's own waitForPendingDomEditSaves must also call this, or undo/redo
|
||||
// can race a write still in flight (see useTrackPendingTimelineEdit.ts).
|
||||
export { flushStudioPendingEdits } from "./utils/studioPendingEdits";
|
||||
export { revertNewestStudioPendingEdit } from "./utils/studioPendingEdits";
|
||||
export type { StudioPendingEditsDrainResult } from "./utils/studioPendingEdits";
|
||||
export type {
|
||||
CanEditTimelineElement,
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
trackedStudioEdit,
|
||||
} from "./studioPendingEdits";
|
||||
import { StudioFileConflictError } from "./studioSaveDiagnostics";
|
||||
import { revertNewestStudioPendingEdit as hostRevert } from "../index";
|
||||
|
||||
describe("studio pending edit flush", () => {
|
||||
it("waits for mounted panels to persist pending local edits", async () => {
|
||||
@@ -277,3 +278,20 @@ describe("a pending edit whose start throws", () => {
|
||||
expect(hasStudioPendingEdits()).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("the package's public revert", () => {
|
||||
it("lets a host's own undo key paint a still-saving move back at once", async () => {
|
||||
let left = "120px";
|
||||
const edit = beginStudioPendingEdit(() => ((left = "0px"), () => void (left = "120px")));
|
||||
try {
|
||||
const putBack = hostRevert();
|
||||
expect(left).toBe("0px");
|
||||
expect(hostRevert()).toBeNull();
|
||||
putBack?.();
|
||||
expect(left).toBe("120px");
|
||||
} finally {
|
||||
edit.settle();
|
||||
await flushStudioPendingEdits();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user