Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
test: drop cosmetic style-equality assertions
Josh Corbettfc48fcfb2ab4
diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.browser.test.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.browser.test.tsxindex 272c2d5bb9..f3f920c815 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.browser.test.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.browser.test.tsx@@ -552,11 +552,6 @@ describe('GalleryImageGrid mixed item cells', () => {expect(header?.getBoundingClientRect().height).toBe(24);expect(trigger.querySelector('svg.lucide-star')).not.toBeNull();- expect(getComputedStyle(trigger).transitionProperty).toBe('color');-- await act(() => userEvent.hover(trigger));-- expect(getComputedStyle(trigger).backgroundColor).toBe('rgba(0, 0, 0, 0)');});it('keeps the starred label and grid together before a dedicated trailing gap', async () => {@@ -643,8 +638,6 @@ describe('GalleryImageGrid mixed item cells', () => {const videoCell = videoButton.closest<HTMLElement>('[role="listitem"]');const videoPoster = videoButton.querySelector<HTMLImageElement>('img');const playIcon = videoCell?.querySelector('svg.lucide-play');- const durationBadge = playIcon?.parentElement;- const durationBadgeStyle = durationBadge ? getComputedStyle(durationBadge) : null;expect(list?.getAttribute('aria-label')).toBe('Gallery items');expect(host?.querySelectorAll('[role="listitem"]')).toHaveLength(2);@@ -655,9 +648,6 @@ describe('GalleryImageGrid mixed item cells', () => {expect(videoPoster?.hasAttribute('loading')).toBe(false);expect(videoCell?.textContent).toContain('1:06');expect(playIcon?.getAttribute('aria-hidden')).toBe('true');- expect(durationBadgeStyle?.fontVariantNumeric).toContain('tabular-nums');- expect(durationBadgeStyle?.opacity).toBe('1');- expect(durationBadgeStyle?.transitionProperty).toBe('opacity');expect(imageButton.closest('[role="listitem"]')?.textContent).toContain('128x96');expect(host?.querySelector('button[aria-label="Star shared"]')).not.toBeNull();expect(host?.querySelector('video')).toBeNull();diff --git a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/DynamicPromptsButton.browser.test.tsx b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/DynamicPromptsButton.browser.test.tsxindex ffebdd470f..78a4ae1985 100644--- a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/DynamicPromptsButton.browser.test.tsx+++ b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/DynamicPromptsButton.browser.test.tsx@@ -1,13 +1,8 @@import type { DynamicPromptsConfig } from '@features/generation/core/dynamicPrompts';-import { Box, ChakraProvider } from '@chakra-ui/react';+import { ChakraProvider } from '@chakra-ui/react';import { DynamicPromptsButton } from '@features/generation/ui/promptFields/DynamicPromptsButton';-import {- captureRowInteractionStyles,- expectRowInteractionStylesToMatch,-} from '@features/generation/ui/promptFields/promptFieldsBrowserTestUtils';import { PromptTextarea } from '@features/generation/ui/promptFields/PromptTextarea';-import { Row } from '@platform/ui/Row';import { QueryClient, QueryClientProvider } from '@tanstack/react-query';import { system } from '@theme/system';import { act } from 'react';@@ -49,13 +44,6 @@ const render = async (prompt: string, onUsePrompt = vi.fn()) => {root?.render(<QueryClientProvider client={new QueryClient()}><ChakraProvider value={system}>- <Box aria-hidden bg="bg.muted/60" data-testid="row-hover-style-probe" />- <Box aria-hidden bg="bg.muted" data-testid="popover-surface-style-probe" />- <Row asChild>- <button aria-label="Row probe" type="button">- Row probe- </button>- </Row><PromptTextareaaria-label="Prompt"defaultHeightPx={100}@@ -97,7 +85,7 @@ afterEach(async () => {});describe('dynamic prompts in the positive prompt field', () => {- it('shows expanded prompts on the standard popover surface', async () => {+ it('shows every expanded prompt and uses the one that was clicked', async () => {const { onUsePrompt } = await render('a {red|green} cat');await vi.waitFor(() => expect(findButton().textContent).toContain('2'));@@ -107,14 +95,9 @@ describe('dynamic prompts in the positive prompt field', () => {});const rows = [...document.querySelectorAll('button')].filter((button) => button.textContent?.includes('a red cat'));- const content = document.querySelector<HTMLElement>('[data-scope="popover"][data-part="content"]')!;- const surface = getComputedStyle(- host!.querySelector('[data-testid="popover-surface-style-probe"]')!- ).backgroundColor;expect(rows.length).toBe(1);expect(document.body.textContent).toContain('a green cat');- expect(getComputedStyle(content).backgroundColor).toBe(surface);await act(async () => {await userEvent.click(rows[0]!);@@ -123,27 +106,6 @@ describe('dynamic prompts in the positive prompt field', () => {expect(onUsePrompt).toHaveBeenCalledWith('a red cat');});- it('uses the shared Row interaction contract for each selectable expanded prompt', async () => {- await render('a {red|green} cat');- const probe = host!.querySelector<HTMLButtonElement>('button[aria-label="Row probe"]')!;- const hoverBackgroundColor = getComputedStyle(- host!.querySelector('[data-testid="row-hover-style-probe"]')!- ).backgroundColor;- const expected = await captureRowInteractionStyles(probe, hoverBackgroundColor);-- await vi.waitFor(() => expect(findButton().textContent).toContain('2'));- await act(async () => {- await userEvent.click(findButton());- });-- const row = [...document.querySelectorAll<HTMLButtonElement>('button')].find(- (button) =>- button.title === 'widgets.generate.dynamicPrompts.usePrompt' && button.textContent?.includes('a red cat')- )!;-- await expectRowInteractionStylesToMatch(expected, row, hoverBackgroundColor);- });-it('is a labeled primary at rest, and widens only to carry a count', async () => {// A labeled button rather than a bare icon; the expansion count appears// beside the label once the prompt is dynamic.diff --git a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PromptTemplates.browser.test.tsx b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PromptTemplates.browser.test.tsxindex 828380ee3c..d463ca1a6d 100644--- a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PromptTemplates.browser.test.tsx+++ b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PromptTemplates.browser.test.tsx@@ -1,18 +1,15 @@-import type { PromptTemplateSnapshot } from '@features/generation/core/promptTemplates';import type { PromptTemplateRecord } from '@features/generation/data/promptTemplates';import type { PromptTemplateCatalog } from '@features/generation/ui/usePromptTemplates';-import { Box, ChakraProvider } from '@chakra-ui/react';+import { ChakraProvider } from '@chakra-ui/react';import { exportPromptTemplates } from '@features/generation/data/promptTemplates';-import { expectRowInteractionsToMatch } from '@features/generation/ui/promptFields/promptFieldsBrowserTestUtils';import { PromptTemplateEditor } from '@features/generation/ui/promptFields/PromptTemplateEditor';import { PromptTemplatesPanel } from '@features/generation/ui/promptFields/PromptTemplatesPanel';import { accountLifecycle } from '@platform/state/accountLifecycle';-import { Row } from '@platform/ui/Row';import { QueryClient, QueryClientProvider } from '@tanstack/react-query';import { system } from '@theme/system';import i18next from 'i18next';-import { act, useState } from 'react';+import { act } from 'react';import { createRoot, type Root } from 'react-dom/client';import { I18nextProvider, initReactI18next } from 'react-i18next';import { afterEach, describe, expect, it, vi } from 'vitest';@@ -108,8 +105,6 @@ let host: HTMLDivElement | null = null;let root: Root | null = null;(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;-const TEMPLATE_ROW_HOVER_PROBE_PROPS = { bg: 'bg.emphasized/60' };-const userTemplate: PromptTemplateRecord = {hasImage: false,id: 'user-1',@@ -157,33 +152,6 @@ const createCatalog = (overrides: Partial<PromptTemplateCatalog> = {}): PromptTe...overrides,});-const StatefulPromptTemplatesPanel = ({ catalog }: { catalog: PromptTemplateCatalog }) => {- const [activeTemplate, setActiveTemplate] = useState<PromptTemplateSnapshot | null>(null);-- return (- <>- {/* The popover surface is bg.muted, so template rows hover one step up;- the probe Row carries the same override so the rest of the Row- contract (focus ring, transitions) is still compared like for like. */}- <Box aria-hidden bg="bg.emphasized/60" data-testid="row-hover-style-probe" />- <Row asChild _hover={TEMPLATE_ROW_HOVER_PROBE_PROPS}>- <button aria-label="Row probe" type="button">- Row probe- </button>- </Row>- <PromptTemplatesPanel- activeTemplate={activeTemplate}- catalog={catalog}- isActiveTemplateMissing={false}- onApply={setActiveTemplate}- onCreate={vi.fn()}- onDetach={vi.fn()}- onEdit={vi.fn()}- />- </>- );-};-const render = async (element: React.ReactNode) => {host = document.createElement('div');host.style.width = '400px';@@ -249,22 +217,26 @@ describe('the prompt templates panel', () => {});});- it('uses the shared Row interaction contract for inactive templates and keeps management controls separate', async () => {- await render(<StatefulPromptTemplatesPanel catalog={createCatalog()} />);+ it('keeps management controls outside the inactive template row button', async () => {+ await render(+ <PromptTemplatesPanel+ activeTemplate={null}+ catalog={createCatalog()}+ isActiveTemplateMissing={false}+ onApply={vi.fn()}+ onCreate={vi.fn()}+ onDetach={vi.fn()}+ onEdit={vi.fn()}+ />+ );- const probe = host!.querySelector<HTMLButtonElement>('button[aria-label="Row probe"]')!;const row = buttonWithText('Cinematic');- const hoverBackgroundColor = getComputedStyle(- host!.querySelector('[data-testid="row-hover-style-probe"]')!- ).backgroundColor;const edit = host!.querySelector<HTMLButtonElement>('button[aria-label="Edit: Cinematic"]')!;const remove = host!.querySelector<HTMLButtonElement>('button[aria-label="Delete: Cinematic"]')!;expect(row.getAttribute('aria-current')).toBeNull();expect(row.contains(edit)).toBe(false);expect(row.contains(remove)).toBe(false);-- await expectRowInteractionsToMatch(probe, row, hoverBackgroundColor);});it('detaches rather than clears when the applied template is deleted', async () => {diff --git a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PromptTemplatesButton.browser.test.tsx b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PromptTemplatesButton.browser.test.tsxindex a9b3e7d500..16960a0763 100644--- a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PromptTemplatesButton.browser.test.tsx+++ b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PromptTemplatesButton.browser.test.tsx@@ -1,7 +1,7 @@import type { PromptTemplateSnapshot } from '@features/generation/core/promptTemplates';import type { PromptTemplateCatalog } from '@features/generation/ui/usePromptTemplates';-import { Box, ChakraProvider } from '@chakra-ui/react';+import { ChakraProvider } from '@chakra-ui/react';import { PromptTemplatesButton } from '@features/generation/ui/promptFields/PromptTemplatesButton';import { system } from '@theme/system';import i18next from 'i18next';@@ -62,7 +62,6 @@ const render = async (activeTemplate: PromptTemplateSnapshot | null) => {root?.render(<I18nextProvider i18n={i18n}><ChakraProvider value={system}>- <Box aria-hidden bg="bg.muted" data-testid="popover-surface-style-probe" /><PromptTemplatesButton activeTemplate={activeTemplate} showSyntaxHighlighting={false} onApply={vi.fn()} /></ChakraProvider></I18nextProvider>@@ -85,7 +84,7 @@ afterEach(async () => {});describe('the prompt templates button', () => {- it('opens the catalog lazily on the standard popover surface', async () => {+ it('opens the catalog lazily', async () => {await render(null);expect(lastIsEnabled()).toBe(false);@@ -95,11 +94,7 @@ describe('the prompt templates button', () => {});expect(lastIsEnabled()).toBe(true);- const content = document.querySelector<HTMLElement>('[data-scope="popover"][data-part="content"]')!;- const surface = getComputedStyle(- host!.querySelector('[data-testid="popover-surface-style-probe"]')!- ).backgroundColor;- expect(getComputedStyle(content).backgroundColor).toBe(surface);+ expect(document.querySelector('[data-scope="popover"][data-part="content"]')).not.toBeNull();});it('dims the name and says so when the applied template is gone', async () => {diff --git a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/WildcardsPanel.browser.test.tsx b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/WildcardsPanel.browser.test.tsxindex 1764f1a47d..a32df15b05 100644--- a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/WildcardsPanel.browser.test.tsx+++ b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/WildcardsPanel.browser.test.tsx@@ -1,11 +1,9 @@import type { WildcardCatalog } from '@features/generation/ui/useWildcards';-import { Box, ChakraProvider } from '@chakra-ui/react';-import { expectRowInteractionsToMatch } from '@features/generation/ui/promptFields/promptFieldsBrowserTestUtils';+import { ChakraProvider } from '@chakra-ui/react';import { WildcardsPanel } from '@features/generation/ui/promptFields/WildcardsPanel';import { WILDCARD_COLLECTION_FORMATS } from '@features/generation/ui/wildcardFiles';import { accountLifecycle } from '@platform/state/accountLifecycle';-import { Row } from '@platform/ui/Row';import { system } from '@theme/system';import { act } from 'react';import { createRoot, type Root } from 'react-dom/client';@@ -34,8 +32,7 @@ const catalog: WildcardCatalog = {const renderPanel = async (showSyntaxHighlighting = true,panelCatalog: WildcardCatalog = catalog,- onInsert = vi.fn(),- includeRowProbe = false+ onInsert = vi.fn()) => {host = document.createElement('div');host.style.width = '380px';@@ -45,16 +42,6 @@ const renderPanel = async (await act(() => {root?.render(<ChakraProvider value={system}>- {includeRowProbe ? (- <>- <Box aria-hidden bg="bg.muted/60" data-testid="row-hover-style-probe" />- <Row asChild>- <button aria-label="Row probe" type="button">- Row probe- </button>- </Row>- </>- ) : null}<WildcardsPanel catalog={panelCatalog} showSyntaxHighlighting={showSyntaxHighlighting} onInsert={onInsert} /></ChakraProvider>);@@ -234,14 +221,10 @@ describe('wildcard list interactions', () => {const selectableWildcardButton = () =>host!.querySelector<HTMLButtonElement>('button[title="widgets.generate.dynamicPrompts.insertWildcard"]')!;- it('uses the shared Row interaction contract without nesting the edit controls', async () => {+ it('keeps the edit controls outside the selectable row button', async () => {const onInsert = vi.fn();- await renderPanel(true, catalog, onInsert, true);+ await renderPanel(true, catalog, onInsert);- const probe = host!.querySelector<HTMLButtonElement>('button[aria-label="Row probe"]')!;- const hoverBackgroundColor = getComputedStyle(- host!.querySelector('[data-testid="row-hover-style-probe"]')!- ).backgroundColor;const row = selectableWildcardButton();const edit = host!.querySelector<HTMLButtonElement>('button[aria-label="common.edit"]')!;const remove = host!.querySelector<HTMLButtonElement>('button[aria-label="common.delete"]')!;@@ -249,8 +232,6 @@ describe('wildcard list interactions', () => {expect(row.contains(edit)).toBe(false);expect(row.contains(remove)).toBe(false);- await expectRowInteractionsToMatch(probe, row, hoverBackgroundColor);-await act(async () => {await userEvent.click(row);});diff --git a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/promptFieldsBrowserTestUtils.ts b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/promptFieldsBrowserTestUtils.tsdeleted file mode 100644index 7c4261b514..0000000000--- a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/promptFieldsBrowserTestUtils.ts+++ /dev/null@@ -1,124 +0,0 @@-import { act } from 'react';-import { expect, vi } from 'vitest';-import { userEvent } from 'vitest/browser';--type FinalComputedStyles = Readonly<Partial<Pick<CSSStyleDeclaration, 'backgroundColor' | 'color'>>>;--export const waitForComputedStyles = async (element: Element, expected: FinalComputedStyles) => {- await vi.waitFor(() => {- const styles = getComputedStyle(element);-- for (const property of Object.keys(expected) as (keyof FinalComputedStyles)[]) {- expect(styles[property]).toBe(expected[property]);- }- });-};--export const captureRowInteractionStyles = async (probe: HTMLButtonElement, hoverBackgroundColor: string) => {- await act(async () => {- await focusWithKeyboard(probe);- await userEvent.hover(probe);- });- await waitForComputedStyles(probe, { backgroundColor: hoverBackgroundColor });- const expected = getInteractionStyles(probe);-- await act(async () => {- await userEvent.unhover(probe);- });-- return expected;-};--export const expectRowInteractionStylesToMatch = async (- expected: ReturnType<typeof getInteractionStyles>,- row: HTMLButtonElement,- hoverBackgroundColor: string-) => {- await act(async () => {- await focusWithKeyboard(row);- await userEvent.hover(row);- });- await waitForComputedStyles(row, { backgroundColor: hoverBackgroundColor });-- expect(getInteractionStyles(row)).toEqual(expected);-};--export const expectRowInteractionsToMatch = async (- probe: HTMLButtonElement,- row: HTMLButtonElement,- hoverBackgroundColor: string-) => {- const expected = await captureRowInteractionStyles(probe, hoverBackgroundColor);- await expectRowInteractionStylesToMatch(expected, row, hoverBackgroundColor);-};--export const getXsButtonDensityStyles = (element: HTMLElement) => {- const styles = getComputedStyle(element);-- return {- borderBottomColor: styles.borderBottomColor,- borderBottomStyle: styles.borderBottomStyle,- borderBottomWidth: styles.borderBottomWidth,- borderLeftColor: styles.borderLeftColor,- borderLeftStyle: styles.borderLeftStyle,- borderLeftWidth: styles.borderLeftWidth,- borderRightColor: styles.borderRightColor,- borderRightStyle: styles.borderRightStyle,- borderRightWidth: styles.borderRightWidth,- borderTopColor: styles.borderTopColor,- borderTopStyle: styles.borderTopStyle,- borderTopWidth: styles.borderTopWidth,- fontSize: styles.fontSize,- fontWeight: styles.fontWeight,- lineHeight: styles.lineHeight,- whiteSpace: styles.whiteSpace,- };-};--export const matchElementWidth = (element: HTMLElement, reference: HTMLElement) => {- element.style.width = `${reference.offsetWidth}px`;-};--export const getElementBoxMetrics = (element: HTMLElement) => ({- clientHeight: element.clientHeight,- clientWidth: element.clientWidth,- offsetHeight: element.offsetHeight,- offsetWidth: element.offsetWidth,- scrollHeight: element.scrollHeight,- scrollWidth: element.scrollWidth,-});--export const getRenderedLineCount = (element: HTMLElement) => {- const range = document.createRange();- range.selectNodeContents(element);- const lineTops = new Set(- [...range.getClientRects()].filter((rect) => rect.width > 0).map((rect) => Math.round(rect.top * 100) / 100)- );-- return lineTops.size;-};--const focusWithKeyboard = async (element: HTMLButtonElement) => {- for (let index = 0; index < 12; index += 1) {- if (document.activeElement === element) {- return;- }- await userEvent.tab();- }-- throw new Error(`Could not focus ${element.title || element.textContent} with the keyboard`);-};--const getInteractionStyles = (element: HTMLElement) => {- const styles = getComputedStyle(element);-- return {- backgroundColor: styles.backgroundColor,- borderRadius: styles.borderRadius,- outline: styles.outline,- outlineOffset: styles.outlineOffset,- transitionDuration: styles.transitionDuration,- transitionProperty: styles.transitionProperty,- transitionTimingFunction: styles.transitionTimingFunction,- };-};diff --git a/invokeai/frontend/webv2/src/platform/ui/Tabs.browser.test.tsx b/invokeai/frontend/webv2/src/platform/ui/Tabs.browser.test.tsxindex e013fd812a..0efc99939a 100644--- a/invokeai/frontend/webv2/src/platform/ui/Tabs.browser.test.tsx+++ b/invokeai/frontend/webv2/src/platform/ui/Tabs.browser.test.tsx@@ -1,12 +1,10 @@-import { Box, ChakraProvider, Stack, Tabs } from '@chakra-ui/react';+import { ChakraProvider, Tabs } from '@chakra-ui/react';import { system } from '@theme/system';import { act } from 'react';import { createRoot, type Root } from 'react-dom/client';import { afterEach, describe, expect, it } from 'vitest';import { userEvent } from 'vitest/browser';-const variants = ['line', 'subtle', 'enclosed', 'outline', 'plain'] as const;-let host: HTMLDivElement | null = null;let root: Root | null = null;(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;@@ -18,184 +16,47 @@ afterEach(async () => {root = null;});-/**- * This test drives real pointer input across five variants, and each move costs- * whatever the machine can spare. Measured on a loaded 16-core box, the moves- * alone took 7–13.5s against the default 15s, and every failure was a timeout- * sitting at 12.5–13.6s — never an assertion. The settle waits were flat at- * ~1.1s throughout, so synchronization was never the problem; the budget was.- * Dropping the redundant unhovers below removes a third of the moves, and this- * ceiling covers what is left.- */-const HOVER_SWEEP_TIMEOUT_MS = 60_000;--describe('tab hover styles', () => {- it(- 'gives every variant restrained hover feedback without changing selected or disabled tabs',- async () => {- host = document.createElement('div');- document.body.append(host);- root = createRoot(host);-- await act(async () => {- root?.render(- <ChakraProvider value={system}>- <Stack>- <Box aria-label="muted background probe" bg="bg.muted" />- <Box aria-label="faint muted background probe" bg="bg.muted/60" />- <Box aria-label="light muted background probe" bg="bg.muted/40" />- <Box aria-label="emphasized background probe" bg="bg.emphasized" />- <Box aria-label="emphasized border probe" borderColor="border.emphasized" borderWidth="1px" />- {variants.map((variant) => (- <Tabs.Root key={variant} value="selected" variant={variant}>- <Tabs.List>- <Tabs.Trigger aria-label={`${variant} idle`} value="idle">- Idle- </Tabs.Trigger>- <Tabs.Trigger aria-label={`${variant} selected`} value="selected">- Selected- </Tabs.Trigger>- <Tabs.Trigger aria-label={`${variant} disabled`} value="disabled" disabled>- Disabled- </Tabs.Trigger>- </Tabs.List>- </Tabs.Root>- ))}- </Stack>- </ChakraProvider>- );- await new Promise<void>((resolve) => {- globalThis.setTimeout(resolve, 0);- });- });-- const mutedBackground = getProbeStyle(host, 'muted background probe').backgroundColor;- const faintMutedBackground = getProbeStyle(host, 'faint muted background probe').backgroundColor;- const lightMutedBackground = getProbeStyle(host, 'light muted background probe').backgroundColor;- const emphasizedBackground = getProbeStyle(host, 'emphasized background probe').backgroundColor;- const emphasizedBorder = getProbeStyle(host, 'emphasized border probe').borderColor;- const expectedHoverBackgrounds = {- enclosed: emphasizedBackground,- line: faintMutedBackground,- outline: mutedBackground,- plain: lightMutedBackground,- subtle: mutedBackground,- };-- for (const variant of variants) {- const idle = host.querySelector<HTMLButtonElement>(`[aria-label="${variant} idle"]`)!;- const selected = host.querySelector<HTMLButtonElement>(`[aria-label="${variant} selected"]`)!;- const disabled = host.querySelector<HTMLButtonElement>(`[aria-label="${variant} disabled"]`)!;- const idleBefore = getInteractionStyles(idle);- const selectedBefore = getInteractionStyles(selected);- const disabledBefore = getInteractionStyles(disabled);-- await act(async () => {- await userEvent.hover(idle);- await waitForSettledStyles(idle);- });- const idleHovered = getInteractionStyles(idle);- expect(idleHovered.transitionDuration).toBe('0.1s');- expect(idleHovered.transitionProperty).toBe('background, border-color, color');- expect(idleHovered.backgroundColor).toBe(expectedHoverBackgrounds[variant]);- if (variant === 'line' || variant === 'plain') {- expect(idleHovered.color).not.toBe(idleBefore.color);- } else {- expect(idleHovered.color).toBe(idleBefore.color);- }- if (variant === 'outline') {- expect(idleHovered.borderColor).toBe(emphasizedBorder);- }-- await act(async () => {- await userEvent.hover(selected);- await waitForSettledStyles(selected);- });- expect(getInteractionStyles(selected)).toEqual(selectedBefore);-- await act(async () => {- await userEvent.hover(disabled);- await waitForSettledStyles(disabled);- });- expect(getInteractionStyles(disabled)).toEqual(disabledBefore);- }-- const lineIdle = host.querySelector<HTMLButtonElement>('[aria-label="line idle"]')!;- const lineSelected = host.querySelector<HTMLButtonElement>('[aria-label="line selected"]')!;- await act(async () => {- await userEvent.tab();- await userEvent.keyboard('{ArrowLeft}');+describe('tab focus feedback', () => {+ it('keeps the keyboard focus outline through hover without disturbing the selected tab', async () => {+ host = document.createElement('div');+ document.body.append(host);+ root = createRoot(host);++ await act(async () => {+ root?.render(+ <ChakraProvider value={system}>+ <Tabs.Root value="selected" variant="line">+ <Tabs.List>+ <Tabs.Trigger aria-label="line idle" value="idle">+ Idle+ </Tabs.Trigger>+ <Tabs.Trigger aria-label="line selected" value="selected">+ Selected+ </Tabs.Trigger>+ </Tabs.List>+ </Tabs.Root>+ </ChakraProvider>+ );+ await new Promise<void>((resolve) => {+ globalThis.setTimeout(resolve, 0);});- expect(document.activeElement).toBe(lineIdle);- const focusOutline = getComputedStyle(lineIdle).outline;- expect(focusOutline).not.toBe('none');-- await act(async () => {- await userEvent.hover(lineIdle);- await waitForSettledStyles(lineIdle);- });- expect(getComputedStyle(lineIdle).outline).toBe(focusOutline);- expect(lineSelected.dataset.selected).toBe('');- },- HOVER_SWEEP_TIMEOUT_MS- );-});--const getInteractionStyles = (element: HTMLElement) => {- const styles = getComputedStyle(element);-- return {- backgroundColor: styles.backgroundColor,- borderColor: styles.borderColor,- color: styles.color,- transitionDuration: styles.transitionDuration,- transitionProperty: styles.transitionProperty,- };-};--/** Consecutive unchanged samples that count as "the transition has finished". */-const STABLE_SAMPLES = 3;-const SAMPLE_INTERVAL_MS = 16;--/**- * Waits until an element's interaction styles stop changing, rather than- * sleeping a fixed interval after each hover.- *- * These transitions run for 0.1s, but the test hovers fifteen triggers and- * used to wait 200ms every time — three seconds of sleeping against a 15s- * test timeout, which is what made this fail on a loaded CI runner. Sampling- * until the values hold still takes as long as the machine actually needs,- * and usually far less.- */-const waitForSettledStyles = (element: HTMLElement, timeoutMs = 5000): Promise<void> =>- new Promise<void>((resolve, reject) => {- const deadline = Date.now() + timeoutMs;- let previous = JSON.stringify(getInteractionStyles(element));- let stableSamples = 0;-- const sample = () => {- const current = JSON.stringify(getInteractionStyles(element));-- stableSamples = current === previous ? stableSamples + 1 : 0;- previous = current;-- if (stableSamples >= STABLE_SAMPLES) {- resolve();-- return;- }-- if (Date.now() > deadline) {- reject(new Error(`Timed out after ${timeoutMs}ms waiting for styles to settle; last value ${current}`));-- return;- }-- globalThis.setTimeout(sample, SAMPLE_INTERVAL_MS);- };-- globalThis.setTimeout(sample, SAMPLE_INTERVAL_MS);+ });++ const idle = host.querySelector<HTMLButtonElement>('[aria-label="line idle"]')!;+ const selected = host.querySelector<HTMLButtonElement>('[aria-label="line selected"]')!;++ await act(async () => {+ await userEvent.tab();+ await userEvent.keyboard('{ArrowLeft}');+ });+ expect(document.activeElement).toBe(idle);+ const focusOutline = getComputedStyle(idle).outline;+ expect(focusOutline).not.toBe('none');++ await act(async () => {+ await userEvent.hover(idle);+ });+ expect(getComputedStyle(idle).outline).toBe(focusOutline);+ expect(selected.dataset.selected).toBe('');});--const getProbeStyle = (container: HTMLElement, label: string) =>- getComputedStyle(container.querySelector<HTMLElement>(`[aria-label="${label}"]`)!);+});diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewMediaChrome.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewMediaChrome.browser.test.tsxindex ca01049e0d..9c8d75887a 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewMediaChrome.browser.test.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewMediaChrome.browser.test.tsx@@ -182,7 +182,7 @@ afterEach(async () => {});describe('PreviewFilmstrip mixed media', () => {- it('uses the gallery-style full accent border for the selected item', async () => {+ it('uses the gallery-style accent border for the selected item', async () => {await render(<><Box borderColor="accent.solid" borderWidth="2px" data-filmstrip-selected-border-reference="" />@@ -199,14 +199,9 @@ describe('PreviewFilmstrip mixed media', () => {const reference = host!.querySelector<HTMLElement>('[data-filmstrip-selected-border-reference]')!;const selected = host!.querySelector<HTMLButtonElement>('[aria-current="true"]')!;- const selectedStyle = getComputedStyle(selected);const accentColor = getComputedStyle(reference).borderTopColor;- expect(selectedStyle.borderTopWidth).toBe('2px');- expect(selectedStyle.borderTopColor).toBe(accentColor);- expect(selectedStyle.borderRightColor).toBe(accentColor);- expect(selectedStyle.borderBottomColor).toBe(accentColor);- expect(selectedStyle.borderLeftColor).toBe(accentColor);+ expect(getComputedStyle(selected).borderTopColor).toBe(accentColor);expect(selected.querySelector(':scope > div')).toBeNull();});