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
+1
View File
@@ -67,6 +67,7 @@ jobs:
JS JS
- name: Start real WordPress and install only the packaged plugin - name: Start real WordPress and install only the packaged plugin
run: | run: |
mkdir -p .wp-env-uploads
npx --no-install wp-env start 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 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 npx --no-install wp-env run cli wp plugin is-active wp-asciiplayer
+1
View File
@@ -54,3 +54,4 @@ dist/
/playwright-report/ /playwright-report/
/test-results/ /test-results/
/.wp-env/ /.wp-env/
/.wp-env-uploads/
+1
View File
@@ -11,6 +11,7 @@
"SCRIPT_DEBUG": true "SCRIPT_DEBUG": true
}, },
"mappings": { "mappings": {
"wp-content/uploads": "./.wp-env-uploads",
"wp-content/uploads/asciiplayer-fixtures": "./tests/fixtures", "wp-content/uploads/asciiplayer-fixtures": "./tests/fixtures",
"wp-content/asciiplayer-packages": "./dist" "wp-content/asciiplayer-packages": "./dist"
}, },
+3
View File
@@ -13,6 +13,7 @@ npm ci
npm run build npm run build
npm test npm test
npm run package npm run package
mkdir -p .wp-env-uploads
npm run wp-env -- start 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 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 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 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 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. 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 ## Coverage
+1 -1
View File
@@ -44,7 +44,7 @@ async function readyPreview(block) {
async function openInspectorPanel(page, name, control) { async function openInspectorPanel(page, name, control) {
await page.evaluate(() => window.wp.data.dispatch('core/edit-post').openGeneralSidebar('edit-post/block')); await page.evaluate(() => window.wp.data.dispatch('core/edit-post').openGeneralSidebar('edit-post/block'));
if (!await control.isVisible()) { 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(); 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 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); const result = await uploadRecording(page, dialog, `asciiplayer-invalid-${Date.now()}-${testInfo.retry}.cast`, malformed);
expect(result.success, JSON.stringify(result)).toBe(false); expect(result.success, JSON.stringify(result)).toBe(false);
expect(result.data.message).toEqual(expect.any(String)); 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).';
await expect(dialog).toContainText(result.data.message); // 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 expect(dialog.locator('.media-button-select')).toBeDisabled();
await dialog.locator('.media-modal-close').click(); await dialog.locator('.media-modal-close').click();
await expect(block.getByRole('textbox', { name: 'Recording URL', exact: true })).toHaveValue(''); await expect(block.getByRole('textbox', { name: 'Recording URL', exact: true })).toHaveValue('');