Skip to content

Commit f52d1e8

Browse files
committed
test(buttons): the arrowed radio's ring follows the engine's :focus-visible, which WebKit drops
1 parent f63dfa9 commit f52d1e8

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

‎test/browser/components/buttons.spec.js‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,22 @@ test.describe('buttons', () => {
5151
expect(await style(page, '#s3', 'opacity')).toBe(await page.evaluate(() => getComputedStyle(document.documentElement).getPropertyValue('--yeti-opacity-muted').trim()));
5252
});
5353

54-
test('the arrow keys move the choice, and the focused label rises and draws the ring', async ({ page }) => {
54+
test('the arrow keys move the choice, and the focused label rises and draws the ring', async ({ page, browserName }) => {
5555
await open(page);
5656
await page.focus('#s1-input');
57+
expect(await style(page, '#s1', 'outline-style')).toBe('solid');
58+
expect(await px(page, '#s1', 'outline-width')).toBe(2);
5759
await page.keyboard.press('ArrowRight');
5860
expect(await page.isChecked('#s2-input')).toBe(true);
5961
expect(await page.isChecked('#s1-input')).toBe(false);
6062
expect(await page.evaluate(() => document.activeElement.id)).toBe('s2-input');
61-
expect(await style(page, '#s2', 'outline-style')).toBe('solid');
62-
expect(await px(page, '#s2', 'outline-width')).toBe(2);
63-
expect(await style(page, '#s2', 'z-index')).toBe('1');
63+
// The ring follows the input's :focus-visible, and WebKit stops matching
64+
// it on a radio that the arrow keys focus, as it does for a bare radio;
65+
// the filled segment still shows where the choice, and the focus, is.
66+
const ringAfterArrow = await page.evaluate(() => document.activeElement.matches(':focus-visible'));
67+
if (browserName !== 'webkit') expect(ringAfterArrow).toBe(true);
68+
expect(await style(page, '#s2', 'outline-style')).toBe(ringAfterArrow ? 'solid' : 'none');
69+
expect(await style(page, '#s2', 'z-index')).toBe(ringAfterArrow ? '1' : 'auto');
6470
});
6571

6672
test('an affixed group short of room stays one row, its labels wrapping inside', async ({ page }) => {

0 commit comments

Comments
 (0)