Skip to content

Commit

Permalink
[New #113] Add useEvent to trigger comment tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
LaChope committed Mar 24, 2022
1 parent e24ec57 commit 77f52a0
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
18 changes: 18 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Expand Up @@ -91,6 +91,7 @@
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.6",
"babel-jest": "^26.0.1",
"babel-loader": "^8.1.0",
"chromatic": "^6.5.3",
"clean-css-cli": "^4.3.0",
"css-loader": "^3.5.3",
"enzyme": "^3.11.0",
Expand All @@ -110,7 +111,8 @@
"lib": "babel ./src -d ./lib",
"build:lib": "npm run build && npm run build:css && npm pack",
"build:css": "cleancss --skip-rebase -d -o ./css/s-forms.min.css ./src/styles/s-forms.css",
"build-storybook": "build-storybook"
"build-storybook": "build-storybook",
"chromatic": "npx chromatic --project-token=4596425d0cfa"
},
"files": [
"dist/",
Expand Down
2 changes: 1 addition & 1 deletion src/components/comment/QuestionCommentIcon.jsx
Expand Up @@ -88,7 +88,7 @@ const QuestionCommentIcon = (props) => {

return (
<div ref={overlayTarget} onClick={handleStopPropagationClick}>
<span ref={target} onClick={handleOverlayClick}>
<span data-testid="comment-bubble" ref={target} onClick={handleOverlayClick}>
<CommentBubble/>
{getCommentsLength() > 0 ? <Badge className="comment-badge" pill variant="primary">{getCommentsLength()}</Badge> : null}
</span>
Expand Down
14 changes: 12 additions & 2 deletions src/stories/QuestionCommentIcon.stories.tsx
Expand Up @@ -3,6 +3,7 @@ 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 question from "./assets/question/question.json";
import questionWithComment from "./assets/question/questionWithComment.json";
Expand Down Expand Up @@ -40,10 +41,19 @@ const Template: ComponentStory<typeof QuestionCommentIcon> = (

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

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

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

0 comments on commit 77f52a0

Please sign in to comment.