GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — ZPLab/e2e/outputForm.spec.ts at main · u8array/ZPLab

Expand file tree

/

outputForm.spec.ts

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
100 lines (86 loc) · 3.92 KB
/

outputForm.spec.ts

Copy path

File metadata and controls

100 lines (86 loc) · 3.92 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
import { readFile } from 'node:fs/promises';
import { test, expect, type Page } from '@playwright/test';
// Enter in the last field clicks a button outside the form, and only a real browser does that.
const DESIGN = '^XA\n^FO50,50^A0N,60,60^FN1"Lot"^FDabc^FS\n^FO50,150^A0N,60,60^FN2"Weight"^FDw^FS\n^XZ';
// TEST-NET-1 leads nowhere. The route below answers before a packet leaves.
const PRINTER = 'http://192.0.2.1:9100/';
const openOutput = async (page: Page, design = DESIGN) => {
await page.goto('/');
await page.getByRole('button', { name: 'File', exact: true }).click();
await page.getByRole('menuitem', { name: 'Import ZPL' }).click();
await page.getByRole('dialog').getByRole('textbox').fill(design);
await page.getByRole('button', { name: 'Import', exact: true }).click();
await expect(page.getByRole('dialog')).toBeHidden();
await page.getByRole('button', { name: 'File', exact: true }).click();
await page.getByRole('menuitem', { name: 'Output' }).click();
return page.getByRole('dialog');
};
test('a scan with Enter as its suffix fills both fields and sends', async ({ page }) => {
const sent: string[] = [];
await page.route(PRINTER, (route) => {
sent.push(route.request().postData() ?? '');
return route.fulfill({ status: 200, headers: { 'access-control-allow-origin': '*' }, body: '' });
});
const dialog = await openOutput(page);
await dialog.getByText('ZPL printer (network)', { exact: true }).click();
await dialog.getByPlaceholder('192.168.1.100').fill('192.0.2.1');
await dialog.getByLabel('Lot').click();
await page.keyboard.type('L1');
await page.keyboard.press('Enter');
await expect(dialog.getByLabel('Weight')).toBeFocused();
expect(sent).toEqual([]);
await page.keyboard.type('12');
await page.keyboard.press('Enter');
await expect.poll(() => sent.length).toBe(1);
expect(sent[0]).toContain('^FDL1^FS');
expect(sent[0]).toContain('^FD12^FS');
await expect(dialog.getByLabel('Lot')).toBeFocused();
});
test('a PNG saved by Enter holds the value typed in the last field', async ({ page }) => {
// Without the picker the file downloads, which the test can read.
await page.addInitScript(() => {
delete (window as { showSaveFilePicker?: unknown }).showSaveFilePicker;
});
const dialog = await openOutput(page);
await dialog.getByText('File', { exact: true }).click();
await dialog.getByText('PNG', { exact: true }).click();
const save = async () => {
const download = page.waitForEvent('download');
await page.keyboard.press('Enter');
return readFile(await (await download).path());
};
const reopen = async () => {
await page.getByRole('button', { name: 'File', exact: true }).click();
await page.getByRole('menuitem', { name: 'Output' }).click();
await dialog.getByLabel('Weight').click();
};
await dialog.getByLabel('Weight').click();
const plain = await save();
await reopen();
expect((await save()).equals(plain)).toBe(true);
await reopen();
await page.keyboard.type('WWWWWW');
const typed = await save();
expect(typed.equals(plain)).toBe(false);
});
test('Enter stops at a value the barcode cannot encode and goes through at one it can', async ({ page }) => {
await page.addInitScript(() => {
delete (window as { showSaveFilePicker?: unknown }).showSaveFilePicker;
});
const dialog = await openOutput(page, `^XA
^FO50,50^BY2^BEN,80,Y,N^FN1"Code"^FD5901234123457^FS
^XZ`);
await dialog.getByText('File', { exact: true }).click();
await dialog.getByText('PNG', { exact: true }).click();
const code = dialog.getByLabel('Code');
await code.click();
await page.keyboard.type('ABC');
await page.keyboard.press('Enter');
await expect(dialog.getByText('Cannot encode', { exact: false })).toBeVisible();
await expect(code).toBeFocused();
const download = page.waitForEvent('download');
await page.keyboard.type('4006381333931');
await page.keyboard.press('Enter');
await download;
await expect(dialog).toBeHidden();
});
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.