GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — ZPLab/e2e/sourceEdit.spec.ts at main · u8array/ZPLab Expand file tree/ Copy pathsourceEdit.spec.tsMore file actions 149 lines (127 loc) · 6.5 KB / Copy pathsourceEdit.spec.tsFile metadata and controls149 lines (127 loc) · 6.5 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 import { test, expect, type Page } from '@playwright/test'; /** Real-browser coverage for the focus-implicit source-edit session: the raw * pointerdown/focusout/Escape listeners have no jsdom-faithful equivalent. */ const SAMPLE_ZPL = '^XA\n^FO50,50^A0N,30,0^FDHello World^FS\n^XZ'; const openOutput = async (page: Page) => { await page.getByRole('button', { name: 'Expand' }).click(); return page.getByRole('region', { name: 'ZPL' }).getByRole('textbox'); }; const importSample = async (page: Page) => { await page.getByRole('button', { name: 'File', exact: true }).click(); await page.getByRole('menuitem', { name: 'Import ZPL' }).click(); await page.getByRole('dialog').getByRole('textbox').fill(SAMPLE_ZPL); await page.getByRole('button', { name: 'Import', exact: true }).click(); await expect(page.getByRole('dialog')).toBeHidden(); return openOutput(page); }; const retype = async (page: Page, output: ReturnType<Page['locator']>, zpl: string) => { await output.click(); await page.keyboard.press('ControlOrMeta+a'); await page.keyboard.type(zpl); }; const editTwoPages = async (page: Page) => { const output = await importSample(page); await page.getByRole('button', { name: 'File', exact: true }).click(); await page.getByRole('menuitem', { name: 'Add page' }).click(); await expect(page.getByText('2 / 2')).toBeVisible(); await retype(page, output, '^XA^FO10,10^A0N,30,30^FDp1^FS^XZ\n^XA^FO10,10^A0N,30,30^FDp2^FS^XZ'); return output; }; test('a blank document accepts ZPL typed straight into the pane', async ({ page }) => { await page.goto('/'); const output = await openOutput(page); await output.click(); await page.keyboard.type('^XA^FO10,10^A0N,30,30^FDscratch^FS^XZ'); await expect(page.getByRole('button', { name: 'Apply' })).toBeVisible(); await page.locator('main').click({ position: { x: 20, y: 20 } }); await expect(page.getByRole('button', { name: 'Apply' })).toBeHidden(); await expect(output).toContainText('^FDscratch'); }); test('a clean edit applies on the outside click that leaves the panel', async ({ page }) => { await page.goto('/'); const output = await importSample(page); await retype(page, output, '^XA^FO10,10^A0N,30,30^FDedited^FS^XZ'); await expect(page.getByRole('button', { name: 'Apply' })).toBeVisible(); await page.locator('main').click({ position: { x: 20, y: 20 } }); // Session over, buffer committed, no dialog. await expect(page.getByRole('button', { name: 'Apply' })).toBeHidden(); await expect(output).toContainText('^FDedited'); }); test('a multi-page edit applied by an outside click stays on the current page', async ({ page }) => { await page.goto('/'); await editTwoPages(page); await page.locator('main').click({ position: { x: 20, y: 20 } }); await expect(page.getByRole('button', { name: 'Apply' })).toBeHidden(); // The implicit apply must not yank the user back to page 1. await expect(page.getByText('2 / 2')).toBeVisible(); }); test('a press on the page navigation leaves the focus in the editor', async ({ page }) => { await page.goto('/'); const output = await editTwoPages(page); await page.getByRole('button', { name: 'Previous page (Page Up)' }).click(); await expect(page.getByText('1 / 2')).toBeVisible(); await page.getByText('1 / 2').click(); await expect(output).toBeFocused(); await expect(page.getByRole('button', { name: 'Apply' })).toBeVisible(); }); test('paging by keyboard to the first page keeps the session open', async ({ page }) => { await page.goto('/'); await editTwoPages(page); const prev = page.getByRole('button', { name: 'Previous page (Page Up)' }); await prev.focus(); await page.keyboard.press('Enter'); await expect(page.getByText('1 / 2')).toBeVisible(); await expect(prev).toBeFocused(); await expect(page.getByRole('button', { name: 'Apply' })).toBeVisible(); }); test('an unbalanced draft shows a positioned lint error while typing', async ({ page }) => { await page.goto('/'); const output = await importSample(page); // The stray ^XZ is the TRAILING one, so an implementation anchoring every // kind at offset 0 would mark the opening ^XA and fail here. await retype(page, output, '^XA^FO10,10^A0N,30,30^FDX^FS^XZ^XZ'); await expect(page.locator('.cm-lintRange-error')).toHaveText('^XZ'); }); test('a device action gets a positioned warning mark while typing', async ({ page }) => { await page.goto('/'); const output = await importSample(page); await retype(page, output, '^XA^FO10,10^A0N,30,30^FDX^FS^XZ~PH'); await expect(page.locator('.cm-lintRange-warning')).toHaveText('~PH'); }); test('Escape asks to discard and restores the export', async ({ page }) => { await page.goto('/'); const output = await importSample(page); await retype(page, output, '^XA^FO10,10^A0N,30,30^FDedited^FS^XZ'); await page.keyboard.press('Escape'); // The discard confirm is an alertdialog (destructive), unlike the apply dialog. const dialog = page.getByRole('alertdialog'); await expect(dialog).toBeVisible(); await dialog.getByRole('button', { name: 'Discard' }).click(); await expect(page.getByRole('button', { name: 'Apply' })).toBeHidden(); await expect(output).toContainText('^FDHello World'); await expect(output).not.toContainText('^FDedited'); }); test('a held exit keeps the File menu closed on a real control', async ({ page }) => { await page.goto('/'); const output = await importSample(page); await retype(page, output, '^XA^JZY^FO10,10^A0N,30,30^FDX^FS^XZ'); // The File trigger opens on pointerdown, so the held exit has to stop that press. await page.getByRole('button', { name: 'File', exact: true }).click(); await expect(page.getByRole('dialog')).toBeVisible(); await expect(page.getByRole('menuitem', { name: 'Import ZPL' })).toBeHidden(); }); test('a lossy edit stops on the confirm dialog; cancel refocuses the editor', async ({ page }) => { await page.goto('/'); const output = await importSample(page); // ^JZY carries a replay-risk finding, which forces the confirm dialog. await retype(page, output, '^XA^JZY^FO10,10^A0N,30,30^FDX^FS^XZ'); await page.locator('main').click({ position: { x: 20, y: 20 } }); const dialog = page.getByRole('dialog'); await expect(dialog).toBeVisible(); await dialog.getByRole('button', { name: 'Cancel' }).click(); await expect(dialog).toBeHidden(); // Cancel means keep editing: session alive, focus back in the editor, // and crucially the dialog must not loop straight back open. await expect(page.getByRole('button', { name: 'Apply' })).toBeVisible(); await expect(output).toBeFocused(); }); |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |