mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-25 08:32:45 +00:00
fix(studio): a failed preview's retry button takes a click again (#8610)
* fix(studio): a failed preview's retry button takes a click again The editing canvas covered the whole stage, above the failure drawn inside it. The live preview now reports its failure to the player store and the canvas stands aside while it shows. * test(studio): the retry walk waits for the canvas to come back once the preview can show * fix(studio): no editing box over a failed preview can take its retry click * fix(studio): a failed preview closes the canvas menu and ends the text edit * fix(studio): a menu or text edit already on its way stays shut once the preview fails * fix(studio): the canvas menu and the text edit each end themselves when the preview fails * test(studio): the canvas menu rows select their target as the overlay does * refactor(studio): name the inline edit's failed-preview refusal and its save on failure * test(studio): the preview failure walk selects text so the formatting toolbar opens
This commit is contained in:
@@ -1165,7 +1165,7 @@ jobs:
|
||||
node packages/studio/tests/e2e/perf-ratchet.mjs check \
|
||||
packages/studio/tests/e2e/perf-ceilings.json studio-open /tmp/studio-open-counts.json \
|
||||
/tmp/base-perf-ceilings.json
|
||||
- name: Check fade handles, render selects, thumbnail connection release, trim snapping and a script-hidden backdrop
|
||||
- name: Check fade handles, render selects, thumbnail connection release, trim snapping, a script-hidden backdrop and a failed preview's retry
|
||||
if: success() || failure()
|
||||
run: |
|
||||
set -euo pipefail
|
||||
@@ -1198,6 +1198,11 @@ jobs:
|
||||
node packages/studio/tests/e2e/timeline-snap-release.mjs || failed "snap release"
|
||||
STUDIO_URL="http://localhost:5316/#project/aroll-backdrop" \
|
||||
node packages/studio/tests/e2e/aroll-backdrop.mjs || failed "script-hidden backdrop"
|
||||
STUDIO_URL="http://localhost:5316/" \
|
||||
node packages/studio/tests/e2e/preview-failure-retry.mjs || failed "preview failure retry"
|
||||
rm -rf packages/studio/data/projects/inline-text-caret
|
||||
cp -R packages/studio/tests/e2e/fixtures/inline-text-caret \
|
||||
packages/studio/data/projects/inline-text-caret
|
||||
rm -rf packages/studio/data/projects/graded-video-transitions
|
||||
cp -R packages/studio/tests/e2e/fixtures/graded-video-transitions \
|
||||
packages/studio/data/projects/graded-video-transitions
|
||||
|
||||
@@ -42,6 +42,7 @@ import { pointerMayHitElement } from "./previewSelection";
|
||||
import { logSelect } from "../../utils/selectDebug";
|
||||
import { useOffCanvasIndicators } from "./useOffCanvasIndicators";
|
||||
import { DomEditGestureReadout } from "./DomEditGestureReadout";
|
||||
import { usePlayerStore } from "../../player/store/playerStore";
|
||||
|
||||
// Re-exports for external consumers — preserving existing import paths.
|
||||
export {
|
||||
@@ -160,6 +161,7 @@ export const DomEditOverlay = memo(function DomEditOverlay({
|
||||
}: DomEditOverlayProps) {
|
||||
const readOnly = usePreviewReadOnly();
|
||||
const hostInput = canvasInput === "host";
|
||||
const previewFailed = usePlayerStore((state) => state.previewFailed);
|
||||
const bodyDrag = allowBodyDrag || !hostInput;
|
||||
const overlayRef = useRef<HTMLDivElement | null>(null);
|
||||
const boxRef = useRef<HTMLDivElement | null>(null);
|
||||
@@ -466,6 +468,7 @@ export const DomEditOverlay = memo(function DomEditOverlay({
|
||||
className={`absolute inset-0 z-10 outline-hidden ${
|
||||
inlineText.editing || hostInput ? "pointer-events-none" : "pointer-events-auto"
|
||||
}`}
|
||||
inert={previewFailed}
|
||||
data-editing-text={inlineText.editing ? "true" : undefined}
|
||||
tabIndex={-1}
|
||||
aria-label="Composition canvas"
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
// @vitest-environment happy-dom
|
||||
|
||||
import React, { act, useRef, useState } from "react";
|
||||
import { createRoot, type Root } from "react-dom/client";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { usePlayerStore } from "../../player/store/playerStore";
|
||||
import type { DomEditSelection } from "./domEditing";
|
||||
import { useCanvasContextMenuState } from "./useCanvasContextMenuState";
|
||||
|
||||
(globalThis as unknown as { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
|
||||
|
||||
let root: Root | null = null;
|
||||
afterEach(() => {
|
||||
act(() => root?.unmount());
|
||||
root = null;
|
||||
usePlayerStore.getState().setPreviewFailed(false);
|
||||
document.body.innerHTML = "";
|
||||
});
|
||||
|
||||
/** The menu hook with its hit test held until the returned release is called. */
|
||||
function mountHeld() {
|
||||
let release: (selection: DomEditSelection | null) => void = () => {};
|
||||
const hitTest = () => new Promise<DomEditSelection | null>((resolve) => (release = resolve));
|
||||
const menu: { current: ReturnType<typeof useCanvasContextMenuState> | null } = { current: null };
|
||||
// As the overlay does: the right-click's hit selects its target, and the menu reads that selection.
|
||||
function Probe() {
|
||||
const [selection, setSelection] = useState<DomEditSelection | null>(null);
|
||||
const selectionRef = useRef(selection);
|
||||
selectionRef.current = selection;
|
||||
const onSelectionChangeRef = useRef((next: DomEditSelection) => setSelection(next));
|
||||
menu.current = useCanvasContextMenuState({
|
||||
selection,
|
||||
selectionRef,
|
||||
hoverSelectionRef: useRef<DomEditSelection | null>(null),
|
||||
onCanvasPointerMoveRef: useRef(hitTest),
|
||||
onSelectionChangeRef,
|
||||
});
|
||||
return null;
|
||||
}
|
||||
const host = document.createElement("div");
|
||||
document.body.append(host);
|
||||
root = createRoot(host);
|
||||
act(() => root!.render(<Probe />));
|
||||
const rightClick = {
|
||||
preventDefault: vi.fn(),
|
||||
clientX: 40,
|
||||
clientY: 30,
|
||||
} as unknown as React.MouseEvent<HTMLDivElement>;
|
||||
let opening: Promise<void> = Promise.resolve();
|
||||
act(() => {
|
||||
opening = menu.current!.handleContextMenu(rightClick);
|
||||
});
|
||||
const target = { element: document.createElement("div") } as unknown as DomEditSelection;
|
||||
return {
|
||||
menu: () => menu.current!,
|
||||
release: () => act(async () => (release(target), await opening)),
|
||||
};
|
||||
}
|
||||
|
||||
describe("the canvas menu's way in", () => {
|
||||
it("opens once the right-click's hit test lands", async () => {
|
||||
const { menu, release } = mountHeld();
|
||||
await release();
|
||||
expect(menu().contextMenu).toMatchObject({ x: 40, y: 30 });
|
||||
});
|
||||
|
||||
it("closes an open menu when the preview fails", async () => {
|
||||
const { menu, release } = mountHeld();
|
||||
await release();
|
||||
act(() => usePlayerStore.getState().setPreviewFailed(true));
|
||||
expect(menu().contextMenu).toBeNull();
|
||||
});
|
||||
|
||||
it("stays shut when the preview fails while the right-click's hit test is still out", async () => {
|
||||
const { menu, release } = mountHeld();
|
||||
act(() => usePlayerStore.getState().setPreviewFailed(true));
|
||||
await release();
|
||||
expect(menu().contextMenu).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
import { useCallback, useEffect, useState, type RefObject } from "react";
|
||||
import type { DomEditSelection } from "./domEditing";
|
||||
import { usePlayerStore } from "../../player/store/playerStore";
|
||||
|
||||
export interface CanvasContextMenuState {
|
||||
x: number;
|
||||
@@ -43,6 +44,10 @@ export function useCanvasContextMenuState({
|
||||
// time so the menu can open even before the React selection state settles.
|
||||
const [contextMenu, setContextMenu] = useState<CanvasContextMenuState | null>(null);
|
||||
const closeContextMenu = useCallback(() => setContextMenu(null), []);
|
||||
const previewFailed = usePlayerStore((state) => state.previewFailed);
|
||||
useEffect(() => {
|
||||
if (previewFailed) setContextMenu(null);
|
||||
}, [previewFailed]);
|
||||
|
||||
// Close the context menu whenever the selection moves off the element the menu
|
||||
// targets (a click that reselects elsewhere, a deselect, or a preview reload
|
||||
@@ -82,7 +87,7 @@ export function useCanvasContextMenuState({
|
||||
}
|
||||
}
|
||||
|
||||
if (!activeSel) return;
|
||||
if (!activeSel || usePlayerStore.getState().previewFailed) return;
|
||||
setContextMenu({ x: event.clientX, y: event.clientY, sel: activeSel });
|
||||
},
|
||||
[selectionRef, hoverSelectionRef, onCanvasPointerMoveRef, onSelectionChangeRef],
|
||||
|
||||
@@ -32,6 +32,7 @@ import { PreviewZoomOverlay, usePreviewZoomOverlay } from "./PreviewZoomOverlay"
|
||||
import { PREVIEW_STAGE_INSET_PX, resolvePreviewStageSize, shadowIframeStyle } from "./previewStage";
|
||||
import { usePreviewFirstFrameTelemetry } from "../../player/hooks/usePreviewFirstFrameTelemetry";
|
||||
import { PreviewPoster, usePreviewPoster } from "./PreviewPoster";
|
||||
import { usePlayerStore } from "../../player/store/playerStore";
|
||||
interface NLEPreviewProps extends Pick<
|
||||
NLEContextValue,
|
||||
| "projectId"
|
||||
@@ -186,10 +187,17 @@ export const NLEPreview = memo(function NLEPreview({
|
||||
const onLiveReadyToShowChange = useCallback(
|
||||
(ready: boolean) => {
|
||||
showLive(ready);
|
||||
if (ready) updateCompositionSizeFromPreview();
|
||||
if (!ready) return;
|
||||
usePlayerStore.getState().setPreviewFailed(false);
|
||||
updateCompositionSizeFromPreview();
|
||||
},
|
||||
[showLive, updateCompositionSizeFromPreview],
|
||||
);
|
||||
const posterError = poster.onPreviewError;
|
||||
const onLivePreviewError = useCallback(() => {
|
||||
posterError();
|
||||
usePlayerStore.getState().setPreviewFailed(true);
|
||||
}, [posterError]);
|
||||
|
||||
const setPreviewIframeRef = useCallback(
|
||||
(node: HTMLIFrameElement | null) => {
|
||||
@@ -515,7 +523,7 @@ export const NLEPreview = memo(function NLEPreview({
|
||||
}}
|
||||
onCompositionLoadingChange={onCompositionLoadingChange}
|
||||
onReadyToShowChange={onLiveReadyToShowChange}
|
||||
onPreviewError={poster.onPreviewError}
|
||||
onPreviewError={onLivePreviewError}
|
||||
onPainted={(details) => reportPreviewFirstFrame(slot, details)}
|
||||
portrait={portrait}
|
||||
suppressLoadingOverlay={suppressLoadingOverlay}
|
||||
|
||||
@@ -6,6 +6,7 @@ import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { PreviewReadOnlyProvider } from "../components/editor/previewReadOnlyContext";
|
||||
import { useInlineTextEdit, type InlineTextEditControls } from "./useInlineTextEdit";
|
||||
import { applyUndoRestoreToPreview } from "../utils/gsapUndoRestore";
|
||||
import { usePlayerStore } from "../player/store/playerStore";
|
||||
|
||||
(globalThis as unknown as { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
|
||||
|
||||
@@ -687,4 +688,33 @@ describe("an undo that lands while a text edit is open", () => {
|
||||
expect(element.style.getPropertyValue("outline")).not.toBe("");
|
||||
act(() => root.unmount());
|
||||
});
|
||||
|
||||
it("saves an open edit when the preview fails, as leaving it does", () => {
|
||||
const element = heading("Motion");
|
||||
const { controls, root, onCommit } = mount();
|
||||
act(() => {
|
||||
controls().start(element);
|
||||
});
|
||||
element.textContent = "Motion kept";
|
||||
act(() => usePlayerStore.getState().setPreviewFailed(true));
|
||||
usePlayerStore.getState().setPreviewFailed(false);
|
||||
expect(element.hasAttribute("contenteditable")).toBe(false);
|
||||
expect(onCommit).toHaveBeenCalledWith(expect.objectContaining({ html: "Motion kept" }));
|
||||
act(() => root.unmount());
|
||||
});
|
||||
|
||||
it("refuses to open an edit while the preview has failed, so a press already on its way does nothing", () => {
|
||||
const element = heading();
|
||||
const { controls, root, onPause } = mount();
|
||||
usePlayerStore.getState().setPreviewFailed(true);
|
||||
let opened = true;
|
||||
act(() => {
|
||||
opened = controls().start(element);
|
||||
});
|
||||
usePlayerStore.getState().setPreviewFailed(false);
|
||||
expect(opened).toBe(false);
|
||||
expect(element.hasAttribute("contenteditable")).toBe(false);
|
||||
expect(onPause).not.toHaveBeenCalled();
|
||||
act(() => root.unmount());
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { sanitizeRichTextChildren } from "@hyperframes/core/rich-text-sanitize";
|
||||
import { usePreviewReadOnly } from "../components/editor/previewReadOnlyContext";
|
||||
import { usePlayerStore } from "../player/store/playerStore";
|
||||
import { holdSealedFrameKeyboard } from "../player/lib/sealedFrameKeyboard";
|
||||
import { settleOnDrain, trackStudioPendingEdit } from "../utils/studioPendingEdits";
|
||||
import {
|
||||
@@ -249,6 +250,16 @@ function endWithOriginal(sealed: NonNullable<InlineTextEditSession["sealed"]>):
|
||||
void previewTextEdit(sealed.iframe, { handle: sealed.handle, action: "end", keep: false });
|
||||
}
|
||||
|
||||
/** Read as the edit opens, so a press already on its way when the preview fails opens nothing. */
|
||||
const editRefused = (readOnly: boolean) => readOnly || usePlayerStore.getState().previewFailed;
|
||||
|
||||
function useSaveOnPreviewFailure(commit: () => void): void {
|
||||
const previewFailed = usePlayerStore((state) => state.previewFailed);
|
||||
useEffect(() => {
|
||||
if (previewFailed) commit();
|
||||
}, [previewFailed, commit]);
|
||||
}
|
||||
|
||||
export function useInlineTextEdit({
|
||||
onCommit,
|
||||
onPause,
|
||||
@@ -298,7 +309,7 @@ export function useInlineTextEdit({
|
||||
|
||||
const start = useCallback(
|
||||
(element: HTMLElement, caretAt?: { x: number; y: number }): boolean => {
|
||||
if (openRef.current || readOnly) return false;
|
||||
if (openRef.current || editRefused(readOnly)) return false;
|
||||
const sealed = previewStandIn(element);
|
||||
if (sealed) {
|
||||
const gesture = beginStudioManualEditGesture(element, "edit");
|
||||
@@ -423,6 +434,7 @@ export function useInlineTextEdit({
|
||||
return handedOff(open.element, saving);
|
||||
}, [onCommit, teardown, endSealed]);
|
||||
const commit = useCallback(() => void save(), [save]);
|
||||
useSaveOnPreviewFailure(commit);
|
||||
|
||||
const cancel = useCallback(() => {
|
||||
const open = openRef.current;
|
||||
|
||||
@@ -11,8 +11,10 @@ export interface PlaybackReadinessSlice {
|
||||
/** Latched when the project's first preview shows its first frame (or fails), kept through edit
|
||||
* reloads, so work that must not compete with the boot waits for it once. */
|
||||
previewBooted: boolean;
|
||||
previewFailed: boolean;
|
||||
setTimelineReady: (ready: boolean) => void;
|
||||
markPreviewBooted: () => void;
|
||||
setPreviewFailed: (failed: boolean) => void;
|
||||
playLocked: boolean;
|
||||
setPlayLocked: (locked: boolean) => void;
|
||||
/** Sets timelineReady once doc's readiness inputs settle, or immediately
|
||||
@@ -32,10 +34,10 @@ let awaitingLoadStep: { doc: Document; generation: number } | null = null;
|
||||
* wait in flight can never resolve into what replaced it. */
|
||||
export function resetPlaybackReadinessState(): Pick<
|
||||
PlaybackReadinessSlice,
|
||||
"timelineReady" | "previewBooted"
|
||||
"timelineReady" | "previewBooted" | "previewFailed"
|
||||
> {
|
||||
timelineReadyGeneration++;
|
||||
return { timelineReady: false, previewBooted: false };
|
||||
return { timelineReady: false, previewBooted: false, previewFailed: false };
|
||||
}
|
||||
|
||||
export function createPlaybackReadinessSlice(
|
||||
@@ -48,7 +50,9 @@ export function createPlaybackReadinessSlice(
|
||||
return {
|
||||
timelineReady: false,
|
||||
previewBooted: false,
|
||||
previewFailed: false,
|
||||
markPreviewBooted: () => set({ previewBooted: true }),
|
||||
setPreviewFailed: (failed) => set({ previewFailed: failed }),
|
||||
playLocked: false,
|
||||
setPlayLocked: (locked) => set({ playLocked: locked }),
|
||||
setTimelineReady: (ready) => {
|
||||
|
||||
@@ -0,0 +1,170 @@
|
||||
#!/usr/bin/env node
|
||||
// A failed preview's retry button must take a real click, whatever the editing canvas holds above the stage.
|
||||
import assert from "node:assert/strict";
|
||||
import { launchStudioChrome } from "./chrome-executable.mjs";
|
||||
|
||||
const STUDIO_URL = process.env.STUDIO_URL;
|
||||
if (!STUDIO_URL) {
|
||||
console.error("STUDIO_URL is required and must point at Studio with the e2e fixtures installed");
|
||||
process.exit(2);
|
||||
}
|
||||
const ORIGIN = new URL(STUDIO_URL).origin;
|
||||
const FAILURE = '[data-testid="composition-preview-error"]';
|
||||
const SELECTION_BOX = '[data-dom-edit-selection-box="true"]';
|
||||
const CANVAS_MENU = "body > div.fixed.z-200";
|
||||
const TEXT_TOOLBAR = '[role="toolbar"][aria-label="Text formatting"]';
|
||||
|
||||
const painted = (page) =>
|
||||
page.waitForFunction(() => document.querySelector("hyperframes-player")?.painted === true, {
|
||||
timeout: 60_000,
|
||||
});
|
||||
|
||||
async function open(page, project) {
|
||||
await page.goto(`${ORIGIN}/#project/${project}`, { waitUntil: "domcontentloaded" });
|
||||
await page.waitForFunction(
|
||||
(project) => {
|
||||
const player = document.querySelector("hyperframes-player");
|
||||
return (
|
||||
player?.getAttribute("src")?.includes(`/projects/${project}/`) && player.painted === true
|
||||
);
|
||||
},
|
||||
{ timeout: 60_000 },
|
||||
project,
|
||||
);
|
||||
}
|
||||
|
||||
async function stagePoint(page, id) {
|
||||
return page.evaluate((id) => {
|
||||
const frame = document.querySelector("hyperframes-player").shadowRoot.querySelector("iframe");
|
||||
const el = frame.contentDocument.getElementById(id).getBoundingClientRect();
|
||||
const box = frame.getBoundingClientRect();
|
||||
const scale = box.width / frame.contentWindow.innerWidth;
|
||||
return { x: box.x + (el.x + el.width / 2) * scale, y: box.y + (el.y + el.height / 2) * scale };
|
||||
}, id);
|
||||
}
|
||||
|
||||
// As the player reports a film with no timeline by its load limit; then a real click on its retry button.
|
||||
async function failThenRetry(page) {
|
||||
await page.evaluate(() =>
|
||||
document.querySelector("hyperframes-player").dispatchEvent(
|
||||
new CustomEvent("error", {
|
||||
detail: { message: "Composition timeline not found after 30s" },
|
||||
}),
|
||||
),
|
||||
);
|
||||
const button = await page.waitForSelector(`${FAILURE} button`, { timeout: 10_000 });
|
||||
const leftOpen = await page.evaluate(
|
||||
({ menu, toolbar }) => ({
|
||||
menu: !!document.querySelector(menu),
|
||||
toolbar: !!document.querySelector(toolbar),
|
||||
}),
|
||||
{ menu: CANVAS_MENU, toolbar: TEXT_TOOLBAR },
|
||||
);
|
||||
assert.deepEqual(
|
||||
leftOpen,
|
||||
{ menu: false, toolbar: false },
|
||||
"a failed preview leaves no canvas menu or text toolbar open",
|
||||
);
|
||||
const box = await button.boundingBox();
|
||||
const center = { x: box.x + box.width / 2, y: box.y + box.height / 2 };
|
||||
const onTop = await page.evaluate(({ x, y }) => {
|
||||
const hit = document.elementFromPoint(x, y);
|
||||
return {
|
||||
isRetry: hit?.closest("button")?.closest('[data-testid="composition-preview-error"]') != null,
|
||||
hit: `${hit?.tagName.toLowerCase()} ${hit?.getAttribute("aria-label") ?? ""}`.trim(),
|
||||
};
|
||||
}, center);
|
||||
assert.ok(onTop.isRetry, `a click at the retry button lands on ${onTop.hit}`);
|
||||
await page.mouse.click(center.x, center.y);
|
||||
await page.waitForFunction(
|
||||
() =>
|
||||
new URL(
|
||||
document.querySelector("hyperframes-player").getAttribute("src"),
|
||||
location.origin,
|
||||
).searchParams.has("_hfStudioRetry"),
|
||||
{ timeout: 10_000 },
|
||||
);
|
||||
await painted(page);
|
||||
await page.waitForFunction(
|
||||
() => !document.querySelector('[aria-label="Composition canvas"]')?.closest("[inert]"),
|
||||
{ timeout: 10_000 },
|
||||
);
|
||||
}
|
||||
|
||||
const selectedId = (page) =>
|
||||
page.evaluate(() => new URLSearchParams(location.hash.split("?")[1] ?? "").get("selId"));
|
||||
|
||||
const { browser } = await launchStudioChrome();
|
||||
try {
|
||||
const page = await browser.newPage();
|
||||
await page.setViewport({ width: 1440, height: 900 });
|
||||
|
||||
await open(page, "fade-handles");
|
||||
await failThenRetry(page);
|
||||
console.log("nothing selected: retry takes the click");
|
||||
|
||||
await open(page, "aroll-backdrop");
|
||||
const aroll = await stagePoint(page, "aroll");
|
||||
await page.mouse.click(aroll.x, aroll.y);
|
||||
await page.waitForSelector(SELECTION_BOX, { timeout: 10_000 });
|
||||
const selected = await selectedId(page);
|
||||
assert.equal(selected, "aroll", "the full-frame layer is selected over the stage");
|
||||
await failThenRetry(page);
|
||||
await page.waitForSelector(SELECTION_BOX, { timeout: 10_000 });
|
||||
assert.equal(await selectedId(page), selected, "the selection comes back as after any reload");
|
||||
console.log("a selected layer over the stage: retry takes the click, the selection comes back");
|
||||
|
||||
const centre = await page.evaluate(() => {
|
||||
const box = document
|
||||
.querySelector("hyperframes-player")
|
||||
.shadowRoot.querySelector("iframe")
|
||||
.getBoundingClientRect();
|
||||
return { x: box.x + box.width / 2 - 60, y: box.y + box.height / 2 - 60 };
|
||||
});
|
||||
await page.mouse.click(centre.x, centre.y, { button: "right" });
|
||||
await page.waitForSelector(CANVAS_MENU, { timeout: 10_000 });
|
||||
await failThenRetry(page);
|
||||
console.log("a canvas menu open over the stage: the failure closes it, retry takes the click");
|
||||
|
||||
await open(page, "inline-text-caret");
|
||||
const title = await stagePoint(page, "title");
|
||||
// One press selects the title and Enter opens its text with the caret at the end, as inline-text-caret.mjs does.
|
||||
await page.mouse.click(title.x, title.y);
|
||||
await page.waitForFunction(
|
||||
() => new URLSearchParams(location.hash.split("?")[1] ?? "").get("selId") === "title",
|
||||
{ timeout: 10_000 },
|
||||
);
|
||||
await page.keyboard.press("Enter");
|
||||
await page.waitForFunction(
|
||||
() =>
|
||||
document
|
||||
.querySelector("hyperframes-player")
|
||||
.shadowRoot.querySelector("iframe")
|
||||
.contentDocument.querySelector("[contenteditable]") !== null,
|
||||
{ timeout: 10_000 },
|
||||
);
|
||||
await page.keyboard.press("End");
|
||||
await page.keyboard.type(" kept");
|
||||
// The toolbar shows only over a selection, never a bare caret.
|
||||
await page.keyboard.down("Shift");
|
||||
await page.keyboard.press("Home");
|
||||
await page.keyboard.up("Shift");
|
||||
await page.waitForSelector(TEXT_TOOLBAR, { timeout: 10_000 });
|
||||
await failThenRetry(page);
|
||||
const saved = await page.waitForFunction(
|
||||
async (origin) => {
|
||||
const response = await fetch(`${origin}/api/projects/inline-text-caret/files/index.html`);
|
||||
const { content } = await response.json();
|
||||
const notice = [...document.querySelectorAll("[data-sonner-toast], [role=status]")].some(
|
||||
(toast) => /not saved/i.test(toast.textContent ?? ""),
|
||||
);
|
||||
return /Title kept</.test(content) ? "saved" : notice ? "refused with a notice" : false;
|
||||
},
|
||||
{ timeout: 15_000, polling: 250 },
|
||||
ORIGIN,
|
||||
);
|
||||
console.log(`a text edit open at the failure: ${await saved.jsonValue()}`);
|
||||
console.log("preview failure retry: ok");
|
||||
} finally {
|
||||
await browser.close();
|
||||
}
|
||||
Reference in New Issue
Block a user