2025-11-29 16:19:13 +01:00
|
|
|
// wxClipboard Tests - Clipboard operations for KiCad copy/paste
|
2025-12-29 12:11:33 +01:00
|
|
|
// Uses element registry for semantic element identification
|
2026-07-07 10:50:24 +02:00
|
|
|
import { test, expect, waitForWxApp, clickByLabel } from './utils/fixtures';
|
|
|
|
|
import { stableShot } from './utils/element-tracker';
|
2025-12-03 10:19:50 +01:00
|
|
|
|
2025-11-29 16:19:13 +01:00
|
|
|
test.describe('wxClipboard Tests', () => {
|
|
|
|
|
|
2025-11-29 20:54:54 +01:00
|
|
|
test('Clipboard test app loads successfully', async ({ page, testLogger }) => {
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.goto('/standalone/clipboard/clipboard_test.html');
|
2026-07-07 10:50:24 +02:00
|
|
|
await waitForWxApp(page);
|
2025-11-29 16:19:13 +01:00
|
|
|
|
2026-07-07 10:50:24 +02:00
|
|
|
await stableShot(page, 'clipboard-01-loaded.png', { fullPage: true });
|
2025-11-29 16:19:13 +01:00
|
|
|
|
2025-11-29 20:54:54 +01:00
|
|
|
const hasStartupLog = testLogger.consoleLogs.some(l =>
|
|
|
|
|
l.includes('wxClipboard test app started') || l.includes('Clipboard test app started')
|
|
|
|
|
);
|
2025-11-29 16:19:13 +01:00
|
|
|
|
2025-11-29 20:54:54 +01:00
|
|
|
expect(testLogger.errors.filter(e => !e.includes('favicon'))).toHaveLength(0);
|
2025-11-29 16:19:13 +01:00
|
|
|
});
|
|
|
|
|
|
2025-12-03 10:19:50 +01:00
|
|
|
test('Copy button copies text to clipboard', async ({ page, testLogger }) => {
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.goto('/standalone/clipboard/clipboard_test.html');
|
2026-07-07 10:50:24 +02:00
|
|
|
await waitForWxApp(page);
|
2025-11-29 16:19:13 +01:00
|
|
|
|
|
|
|
|
// Click "Copy to Clipboard" button
|
2025-12-29 12:11:33 +01:00
|
|
|
await clickByLabel(page, 'Copy to Clipboard');
|
2025-12-03 10:19:50 +01:00
|
|
|
|
|
|
|
|
// Either success (real clipboard worked) or at least attempt was made
|
2026-07-07 10:50:24 +02:00
|
|
|
await expect.poll(() => testLogger.consoleLogs.some(l =>
|
|
|
|
|
(l.includes('SUCCESS') && l.includes('Copied')) || l.includes('Attempting to copy')
|
|
|
|
|
), { message: 'Copy should succeed or at least attempt' }).toBe(true);
|
|
|
|
|
|
|
|
|
|
await stableShot(page, 'clipboard-02-copy-clicked.png', { fullPage: true });
|
2025-11-29 16:19:13 +01:00
|
|
|
});
|
|
|
|
|
|
2025-12-03 10:19:50 +01:00
|
|
|
test('Paste button retrieves text from clipboard', async ({ page, testLogger }) => {
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.goto('/standalone/clipboard/clipboard_test.html');
|
2026-07-07 10:50:24 +02:00
|
|
|
await waitForWxApp(page);
|
2025-11-29 16:19:13 +01:00
|
|
|
|
|
|
|
|
// First copy something
|
2025-12-29 12:11:33 +01:00
|
|
|
await clickByLabel(page, 'Copy to Clipboard');
|
2026-07-07 10:50:24 +02:00
|
|
|
await expect.poll(() => testLogger.consoleLogs.some(l =>
|
|
|
|
|
(l.includes('SUCCESS') && l.includes('Copied')) || l.includes('Attempting to copy')
|
|
|
|
|
), { message: 'Copy should log activity' }).toBe(true);
|
2025-11-29 16:19:13 +01:00
|
|
|
|
|
|
|
|
// Click "Paste from Clipboard" button
|
2025-12-29 12:11:33 +01:00
|
|
|
await clickByLabel(page, 'Paste from Clipboard');
|
2025-11-29 16:19:13 +01:00
|
|
|
|
2026-07-07 10:50:24 +02:00
|
|
|
// Either we successfully pasted, there was no text (valid), or at least we attempted
|
|
|
|
|
await expect.poll(() => testLogger.consoleLogs.some(l =>
|
|
|
|
|
(l.includes('SUCCESS') && l.includes('Pasted')) ||
|
|
|
|
|
(l.includes('WARNING') && l.includes('No text data')) ||
|
2025-12-03 10:19:50 +01:00
|
|
|
l.includes('Attempting to paste')
|
2026-07-07 10:50:24 +02:00
|
|
|
), { message: 'Paste should succeed or report no text' }).toBe(true);
|
2025-12-03 10:19:50 +01:00
|
|
|
|
2026-07-07 10:50:24 +02:00
|
|
|
await stableShot(page, 'clipboard-03-paste-clicked.png', { fullPage: true });
|
2025-11-29 16:19:13 +01:00
|
|
|
});
|
|
|
|
|
|
2025-12-03 10:19:50 +01:00
|
|
|
test('Check clipboard button reports clipboard content', async ({ page, testLogger }) => {
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.goto('/standalone/clipboard/clipboard_test.html');
|
2026-07-07 10:50:24 +02:00
|
|
|
await waitForWxApp(page);
|
2025-11-29 16:19:13 +01:00
|
|
|
|
2025-12-03 10:19:50 +01:00
|
|
|
// First copy something to ensure clipboard has content
|
2025-12-29 12:11:33 +01:00
|
|
|
await clickByLabel(page, 'Copy to Clipboard');
|
2026-07-07 10:50:24 +02:00
|
|
|
await expect.poll(() => testLogger.consoleLogs.some(l =>
|
|
|
|
|
(l.includes('SUCCESS') && l.includes('Copied')) || l.includes('Attempting to copy')
|
|
|
|
|
), { message: 'Copy should log activity' }).toBe(true);
|
2025-12-03 10:19:50 +01:00
|
|
|
|
2025-11-29 16:19:13 +01:00
|
|
|
// Click "Check Clipboard" button
|
2025-12-29 12:11:33 +01:00
|
|
|
await clickByLabel(page, 'Check Clipboard');
|
2025-11-29 16:19:13 +01:00
|
|
|
|
2025-12-03 10:19:50 +01:00
|
|
|
// Check for clipboard content report
|
2026-07-07 10:50:24 +02:00
|
|
|
await expect.poll(() => testLogger.consoleLogs.some(l =>
|
2025-12-03 10:19:50 +01:00
|
|
|
l.includes('Clipboard contains') || l.includes('Checking clipboard')
|
2026-07-07 10:50:24 +02:00
|
|
|
), { message: 'Check should report clipboard contents' }).toBe(true);
|
2025-12-03 10:19:50 +01:00
|
|
|
|
2026-07-07 10:50:24 +02:00
|
|
|
await stableShot(page, 'clipboard-04-check-clicked.png', { fullPage: true });
|
2025-11-29 16:19:13 +01:00
|
|
|
});
|
|
|
|
|
|
2025-12-03 10:19:50 +01:00
|
|
|
test('Clear clipboard button clears clipboard', async ({ page, testLogger }) => {
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.goto('/standalone/clipboard/clipboard_test.html');
|
2026-07-07 10:50:24 +02:00
|
|
|
await waitForWxApp(page);
|
2025-11-29 16:19:13 +01:00
|
|
|
|
|
|
|
|
// First copy something
|
2025-12-29 12:11:33 +01:00
|
|
|
await clickByLabel(page, 'Copy to Clipboard');
|
2026-07-07 10:50:24 +02:00
|
|
|
await expect.poll(() => testLogger.consoleLogs.some(l =>
|
|
|
|
|
(l.includes('SUCCESS') && l.includes('Copied')) || l.includes('Attempting to copy')
|
|
|
|
|
), { message: 'Copy should log activity' }).toBe(true);
|
2025-11-29 16:19:13 +01:00
|
|
|
|
|
|
|
|
// Click "Clear Clipboard" button
|
2025-12-29 12:11:33 +01:00
|
|
|
await clickByLabel(page, 'Clear Clipboard');
|
2025-11-29 16:19:13 +01:00
|
|
|
|
2025-12-03 10:19:50 +01:00
|
|
|
// Check for SUCCESS log or at least attempt
|
2026-07-07 10:50:24 +02:00
|
|
|
await expect.poll(() => testLogger.consoleLogs.some(l =>
|
|
|
|
|
(l.includes('SUCCESS') && l.includes('Clipboard cleared')) || l.includes('Attempting to clear')
|
|
|
|
|
), { message: 'Clear should succeed or at least attempt' }).toBe(true);
|
2025-12-03 10:19:50 +01:00
|
|
|
|
2026-07-07 10:50:24 +02:00
|
|
|
await stableShot(page, 'clipboard-05-clear-clicked.png', { fullPage: true });
|
2025-11-29 16:19:13 +01:00
|
|
|
});
|
|
|
|
|
|
2025-11-29 20:54:54 +01:00
|
|
|
test('Full clipboard flow: copy, check, paste, clear', async ({ page, testLogger }) => {
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.goto('/standalone/clipboard/clipboard_test.html');
|
2026-07-07 10:50:24 +02:00
|
|
|
await waitForWxApp(page);
|
2025-11-29 16:19:13 +01:00
|
|
|
|
|
|
|
|
// 1. Copy
|
2025-12-29 12:11:33 +01:00
|
|
|
await clickByLabel(page, 'Copy to Clipboard');
|
2026-07-07 10:50:24 +02:00
|
|
|
await expect.poll(() => testLogger.consoleLogs.some(l =>
|
2025-12-03 10:19:50 +01:00
|
|
|
l.includes('SUCCESS') && l.includes('Copied') || l.includes('Attempting to copy')
|
2026-07-07 10:50:24 +02:00
|
|
|
), { message: 'Copy should log activity' }).toBe(true);
|
2025-11-29 16:19:13 +01:00
|
|
|
|
|
|
|
|
// 2. Check
|
2025-12-29 12:11:33 +01:00
|
|
|
await clickByLabel(page, 'Check Clipboard');
|
2026-07-07 10:50:24 +02:00
|
|
|
await expect.poll(() => testLogger.consoleLogs.some(l =>
|
2025-12-03 10:19:50 +01:00
|
|
|
l.includes('Clipboard contains') || l.includes('Checking clipboard')
|
2026-07-07 10:50:24 +02:00
|
|
|
), { message: 'Check should report clipboard' }).toBe(true);
|
2025-11-29 16:19:13 +01:00
|
|
|
|
|
|
|
|
// 3. Paste
|
2025-12-29 12:11:33 +01:00
|
|
|
await clickByLabel(page, 'Paste from Clipboard');
|
2026-07-07 10:50:24 +02:00
|
|
|
await expect.poll(() => testLogger.consoleLogs.some(l =>
|
2025-12-03 10:19:50 +01:00
|
|
|
l.includes('SUCCESS') && l.includes('Pasted') || l.includes('Attempting to paste')
|
2026-07-07 10:50:24 +02:00
|
|
|
), { message: 'Paste should log activity' }).toBe(true);
|
2025-11-29 16:19:13 +01:00
|
|
|
|
|
|
|
|
// 4. Clear
|
2025-12-29 12:11:33 +01:00
|
|
|
await clickByLabel(page, 'Clear Clipboard');
|
2026-07-07 10:50:24 +02:00
|
|
|
await expect.poll(() => testLogger.consoleLogs.some(l =>
|
2025-12-03 10:19:50 +01:00
|
|
|
l.includes('SUCCESS') && l.includes('Clipboard cleared') || l.includes('Attempting to clear')
|
2026-07-07 10:50:24 +02:00
|
|
|
), { message: 'Clear should log activity' }).toBe(true);
|
2025-11-29 16:19:13 +01:00
|
|
|
|
2026-07-07 10:50:24 +02:00
|
|
|
await stableShot(page, 'clipboard-06-full-flow.png', { fullPage: true });
|
2025-11-29 16:19:13 +01:00
|
|
|
|
2025-11-29 20:54:54 +01:00
|
|
|
expect(testLogger.errors.filter(e => !e.includes('favicon'))).toHaveLength(0);
|
2025-11-29 16:19:13 +01:00
|
|
|
});
|
|
|
|
|
});
|