fix(webhelpers): improve browser test fixture to append element and await custom element upgrade and Lit update completion; add generic return type; update npm packaging release config; remove pnpm onlyBuiltDependencies

This commit is contained in:
2025-12-30 11:29:44 +00:00
parent c9950d31ac
commit 2b81e8e5aa
5 changed files with 35 additions and 12 deletions

View File

@@ -22,10 +22,24 @@ class WebHelpers {
// Initialize fixture function based on environment
if (smartenv.isBrowser) {
this.fixture = async (htmlString: string): Promise<HTMLElement> => {
this.fixture = async <T extends HTMLElement>(htmlString: string): Promise<T> => {
const container = document.createElement('div');
container.innerHTML = htmlString.trim();
const element = container.firstChild as HTMLElement;
const element = container.firstElementChild as T;
// Append to document so custom elements upgrade and lifecycle hooks fire
document.body.appendChild(element);
// Wait for custom element definition if it's a custom element
if (element.localName.includes('-')) {
await customElements.whenDefined(element.localName).catch(() => {});
}
// Wait for Lit/async components to finish rendering
if ((element as any).updateComplete) {
await (element as any).updateComplete;
}
return element;
};
} else {