Skip to content

Commit

Permalink
Merge pull request #1152 from vektor-inc/develop
Browse files Browse the repository at this point in the history
[ Change version ] 1.30.0.1
  • Loading branch information
kurudrive authored Apr 5, 2022
2 parents a1a34bb + 5266d23 commit 0aa6150
Show file tree
Hide file tree
Showing 9 changed files with 335 additions and 92 deletions.

Large diffs are not rendered by default.

Binary file modified inc/vk-blocks/languages/vk-blocks-ja.mo
Binary file not shown.
203 changes: 119 additions & 84 deletions inc/vk-blocks/languages/vk-blocks-ja.po

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion inc/vk-blocks/languages/vk-blocks-js.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2197,7 +2197,7 @@ msgstr ""
#: src/utils/font-awesome-new.js:255
msgid ""
"When you click save button, the window will be reloaded and this setting "
"will be applied"
"will be applied."
msgstr ""

#: src/utils/font-awesome-new.js:265
Expand Down
6 changes: 3 additions & 3 deletions inc/vk-blocks/languages/vk-blocks.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# This file is distributed under the same license as the VK Blocks Pro plugin.
msgid ""
msgstr ""
"Project-Id-Version: VK Blocks Pro 1.29.2.0\n"
"Project-Id-Version: VK Blocks Pro 1.30.0.0\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/vk-blocks-pro\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2022-04-05T06:34:09+00:00\n"
"POT-Creation-Date: 2022-04-05T07:22:35+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.5.0-alpha-3f4c34b\n"
"X-Domain: vk-blocks\n"
Expand Down Expand Up @@ -2212,7 +2212,7 @@ msgid "Ex) <i class=\"fas fa-arrow-circle-right\"></i>"
msgstr ""

#: src/utils/font-awesome-new.js:255
msgid "When you click save button, the window will be reloaded and this setting will be applied"
msgid "When you click save button, the window will be reloaded and this setting will be applied."
msgstr ""

#: src/utils/font-awesome-new.js:265
Expand Down
4 changes: 2 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ e.g.

= 1.30.0 =
[ Add Function ][ Border Box ] Add body align control in toolbar.
[ Update ][ Button ] Move url interface to block toolbar.
[ Update ][ Button outer(Pro) ] Add button width option.
[ Add Function ][ Button outer(Pro) ] Add button width option.
[ Update ][ Font Awesome ] Add version chenge setting on block-editor screen.
[ Specification Change ][ Button ] Move url interface to block toolbar.
[ Specification Change ] Change default --vk-margin-md size 2rem -> 2.4rem
[ Specification Change ][ icon ] fix icon margin bottom

Expand Down
26 changes: 26 additions & 0 deletions src/extensions/common/margin-extension/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { addFilter } from '@wordpress/hooks';
import { BlockControls } from '@wordpress/block-editor';
import { createHigherOrderComponent } from '@wordpress/compose';
import { ToolbarDropdownMenu } from '@wordpress/components';
// import { getBlockTypes } from '@wordpress/blocks';

/**
* External dependencies
Expand Down Expand Up @@ -88,6 +89,31 @@ addFilter(
'blocks.registerBlockType',
'vk-blocks/margin-extension',
(settings) => {
/**
* e2eテストコード用 test/e2e-tests/specs/margin-extension.test.js
*
* ブラウザーコンソールで除外しないブロック一覧が表示されるので右クリックしてobjectのコピーして確認する
*/
// const blockArr = getBlockTypes();
// console.log(blockArr);
// const testBlockList = [];
// const testHasParentBlockList = [];
// for (let i = 0; i < blockArr.length; i++) {
// if (isAddMargin(blockArr[i].name)) {
// if (blockArr[i].parent) {
// testHasParentBlockList.push([
// blockArr[i].parent[0],
// blockArr[i].title,
// blockArr[i].name,
// ]);
// } else {
// testBlockList.push([blockArr[i].title, blockArr[i].title, blockArr[i].name,]);
// }
// }
// }
// console.log(testBlockList);
// console.log(testHasParentBlockList);

