From 04f19543d3b436dfac1f220eb55b5b0a23ba1df1 Mon Sep 17 00:00:00 2001 From: LamGC Date: Tue, 13 Oct 2026 17:57:41 +0800 Subject: [PATCH] Fix Media Library test storage and scope sidebar selectors --- .github/workflows/ci.yml | 1 + .gitignore | 1 + .wp-env.json | 1 + tests/e2e/README.md | 3 +++ tests/e2e/layout.spec.js | 2 +- tests/e2e/recording-source.spec.js | 6 ++++-- 6 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f304220..b16102f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,6 +67,7 @@ jobs: JS - name: Start real WordPress and install only the packaged plugin run: | + mkdir -p .wp-env-uploads npx --no-install wp-env start npx --no-install wp-env run cli wp plugin install /var/www/html/wp-content/asciiplayer-packages/wp-asciiplayer.zip --activate --force npx --no-install wp-env run cli wp plugin is-active wp-asciiplayer diff --git a/.gitignore b/.gitignore index 0b17946..7730d59 100644 --- a/.gitignore +++ b/.gitignore @@ -54,3 +54,4 @@ dist/ /playwright-report/ /test-results/ /.wp-env/ +/.wp-env-uploads/ diff --git a/.wp-env.json b/.wp-env.json index f16c9e8..fdd3da7 100644 --- a/.wp-env.json +++ b/.wp-env.json @@ -11,6 +11,7 @@ "SCRIPT_DEBUG": true }, "mappings": { + "wp-content/uploads": "./.wp-env-uploads", "wp-content/uploads/asciiplayer-fixtures": "./tests/fixtures", "wp-content/asciiplayer-packages": "./dist" }, diff --git a/tests/e2e/README.md b/tests/e2e/README.md index 8772831..f695421 100644 --- a/tests/e2e/README.md +++ b/tests/e2e/README.md @@ -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 diff --git a/tests/e2e/layout.spec.js b/tests/e2e/layout.spec.js index df54b35..f2a9916 100644 --- a/tests/e2e/layout.spec.js +++ b/tests/e2e/layout.spec.js @@ -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(); } diff --git a/tests/e2e/recording-source.spec.js b/tests/e2e/recording-source.spec.js index d9b14f2..563192d 100644 --- a/tests/e2e/recording-source.spec.js +++ b/tests/e2e/recording-source.spec.js @@ -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('');