Skip to content

Commit

Permalink
[New #113] Add interaction test
Browse files Browse the repository at this point in the history
  • Loading branch information
LaChope committed Mar 29, 2022
1 parent d69fae8 commit f8f8473
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/stories/QuestionCommentIcon.stories.tsx
Expand Up @@ -3,7 +3,8 @@ import QuestionCommentIcon from "../components/comment/QuestionCommentIcon";
import { ComponentMeta, ComponentStory } from "@storybook/react";
import IntlContextProvider from "../contexts/IntlContextProvider";
import { ConfigurationContextProvider } from "../contexts/ConfigurationContext";
import { screen, userEvent, within } from "@storybook/testing-library";
import { userEvent, within } from "@storybook/testing-library";
import { expect } from '@storybook/jest';

import question from "./assets/question/question.json";
import questionWithComment from "./assets/question/questionWithComment.json";
Expand Down Expand Up @@ -44,16 +45,29 @@ Default.args = {
question: question,
};

export const TooltipOpen = Template.bind({});
TooltipOpen.args = {
question: question,
};
TooltipOpen.play = async ({ canvasElement }) => {
const canvas = within(canvasElement);
await userEvent.click(canvas.getByTestId("comment-bubble"));
};

export const WithComment = Template.bind({});
WithComment.args = {
question: questionWithComment,
};

export const TooltipOpen = Template.bind({});
TooltipOpen.args = {
question: question,
export const TooltipOpenWithComment = Template.bind({});
TooltipOpenWithComment.args = {
question: questionWithComment,
};
TooltipOpen.play = async ({ canvasElement }) => {

TooltipOpenWithComment.play = async ({ canvasElement }) => {
const canvas = within(canvasElement);
await userEvent.click(canvas.getByTestId("comment-bubble"));
await expect(canvas.getByRole('tooltip')).toBeInTheDocument();
await expect(canvas.getByText("Hello, my name is Max Chopart")).toBeInTheDocument();
};

0 comments on commit f8f8473

Please sign in to comment.