mirror of
https://github.com/LamGC/wp-asciiplayer.git
synced 2026-11-26 20:55:48 +00:00
Show native cast dimensions and add Media Library recordings (1.2.2)
This commit is contained in:
@@ -47,6 +47,17 @@ Tests check the request count, stale-response cleanup, immediate Apply, error
|
||||
retry, and no requests for empty/invalid URLs or static inserter examples.
|
||||
Floating-toolbar dimension controls are checked against the collapsed sidebar,
|
||||
including keyboard focus, Escape/close/reopen, and shared attribute values.
|
||||
Both controls show the recording header's native columns and rows as placeholders
|
||||
without saving overrides. URL replacement, pending/error/invalid sources and late
|
||||
responses cover metadata cleanup; recorded resize events still control blank axes.
|
||||
Pretty-printed v1 and comment-bearing v3 fixtures also exercise actual parsing,
|
||||
native-size placeholders and playback output, alongside the existing v2 fixtures.
|
||||
|
||||
Media Library tests use WordPress's real upload dialog, file input and attachment
|
||||
tiles. They upload a valid `.cast`, select and play it without Apply URL, cancel a
|
||||
replacement, reopen to select the existing replacement, and reload the saved URL.
|
||||
A malformed `.cast` must be rejected by the real upload endpoint and shown as an
|
||||
upload error. These tests create small attachments in the isolated wp-env database.
|
||||
|
||||
## CI evidence and limits
|
||||
|
||||
@@ -68,3 +79,9 @@ References:
|
||||
- https://developer.wordpress.org/block-editor/reference-guides/packages/packages-env/
|
||||
- https://developer.wordpress.org/block-editor/reference-guides/block-api/block-api-versions/block-migration-for-iframe-editor-compatibility/
|
||||
- https://github.com/WordPress/plugin-check/blob/trunk/docs/CLI.md
|
||||
|
||||
Native recording-size hints are checked against v1/v2/v3 headers, explicit
|
||||
overrides, URL replacement, error/empty states and recorded resize events.
|
||||
The Media Library tests use actual isolated WordPress upload dialogs to upload
|
||||
validated fixtures, reject malformed casts, cancel/reopen and select an existing
|
||||
recording. No production-site media is accessed.
|
||||
|
||||
@@ -330,6 +330,14 @@ test('replacing a pending recording ignores its stale response', async ({ page }
|
||||
window.wp.data.select('core/block-editor').getBlockAttributes(clientId).source, id
|
||||
)).toBe(latest);
|
||||
await readyPreview(block);
|
||||
await page.evaluate(() => window.wp.data.dispatch('core/edit-post').openGeneralSidebar('edit-post/block'));
|
||||
const columns = page.getByRole('spinbutton', { name: 'Columns', exact: true });
|
||||
const rows = page.getByRole('spinbutton', { name: 'Rows', exact: true });
|
||||
if (!await columns.isVisible()) {
|
||||
await page.locator('.components-panel__body-toggle').filter({ hasText: /^Terminal size$/ }).click();
|
||||
}
|
||||
await expect(columns).toHaveAttribute('placeholder', '64');
|
||||
await expect(rows).toHaveAttribute('placeholder', '12');
|
||||
release();
|
||||
await expect.poll(() => oldResponseSettled).toBe(true);
|
||||
await page.waitForTimeout(750);
|
||||
@@ -337,6 +345,11 @@ test('replacing a pending recording ignores its stale response', async ({ page }
|
||||
await expect.poll(() => block.locator('.ap-term').evaluate((terminal) =>
|
||||
Number(terminal.style.getPropertyValue('--term-cols'))
|
||||
)).toBe(64);
|
||||
// A late header from the old 120-column cast must not become a hint.
|
||||
await expect(columns).toHaveAttribute('placeholder', '64');
|
||||
await expect(rows).toHaveAttribute('placeholder', '12');
|
||||
await expect(columns).toHaveValue('');
|
||||
await expect(rows).toHaveValue('');
|
||||
await expect(block.getByRole('textbox', { name: 'Recording URL', exact: true })).toHaveValue(latest);
|
||||
} finally {
|
||||
release();
|
||||
|
||||
@@ -211,6 +211,10 @@ test('toolbar terminal dimensions are discoverable, preserve focus and synchroni
|
||||
await expect(columns).toBeFocused();
|
||||
await expect(columns).toHaveValue('');
|
||||
await expect(rows).toHaveValue('');
|
||||
await expect(columns).toHaveAttribute('placeholder', '64');
|
||||
await expect(rows).toHaveAttribute('placeholder', '12');
|
||||
expect((await attributes(page, id)).cols).toBeUndefined();
|
||||
expect((await attributes(page, id)).rows).toBeUndefined();
|
||||
const after = await block.boundingBox();
|
||||
expect(Math.abs(after.width - before.width)).toBeLessThan(2);
|
||||
expect(Math.abs(after.height - before.height)).toBeLessThan(2);
|
||||
@@ -236,6 +240,9 @@ test('toolbar terminal dimensions are discoverable, preserve focus and synchroni
|
||||
await toggle.click();
|
||||
await expect(columns).toHaveValue('88');
|
||||
await expect(rows).toHaveValue('16');
|
||||
// A manual override must not become the displayed recording metadata.
|
||||
await expect(columns).toHaveAttribute('placeholder', '64');
|
||||
await expect(rows).toHaveAttribute('placeholder', '12');
|
||||
await columns.fill('');
|
||||
await columns.press('Tab');
|
||||
await expectGrid(block, 64, 16);
|
||||
@@ -261,6 +268,8 @@ test('toolbar terminal dimensions are discoverable, preserve focus and synchroni
|
||||
const sidebarRows = page.getByRole('spinbutton', { name: 'Rows', exact: true });
|
||||
await expect(sidebarColumns).toHaveValue('88');
|
||||
await expect(sidebarRows).toHaveValue('16');
|
||||
await expect(sidebarColumns).toHaveAttribute('placeholder', '64');
|
||||
await expect(sidebarRows).toHaveAttribute('placeholder', '12');
|
||||
await sidebarRows.fill('');
|
||||
await sidebarRows.press('Tab');
|
||||
await expectGrid(block, 88, 12);
|
||||
@@ -271,6 +280,8 @@ test('toolbar terminal dimensions are discoverable, preserve focus and synchroni
|
||||
await toggle.click();
|
||||
await expect(columns).toHaveValue('');
|
||||
await expect(rows).toHaveValue('');
|
||||
await expect(columns).toHaveAttribute('placeholder', '64');
|
||||
await expect(rows).toHaveAttribute('placeholder', '12');
|
||||
await popover.getByRole('button', { name: 'Close', exact: true }).click();
|
||||
const saved = await publish(page, 'Reset terminal dimensions regression');
|
||||
await page.goto(saved.url);
|
||||
@@ -291,11 +302,19 @@ test('recorded resize events remain authoritative except on explicitly overridde
|
||||
{ overrides: { cols: 80, rows: 24 }, cols: 80, rows: 24 },
|
||||
];
|
||||
for (const entry of cases) {
|
||||
const { block } = await insertPlayer(page, { source, startAt: 2, ...entry.overrides });
|
||||
const { id, block } = await insertPlayer(page, { source, startAt: 2, ...entry.overrides });
|
||||
await readyPreview(block);
|
||||
await expectGrid(block, entry.overrides.cols ?? 64, entry.overrides.rows ?? 12);
|
||||
await block.locator('.ap-overlay-start .ap-play-button').click();
|
||||
await expectGrid(block, entry.cols, entry.rows);
|
||||
const columns = page.getByRole('spinbutton', { name: 'Columns', exact: true });
|
||||
const rows = page.getByRole('spinbutton', { name: 'Rows', exact: true });
|
||||
await openInspectorPanel(page, 'Terminal size', columns);
|
||||
// Placeholders describe the cast header, even after its resize event.
|
||||
await expect(columns).toHaveAttribute('placeholder', '64');
|
||||
await expect(rows).toHaveAttribute('placeholder', '12');
|
||||
expect((await attributes(page, id)).cols).toBe(entry.overrides.cols);
|
||||
expect((await attributes(page, id)).rows).toBe(entry.overrides.rows);
|
||||
}
|
||||
const saved = await publish(page, 'Recording resize and explicit axes regression');
|
||||
await page.goto(saved.url);
|
||||
|
||||
@@ -0,0 +1,288 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
|
||||
const blockName = 'lamgc/asciiplayer';
|
||||
const fixtures = '/wp-content/uploads/asciiplayer-fixtures';
|
||||
|
||||
async function openEditor(page) {
|
||||
await page.goto('/wp-login.php');
|
||||
await page.locator('#user_login').fill(process.env.WP_USERNAME || 'admin');
|
||||
await page.locator('#user_pass').fill(process.env.WP_PASSWORD || 'password');
|
||||
await page.locator('#wp-submit').click();
|
||||
await expect(page).toHaveURL(/\/wp-admin\//);
|
||||
await page.goto('/wp-admin/post-new.php');
|
||||
await page.waitForFunction((name) => Boolean(
|
||||
window.wp?.blocks?.getBlockType(name) &&
|
||||
window.wp?.data?.select('core/editor')?.getCurrentPostId()
|
||||
), blockName);
|
||||
await page.evaluate(() => {
|
||||
for (const scope of ['core/edit-post', 'core/editor']) {
|
||||
window.wp.data.dispatch('core/preferences').set(scope, 'welcomeGuide', false);
|
||||
}
|
||||
});
|
||||
await expect(page.locator('iframe[name="editor-canvas"]')).toBeVisible();
|
||||
}
|
||||
|
||||
function playerBlock(page, id) {
|
||||
return page.frameLocator('iframe[name="editor-canvas"]').locator(`[data-block="${id}"]`);
|
||||
}
|
||||
|
||||
async function insertPlayer(page, attributes = {}) {
|
||||
const id = await page.evaluate(({ name, attrs }) => {
|
||||
const block = window.wp.blocks.createBlock(name, attrs);
|
||||
window.wp.data.dispatch('core/block-editor').insertBlocks(block);
|
||||
window.wp.data.dispatch('core/block-editor').selectBlock(block.clientId);
|
||||
return block.clientId;
|
||||
}, { name: blockName, attrs: attributes });
|
||||
return { id, block: playerBlock(page, id) };
|
||||
}
|
||||
|
||||
async function attributes(page, id) {
|
||||
return page.evaluate((clientId) => window.wp.data.select('core/block-editor').getBlockAttributes(clientId), id);
|
||||
}
|
||||
|
||||
async function readyPreview(block) {
|
||||
await expect(block.locator('.asciiplayer-editor__preview')).toHaveAttribute('data-preview-status', 'ready');
|
||||
await expect(block.locator('.ap-wrapper')).toHaveCount(1);
|
||||
await expect(block.locator('.ap-term')).toBeVisible();
|
||||
}
|
||||
|
||||
async function expectGrid(block, cols, rows) {
|
||||
await expect.poll(() => block.locator('.ap-term').evaluate((terminal) => ({
|
||||
cols: Number(terminal.style.getPropertyValue('--term-cols')),
|
||||
rows: Number(terminal.style.getPropertyValue('--term-rows')),
|
||||
}))).toEqual({ cols, rows });
|
||||
}
|
||||
|
||||
async function openDimensions(page) {
|
||||
await page.evaluate(() => window.wp.data.dispatch('core/edit-post').openGeneralSidebar('edit-post/block'));
|
||||
const columns = page.getByRole('spinbutton', { name: 'Columns', exact: true });
|
||||
const rows = page.getByRole('spinbutton', { name: 'Rows', exact: true });
|
||||
if (!await columns.isVisible()) {
|
||||
await page.locator('.components-panel__body-toggle').filter({ hasText: /^Terminal size$/ }).click();
|
||||
}
|
||||
await expect(columns).toBeVisible();
|
||||
return { columns, rows };
|
||||
}
|
||||
|
||||
async function expectNativeSize(controls, cols, rows) {
|
||||
await expect(controls.columns).toHaveAttribute('placeholder', cols === undefined ? 'From recording' : String(cols));
|
||||
await expect(controls.rows).toHaveAttribute('placeholder', rows === undefined ? 'From recording' : String(rows));
|
||||
}
|
||||
|
||||
async function openMedia(page, block) {
|
||||
await block.getByRole('button', { name: 'Choose recording', exact: true }).click();
|
||||
const dialog = page.getByRole('dialog', { name: 'Choose an Asciicast recording', exact: true });
|
||||
await expect(dialog).toBeVisible();
|
||||
return dialog;
|
||||
}
|
||||
|
||||
async function uploadRecording(page, dialog, name, buffer) {
|
||||
await dialog.getByRole('tab', { name: 'Upload files', exact: true }).click();
|
||||
// Native WP media uses Plupload. Its file input is intentionally hidden and
|
||||
// may live outside the modal; setInputFiles exercises the actual uploader.
|
||||
const input = page.locator('.moxie-shim input[type="file"]').last();
|
||||
await expect(input).toBeAttached();
|
||||
const response = page.waitForResponse((result) =>
|
||||
/\/wp-admin\/async-upload\.php(?:\?|$)/.test(result.url()) && result.request().method() === 'POST'
|
||||
);
|
||||
await input.setInputFiles({ name, mimeType: 'application/x-asciicast', buffer });
|
||||
return (await response).json();
|
||||
}
|
||||
|
||||
async function selectAttachment(dialog, id) {
|
||||
await dialog.getByRole('tab', { name: 'Media Library', exact: true }).click();
|
||||
const attachment = dialog.locator(`.attachment[data-id="${id}"]`);
|
||||
await expect(attachment).toBeVisible();
|
||||
// Newly uploaded files are already selected; clicking them again deselects.
|
||||
if (!await attachment.evaluate((element) => element.classList.contains('selected'))) await attachment.click();
|
||||
const confirm = dialog.locator('.media-button-select');
|
||||
await expect(confirm).toBeEnabled();
|
||||
await confirm.click();
|
||||
await expect(dialog).toBeHidden();
|
||||
}
|
||||
|
||||
test('recording metadata follows URL changes, clears while loading or invalid, and never replaces explicit dimensions', async ({ page }) => {
|
||||
await openEditor(page);
|
||||
const original = new URL(`${fixtures}/hello.cast`, page.url()).href;
|
||||
const replacement = new URL(`${fixtures}/replacement.cast?metadata=delayed`, page.url()).href;
|
||||
const unavailable = new URL(`${fixtures}/missing.cast?metadata=error`, page.url()).href;
|
||||
const malformed = new URL(`${fixtures}/malformed.cast?metadata=valid-header`, page.url()).href;
|
||||
const recording = await readFile(new URL('../fixtures/replacement.cast', import.meta.url));
|
||||
let release;
|
||||
let requested = false;
|
||||
const pending = new Promise((resolve) => { release = resolve; });
|
||||
await page.route(replacement, async (route) => {
|
||||
requested = true;
|
||||
await pending;
|
||||
await route.fulfill({ contentType: 'text/plain', body: recording }).catch(() => {});
|
||||
});
|
||||
await page.route(unavailable, (route) => route.fulfill({ status: 503, contentType: 'text/plain', body: 'Unavailable' }));
|
||||
await page.route(malformed, (route) => route.fulfill({
|
||||
contentType: 'text/plain', body: '{"version":2,"width":101,"height":31}\n[invalid event]\n',
|
||||
}));
|
||||
try {
|
||||
const { id, block } = await insertPlayer(page, { source: original });
|
||||
await readyPreview(block);
|
||||
const dimensions = await openDimensions(page);
|
||||
await expectNativeSize(dimensions, 64, 12);
|
||||
await expect(dimensions.columns).toHaveValue('');
|
||||
await expect(dimensions.rows).toHaveValue('');
|
||||
expect((await attributes(page, id)).cols).toBeUndefined();
|
||||
expect((await attributes(page, id)).rows).toBeUndefined();
|
||||
await dimensions.columns.fill('80');
|
||||
await dimensions.rows.fill('20');
|
||||
await dimensions.rows.press('Tab');
|
||||
await readyPreview(block);
|
||||
await expectGrid(block, 80, 20);
|
||||
await expectNativeSize(dimensions, 64, 12);
|
||||
|
||||
const input = block.getByRole('textbox', { name: 'Recording URL', exact: true });
|
||||
await input.fill(replacement);
|
||||
await expectNativeSize(dimensions);
|
||||
await expect.poll(() => requested).toBe(true);
|
||||
await expectNativeSize(dimensions);
|
||||
await expect(dimensions.columns).toHaveValue('80');
|
||||
await expect(dimensions.rows).toHaveValue('20');
|
||||
release();
|
||||
await readyPreview(block);
|
||||
await expectNativeSize(dimensions, 100, 30);
|
||||
await expectGrid(block, 80, 20);
|
||||
expect(await attributes(page, id)).toMatchObject({ source: replacement, cols: 80, rows: 20 });
|
||||
|
||||
await input.fill('javascript:alert(1)');
|
||||
await expect(block.locator('.asciiplayer-editor__preview')).toHaveCount(0);
|
||||
await expectNativeSize(dimensions);
|
||||
// Invalid drafts do not overwrite the last valid saved URL or overrides.
|
||||
expect(await attributes(page, id)).toMatchObject({ source: replacement, cols: 80, rows: 20 });
|
||||
await input.fill(original);
|
||||
await block.getByRole('button', { name: 'Apply URL', exact: true }).click();
|
||||
await readyPreview(block);
|
||||
await expectNativeSize(dimensions, 64, 12);
|
||||
for (const failingSource of [unavailable, malformed]) {
|
||||
await input.fill(failingSource);
|
||||
await expect(block.locator('.asciiplayer-editor__preview')).toHaveAttribute('data-preview-status', 'error');
|
||||
// Even a readable header must be discarded if the player fails.
|
||||
await expectNativeSize(dimensions);
|
||||
expect(await attributes(page, id)).toMatchObject({ source: failingSource, cols: 80, rows: 20 });
|
||||
}
|
||||
await input.fill('');
|
||||
await expect.poll(async () => (await attributes(page, id)).source).toBe('');
|
||||
await expectNativeSize(dimensions);
|
||||
expect(await attributes(page, id)).toMatchObject({ cols: 80, rows: 20 });
|
||||
} finally {
|
||||
release();
|
||||
}
|
||||
});
|
||||
|
||||
test('pretty v1 and commented v3 recordings play with native header dimensions', async ({ page }) => {
|
||||
await openEditor(page);
|
||||
// Fixtures follow the official formats, including v1's multiline JSON and
|
||||
// v3's comments after its single-line header and relative event timestamps:
|
||||
// https://docs.asciinema.org/manual/asciicast/v1/
|
||||
// https://docs.asciinema.org/manual/asciicast/v3/
|
||||
const cases = [
|
||||
{ filename: 'v1-pretty.cast', cols: 72, rows: 18, output: 'Pretty v1 recording' },
|
||||
{ filename: 'v3-comments.cast', cols: 92, rows: 22, output: 'Commented v3 recording' },
|
||||
];
|
||||
for (const entry of cases) {
|
||||
const source = new URL(`${fixtures}/${entry.filename}`, page.url()).href;
|
||||
const { id, block } = await insertPlayer(page, { source });
|
||||
await readyPreview(block);
|
||||
await expectGrid(block, entry.cols, entry.rows);
|
||||
const dimensions = await openDimensions(page);
|
||||
await expectNativeSize(dimensions, entry.cols, entry.rows);
|
||||
await expect(dimensions.columns).toHaveValue('');
|
||||
await expect(dimensions.rows).toHaveValue('');
|
||||
expect((await attributes(page, id)).cols).toBeUndefined();
|
||||
expect((await attributes(page, id)).rows).toBeUndefined();
|
||||
await block.locator('.ap-overlay-start .ap-play-button').click();
|
||||
await expect(block.locator('.ap-term-text')).toContainText(entry.output);
|
||||
}
|
||||
});
|
||||
|
||||
test('native Media Library uploads, selects and replaces a cast while cancel leaves the current recording intact', async ({ page }, testInfo) => {
|
||||
await openEditor(page);
|
||||
const { id, block } = await insertPlayer(page);
|
||||
const firstCast = await readFile(new URL('../fixtures/hello.cast', import.meta.url));
|
||||
const secondCast = await readFile(new URL('../fixtures/replacement.cast', import.meta.url));
|
||||
const unique = `${Date.now()}-${testInfo.retry}`;
|
||||
let dialog = await openMedia(page, block);
|
||||
const first = await uploadRecording(page, dialog, `asciiplayer-original-${unique}.cast`, firstCast);
|
||||
expect(first.success, JSON.stringify(first)).toBe(true);
|
||||
expect(first.data.mime).toBe('application/x-asciicast');
|
||||
await selectAttachment(dialog, first.data.id);
|
||||
const input = block.getByRole('textbox', { name: 'Recording URL', exact: true });
|
||||
await expect(input).toHaveValue(first.data.url);
|
||||
// Selecting in the native media frame applies and autoloads, with no Apply URL click.
|
||||
await readyPreview(block);
|
||||
await expectGrid(block, 64, 12);
|
||||
let dimensions = await openDimensions(page);
|
||||
await expectNativeSize(dimensions, 64, 12);
|
||||
expect(await attributes(page, id)).toMatchObject({ source: first.data.url });
|
||||
expect((await attributes(page, id)).cols).toBeUndefined();
|
||||
expect((await attributes(page, id)).rows).toBeUndefined();
|
||||
await block.locator('.ap-term').evaluate((element) => { element.dataset.mediaIdentity = 'original'; });
|
||||
|
||||
dialog = await openMedia(page, block);
|
||||
const second = await uploadRecording(page, dialog, `asciiplayer-replacement-${unique}.cast`, secondCast);
|
||||
expect(second.success, JSON.stringify(second)).toBe(true);
|
||||
await dialog.locator('.media-modal-close').click();
|
||||
await expect(dialog).toBeHidden();
|
||||
await expect(input).toHaveValue(first.data.url);
|
||||
expect((await attributes(page, id)).source).toBe(first.data.url);
|
||||
await expectNativeSize(dimensions, 64, 12);
|
||||
await expect(block.locator('.ap-term')).toHaveAttribute('data-media-identity', 'original');
|
||||
|
||||
// The upload above is now an existing media item. Reopen the real frame and
|
||||
// select its tile rather than changing block attributes through the store.
|
||||
dialog = await openMedia(page, block);
|
||||
await selectAttachment(dialog, second.data.id);
|
||||
await expect(input).toHaveValue(second.data.url);
|
||||
await readyPreview(block);
|
||||
await expectGrid(block, 100, 30);
|
||||
await expectNativeSize(dimensions, 100, 30);
|
||||
await block.locator('.ap-overlay-start .ap-play-button').click();
|
||||
await expect(block.locator('.ap-term-text')).toContainText('Replacement recording');
|
||||
expect((await attributes(page, id)).source).toBe(second.data.url);
|
||||
expect((await attributes(page, id)).cols).toBeUndefined();
|
||||
expect((await attributes(page, id)).rows).toBeUndefined();
|
||||
const path = testInfo.outputPath('media-library-selected-recording.png');
|
||||
await page.screenshot({ path, fullPage: true });
|
||||
await testInfo.attach('media-library-selected-recording', { path, contentType: 'image/png' });
|
||||
await page.evaluate(async () => {
|
||||
const editor = window.wp.data.dispatch('core/editor');
|
||||
editor.editPost({ title: 'Native media recording selection regression' });
|
||||
await editor.savePost();
|
||||
if (window.wp.data.select('core/editor').didPostSaveRequestFail()) throw new Error('WordPress could not save the test post.');
|
||||
});
|
||||
await page.reload();
|
||||
await page.waitForFunction((name) => window.wp?.data?.select('core/block-editor')?.getBlocks().some((entry) => entry.name === name), blockName);
|
||||
const reloaded = await page.evaluate((name) => {
|
||||
const block = window.wp.data.select('core/block-editor').getBlocks().find((entry) => entry.name === name);
|
||||
window.wp.data.dispatch('core/block-editor').selectBlock(block.clientId);
|
||||
return block;
|
||||
}, blockName);
|
||||
expect(reloaded.attributes.source).toBe(second.data.url);
|
||||
expect(reloaded.attributes.cols).toBeUndefined();
|
||||
expect(reloaded.attributes.rows).toBeUndefined();
|
||||
await readyPreview(playerBlock(page, reloaded.clientId));
|
||||
dimensions = await openDimensions(page);
|
||||
await expectNativeSize(dimensions, 100, 30);
|
||||
});
|
||||
|
||||
test('native Media Library rejects an invalid cast upload without applying a source', async ({ page }, testInfo) => {
|
||||
await openEditor(page);
|
||||
const { id, block } = await insertPlayer(page);
|
||||
const dialog = await openMedia(page, block);
|
||||
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);
|
||||
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('');
|
||||
expect((await attributes(page, id)).source).toBe('');
|
||||
await expect(block.locator('.asciiplayer-editor__preview')).toHaveCount(0);
|
||||
});
|
||||
Reference in New Issue
Block a user