Skip to content
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

Storybook: Add stories for BlockTitle Component #67234

Merged
merged 6 commits into from
Dec 19, 2024
Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/**
* WordPress dependencies
*/
import { registerCoreBlocks } from '@wordpress/block-library';
import { createBlock } from '@wordpress/blocks';

/**
* Internal dependencies
*/
import { ExperimentalBlockEditorProvider } from '../../provider';
import BlockTitle from '../';

// Register core blocks for the story environment
registerCoreBlocks();

// Sample blocks for testing
const blocks = [ createBlock( 'core/paragraph' ) ];

const meta = {
title: 'BlockEditor/BlockTitle',
component: BlockTitle,
parameters: {
docs: {
canvas: { sourceState: 'shown' },
description: {
component:
"Renders the block's configured title as a string, or empty if the title cannot be determined.",
},
},
},
decorators: [
( Story ) => (
<ExperimentalBlockEditorProvider value={ blocks }>
<Story />
</ExperimentalBlockEditorProvider>
),
],
argTypes: {
clientId: {
control: { type: null },
description: 'Client ID of block.',
t-hamano marked this conversation as resolved.
Show resolved Hide resolved
table: {
type: {
summary: 'string',
},
},
},
maximumLength: {
control: { type: 'number' },
description:
'The maximum length that the block title string may be before truncated.',
table: {
type: {
summary: 'number',
},
},
},
context: {
control: { type: 'text' },
description: 'The context to pass to `getBlockLabel`.',
table: {
type: {
summary: 'string',
},
},
},
},
};

export default meta;

export const Default = {
args: {
clientId: blocks[ 0 ].clientId,
},
};

Unchanged files with check annotations Beta

// Use arrow up/down to move through the list.
await page.keyboard.press( 'ArrowDown' );
await expect( page.getByLabel( 'Sample Page' ) ).toBeFocused();

Check failure on line 113 in test/e2e/specs/site-editor/dataviews-list-layout-keyboard.spec.js

GitHub Actions / Playwright - 5

[chromium] › site-editor/dataviews-list-layout-keyboard.spec.js:96:2 › Dataviews List Layout › Navigates the items list via UP/DOWN arrow keys

1) [chromium] › site-editor/dataviews-list-layout-keyboard.spec.js:96:2 › Dataviews List Layout › Navigates the items list via UP/DOWN arrow keys Error: Timed out 5000ms waiting for expect(locator).toBeFocused() Locator: getByLabel('Sample Page') Expected: focused Received: inactive Call log: - expect.toBeFocused with timeout 5000ms - waiting for getByLabel('Sample Page') - locator resolved to <button type="button" tabindex="-1" aria-pressed="false" id="view-list-0-177-item-wrapper" class="dataviews-view-list__item" aria-labelledby="view-list-0-177-label" aria-describedby="view-list-0-177-description"></button> - unexpected value "not focused" - locator resolved to <button type="button" tabindex="-1" aria-pressed="false" id="view-list-0-177-item-wrapper" class="dataviews-view-list__item" aria-labelledby="view-list-0-177-label" aria-describedby="view-list-0-177-description"></button> - unexpected value "not focused" - locator resolved to <button type="button" tabindex="-1" aria-pressed="false" id="view-list-0-177-item-wrapper" class="dataviews-view-list__item" aria-labelledby="view-list-0-177-label" aria-describedby="view-list-0-177-description"></button> - unexpected value "not focused" - locator resolved to <button type="button" tabindex="-1" aria-pressed="false" id="view-list-0-177-item-wrapper" class="dataviews-view-list__item" aria-labelledby="view-list-0-177-label" aria-describedby="view-list-0-177-description"></button> - unexpected value "not focused" - locator resolved to <button type="button" tabindex="-1" aria-pressed="false" id="view-list-0-177-item-wrapper" class="dataviews-view-list__item" aria-labelledby="view-list-0-177-label" aria-describedby="view-list-0-177-description"></button> - unexpected value "not focused" - locator resolved to <button type="button" tabindex="-1" aria-pressed="false" id="view-list-0-177-item-wrapper" class="dataviews-view-list__item" aria-labelledby="view-list-0-177-label" aria-describedby="view-list-0-177-description"></button> - unexpected value "not focused" - locator resolved to <button type="button" tabindex="-1" aria-pressed="false" id="view-list-0-177-item-wrapper" class="dataviews-view-list__item" aria-labelledby="view-list-0-177-label" aria-describedby="view-list-0-177-description"></button> - unexpected value "not focused" - locator resolved to <button type="button" tabindex="-1" aria-pressed="false" id="view-list-0-177-item-wrapper" class="dataviews-view-list__item" aria-labelledby="view-list-0-177-label" aria-describedby="view-list-0-177-description"></button> - unexpected value "not focused" - locator resolved to <button type="button" tabindex="-1" aria-pressed="false" id="view-list-0-177-item-wrapper" class="dataviews-view-list__item" aria-labelledby="view-list-0-177-label" aria-describedby="view-list-0-177-description"></button> - unexpected value "not focused" 111 | // Use arrow up/down to move through the list. 112 | await page.keyboard.press( 'ArrowDown' ); > 113 | await expect( page.getByLabel( 'Sample Page' ) ).toBeFocused(); | ^ 114 | 115 | await page.keyboard.press( 'ArrowUp' ); 116 | await expect( page.getByLabel( 'Privacy Policy' ) ).toBeFocused(); at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/dataviews-list-layout-keyboard.spec.js:113:52
await page.keyboard.press( 'ArrowUp' );
await expect( page.getByLabel( 'Privacy Policy' ) ).toBeFocused();
// Wait for the canvas loader to appear first, so that the locator that
// waits for the hidden state doesn't resolve prematurely.
await canvasLoader.waitFor( { state: 'visible' } );

Check failure on line 57 in packages/e2e-test-utils-playwright/src/admin/visit-site-editor.ts

GitHub Actions / Playwright - 8

[firefox] › editor/blocks/navigation-frontend-interactivity.spec.js:378:3 › Navigation block - Frontend interactivity › Submenus (Arrow setting) (@firefox

1) [firefox] › editor/blocks/navigation-frontend-interactivity.spec.js:378:3 › Navigation block - Frontend interactivity › Submenus (Arrow setting) (@Firefox, @WebKit) › submenu click on the arrow interactions TimeoutError: locator.waitFor: Timeout 60000ms exceeded. Call log: - waiting for locator('.edit-site-canvas-loader, .edit-site-canvas-spinner') to be visible at ../../../packages/e2e-test-utils-playwright/src/admin/visit-site-editor.ts:57 55 | // Wait for the canvas loader to appear first, so that the locator that 56 | // waits for the hidden state doesn't resolve prematurely. > 57 | await canvasLoader.waitFor( { state: 'visible', timeout: 60_000 } ); | ^ 58 | await canvasLoader.waitFor( { 59 | state: 'hidden', 60 | // Bigger timeout is needed for larger entities, like the Large Post at Admin.visitSiteEditor (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/admin/visit-site-editor.ts:57:22) at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/navigation-frontend-interactivity.spec.js:353:4
await canvasLoader.waitFor( {
state: 'hidden',
// Bigger timeout is needed for larger entities, like the Large Post