From 5ce2fe144a3de7c888960fac2e7f9902f37ff344 Mon Sep 17 00:00:00 2001 From: William Spada Date: Fri, 27 Sep 2024 16:03:19 -0300 Subject: [PATCH 1/6] build: remove react-clipboard.js and replace by using react-copy-to-clipboard package --- .../ExpandedStoryHistoryLocation.jsx | 36 +++++++---------- .../components/story/StoryCopyIdClipboard.jsx | 13 ++---- package.json | 2 +- .../expanded_story_history_location_spec.js | 6 +-- yarn.lock | 40 ++++++++++--------- 5 files changed, 44 insertions(+), 53 deletions(-) diff --git a/app/assets/javascripts/components/story/ExpandedStory/ExpandedStoryHistoryLocation.jsx b/app/assets/javascripts/components/story/ExpandedStory/ExpandedStoryHistoryLocation.jsx index 7b305deb7..93a82a7c1 100644 --- a/app/assets/javascripts/components/story/ExpandedStory/ExpandedStoryHistoryLocation.jsx +++ b/app/assets/javascripts/components/story/ExpandedStory/ExpandedStoryHistoryLocation.jsx @@ -1,6 +1,6 @@ import React from 'react'; -import Clipboard from 'react-clipboard.js'; import { storyUrl } from '../StoryUrl'; +import { CopyToClipboard } from 'react-copy-to-clipboard'; import { editingStoryPropTypesShape, hasHistory, @@ -17,27 +17,21 @@ const ExpandedStoryHistoryLocation = ({ story, onClone, showHistory }) => ( /> - - {I18n.t('story.events.copy_url')} - + + + {I18n.t('story.events.copy_url')} + + - - ID - + +

+ ID {`#${story.id.toString()}`} +

+
{hasHistory(story) && ( , @@ -19,4 +19,18 @@ describe('', function () { component.container.querySelector('data-clipboard-textt') ).toBeDefined(); }); + + it('should copy correct id', async () => { + const onCopy = vi.fn(); + + const { container } = render( + + ); + + const paragraph = container.querySelector('p'); + + fireEvent.click(paragraph); + + expect(onCopy).toHaveBeenCalledWith('#70', false); + }); });