55 lines
2.2 KiB
JavaScript
55 lines
2.2 KiB
JavaScript
import { execFileSync } from 'node:child_process';
|
|
import { expect, test } from '@playwright/test';
|
|
|
|
test.beforeAll( () => {
|
|
execFileSync(
|
|
'npm',
|
|
[ 'exec', '--', 'wp-env', 'run', 'cli', 'wp', 'eval', 'chrnx_seed_editorial_terms();' ],
|
|
{ cwd: process.cwd(), env: process.env, stdio: 'inherit' },
|
|
);
|
|
} );
|
|
|
|
test( 'editorial and podcast controls initialize in the real post editor', async ( { page } ) => {
|
|
const openPanel = async ( name ) => {
|
|
const button = page.getByRole( 'button', { name, exact: true } );
|
|
if ( ( await button.getAttribute( 'aria-expanded' ) ) !== 'true' ) {
|
|
await button.click();
|
|
}
|
|
};
|
|
|
|
await page.goto( '/wp-login.php' );
|
|
await page.locator( '#user_login' ).fill( 'admin' );
|
|
await page.locator( '#user_pass' ).fill( 'password' );
|
|
await Promise.all( [
|
|
page.waitForURL( /\/wp-admin\// ),
|
|
page.getByRole( 'button', { name: /log in/i } ).click(),
|
|
] );
|
|
|
|
await page.goto( '/wp-admin/post-new.php' );
|
|
const welcomeDialog = page.getByRole( 'dialog', { name: 'Welcome to the editor' } );
|
|
if ( await welcomeDialog.isVisible() ) {
|
|
await welcomeDialog.getByRole( 'button', { name: 'Close' } ).click();
|
|
}
|
|
await expect( page.getByRole( 'heading', { name: 'Add Post', exact: true } ) ).toBeVisible();
|
|
|
|
const podcasts = page.getByRole( 'radio', { name: 'Podcasts', exact: true } );
|
|
const settings = page.getByRole( 'button', { name: /^settings$/i } ).last();
|
|
if ( ( await settings.getAttribute( 'aria-expanded' ) ) !== 'true' ) {
|
|
await settings.click();
|
|
}
|
|
|
|
await openPanel( 'Topic' );
|
|
await expect( podcasts ).toBeVisible();
|
|
await openPanel( 'Language' );
|
|
await expect( page.getByRole( 'radio', { name: 'English', exact: true } ) ).toBeVisible();
|
|
await openPanel( 'Show' );
|
|
await expect( page.getByRole( 'radio', { name: 'Silicon Ranch', exact: true } ) ).toBeVisible();
|
|
|
|
await podcasts.check();
|
|
await openPanel( 'Podcast episode' );
|
|
await expect( page.getByLabel( 'Episode number', { exact: true } ) ).toBeVisible();
|
|
await expect( page.getByLabel( 'Duration', { exact: true } ) ).toBeVisible();
|
|
await expect( page.getByLabel( 'Participants (one per line)', { exact: true } ) ).toBeVisible();
|
|
await expect( page.getByLabel( 'Canonical episode URL', { exact: true } ) ).toBeVisible();
|
|
} );
|