Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );
const { EXPERIMENTS, openPostSummary } = require( './utils' );

/*
* Mirrors the 'should be able to create an hierarchical post without title
* support' test of `test/e2e/specs/editor/plugins/custom-post-types.spec.js`
* with the DataForm inspector experiment enabled; delete that test there when
* the experiment graduates. The other tests of that classic file don't drive
* the summary and stay where they are.
*/
test.describe( 'Test Custom Post Types (DataForm inspector)', () => {
test.beforeAll( async ( { requestUtils } ) => {
await requestUtils.activatePlugin( 'gutenberg-test-custom-post-types' );
} );

test.beforeEach( async ( { requestUtils } ) => {
await requestUtils.setGutenbergExperiments( EXPERIMENTS );
} );

test.afterEach( async ( { requestUtils } ) => {
await requestUtils.setGutenbergExperiments( [] );
} );

test.afterAll( async ( { requestUtils } ) => {
await requestUtils.deactivatePlugin(
'gutenberg-test-custom-post-types'
);
} );

test( 'should be able to create an hierarchical post without title support', async ( {
admin,
editor,
page,
} ) => {
await admin.createNewPost( { postType: 'hierar-no-title' } );
await editor.canvas
.getByRole( 'document', { name: 'Add default block' } )
.click();
await page.keyboard.type( 'Parent Post' );
await editor.publishPost();

// Create a post that is a child of the previously created post.
await admin.createNewPost( { postType: 'hierar-no-title' } );
const summary = await openPostSummary( {
editor,
page,
tab: 'Hierarchical No Title',
} );

await summary.getByRole( 'button', { name: 'Edit Parent' } ).click();

const parentPageLocator = page.getByRole( 'combobox', {
name: 'Parent',
} );

await parentPageLocator.click();
await page.getByRole( 'listbox' ).getByRole( 'option' ).first().click();
const parentPage = await parentPageLocator.inputValue();
await page.keyboard.press( 'Escape' );

await expect(
summary.getByText( parentPage, { exact: true } )
).toBeVisible();

await editor.canvas
.getByRole( 'document', { name: 'Add default block' } )
.click();
await page.keyboard.type( 'Child Post' );
await editor.publishPost();
await page.reload();

const reloadedSummary = await openPostSummary( {
editor,
page,
tab: 'Hierarchical No Title',
} );
await reloadedSummary
.getByRole( 'button', { name: 'Edit Parent' } )
.click();
// The auto-focused combobox shows its (empty) filter text; blur it so
// it renders the selected value.
await page.getByRole( 'heading', { name: 'Parent' } ).click();

// Confirm parent page selection matches after reloading.
await expect( parentPageLocator ).toHaveValue( parentPage );
} );
} );
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );
const { EXPERIMENTS, openPostSummary } = require( './utils' );

// Set browser to a timezone that's different to `timezone`.
test.use( {
timezoneId: 'America/New_York',
} );

// The `timezone` setting exposed via REST API only accepts `UTC`
// and timezone strings by location.
const TIMEZONES = [ 'Pacific/Honolulu', 'UTC', 'Australia/Sydney' ];

/*
* Mirrors `test/e2e/specs/editor/various/datepicker.spec.js` with the DataForm
* inspector experiment enabled; delete that spec when the experiment graduates.
* The classic tests asserting the "Immediately" state have no counterpart here:
* the DataForm summary date row always renders a concrete date.
*/
test.beforeEach( async ( { requestUtils } ) => {
await requestUtils.setGutenbergExperiments( EXPERIMENTS );
} );

test.afterEach( async ( { requestUtils } ) => {
await requestUtils.setGutenbergExperiments( [] );
} );

TIMEZONES.forEach( ( timezone ) => {
test.describe( `Datepicker: ${ timezone } (DataForm inspector)`, () => {
let originalTimezone;

test.beforeAll( async ( { requestUtils } ) => {
originalTimezone = ( await requestUtils.getSiteSettings() )
.timezone;
await requestUtils.updateSiteSettings( { timezone } );
} );

test.beforeEach( async ( { admin } ) => {
await admin.createNewPost();
} );

test.afterAll( async ( { requestUtils } ) => {
await requestUtils.updateSiteSettings( {
timezone: originalTimezone,
} );
} );

test( 'should show the publishing date if the date is in the past', async ( {
editor,
page,
} ) => {
const summary = await openPostSummary( { editor, page } );
await summary.getByRole( 'button', { name: 'Edit Date' } ).click();

const lastYear = new Date().getFullYear() - 1;
await page
.getByLabel( 'Date time' )
.fill( `${ lastYear }-03-15T10:00` );
await page.keyboard.press( 'Escape' );

// The row renders the date in the site timezone, so the wall time
// entered above must come back unshifted regardless of the
// browser timezone.
await expect(
summary.getByText( `Mar 15, ${ lastYear } 10:00 am` )
).toBeVisible();
} );

test( 'should show the publishing date if the date is in the future', async ( {
editor,
page,
} ) => {
const summary = await openPostSummary( { editor, page } );
await summary.getByRole( 'button', { name: 'Edit Date' } ).click();

const nextYear = new Date().getFullYear() + 1;
await page
.getByLabel( 'Date time' )
.fill( `${ nextYear }-03-15T10:00` );
await page.keyboard.press( 'Escape' );

await expect(
summary.getByText( `Mar 15, ${ nextYear } 10:00 am` )
).toBeVisible();
} );
} );
} );

This file was deleted.

Loading
Loading