From 0749e5999faf6faa9f7b737e13f8c39d1e9c3680 Mon Sep 17 00:00:00 2001 From: Gert Hengeveld Date: Thu, 23 Jun 2022 12:15:55 +0200 Subject: [PATCH] Test debugger controls --- addons/interactions/src/Panel.stories.tsx | 31 +++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/addons/interactions/src/Panel.stories.tsx b/addons/interactions/src/Panel.stories.tsx index caa41282e2b..cc4a5e6561b 100644 --- a/addons/interactions/src/Panel.stories.tsx +++ b/addons/interactions/src/Panel.stories.tsx @@ -1,8 +1,11 @@ +/* eslint-disable jest/no-standalone-expect */ import React from 'react'; import { action } from '@storybook/addon-actions'; import type { ComponentStoryObj, ComponentMeta } from '@storybook/react'; import { CallStates } from '@storybook/instrumenter'; import { styled } from '@storybook/theming'; +import { userEvent, within, waitFor } from '@storybook/testing-library'; +import { expect } from '@storybook/jest'; import { getCalls, getInteractions } from './mocks'; import { AddonPanelPure } from './Panel'; @@ -57,6 +60,34 @@ export const Passing: Story = { interactions: getInteractions(CallStates.DONE), }, }; +Passing.play = async ({ args, canvasElement }) => { + const canvas = within(canvasElement); + + await waitFor(async () => { + await userEvent.click(canvas.getByLabelText('Go to start')); + await expect(args.controls.start).toHaveBeenCalled(); + }); + + await waitFor(async () => { + await userEvent.click(canvas.getByLabelText('Go back')); + await expect(args.controls.back).toHaveBeenCalled(); + }); + + await waitFor(async () => { + await userEvent.click(canvas.getByLabelText('Go forward')); + await expect(args.controls.next).not.toHaveBeenCalled(); + }); + + await waitFor(async () => { + await userEvent.click(canvas.getByLabelText('Go to end')); + await expect(args.controls.end).not.toHaveBeenCalled(); + }); + + await waitFor(async () => { + await userEvent.click(canvas.getByLabelText('Rerun')); + await expect(args.controls.rerun).toHaveBeenCalled(); + }); +}; export const Paused: Story = { args: {