@jskit-ai/jskit-cli 0.2.136 → 0.2.137
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -4
- package/src/test/playwright.js +95 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jskit-ai/jskit-cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.137",
|
|
4
4
|
"description": "Bundle and package orchestration CLI for JSKIT apps.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -14,15 +14,16 @@
|
|
|
14
14
|
"exports": {
|
|
15
15
|
".": "./src/index.js",
|
|
16
16
|
"./server": "./src/server/index.js",
|
|
17
|
-
"./client": "./src/client/index.js"
|
|
17
|
+
"./client": "./src/client/index.js",
|
|
18
|
+
"./test/playwright": "./src/test/playwright.js"
|
|
18
19
|
},
|
|
19
20
|
"scripts": {
|
|
20
21
|
"test": "node --test"
|
|
21
22
|
},
|
|
22
23
|
"dependencies": {
|
|
23
|
-
"@jskit-ai/jskit-catalog": "0.1.
|
|
24
|
+
"@jskit-ai/jskit-catalog": "0.1.132",
|
|
24
25
|
"@jskit-ai/kernel": "0.1.121",
|
|
25
|
-
"@jskit-ai/shell-web": "0.1.
|
|
26
|
+
"@jskit-ai/shell-web": "0.1.121",
|
|
26
27
|
"@vue/compiler-sfc": "^3.5.29",
|
|
27
28
|
"ts-morph": "^28.0.0",
|
|
28
29
|
"yaml": "^2.8.3"
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
const DEFAULT_LOCAL_BASE_URL = "http://127.0.0.1:4173";
|
|
2
|
+
const DEFAULT_SMOKE_PATH = "/home";
|
|
3
|
+
const DEFAULT_VIEWPORTS = Object.freeze([
|
|
4
|
+
Object.freeze({ name: "compact", width: 390, height: 844 }),
|
|
5
|
+
Object.freeze({ name: "medium", width: 768, height: 1024 }),
|
|
6
|
+
Object.freeze({ name: "expanded", width: 1280, height: 900 })
|
|
7
|
+
]);
|
|
8
|
+
|
|
9
|
+
function normalizeBaseUrl(value) {
|
|
10
|
+
return String(value || "").trim().replace(/\/+$/u, "");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function createJskitPlaywrightConfig({ env = process.env } = {}) {
|
|
14
|
+
const managedBaseUrl = normalizeBaseUrl(env.PLAYWRIGHT_BASE_URL);
|
|
15
|
+
const baseURL = managedBaseUrl || DEFAULT_LOCAL_BASE_URL;
|
|
16
|
+
const storageState = String(env.JSKIT_PLAYWRIGHT_STORAGE_STATE || "").trim();
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
testDir: "./tests/e2e",
|
|
20
|
+
timeout: 60_000,
|
|
21
|
+
expect: {
|
|
22
|
+
timeout: 10_000
|
|
23
|
+
},
|
|
24
|
+
use: {
|
|
25
|
+
baseURL,
|
|
26
|
+
headless: true,
|
|
27
|
+
...(storageState ? { storageState } : {})
|
|
28
|
+
},
|
|
29
|
+
...(managedBaseUrl ? {} : {
|
|
30
|
+
webServer: {
|
|
31
|
+
command: "npm run build && node ./bin/server.js",
|
|
32
|
+
env: {
|
|
33
|
+
PORT: "4173"
|
|
34
|
+
},
|
|
35
|
+
url: `${baseURL}/api/health`,
|
|
36
|
+
reuseExistingServer: true,
|
|
37
|
+
timeout: 180_000
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function expectNoHorizontalOverflow(page, expect) {
|
|
44
|
+
const metrics = await page.evaluate(() => ({
|
|
45
|
+
clientWidth: document.documentElement.clientWidth,
|
|
46
|
+
scrollWidth: document.documentElement.scrollWidth
|
|
47
|
+
}));
|
|
48
|
+
|
|
49
|
+
expect(metrics.scrollWidth).toBeLessThanOrEqual(metrics.clientWidth + 1);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async function expectVisibleTapTargets(page, expect) {
|
|
53
|
+
const heights = await page.locator("a[href], button, [role='button'], .v-btn, .v-list-item").evaluateAll(
|
|
54
|
+
(elements) => elements
|
|
55
|
+
.filter((element) => {
|
|
56
|
+
const rect = element.getBoundingClientRect();
|
|
57
|
+
const style = window.getComputedStyle(element);
|
|
58
|
+
return style.display !== "none" && style.visibility !== "hidden" && rect.width > 0 && rect.height > 0;
|
|
59
|
+
})
|
|
60
|
+
.map((element) => element.getBoundingClientRect().height)
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
for (const height of heights) {
|
|
64
|
+
expect(height).toBeGreaterThanOrEqual(48);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function runGeneratedAppSmoke({ test, expect, expectedText } = {}) {
|
|
69
|
+
if (!test || !expect || !String(expectedText || "").trim()) {
|
|
70
|
+
throw new Error("runGeneratedAppSmoke requires Playwright test, expect, and expectedText.");
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const smokePath = String(process.env.JSKIT_PLAYWRIGHT_SMOKE_PATH || DEFAULT_SMOKE_PATH);
|
|
74
|
+
|
|
75
|
+
test.describe("generated app responsive smoke", () => {
|
|
76
|
+
for (const viewport of DEFAULT_VIEWPORTS) {
|
|
77
|
+
test(`${viewport.name} home route renders without horizontal overflow`, async ({ page }) => {
|
|
78
|
+
await page.setViewportSize({ width: viewport.width, height: viewport.height });
|
|
79
|
+
await page.goto(smokePath);
|
|
80
|
+
await expect(page.locator("body")).toBeVisible();
|
|
81
|
+
await expect(page.getByText(expectedText)).toBeVisible();
|
|
82
|
+
await expect(page.locator(".generated-ui-screen").first()).toBeVisible();
|
|
83
|
+
await expectVisibleTapTargets(page, expect);
|
|
84
|
+
await expectNoHorizontalOverflow(page, expect);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export {
|
|
91
|
+
createJskitPlaywrightConfig,
|
|
92
|
+
DEFAULT_LOCAL_BASE_URL,
|
|
93
|
+
DEFAULT_VIEWPORTS,
|
|
94
|
+
runGeneratedAppSmoke
|
|
95
|
+
};
|