Skip to content
This repository has been archived by the owner on Oct 4, 2022. It is now read-only.

P2 786 only render ok when block is valid #1146

Merged
merged 41 commits into from
May 10, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
4f15ce7
Added a method that checks if the blockValidationResult is considered…
Apr 7, 2021
d976c74
Adds a check to see if the added suggestion is valid
Apr 7, 2021
0e3a803
Updates the tests for the blocksuggestions
Apr 7, 2021
f772213
Improval of the test by mocking the functions directly
Apr 7, 2021
bc2a734
Merge branch 'develop' of https://github.com/Yoast/javascript into P2…
Apr 8, 2021
9eb9930
Process CR
Apr 8, 2021
c467972
Remove typehints in jsdoc
Apr 8, 2021
54dfb3a
Merge branch 'develop' of https://github.com/Yoast/javascript into P2…
Apr 8, 2021
cd2ea53
Check if the block validation is OK
Apr 12, 2021
c67c29a
Merge branch 'develop' of https://github.com/Yoast/javascript into P2…
Apr 12, 2021
ebfa7e5
Merge branch 'develop' of https://github.com/Yoast/javascript into P2…
Apr 14, 2021
8e2debd
Refactored the BlockSuggestionsPresenter a little bit
Apr 15, 2021
7404075
Changes the working of the validation a little bit.
Apr 15, 2021
51d120d
make the SidebarWarningPresenter retrieve validation for a client Id
increddibelly Apr 15, 2021
74d36e4
fix unit tests
increddibelly Apr 16, 2021
c89071d
extract the BlockSuggestionsPresenter logic from the component
increddibelly Apr 16, 2021
e95a228
BlockSuggestionsPresenter allows more detailed control now; validatio…
increddibelly Apr 19, 2021
565f3fe
Merge branch 'develop' into P2-786-only-render-ok-when-block-is-valid
increddibelly Apr 19, 2021
0426ce0
added additional valid results and validation
increddibelly Apr 20, 2021
9c10dcf
Add validation to RichtTextBase
increddibelly Apr 20, 2021
e251ab9
remove unused code
increddibelly Apr 20, 2021
25356ce
added ValidationBlockInstruction to allow blocks to opt-in validation
increddibelly Apr 23, 2021
9872f78
fixing unit tests
increddibelly Apr 23, 2021
cd31dfe
fixed unit tests
increddibelly Apr 29, 2021
94a719f
Bump @wordpress/data to the latest version
johannadevos Apr 29, 2021
87a09ca
prevent an error for missing instructions
increddibelly Apr 29, 2021
f9f5aaf
Merge remote-tracking branch 'origin/release/16.3' into P2-786-only-r…
increddibelly Apr 29, 2021
cad6799
replaced ValidatingBlockInstruction base class with single function
increddibelly Apr 30, 2021
9f8404e
Merge remote-tracking branch 'origin/release/16.3' into P2-786-only-r…
increddibelly Apr 30, 2021
1d0e61d
fine tune variationpicker validation
increddibelly May 3, 2021
a41779b
fix Date validation
increddibelly May 3, 2021
3c14f53
typo
increddibelly May 3, 2021
e28dcb0
Merge remote-tracking branch 'origin/develop' into P2-786-only-render…
increddibelly May 3, 2021
8db91db
fix Date tests.
increddibelly May 4, 2021
318b5a3
Update packages/schema-blocks/src/functions/presenters/BlockSuggestio…
increddibelly May 6, 2021
0f4d7b1
Update packages/schema-blocks/src/functions/presenters/BlockSuggestio…
increddibelly May 6, 2021
94fa03a
processed CR comments
increddibelly May 6, 2021
c93634a
Update packages/schema-blocks/src/core/validation/BlockValidationResu…
increddibelly May 6, 2021
3cfa7f1
fix CS
increddibelly May 6, 2021
a92916b
make method of reading current block content consistent with other Yo…
increddibelly May 6, 2021
0053d33
Removed superfluous isValid check from BlockSuggestionsPresenter.
hansjovis May 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'develop' of https://github.com/Yoast/javascript into P2…
…-786-only-render-ok-when-block-is-valid

