test: require modal shadow labels

This commit is contained in:
Peter Steinberger
2026-05-08 17:36:02 +01:00
parent 6c015e83a1
commit ebe6ef321c

View File

@@ -74,6 +74,14 @@ async function renderModal() {
return { modal, dialog };
}
function expectShadowElement(modal: OpenClawModalDialog, id: string): HTMLElement {
const element = modal.shadowRoot?.getElementById(id);
if (!(element instanceof HTMLElement)) {
throw new Error(`Expected shadow element #${id}`);
}
return element;
}
describe("openclaw-modal-dialog", () => {
beforeEach(() => {
installDialogPolyfill();
@@ -101,8 +109,10 @@ describe("openclaw-modal-dialog", () => {
expect(descriptionId).toBe("openclaw-modal-dialog-description");
expect(dialog.getRootNode()).toBe(modal.shadowRoot);
expect(dialog.ownerDocument.querySelector(`#${labelId}`)).toBeNull();
expect(modal.shadowRoot?.getElementById(labelId!)?.textContent).toBe("Confirm action");
expect(modal.shadowRoot?.getElementById(descriptionId!)?.textContent).toBe(
expect(expectShadowElement(modal, "openclaw-modal-dialog-label").textContent).toBe(
"Confirm action",
);
expect(expectShadowElement(modal, "openclaw-modal-dialog-description").textContent).toBe(
"Review the operation before continuing.",
);
});