test: require modal dialog helpers

This commit is contained in:
Peter Steinberger
2026-05-08 16:18:15 +01:00
parent 1c4a20d581
commit ffcb7bf7a0
2 changed files with 22 additions and 10 deletions

View File

@@ -60,12 +60,18 @@ async function renderModal() {
container,
);
const modal = container.querySelector<OpenClawModalDialog>("openclaw-modal-dialog");
expect(modal).not.toBeNull();
await modal!.updateComplete;
expect(modal).toBeInstanceOf(HTMLElement);
if (!modal) {
throw new Error("Expected openclaw-modal-dialog");
}
await modal.updateComplete;
await nextFrame();
const dialog = modal!.shadowRoot?.querySelector("dialog");
expect(dialog).not.toBeNull();
return { modal: modal!, dialog: dialog! };
const dialog = modal.shadowRoot?.querySelector("dialog");
expect(dialog).toBeInstanceOf(HTMLDialogElement);
if (!(dialog instanceof HTMLDialogElement)) {
throw new Error("Expected rendered dialog");
}
return { modal, dialog };
}
describe("openclaw-modal-dialog", () => {

View File

@@ -50,12 +50,18 @@ function restoreDescriptor(name: "showModal" | "close", descriptor?: PropertyDes
async function getRenderedDialog() {
const modal = container.querySelector<OpenClawModalDialog>("openclaw-modal-dialog");
expect(modal).not.toBeNull();
await modal!.updateComplete;
expect(modal).toBeInstanceOf(HTMLElement);
if (!modal) {
throw new Error("Expected openclaw-modal-dialog");
}
await modal.updateComplete;
await nextFrame();
const dialog = modal!.shadowRoot?.querySelector("dialog");
expect(dialog).not.toBeNull();
return { modal: modal!, dialog: dialog! };
const dialog = modal.shadowRoot?.querySelector("dialog");
expect(dialog).toBeInstanceOf(HTMLDialogElement);
if (!(dialog instanceof HTMLDialogElement)) {
throw new Error("Expected rendered dialog");
}
return { modal, dialog };
}
function dispatchEscape(target: EventTarget) {