diff --git a/frontend/tests/componentTests/blocksrendererclient.desktop.spec.tsx b/frontend/tests/componentTests/blocksrendererclient.spec.tsx similarity index 91% rename from frontend/tests/componentTests/blocksrendererclient.desktop.spec.tsx rename to frontend/tests/componentTests/blocksrendererclient.spec.tsx index a307383..94f2bc3 100644 --- a/frontend/tests/componentTests/blocksrendererclient.desktop.spec.tsx +++ b/frontend/tests/componentTests/blocksrendererclient.spec.tsx @@ -24,7 +24,6 @@ test("Check content rendering in BlockRendererClient", async ({ mount }) => { }, ], }, - // Add other content blocks as needed ]; // Mount the BlockRendererClient with mock content @@ -37,6 +36,4 @@ test("Check content rendering in BlockRendererClient", async ({ mount }) => { await expect(component.getByRole("paragraph")).toContainText( "Dolor sit amet", ); - - // Add more assertions based on your content blocks }); diff --git a/frontend/tests/componentTests/slicepreviewtext.spec.tsx b/frontend/tests/componentTests/slicepreviewtext.spec.tsx new file mode 100644 index 0000000..b09ec88 --- /dev/null +++ b/frontend/tests/componentTests/slicepreviewtext.spec.tsx @@ -0,0 +1,53 @@ +import { test, expect } from "@playwright/experimental-ct-react"; +import { SlicePreviewText } from "@/components/SlicePreviewText"; +import { BlocksContent } from "@strapi/blocks-react-renderer"; + +test("Check SlicePreviewText function", async () => { + // Mock content with a paragraph block + const mockContent: BlocksContent = [ + { + type: "heading", + children: [ + { + type: "text", + text: "Lorem ipsum", + }, + ], + level: 1, + }, + { + type: "paragraph", + children: [ + { + type: "text", + text: "", + }, + ], + }, + { + type: "paragraph", + children: [ + { + type: "text", + text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum pulvinar viverra diam. Aliquam venenatis fermentum nisl, ut pulvinar nunc consectetur ac. Nunc sit amet velit nibh. Sed sagittis mauris in elit varius aliquet. Phasellus lacus risus, suscipit sed nisl ac, consectetur faucibus est. Curabitur porta ante nec tortor finibus venenatis. Etiam ac nulla vitae est dapibus tincidunt. Quisque mollis pulvinar bibendum.", + }, + ], + }, + { + type: "paragraph", + children: [ + { + type: "text", + text: "Do not slice this paragraph, only the first one", + }, + ], + }, + ]; + + const slicedText = SlicePreviewText(mockContent); + + // Assert that the sliced text contains the expected content + expect(slicedText).toContain( + "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum pulvinar viverra diam. Aliquam v...", + ); +});