diff --git a/packages/calcite-components/src/tests/commonTests/themed.ts b/packages/calcite-components/src/tests/commonTests/themed.ts index dd72ec0c4bd..f03b7a76891 100644 --- a/packages/calcite-components/src/tests/commonTests/themed.ts +++ b/packages/calcite-components/src/tests/commonTests/themed.ts @@ -352,6 +352,12 @@ async function assertThemedProps(page: E2EPage, options: TestTarget): Promise](); + try { + await targetEl[state as Exclude](); + } catch (error) { + // checking for explicit Puppeteer ElementHandle error: https://github.com/puppeteer/puppeteer/blob/68fd7712932f94730b6186107a0509c233938084/packages/puppeteer-core/src/api/ElementHandle.ts#L625 + const message = + error.message === "Node is either not clickable or not an Element" + ? `[${token}] target node (${target.selector}${ + target.shadowSelector ? " >>> " + target.shadowSelector : "" + }) must be clickable (larger than 1x1) for state: ${state}` + : `[${token}] ${error.message} for state: ${state} on target node (${target.selector}${ + target.shadowSelector ? " >>> " + target.shadowSelector : "" + })`; + + throw new Error(message); + } } await page.waitForChanges(); if (targetProp.startsWith("--calcite-")) { - expect(await getComputedStylePropertyValue(targetEl, targetProp, pseudoElement)).toBe(expectedValue); + const customPropValue = await getComputedStylePropertyValue(targetEl, targetProp, pseudoElement); + expect(getStyleString(token, targetProp, customPropValue)).toBe(getStyleString(token, targetProp, expectedValue)); return; } const styles = await targetEl.getComputedStyle(pseudoElement); - const isFakeBorderToken = token.includes("border-color") && targetProp === "boxShadow"; + const isFakeBorderColorToken = + token.includes("-color") && + (targetProp === "boxShadow" || targetProp === "outline" || targetProp === "outlineColor"); const isLinearGradientUnderlineToken = token.includes("link-underline-color") && targetProp === "backgroundImage"; - if (isFakeBorderToken || isLinearGradientUnderlineToken) { - expect(styles[targetProp]).toMatch(expectedValue); + if (isFakeBorderColorToken || isLinearGradientUnderlineToken) { + expect(getStyleString(token, targetProp, styles[targetProp])).toMatch(expectedValue); return; } - expect(styles[targetProp]).toBe(expectedValue); + expect(getStyleString(token, targetProp, styles[targetProp])).toBe(getStyleString(token, targetProp, expectedValue)); +} + +/** + * Generates a message with the token, property, and value. + * + * Used for debugging. + * + * @param token - the token as a CSS variable + * @param prop - the CSS property + * @param value - the value of the CSS property + */ +function getStyleString(token: string, prop: string, value: string): string { + return `[${token}:${prop}] ${value}`; } /** @@ -398,7 +434,9 @@ async function assertThemedProps(page: E2EPage, options: TestTarget): Promise