Skip to content

Commit dd34f1e

Browse files
samuelreichertclaude
authored andcommitted
test(barcode-generator-web): add Data Matrix e2e coverage
Replace the placeholder body assertion with plain render, GS1 render, rectangular shape, value re-render and PNG download tests. These stay dormant: mendix/testProjects has no barcode-generator-web branch yet, so the e2e script remains stubbed. The spec header lists the page route and mx-names the test project needs before the runner can be enabled. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 3aad394 commit dd34f1e

1 file changed

Lines changed: 61 additions & 11 deletions

File tree

Lines changed: 61 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,70 @@
11
import { test, expect } from "@mendix/run-e2e/fixtures";
2-
import { waitForMendixApp } from "@mendix/run-e2e/mendix-helpers";
32

3+
/**
4+
* These tests are dormant until the test project exists: `package.json` still has
5+
* `"e2e": "echo ..."` because https://github.com/mendix/testProjects has no
6+
* `barcode-generator-web` branch yet (only `barcode-scanner-web`).
7+
*
8+
* To enable, create that branch with a `/p/datamatrix` page containing:
9+
* - dataMatrixPlain Data Matrix, GS1 off, square, value "ABC-12345"
10+
* - dataMatrixGs1 Data Matrix, GS1 on, value "(01)09501101020917(17)261231(10)ABC123"
11+
* - dataMatrixRectangle Data Matrix, shape Rectangle
12+
* - dataMatrixDownload Data Matrix with "Allow download" on, file name "datamatrix"
13+
* - textBoxCodeValue text box bound to the attribute dataMatrixBound reads from
14+
* - dataMatrixBound Data Matrix bound to that attribute
15+
* then swap the `e2e` script to `run-e2e ci`.
16+
*/
417
test.describe("BarcodeGenerator", () => {
518
test.beforeEach(async ({ page }) => {
6-
await page.goto("/");
7-
await waitForMendixApp(page);
19+
await page.goto("/p/datamatrix");
820
});
921

10-
test("renders barcode generator widget", async ({ page }) => {
11-
// TODO: Replace with actual barcode generator test when implementation is complete
12-
// Example test structure for barcode generator:
13-
// await expect(page.locator(".mx-name-barcodeGenerator").first()).toBeVisible();
14-
// await page.locator(".mx-name-textInput").fill("Test QR Code");
15-
// await expect(page.locator(".mx-name-barcodeGenerator canvas")).toBeVisible();
22+
test("renders a Data Matrix symbol as inline SVG @smoke", async ({ page }) => {
23+
const symbol = page.locator(".mx-name-dataMatrixPlain .datamatrix-svg svg");
1624

17-
// Placeholder test for now
18-
await expect(page.locator("body")).toBeVisible();
25+
await expect(symbol).toBeVisible();
26+
await expect(symbol).toHaveAttribute("viewBox", /^0 0 \d+(\.\d+)? \d+(\.\d+)?$/);
27+
});
28+
29+
test("renders a GS1 Data Matrix without falling back to the error state", async ({ page }) => {
30+
const widget = page.locator(".mx-name-dataMatrixGs1");
31+
32+
await expect(widget.locator(".datamatrix-svg svg")).toBeVisible();
33+
await expect(widget.locator(".alert-danger")).toHaveCount(0);
34+
});
35+
36+
test("renders the rectangular shape wider than it is tall", async ({ page }) => {
37+
const symbol = page.locator(".mx-name-dataMatrixRectangle .datamatrix-svg svg");
38+
await expect(symbol).toBeVisible();
39+
40+
await expect
41+
.poll(async () => {
42+
const box = await symbol.boundingBox();
43+
return box ? box.width > box.height : false;
44+
})
45+
.toBe(true);
46+
});
47+
48+
test("re-renders when the bound value changes", async ({ page }) => {
49+
const symbol = page.locator(".mx-name-dataMatrixBound .datamatrix-svg svg");
50+
await expect(symbol).toBeVisible();
51+
const before = await symbol.getAttribute("viewBox");
52+
53+
// A longer value needs more modules, so the symbol grows
54+
await page.locator(".mx-name-textBoxCodeValue input").fill("ABC-12345-67890-LONGER-VALUE");
55+
await page.locator(".mx-name-textBoxCodeValue input").blur();
56+
57+
await expect(symbol).not.toHaveAttribute("viewBox", before);
58+
});
59+
60+
test("downloads the Data Matrix as a PNG", async ({ page }) => {
61+
await expect(page.locator(".mx-name-dataMatrixDownload .datamatrix-svg svg")).toBeVisible();
62+
63+
// Start waiting for the download before clicking
64+
const downloadPromise = page.waitForEvent("download");
65+
await page.locator(".mx-name-dataMatrixDownload .barcode-generator-download-button").click();
66+
const download = await downloadPromise;
67+
68+
expect(download.suggestedFilename()).toMatch(/\.png$/);
1969
});
2070
});

0 commit comments

Comments
 (0)