From 91caf7b08ee02a70940320aedf27c1580ead2324 Mon Sep 17 00:00:00 2001 From: Spencer Hamm Date: Tue, 3 Feb 2026 23:49:43 -0600 Subject: [PATCH 1/2] cleanup tests and remove async act --- .../manager/__tests__/managed-player.test.tsx | 59 ++++++++++--------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/react/player/src/manager/__tests__/managed-player.test.tsx b/react/player/src/manager/__tests__/managed-player.test.tsx index b35d9b170..b8a6926f7 100644 --- a/react/player/src/manager/__tests__/managed-player.test.tsx +++ b/react/player/src/manager/__tests__/managed-player.test.tsx @@ -83,6 +83,7 @@ describe.each([ const onComplete = vitest.fn(); const onError = vitest.fn(); + const onStartedFlow = vitest.fn(); const container = render( @@ -91,6 +92,7 @@ describe.each([ plugins={[new SimpleAssetPlugin(), new MetricsCorePlugin()]} onComplete={onComplete} onError={onError} + onStartedFlow={onStartedFlow} /> , { legacyRoot }, @@ -98,22 +100,26 @@ describe.each([ expect(manager.next).toBeCalledWith(undefined); const view = await container.findByTestId("flow-1"); + expect(onStartedFlow).toBeCalledTimes(1); expect(view).toBeInTheDocument(); + const nextButton = await container.findByText("Continue"); - await act(async () => { - const nextButton = await container.findByText("Continue"); + act(() => { nextButton.click(); }); - expect(manager.next).toBeCalledTimes(2); - const view2 = await container.findByTestId("flow-2"); expect(view2).toBeInTheDocument(); + expect(manager.next).toBeCalledTimes(2); + expect(onStartedFlow).toBeCalledTimes(2); - await act(async () => { - const nextButton = await container.findByText("Continue"); - nextButton.click(); + const nextButton2 = await container.findByText("Continue"); + + act(() => { + nextButton2.click(); }); + + await container.findByText("loading"); const getRequestTime = (RequestTimeWebPlugin as any).mock.calls[0][0]; expect(getRequestTime()).toBeDefined(); expect(onComplete).toBeCalled(); @@ -183,21 +189,23 @@ describe.each([ expect(manager.next).toBeCalledWith(undefined); const view = await screen.findByTestId("flow-1"); expect(view).toBeInTheDocument(); + const nextButton = await screen.findByText("Continue"); - await act(async () => { - const nextButton = await screen.findByText("Continue"); + act(() => { nextButton.click(); }); - expect(manager.next).toBeCalledTimes(2); - const view2 = await screen.findByTestId("flow-2"); expect(view2).toBeInTheDocument(); + expect(manager.next).toBeCalledTimes(2); - await act(async () => { - const nextButton = await screen.findByText("Continue"); - nextButton.click(); + const nextButton2 = await screen.findByText("Continue"); + + act(() => { + nextButton2.click(); }); + + await screen.findByText("loading"); expect(onComplete).toBeCalledWith( expect.objectContaining({ status: "completed", @@ -240,9 +248,7 @@ describe.each([ const onComplete = vitest.fn(); const onError = vitest.fn(); - /** - * - */ + const MyFallback = (props: FallbackProps) => (