// If margin function target block...
if (isAddMargin(settings.name)) {
settings.attributes = {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/font-awesome-new.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ export const FontAwesome = (props) => {
/>
<p className="mt-1">
{__(
'When you click save button, the window will be reloaded and this setting will be applied',
'When you click save button, the window will be reloaded and this setting will be applied.',
'vk-blocks'
)}
</p>
Expand Down
182 changes: 182 additions & 0 deletions test/e2e-tests/specs/margin-extension.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
/**
* WordPress dependencies
*/
import {
createNewPost,
searchForBlock,
clickButton,
} from '@wordpress/e2e-test-utils';

/**
* Internal dependencies
*/
import { changeSiteLang } from '../helper/changeSiteLang';

// https://github.com/WordPress/gutenberg/blob/7d880708c6281c185256b8e7d3dffe178da33d09/packages/e2e-tests/specs/performance/post-editor.test.js#L34
jest.setTimeout( 1000000 );

describe( 'MarginExtension', () => {
let oldLanguage;
beforeEach( async () => {
jest.setTimeout(600000);
oldLanguage = await changeSiteLang( 'en' );
await createNewPost();
} );
afterEach( async () => {
await changeSiteLang( oldLanguage );
});
it( 'MarginExtension', async () => {
// 共通余白を選択をしやすくするためにトップツールバーをオンにする
const optionsButtonSelector = `//button[@aria-label='Options']`;
const [optionsButton] = await page.$x(optionsButtonSelector);
await optionsButton.click();
await page.keyboard.press( 'Enter' );

/**
* 共通余白が設定できるブロック一覧
*
* ブロック名の変更や追加した場合はこの一覧を更新する必要ある
*
* 子ブロックに共通余白を追加する場合、親ブロックを配置していないと子ブロックの共通余白を追加することが出来ないため配置するブロックと余白を追加したいブロックの配列を用意している
*/

// 配列サンプル
// const testBlockTitleLists = [
// // ['配置したいブロック','共通余白を設定するブロック','editor-block-list-item-に続くクラス名']
// ['Paragraph', 'Paragraph', 'paragraph'],
// [ "Ballon", "Ballon", "vk-blocks-balloon" ],
// [ "New FAQ", "New FAQ", "vk-blocks-faq2" ],
// ['Heading', 'Heading', 'vk-blocks-heading'],
// ['Image', 'Image', 'image'],
// ['Heading', 'Heading', 'heading'],
// ]

const testBlockTitleLists = [
[ "Alert", "Alert", "vk-blocks-alert" ],
[ "Ballon", "Ballon", "vk-blocks-balloon" ],
[ "Border Box", "Border Box", "vk-blocks-border-box" ],
[ "Button", "Button", "vk-blocks-button" ],
[ "Classic FAQ", "Classic FAQ", "vk-blocks-faq" ],
[ "New FAQ", "New FAQ", "vk-blocks-faq2" ],
[ "Flow", "Flow", "vk-blocks-flow" ],
[ "Heading", "Heading", "vk-blocks-heading" ],
[ "Icon", "Icon", "vk-blocks-icon" ],
[ "Icon Outer", "Icon Outer", "vk-blocks-icon-outer" ],
[ "Page Content", "Page Content", "vk-blocks-page-content" ],
[ "PR Blocks (not recommended)", "PR Blocks (not recommended)", "vk-blocks-pr-blocks" ],
[ "PR Content", "PR Content", "vk-blocks-pr-content" ],
[ "Responsive Spacer", "Responsive Spacer", "vk-blocks-spacer" ],
[ "Staff", "Staff", "vk-blocks-staff" ],
[ "Accordion", "Accordion", "vk-blocks-accordion" ],
[ "Animation", "Animation", "vk-blocks-animation" ],
[ "Breadcrumb", "Breadcrumb", "vk-blocks-breadcrumb" ],
[ "Button Outer", "Button Outer", "vk-blocks-button-outer" ],
[ "Card", "Card", "vk-blocks-card" ],
[ "Child page list", "Child page list", "vk-blocks-child-page" ],
[ "Grid Column Card", "Grid Column Card", "vk-blocks-gridcolcard" ],
[ "Icon Card", "Icon Card", "vk-blocks-icon-card" ],
[ "Outer", "Outer", "vk-blocks-outer" ],
[ "Post list", "Post list", "vk-blocks-post-list" ],
[ "Selected Post List", "Selected Post List", "vk-blocks-select-post-list" ],
[ "Step", "Step", "vk-blocks-step" ],
[ "Slider", "Slider", "vk-blocks-slider" ],
[ "Table of Contents", "Table of Contents", "vk-blocks-table-of-contents-new" ],
[ "Timeline", "Timeline", "vk-blocks-timeline" ],
[ "Paragraph", "Paragraph", "paragraph" ],
[ "Image", "Image", "image" ],
[ "Heading", "Heading", "heading" ],
[ "Gallery", "Gallery", "gallery" ],
[ "List", "List", "list" ],
[ "Quote", "Quote", "quote" ],
[ "Buttons", "Buttons", "buttons" ],
[ "Code", "Code", "code" ],
[ "Columns", "Columns", "columns" ],
[ "Cover", "Cover", "cover" ],
[ "Embed", "Embed", "embed" ],
[ "File", "File", "file" ],
[ "Group", "Group", "group" ],
[ "Media & Text", "Media & Text", "media-text" ],
[ "Preformatted", "Preformatted", "preformatted" ],
[ "Pullquote", "Pullquote", "pullquote" ],
[ "Separator", "Separator", "separator" ],
[ "Spacer", "Spacer", "spacer" ],
[ "Table", "Table", "table" ],
// [ "Text Columns (deprecated)", "Text Columns (deprecated)", "text-columns" ], // ブロックが存在しないのでコメントアウト
[ "Verse", "Verse", "verse" ],
[ "Video", "Video", "video" ],
[ "Navigation", "Navigation", "navigation" ],
[ "Query Loop", "Query Loop", "query" ],
// 子ブロック
[ "New FAQ", "FAQ Answer", "vk-blocks-faq2" ],
[ "New FAQ", "FAQ Question", "vk-blocks-faq2" ],
[ "Accordion", "Accordion Target", "vk-blocks-accordion" ],
[ "Accordion", "Accordion Trigger", "vk-blocks-accordion" ],
[ "Grid Column Card", "Grid Column Card Item", "vk-blocks-gridcolcard" ],
[ "Grid Column Card", "Grid Column Card Item Body", "vk-blocks-gridcolcard" ],
[ "Step", "Step Item", "vk-blocks-step" ],
[ "Timeline", "Timeline Item", "vk-blocks-timeline" ],
[ "Buttons", "Button", "buttons" ]
]

for (let i = 0; i < testBlockTitleLists.length; i++) {

// ブロックを追加
await searchForBlock( testBlockTitleLists[i][0] );
const insertButton = await page.waitForXPath(
`//button[contains(@class, "editor-block-list-item-${ testBlockTitleLists[i][2] }")]`
);
await insertButton.click();

// List viewをクリック
const listViewButtonSelector = `//button[@aria-label='List View']`;
const [listViewButton] = await page.$x(listViewButtonSelector);
await listViewButton.click();

// 共通余白を設定したいブロックをクリック
await clickButton( testBlockTitleLists[i][1] );

// 共通余白のドロップダウンをクリック
const marginDropdownButtonSelector = `//button[@aria-label='Margin the block']`;
const [marginDropdownButton] = await page.$x(marginDropdownButtonSelector);
await marginDropdownButton.click();

//共通余白 Top lgを選択
await page.keyboard.press( 'Enter' );

//共通余白 下をクリック
await marginDropdownButton.click();
for (let i = 0; i < 4; i++) {
await page.keyboard.press( 'Tab' );
}
await page.keyboard.press( 'Enter' );

// 共通余白のクラス名が存在するかチェック
expect(
await page.$( '.vk_block-margin-lg--margin-top' )
).not.toBeNull();
expect(
await page.$( '.vk_block-margin-0--margin-bottom' )
).not.toBeNull();

// 配置したブロックが増えるとテストが動かなくなる,またインナーブロックの場合、その中に配置されることがありテストわかりにくくなるので配置したブロックを削除
await clickButton( testBlockTitleLists[i][0] );
await page.keyboard.press( 'Escape' );
await page.keyboard.press( 'Backspace' );

}
} )

/**
* 以下のブロックは上記のテストではブロックの配置が単純ではないため対応出来ていない
*
* Columns, Columns > Column
* Navigation > Custom Link, Submenu
* Query Loop > Post Template, Pagination
*
* 初期配置ではブロックが配置されないためクラス名が見当たらないため
* Grid Column Card Item Footer
* Grid Column Card Item header
*/

});

0 comments on commit 0aa6150

Please sign in to comment.