From 24e428d9cb31b2ad67d7e7f744bb31325347b03d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o?= Date: Wed, 30 Sep 2026 11:26:38 +0200 Subject: [PATCH] test(document): use platform-correct input in the rich color test test_rich_colors_follow_theme_and_undo_as_one_edit fails identically on every macOS run, timing out after 30s waiting for a span that never appears. It was written off as timing noise twice. It is not flaky - it is two Linux-only input conventions, and the product code is fine. Control+click: macOS delivers a Control-modified primary click as contextmenu, not click. Instrumenting the Lemon swatch shows the button receiving pointerdown, mousedown, contextmenu, pointerup, mouseup - and no click, so the menu item's handler never runs and no highlight is applied. Control was never meaningful here anyway; the palette item has no modifier behaviour. The two calls now use a plain click. Control+Z: the editor's undo accelerator is Cmd+Z on macOS. With the clicks fixed, both undo assertions still failed until the presses became ControlOrMeta+Z, which Playwright maps per platform. Both fixes are portable - a plain click and ControlOrMeta are unchanged on Linux, where this test already passes. pytest tests/test_document_rich_color_reset_and_contrast.py 2 passed in 2.11s (1 failed, 1 passed before) Not verified: Linux. I only have macOS here, so the claim that this stays green on CI rests on the modifier being a no-op there, not on a run. --- .../test_document_rich_color_reset_and_contrast.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/test_document_rich_color_reset_and_contrast.py b/tests/test_document_rich_color_reset_and_contrast.py index 64c237a7b..c74f3576b 100644 --- a/tests/test_document_rich_color_reset_and_contrast.py +++ b/tests/test_document_rich_color_reset_and_contrast.py @@ -20,6 +20,12 @@ def test_color_controls_have_theme_reset_and_split_palettes(): def test_rich_colors_follow_theme_and_undo_as_one_edit(): + # Two input conventions in here are platform-sensitive and must stay that + # way. Palette entries are opened with a plain click: on macOS a + # Control+click is delivered as `contextmenu`, so the menu item's `click` + # handler never runs and nothing is applied. Undo uses Playwright's + # `ControlOrMeta` alias because the editor's undo accelerator is Cmd+Z on + # macOS and Ctrl+Z everywhere else. script = r""" import { chromium } from 'playwright'; const browser = await chromium.launch({ headless: true }); @@ -58,24 +64,24 @@ def test_rich_colors_follow_theme_and_undo_as_one_edit(): labels: [...document.querySelectorAll('.rich-color-palette-label')].map(item => item.textContent), reset: document.querySelector('.rich-color-reset')?.textContent.trim(), })); - await page.locator('#doc-md-dd-menu .doc-overflow-item').filter({ hasText: 'Lemon' }).click({ modifiers: ['Control'] }); + await page.locator('#doc-md-dd-menu .doc-overflow-item').filter({ hasText: 'Lemon' }).click(); const highlighted = await page.locator('#doc-email-richbody p').nth(0).locator('span').evaluate(span => ({ color: getComputedStyle(span).color, background: getComputedStyle(span).backgroundColor, })); - await page.locator('#doc-email-richbody').press('Control+z'); + await page.locator('#doc-email-richbody').press('ControlOrMeta+z'); const highlightUndone = await page.locator('#doc-email-richbody p').nth(0).innerHTML(); await selectParagraph(1); await openMenu('color'); - await page.locator('.rich-color-reset').click({ modifiers: ['Control'] }); + await page.locator('.rich-color-reset').click(); const defaultColor = await page.locator('#doc-email-richbody p').nth(1).locator('span').evaluate(span => ({ style: span.getAttribute('style'), color: getComputedStyle(span).color, })); await page.evaluate(() => document.documentElement.style.setProperty('--fg', '#88cc44')); const changedThemeColor = await page.locator('#doc-email-richbody p').nth(1).locator('span').evaluate(span => getComputedStyle(span).color); - await page.locator('#doc-email-richbody').press('Control+z'); + await page.locator('#doc-email-richbody').press('ControlOrMeta+z'); const colorUndone = await page.locator('#doc-email-richbody p').nth(1).innerHTML(); console.log(JSON.stringify({ palette, highlighted, highlightUndone, defaultColor, changedThemeColor, colorUndone })); await browser.close();