eeschema copy/paste fix: wx UTF-8 text dataobj (c1f1477) + regression specs
Cmd+C/Cmd+V in the wasm eeschema pasted a stray "(" SCH_TEXT — the stroke
font renders it as a small blue arc — instead of the copied symbol, and any
copy reached navigator.clipboard as a single character. Root cause and fix
live in wxwidgets (90bbad29822: UTF-8 wxDF_UNICODETEXT + the port's missing
GetAllFormats key function; c1f14775ba3: empty-read cache fallback + no
browser pre-clear on copy). This bump carries them plus the guards:
- tests/kicad/eeschema-copy-paste.spec.ts: chromium asserts the full
multi-form (lib_symbols …)(symbol …) blob reaches navigator.clipboard;
both engines assert copy → paste → save yields a second symbol and no
stray (text …) item (firefox exercises the m_textCache fallback path).
The kicad-chromium project now grants clipboard-read/write. NB the kicad
projects' device UAs claim Windows, so specs must send plain Control+…
— ControlOrMeta resolves to Meta on a mac host, which the "Windows" app
ignores, and the bare key fires eeschema hotkeys instead.
- tests/e2e/textdataobj.spec.ts + Makefile.wasm target `textdataobj`:
drives the wx-repo harness app (wxwidgets/tests/wasm/textdataobj_test.cpp)
and asserts the SUITE-DONE failure counters plus the full-string browser
round-trip, sentinel-seeded so a failed write cannot read as stale success.
- tests/e2e/clipboard.spec.ts: the Copy test now asserts the full input
text reaches the clipboard (previously truncated to "S").
Verified locally: all specs red on the old wx, green after; wx-chromium
320/320, kicad-chromium 121/121 (collab specs env-gated).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
fcad12d251
commit
6034a0550d
6 changed files with 324 additions and 2 deletions
|
|
@ -22,6 +22,9 @@ test.describe('wxClipboard Tests', () => {
|
|||
await page.goto('/standalone/clipboard/clipboard_test.html');
|
||||
await waitForWxApp(page);
|
||||
|
||||
// Seed the clipboard so a silently-failed write cannot pass as success.
|
||||
await page.evaluate(() => navigator.clipboard.writeText('SENTINEL-BEFORE-COPY'));
|
||||
|
||||
// Click "Copy to Clipboard" button
|
||||
await clickByLabel(page, 'Copy to Clipboard');
|
||||
|
||||
|
|
@ -30,6 +33,11 @@ test.describe('wxClipboard Tests', () => {
|
|||
(l.includes('SUCCESS') && l.includes('Copied')) || l.includes('Attempting to copy')
|
||||
), { message: 'Copy should succeed or at least attempt' }).toBe(true);
|
||||
|
||||
// The FULL input text must reach the browser clipboard — the UTF-32/UTF-8
|
||||
// mixup in wxTextDataObject used to truncate it to its first character.
|
||||
const clip = await page.evaluate(() => navigator.clipboard.readText());
|
||||
expect(clip).toBe('Sample text for clipboard test');
|
||||
|
||||
await stableShot(page, 'clipboard-02-copy-clicked.png', { fullPage: true });
|
||||
});
|
||||
|
||||
|
|
|
|||
77
tests/e2e/textdataobj.spec.ts
Normal file
77
tests/e2e/textdataobj.spec.ts
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
// wxTextDataObject UTF-8 encoding regression (wasm clipboard truncation).
|
||||
//
|
||||
// Drives wxwidgets/tests/wasm/textdataobj_test.cpp (built by Makefile.wasm
|
||||
// target `textdataobj`). The bug: without wxNEEDS_UTF8_FOR_TEXT_DATAOBJ the
|
||||
// port's wxTextDataObject served UTF-32 for wxDF_UNICODETEXT; the wasm
|
||||
// wxClipboard read it as UTF-8 and the JS write helper truncated at the first
|
||||
// NUL — navigator.clipboard got exactly ONE character of any copy. In KiCad
|
||||
// that surfaced as eeschema pasting a stray "(" SCH_TEXT (rendered as a small
|
||||
// blue arc) instead of the copied symbol.
|
||||
//
|
||||
// The C++ side logs [WXTEST] PASS/FAIL lines for the wx-API-level contract;
|
||||
// this spec asserts none failed AND that the browser clipboard ends up with
|
||||
// the complete multi-line, non-ASCII string.
|
||||
import { test, expect, waitForWxApp, clickByLabel } from './utils/fixtures';
|
||||
|
||||
// Must match TEST_UTF8 in wxwidgets/tests/wasm/textdataobj_test.cpp byte for byte.
|
||||
const TEST_STRING = [
|
||||
'(kicad_sch (version 20250114)',
|
||||
' (symbol (lib_id "Device:R") (value "10kµΩ¶→"))',
|
||||
')',
|
||||
].join('\n');
|
||||
|
||||
test.describe('wxTextDataObject UTF-8 encoding', () => {
|
||||
test('serves UTF-8 for wxDF_UNICODETEXT and round-trips the clipboard in full', async ({
|
||||
page,
|
||||
testLogger,
|
||||
}) => {
|
||||
await page.goto('/standalone/textdataobj/textdataobj_test.html');
|
||||
await waitForWxApp(page);
|
||||
|
||||
// Startup suite: pure data-object assertions (size/bytes/composite/SetData).
|
||||
await expect.poll(
|
||||
() => testLogger.consoleLogs.some(l => l.includes('[WXTEST] SUITE-DONE startup')),
|
||||
{ message: 'startup checks should complete' }
|
||||
).toBe(true);
|
||||
|
||||
// Seed the clipboard so a silently-failed write cannot pass as success.
|
||||
await page.evaluate(() => navigator.clipboard.writeText('SENTINEL-BEFORE-COPY'));
|
||||
|
||||
// The wxClipboard round-trip suspends via JSPI, so it runs from a button
|
||||
// handler — the port's supported suspension context.
|
||||
expect(await clickByLabel(page, 'Run Clipboard RoundTrip')).toBe(true);
|
||||
await expect.poll(
|
||||
() => testLogger.consoleLogs.some(l => l.includes('[WXTEST] SUITE-DONE clipboard')),
|
||||
{ message: 'clipboard round-trip should complete' }
|
||||
).toBe(true);
|
||||
|
||||
// Browser-level contract: the FULL text reached navigator.clipboard
|
||||
// (the original bug left exactly one character here).
|
||||
const clip = await page.evaluate(() => navigator.clipboard.readText());
|
||||
expect(clip).toBe(TEST_STRING);
|
||||
|
||||
// Empty the browser clipboard, then drive a wx paste: it must fall back
|
||||
// to wxClipboard's local text cache (the round-trip copy) instead of
|
||||
// reporting the empty browser read as the result.
|
||||
await page.evaluate(() => navigator.clipboard.writeText(''));
|
||||
expect(await clickByLabel(page, 'Run Cache Fallback')).toBe(true);
|
||||
await expect.poll(
|
||||
() => testLogger.consoleLogs.some(l => l.includes('[WXTEST] SUITE-DONE fallback')),
|
||||
{ message: 'cache-fallback check should complete' }
|
||||
).toBe(true);
|
||||
|
||||
// wx-level contract: every [WXTEST] assertion passed. Assert on the
|
||||
// SUITE-DONE failure COUNTERS, not just the absence of FAIL lines — a
|
||||
// FAIL line that never reaches the console must not read as a pass.
|
||||
expect(testLogger.consoleLogs.filter(l => l.includes('[WXTEST] FAIL'))).toEqual([]);
|
||||
const counters = testLogger.consoleLogs
|
||||
.map(l => l.match(/\[WXTEST\] SUITE-DONE \w+ failures=(\d+)/))
|
||||
.filter((m): m is RegExpMatchArray => !!m)
|
||||
.map(m => parseInt(m[1], 10));
|
||||
expect(counters.length).toBe(3);
|
||||
expect(counters).toEqual([0, 0, 0]);
|
||||
|
||||
// (The full-text browser assertion ran above, before the fallback step
|
||||
// deliberately emptied navigator.clipboard.)
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue