mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-13 23:56:07 +00:00
test: require modal shadow labels
This commit is contained in:
@@ -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.",
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user