# Conflicts:
#	packages/schema-blocks/src/functions/presenters/BlockSuggestionsPresenter.tsx
#	packages/schema-blocks/tests/functions/presenters/BlockSuggestions.test.ts
  • Loading branch information
Andy Meerwaldt committed Apr 8, 2021
commit 54dfb3ac9da2fda5994d2b9e81c9d6c7033d11be
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { ReactElement } from "react";
import { BlockInstance, createBlock } from "@wordpress/blocks";
import { PanelBody } from "@wordpress/components";
import { SuggestedBlockProperties, BlockValidationResult } from "../core/validation";
import { getAllDescendantIssues, getValidationResult } from "../functions/validators";
import { isResultValidForSchema } from "../functions/validators/validateResults";
import { BlockValidationResult } from "../../core/validation";
import { getAllDescendantIssues, getValidationResult } from "../validators";
import { isResultValidForSchema } from "../validators/validateResults";
import { createElement } from "@wordpress/element";

import { getBlockType } from "../BlockHelper";
import { getInnerblocksByName, insertBlock } from "../innerBlocksHelper";

type BlockSuggestionAddedDto = {
blockTitle: string;
Expand Down Expand Up @@ -70,11 +74,9 @@ function BlockSuggestionAdded( { blockTitle, isValid }: BlockSuggestionAddedDto
/**
* Renders a list of suggested blocks.
*
* @param sidebarTitle The title of the sidebar section.
* @param block The block to render the suggestions for.
* @param suggestedBlocks The required/recommended blocks.
* @param props The props.
*
* @returns The rendered sidebar section with block suggestions.
* @returns The block suggestions element.
*/
export default function BlockSuggestionsPresenter( { title, block, suggestions }: BlockSuggestionsProps ) {
const suggestedBlockNames = suggestions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { BlockInstance, createBlock } from "@wordpress/blocks";
import * as renderer from "react-test-renderer";
import { mount } from "enzyme";
import { BlockValidationResult, RequiredBlock } from "../../src/core/validation";
import BlockSuggestions from "../../src/blocks/BlockSuggestions";
import { insertBlock } from "../../src/functions/innerBlocksHelper";
import { BlockPresence } from "../../src/core/validation/BlockValidationResult";
import BlockSuggestionsPresenter from "../../../src/functions/presenters/BlockSuggestionsPresenter";
import { BlockValidationResult } from "../../../src/core/validation";
import { insertBlock } from "../../../src/functions/innerBlocksHelper";
import { BlockPresence } from "../../../src/core/validation/BlockValidationResult";

jest.mock( "@wordpress/blocks", () => {
return {
createBlock: jest.fn(),
};
} );

jest.mock( "../../src/functions/validators", () => {
jest.mock( "../../../src/functions/validators", () => {
return {
getValidationResult: jest.fn( () => {
return new BlockValidationResult( "1", "yoast/valid-block", -1, BlockPresence.Required, "Is not that present" );
Expand All @@ -25,7 +25,7 @@ jest.mock( "../../src/functions/validators", () => {
};
} );

jest.mock( "../../src/functions/BlockHelper", () => {
jest.mock( "../../../src/functions/BlockHelper", () => {
return {
getBlockType: jest.fn( ( blockName: string ) => {
if ( blockName === "yoast/nonexisting" ) {
Expand Down Expand Up @@ -64,17 +64,8 @@ describe( "The required blocks in the sidebar", () => {
} );

it( "renders the required block as an added one", () => {
const block = { clientId: "1", innerBlocks: [] } as BlockInstance;
const requiredBlocks = [
{
name: "yoast/added-to-content",
option: "One",
} as RequiredBlock,
{
name: "yoast/added-to-content-valid",
option: "One",
} as RequiredBlock,
];
const block = { innerBlocks: [] } as BlockInstance;
const requiredBlocks = [ "yoast/added-to-content" ];

const tree = renderer
.create( BlockSuggestionsPresenter( { title: "Required blocks", block, suggestions: requiredBlocks } ) )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,6 @@ exports[`The required blocks in the sidebar renders the required block as an add
>
The required block
</li>
<li
className="yoast-block-suggestion"
>
The required block
<button
className="yoast-block-suggestion-button"
onClick={[Function]}
>
Add
</button>
</li>
</ul>
</div>
`;
You are viewing a condensed version of this merge commit. You can view the full changes here.