Files
chrnx-dev-wp/tests/e2e/editorial-editor.spec.mjs
T
2026-08-15 16:19:25 -05:00

51 lines
2.2 KiB
JavaScript

import { expect, test } from '@playwright/test';
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();
// Switching topic swaps which per-topic panel is offered.
await openPanel( 'Topic' );
await page.getByRole( 'radio', { name: 'Projects', exact: true } ).check();
await expect( page.getByLabel( 'Episode number', { exact: true } ) ).toBeHidden();
} );