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(webv2): synchronize prompt row transitions
joshistoasta3b0b30af229
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 3da7820ad0..32a6203e2c 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@@ -188,11 +188,12 @@ describe('dynamic prompts in the positive prompt field', () => {});const getRowInteractionStyles = async (probe: HTMLButtonElement) => {+ const probeBackgroundTransition = waitForBackgroundTransition(probe);await act(async () => {await userEvent.tab();await userEvent.hover(probe);- await waitForTransition();});+ await probeBackgroundTransition;const expected = getInteractionStyles(probe);await act(async () => {@@ -206,11 +207,12 @@ const expectRowInteractionsToMatch = async (expected: ReturnType<typeof getInteractionStyles>,row: HTMLButtonElement) => {+ const rowBackgroundTransition = waitForBackgroundTransition(row);await act(async () => {await focusWithKeyboard(row);await userEvent.hover(row);- await waitForTransition();});+ await rowBackgroundTransition;expect(getInteractionStyles(row)).toEqual(expected);};@@ -240,7 +242,14 @@ const getInteractionStyles = (element: HTMLElement) => {};};-const waitForTransition = () =>+const waitForBackgroundTransition = (element: HTMLElement) =>new Promise<void>((resolve) => {- globalThis.setTimeout(resolve, 200);+ const onTransitionEnd = (event: TransitionEvent) => {+ if (event.target === element && event.propertyName === 'background-color') {+ element.removeEventListener('transitionend', onTransitionEnd);+ resolve();+ }+ };++ element.addEventListener('transitionend', onTransitionEnd);});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 5d5991acaa..32182d7746 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@@ -835,19 +835,21 @@ describe('prompt template image outlines', () => {});const expectRowInteractionsToMatch = async (probe: HTMLButtonElement, row: HTMLButtonElement) => {+ const probeBackgroundTransition = waitForBackgroundTransition(probe);await act(async () => {await userEvent.tab();await userEvent.hover(probe);- await waitForTransition();});+ await probeBackgroundTransition;const expected = getInteractionStyles(probe);+ const rowBackgroundTransition = waitForBackgroundTransition(row);await act(async () => {await userEvent.unhover(probe);await focusWithKeyboard(row);await userEvent.hover(row);- await waitForTransition();});+ await rowBackgroundTransition;expect(getInteractionStyles(row)).toEqual(expected);};@@ -877,7 +879,14 @@ const getInteractionStyles = (element: HTMLElement) => {};};-const waitForTransition = () =>+const waitForBackgroundTransition = (element: HTMLElement) =>new Promise<void>((resolve) => {- globalThis.setTimeout(resolve, 200);+ const onTransitionEnd = (event: TransitionEvent) => {+ if (event.target === element && event.propertyName === 'background-color') {+ element.removeEventListener('transitionend', onTransitionEnd);+ resolve();+ }+ };++ element.addEventListener('transitionend', onTransitionEnd);});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 b1f41e9f56..937fda35bd 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@@ -374,19 +374,21 @@ describe('deleting a wildcard', () => {});const expectRowInteractionsToMatch = async (probe: HTMLButtonElement, row: HTMLButtonElement) => {+ const probeBackgroundTransition = waitForBackgroundTransition(probe);await act(async () => {await userEvent.tab();await userEvent.hover(probe);- await waitForTransition();});+ await probeBackgroundTransition;const expected = getInteractionStyles(probe);+ const rowBackgroundTransition = waitForBackgroundTransition(row);await act(async () => {await userEvent.unhover(probe);await focusWithKeyboard(row);await userEvent.hover(row);- await waitForTransition();});+ await rowBackgroundTransition;expect(getInteractionStyles(row)).toEqual(expected);};@@ -416,7 +418,14 @@ const getInteractionStyles = (element: HTMLElement) => {};};-const waitForTransition = () =>+const waitForBackgroundTransition = (element: HTMLElement) =>new Promise<void>((resolve) => {- globalThis.setTimeout(resolve, 200);+ const onTransitionEnd = (event: TransitionEvent) => {+ if (event.target === element && event.propertyName === 'background-color') {+ element.removeEventListener('transitionend', onTransitionEnd);+ resolve();+ }+ };++ element.addEventListener('transitionend', onTransitionEnd);});