Fix Media Library test storage and scope sidebar selectors

This commit is contained in:
2026-10-13 17:57:41 +08:00
parent af866bc20e
commit 04f19543d3
6 changed files with 11 additions and 3 deletions
+3
View File
@@ -13,6 +13,7 @@ npm ci
npm run build
npm test
npm run package
mkdir -p .wp-env-uploads
npm run wp-env -- start
npm run wp-env -- run cli wp plugin install /var/www/html/wp-content/asciiplayer-packages/wp-asciiplayer.zip --activate --force
npx --no-install playwright install chromium
@@ -29,6 +30,8 @@ The plugin's source tree is deliberately not mounted as an active plugin in the
committed wp-env configuration. The build ZIP is installed into WordPress through
WP-CLI, so missing package files cause a real integration failure. Fixtures are
mapped under uploads; the package directory is mapped separately for WP-CLI.
The host-owned .wp-env-uploads directory keeps real Media Library uploads writable
without relaxing file modes or modifying the fixture files.
## Coverage
+1 -1
View File
@@ -44,7 +44,7 @@ async function readyPreview(block) {
async function openInspectorPanel(page, name, control) {
await page.evaluate(() => window.wp.data.dispatch('core/edit-post').openGeneralSidebar('edit-post/block'));
if (!await control.isVisible()) {
await page.getByRole('button', { name, exact: true }).click();
await page.locator('.components-panel__body-toggle').filter({ hasText: new RegExp(`^${name}$`) }).click();
}
await expect(control).toBeVisible();
}
+4 -2
View File
@@ -278,8 +278,10 @@ test('native Media Library rejects an invalid cast upload without applying a sou
const malformed = await readFile(new URL('../fixtures/malformed.cast', import.meta.url));
const result = await uploadRecording(page, dialog, `asciiplayer-invalid-${Date.now()}-${testInfo.retry}.cast`, malformed);
expect(result.success, JSON.stringify(result)).toBe(false);
expect(result.data.message).toEqual(expect.any(String));
await expect(dialog).toContainText(result.data.message);
const validationMessage = 'Upload a valid Asciicast v2/v3 JSONL or pretty-printed v1 .cast recording (up to 32 MiB; v1 up to 2 MiB, 100,000 events, 256 KiB per JSONL line, and 1,000 columns or rows).';
// A filesystem/permission failure is not evidence of content validation.
expect(result.data.message).toBe(validationMessage);
await expect(dialog).toContainText(validationMessage);
await expect(dialog.locator('.media-button-select')).toBeDisabled();
await dialog.locator('.media-modal-close').click();
await expect(block.getByRole('textbox', { name: 'Recording URL', exact: true })).toHaveValue('');