fix: wait for settled theme colors in browser checks

This commit is contained in:
2026-10-16 05:59:39 +09:00
parent b7cef01afd
commit ad08037f4f
+5
View File
@@ -48,6 +48,11 @@ async function paint(locator: Locator, property = 'color') {
}, property);
}
async function readable(locator: Locator, minimum = 4.5, property = 'color') {
// Assert the requested palette state, not a scheduler-dependent intermediate
// frame of the existing hover/focus color transition.
await locator.evaluate(async (element) => {
await Promise.all(element.getAnimations().map((animation) => animation.finished.catch(() => {})));
});
const colors = await paint(locator, property);
expect(contrast(colors.color, colors.background), `${property} contrast for ${locator}`).toBeGreaterThanOrEqual(minimum);
return colors;