fix: wait for settled theme colors in browser checks
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user