-
Notifications
You must be signed in to change notification settings - Fork 1
chore(VE-6918/error-text): warning message improved #459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
3d61705
Merge pull request #452 from contentstack/develop_v3
karancs06 a3d3294
Merge pull request #454 from contentstack/stage_v3
karancs06 1a4dc42
chore(VE-6918/error-text): warning message improved
csAdityaPachauri cce1c21
Merge branch 'develop_v3' of https://github.com/contentstack/live-pre…
csAdityaPachauri 5693ccd
chore(VE-6918/error-text): component name changed to title case
csAdityaPachauri a273355
Merge branch 'develop_v3' of https://github.com/contentstack/live-pre…
csAdityaPachauri 5084bb3
chore(talismanrc): updated
csAdityaPachauri 699f81c
Merge pull request #455 from contentstack/VE-6600-Hover-Toolbar-Support
csAyushDubey 7146855
Merge pull request #464 from contentstack/VE-6600-Hover-Toolbar-Support
csAyushDubey f6939b1
Merge pull request #461 from contentstack/VE-6600-Hover-Toolbar-Support
csAyushDubey 11c9812
Merge pull request #473 from contentstack/release-24-jul-main
sairaj-cs 950170c
chore:increment package version
csAdityaPachauri 71913fb
Merge branch 'main' into stage_v3
csAdityaPachauri 95fb850
Merge pull request #474 from contentstack/stage_v3
sairaj-cs 3a21b82
chore(VE-6918/error-text): unit test file added
csAdityaPachauri 04f22dd
Merge branch 'main' of https://github.com/contentstack/live-preview-s…
csAdityaPachauri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| import React from "preact/compat"; | ||
| import { render, fireEvent, waitFor } from "@testing-library/preact"; | ||
| import { EmptyBlock } from "../emptyBlock"; | ||
| import visualBuilderPostMessage from "../../utils/visualBuilderPostMessage"; | ||
| import { observeParentAndFocusNewInstance } from "../../utils/multipleElementAddButton"; | ||
| import { CslpData } from "../../../cslp/types/cslp.types"; | ||
| import { ISchemaFieldMap } from "../../utils/types/index.types"; | ||
| import { VisualBuilderPostMessageEvents } from "../../utils/types/postMessage.types"; | ||
|
|
||
| vi.mock("../../utils/visualBuilderPostMessage", () => ({ | ||
| default: { | ||
| send: vi.fn(), | ||
| }, | ||
| })); | ||
|
|
||
| vi.mock("../../utils/multipleElementAddButton", () => ({ | ||
| observeParentAndFocusNewInstance: vi.fn(), | ||
| })); | ||
|
|
||
| describe("EmptyBlock", () => { | ||
| const mockDetails = { | ||
| fieldMetadata: { | ||
| cslpValue: "parent.cslp.value", | ||
| } as CslpData, | ||
| fieldSchema: { | ||
| display_name: "Test Block", | ||
| } as ISchemaFieldMap, | ||
| }; | ||
|
|
||
| afterEach(() => { | ||
| vi.clearAllMocks(); | ||
| }); | ||
|
|
||
| test("should render correctly", () => { | ||
| const { getByText, getByTestId } = render( | ||
| <EmptyBlock details={mockDetails} /> | ||
| ); | ||
|
|
||
| expect( | ||
| getByText( | ||
| (_, element) => | ||
| element?.textContent === | ||
| "This page doesn’t have any Test Block added. Click the button below to add one." | ||
| ) | ||
| ).toBeTruthy(); | ||
| expect( | ||
| getByTestId("visual-builder__empty-block-add-button") | ||
| ).toBeTruthy(); | ||
| expect(getByText("Add Test Block")).toBeTruthy(); | ||
| }); | ||
|
|
||
| test("should call sendAddInstanceEvent on button click", async () => { | ||
| const { getByTestId } = render(<EmptyBlock details={mockDetails} />); | ||
| const addButton = getByTestId("visual-builder__empty-block-add-button"); | ||
|
|
||
| fireEvent.click(addButton); | ||
|
|
||
| await waitFor(() => { | ||
| expect((visualBuilderPostMessage as any).send).toHaveBeenCalledWith( | ||
| VisualBuilderPostMessageEvents.ADD_INSTANCE, | ||
| { | ||
| fieldMetadata: mockDetails.fieldMetadata, | ||
| index: 0, | ||
| } | ||
| ); | ||
| }); | ||
|
|
||
| expect(observeParentAndFocusNewInstance).toHaveBeenCalledWith({ | ||
| parentCslp: mockDetails.fieldMetadata.cslpValue, | ||
| index: 0, | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.