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

Replace TT1-Blocks with Empty Theme in the wp-env of gutenberg and CI #37446

Merged
merged 13 commits into from
Jan 6, 2022
Merged
2 changes: 1 addition & 1 deletion .wp-env.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"core": "WordPress/WordPress",
"plugins": [ "." ],
"themes": [ "WordPress/theme-experiments/tt1-blocks#[email protected]" ],
"themes": [ "./test/emptytheme" ],
"env": {
"tests": {
"mappings": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ describe( 'Navigation', () => {
expect( await getNavigationMenuRawContent() ).toMatchSnapshot();
} );

it( 'allows pages to be created from the navigation block and their links added to menu', async () => {
it.skip( 'allows pages to be created from the navigation block and their links added to menu', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@talldan As seen on the latest commits on trunk, this test is failing too often, I'm skipping it for now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's been failing for a while now. I suggested skipping it in slack last week.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've created #37729 that skips this test as it's blocking #36746 as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies, I did get some failures on this when working on it, but I thought I'd solved them all as they passed multiple times locally.

Some discussion on fixing the test - #37755.

// The URL Details endpoint 404s for the created page, since it will
// be a draft that is inaccessible publicly. To avoid this we mock
// out the endpoint response to be empty which will be handled gracefully
Expand Down
68 changes: 57 additions & 11 deletions packages/e2e-tests/specs/editor/various/font-size-picker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
createNewPost,
pressKeyWithModifier,
pressKeyTimes,
activateTheme,
openTypographyToolsPanelMenu,
} from '@wordpress/e2e-test-utils';

Expand Down Expand Up @@ -100,21 +99,68 @@ describe( 'Font Size Picker', () => {
` );
} );
} );

// A different control is rendered based on the available font sizes number.
describe( 'More font sizes', () => {
beforeAll( async () => {
await activateTheme( 'tt1-blocks' );
} );
afterAll( async () => {
await activateTheme( 'twentytwentyone' );
beforeEach( async () => {
await page.evaluate( () => {
wp.data.dispatch( 'core/block-editor' ).updateSettings(
// eslint-disable-next-line no-undef
lodash.merge(
wp.data.select( 'core/block-editor' ).getSettings(),
{
__experimentalFeatures: {
typography: {
fontSizes: {
default: [
{
name: 'Tiny',
slug: 'tiny',
size: '11px',
},
,
{
name: 'Small',
slug: 'small',
size: '13px',
},
{
name: 'Medium',
slug: 'medium',
size: '20px',
},
{
name: 'Large',
slug: 'large',
size: '36px',
},
{
name: 'Extra Large',
slug: 'x-large',
size: '42px',
},
{
name: 'Huge',
slug: 'huge',
size: '48px',
},
],
},
},
},
}
)
);
} );
} );

it( 'should apply a named font size using the font size buttons', async () => {
// Create a paragraph block with some content.
await clickBlockAppender();
await page.keyboard.type( 'Paragraph to be made "large"' );

await openFontSizeSelectControl();
await pressKeyTimes( 'ArrowDown', 4 );
await pressKeyTimes( 'ArrowDown', 5 );
await page.keyboard.press( 'Enter' );

expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
Expand All @@ -131,11 +177,11 @@ describe( 'Font Size Picker', () => {
);

await openFontSizeSelectControl();
await pressKeyTimes( 'ArrowDown', 3 );
await pressKeyTimes( 'ArrowDown', 4 );
await page.keyboard.press( 'Enter' );
expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
"<!-- wp:paragraph {\\"fontSize\\":\\"normal\\"} -->
<p class=\\"has-normal-font-size\\">Paragraph with font size reset using tools panel menu</p>
"<!-- wp:paragraph {\\"fontSize\\":\\"medium\\"} -->
<p class=\\"has-medium-font-size\\">Paragraph with font size reset using tools panel menu</p>
<!-- /wp:paragraph -->"
` );

Expand All @@ -158,7 +204,7 @@ describe( 'Font Size Picker', () => {
);

await openFontSizeSelectControl();
await pressKeyTimes( 'ArrowDown', 2 );
await pressKeyTimes( 'ArrowDown', 3 );
await page.keyboard.press( 'Enter' );
expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
"<!-- wp:paragraph {\\"fontSize\\":\\"small\\"} -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ describe( 'Post Editor Template mode', () => {
} );

it( 'Allow to switch to template mode, edit the template and check the result', async () => {
await activateTheme( 'tt1-blocks' );
await activateTheme( 'emptytheme' );
await createNewPost();
// Create a random post.
await page.type( '.editor-post-title__input', 'Just an FSE Post' );
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e-tests/specs/performance/site-editor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jest.setTimeout( 1000000 );

describe( 'Site Editor Performance', () => {
beforeAll( async () => {
await activateTheme( 'tt1-blocks' );
await activateTheme( 'emptytheme' );
await trashAllPosts( 'wp_template' );
await trashAllPosts( 'wp_template', 'auto-draft' );
await trashAllPosts( 'wp_template_part' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async function getDocumentSettingsSecondaryTitle() {

describe( 'Document Settings', () => {
beforeAll( async () => {
await activateTheme( 'tt1-blocks' );
await activateTheme( 'emptytheme' );
await trashAllPosts( 'wp_template' );
await trashAllPosts( 'wp_template_part' );
} );
Expand All @@ -43,7 +43,7 @@ describe( 'Document Settings', () => {
it( 'should display the selected templates name in the document header', async () => {
// Navigate to a template
await siteEditor.visit( {
postId: 'tt1-blocks//index',
postId: 'emptytheme//index',
postType: 'wp_template',
} );

Expand Down Expand Up @@ -79,7 +79,7 @@ describe( 'Document Settings', () => {
it( "should display the selected template part's name in the document header", async () => {
// Navigate to a template part
await siteEditor.visit( {
postId: 'tt1-blocks//header',
postId: 'emptytheme//header',
postType: 'wp_template_part',
} );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ const removeErrorMocks = () => {

describe( 'Multi-entity editor states', () => {
beforeAll( async () => {
await activateTheme( 'tt1-blocks' );
await activateTheme( 'emptytheme' );
await trashAllPosts( 'wp_template' );
await trashAllPosts( 'wp_template_part' );
} );
Expand All @@ -152,7 +152,7 @@ describe( 'Multi-entity editor states', () => {
// Skip reason: This should be rewritten to use other methods to switching to different templates.
it.skip( 'should not dirty an entity by switching to it in the template dropdown', async () => {
await siteEditor.visit( {
postId: 'tt1-blocks//header',
postId: 'emptytheme//header',
postType: 'wp_template_part',
} );
await page.waitForFunction( () =>
Expand Down
31 changes: 14 additions & 17 deletions packages/e2e-tests/specs/site-editor/multi-entity-saving.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe( 'Multi-entity save flow', () => {
let originalSiteTitle, originalBlogDescription;

beforeAll( async () => {
await activateTheme( 'tt1-blocks' );
await activateTheme( 'emptytheme' );
await trashAllPosts( 'wp_template' );
await trashAllPosts( 'wp_template_part' );
await trashAllPosts( 'wp_block' );
Expand Down Expand Up @@ -165,6 +165,11 @@ describe( 'Multi-entity save flow', () => {
'//*[@id="a11y-speak-polite"][contains(text(), "Post published")]'
);

// Unselect the blocks to avoid clicking the block toolbar.
await page.evaluate( () => {
wp.data.dispatch( 'core/block-editor' ).clearSelectedBlock();
} );

// Update the post.
await page.click( '.editor-post-title' );
await page.keyboard.type( '...more title!' );
Expand Down Expand Up @@ -259,7 +264,7 @@ describe( 'Multi-entity save flow', () => {
it( 'Save flow should work as expected', async () => {
// Navigate to site editor.
await siteEditor.visit( {
postId: 'tt1-blocks//index',
postId: 'emptytheme//index',
postType: 'wp_template',
} );
await siteEditor.disableWelcomeGuide();
Expand Down Expand Up @@ -297,7 +302,7 @@ describe( 'Multi-entity save flow', () => {
it( 'Save flow should allow re-saving after changing the same block attribute', async () => {
// Navigate to site editor.
await siteEditor.visit( {
postId: 'tt1-blocks//index',
postId: 'emptytheme//index',
postType: 'wp_template',
} );
await siteEditor.disableWelcomeGuide();
Expand All @@ -308,26 +313,18 @@ describe( 'Multi-entity save flow', () => {
// Open the block settings.
await page.click( 'button[aria-label="Settings"]' );

// Click on font size selector.
await page.click( 'button[aria-label="Font size"]' );

// Click on a different font size.
const extraSmallFontSize = await page.waitForXPath(
'//li[contains(text(), "Extra small")]'
// Change the font size
await page.click(
'.components-font-size-picker__controls button[aria-label="Small"]'
);
await extraSmallFontSize.click();

// Save all changes.
await saveAllChanges();

// Click on font size selector again.
await page.click( 'button[aria-label="Font size"]' );

// Select another font size.
const normalFontSize = await page.waitForXPath(
'//li[contains(text(), "Normal")]'
// Change the font size
await page.click(
'.components-font-size-picker__controls button[aria-label="Medium"]'
);
await normalFontSize.click();

// Assert that the save button has been re-enabled.
const saveButton = await page.waitForSelector(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async function getTemplateCard() {

describe( 'Settings sidebar', () => {
beforeAll( async () => {
await activateTheme( 'tt1-blocks' );
await activateTheme( 'emptytheme' );
await trashAllPosts( 'wp_template' );
await trashAllPosts( 'wp_template_part' );
} );
Expand Down Expand Up @@ -70,7 +70,7 @@ describe( 'Settings sidebar', () => {

const templateCardBeforeNavigation = await getTemplateCard();
await siteEditor.visit( {
postId: 'tt1-blocks//404',
postId: 'emptytheme//singular',
postType: 'wp_template',
} );
const templateCardAfterNavigation = await getTemplateCard();
Expand All @@ -80,8 +80,8 @@ describe( 'Settings sidebar', () => {
description: 'Displays posts.',
} );
expect( templateCardAfterNavigation ).toMatchObject( {
title: '404',
description: 'Displays when no content is found.',
title: 'Singular',
description: 'Displays a single post or page.',
} );
} );
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async function waitForFileExists( filePath, timeout = 10000 ) {

describe( 'Site Editor Templates Export', () => {
beforeAll( async () => {
await activateTheme( 'tt1-blocks' );
await activateTheme( 'emptytheme' );
await trashAllPosts( 'wp_template' );
await trashAllPosts( 'wp_template_part' );
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { siteEditor } from './utils';

describe( 'Site Editor Inserter', () => {
beforeAll( async () => {
await activateTheme( 'tt1-blocks' );
await activateTheme( 'emptytheme' );
await trashAllPosts( 'wp_template' );
await trashAllPosts( 'wp_template_part' );
} );
Expand Down
21 changes: 9 additions & 12 deletions packages/e2e-tests/specs/site-editor/template-part.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const templatePartNameInput =

describe( 'Template Part', () => {
beforeAll( async () => {
await activateTheme( 'tt1-blocks' );
await activateTheme( 'emptytheme' );
await trashAllPosts( 'wp_template' );
await trashAllPosts( 'wp_template_part' );
} );
Expand All @@ -40,7 +40,7 @@ describe( 'Template Part', () => {
async function navigateToHeader() {
// Switch to editing the header template part.
await siteEditor.visit( {
postId: 'tt1-blocks//header',
postId: 'emptytheme//header',
postType: 'wp_template_part',
} );
}
Expand All @@ -61,7 +61,7 @@ describe( 'Template Part', () => {

// Switch back to the Index template.
await siteEditor.visit( {
postId: 'tt1-blocks//index',
postId: 'emptytheme//index',
postType: 'wp_template',
} );
}
Expand Down Expand Up @@ -93,12 +93,9 @@ describe( 'Template Part', () => {
expect( paragraphInTemplatePart ).not.toBeNull();
}

async function awaitHeaderAndFooterLoad() {
async function awaitHeaderLoad() {
await canvas().waitForSelector(
'.wp-block-template-part.site-header.block-editor-block-list__layout'
);
await canvas().waitForSelector(
'.wp-block-template-part.site-footer.block-editor-block-list__layout'
'header.wp-block-template-part.block-editor-block-list__layout'
);
}

Expand Down Expand Up @@ -172,7 +169,7 @@ describe( 'Template Part', () => {
} );

it( 'Should convert selected block to template part', async () => {
await awaitHeaderAndFooterLoad();
await awaitHeaderLoad();
const initialTemplateParts = await canvas().$$(
'.wp-block-template-part'
);
Expand Down Expand Up @@ -210,7 +207,7 @@ describe( 'Template Part', () => {
} );

it( 'Should convert multiple selected blocks to template part', async () => {
await awaitHeaderAndFooterLoad();
await awaitHeaderLoad();
const initialTemplateParts = await canvas().$$(
'.wp-block-template-part'
);
Expand Down Expand Up @@ -277,7 +274,7 @@ describe( 'Template Part', () => {

it( 'Should insert new template part on creation', async () => {
let siteEditorCanvas = canvas();
await awaitHeaderAndFooterLoad();
await awaitHeaderLoad();

// Create new template part.
await insertBlock( 'Template Part' );
Expand Down Expand Up @@ -319,7 +316,7 @@ describe( 'Template Part', () => {
// Reload the page so as the new template part is available in the existing template parts.
await siteEditor.visit();
siteEditorCanvas = canvas();
await awaitHeaderAndFooterLoad();
await awaitHeaderLoad();
// Try to insert the template part we created.
await insertBlock( 'Template Part' );
const chooseExistingButton = await siteEditorCanvas.waitForXPath(
Expand Down
Loading