@joiner-platform/cli 0.1.17 → 0.1.19
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 +2 -2
- package/skills/tile-creator/references/cli.md +1 -1
- package/skills/tile-creator/references/client-api.md +16 -6
- package/src/commands/init/scaffold.ts +2 -9
- package/src/commands/init/sdk-tarball-url.generated.ts +2 -2
- package/src/commands/init/template-names.ts +18 -0
- package/bundled-resources/poe-tile-templates/coverage.config.json +0 -6
- package/bundled-resources/poe-tile-templates/index.ts +0 -27
- package/bundled-resources/poe-tile-templates/package.json +0 -31
- package/bundled-resources/poe-tile-templates/scripts/cleanup.ts +0 -10
- package/bundled-resources/poe-tile-templates/scripts/generate.ts +0 -57
- package/bundled-resources/poe-tile-templates/scripts/install-diagnostics.ts +0 -52
- package/bundled-resources/poe-tile-templates/scripts/paths.ts +0 -7
- package/bundled-resources/poe-tile-templates/scripts/sdk-dependency-key.ts +0 -288
- package/bundled-resources/poe-tile-templates/scripts/verify-all-sdks.ts +0 -132
- package/bundled-resources/poe-tile-templates/scripts/verify-local-sdk-command.ts +0 -30
- package/bundled-resources/poe-tile-templates/scripts/verify-local-sdk-tarball.ts +0 -397
- package/bundled-resources/poe-tile-templates/tests/check-source.test.ts +0 -131
- package/bundled-resources/poe-tile-templates/tests/dev-script.test.slow.ts +0 -166
- package/bundled-resources/poe-tile-templates/tests/doctor-launcher.test.ts +0 -48
- package/bundled-resources/poe-tile-templates/tests/fixtures/customized-manager.ts +0 -67
- package/bundled-resources/poe-tile-templates/tests/fixtures/extended-mutators.ts.txt +0 -106
- package/bundled-resources/poe-tile-templates/tests/fixtures/multiplayer-verification.test.playwright.ts.txt +0 -103
- package/bundled-resources/poe-tile-templates/tests/fixtures/replace-starter-schema.ts +0 -67
- package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/phaserjs.tsx.txt +0 -85
- package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/preact.tsx.txt +0 -69
- package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/react.tsx.txt +0 -73
- package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/seating.ts.txt +0 -54
- package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/solidjs.tsx.txt +0 -70
- package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/vanilla-js.tsx.txt +0 -85
- package/bundled-resources/poe-tile-templates/tests/generated-templates.test.ts +0 -278
- package/bundled-resources/poe-tile-templates/tests/happy-dom-version.test.ts +0 -27
- package/bundled-resources/poe-tile-templates/tests/install-diagnostics.test.ts +0 -99
- package/bundled-resources/poe-tile-templates/tests/native-gesture-defaults.test.ts +0 -23
- package/bundled-resources/poe-tile-templates/tests/playwright-version.test.ts +0 -84
- package/bundled-resources/poe-tile-templates/tests/render-check-scaffold.test.ts +0 -56
- package/bundled-resources/poe-tile-templates/tests/sdk-dependency-key.test.ts +0 -129
- package/bundled-resources/poe-tile-templates/tests/visual-check.test.ts +0 -90
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
// owner: jyoung-q
|
|
2
|
-
import { expect, test } from "bun:test";
|
|
3
|
-
import { cleanup, render, waitFor } from "@testing-library/preact";
|
|
4
|
-
import { App } from "./App";
|
|
5
|
-
import { createPoeTileTestHarness } from "joiner-sdk/v1/test-utils.js";
|
|
6
|
-
import type { AppReadContext } from "../client";
|
|
7
|
-
import { tileBackendConfig } from "../synced-store/backend-config";
|
|
8
|
-
import type { AppSchema } from "../synced-store/schema";
|
|
9
|
-
import { createTestAppProps } from "../tests/app-test-props";
|
|
10
|
-
|
|
11
|
-
test("renders with a real two-client store and configured DOM matchers", async () => {
|
|
12
|
-
const harness = createPoeTileTestHarness<AppSchema>({
|
|
13
|
-
store: { backendConfig: tileBackendConfig },
|
|
14
|
-
});
|
|
15
|
-
let container: Element = document.createElement("div");
|
|
16
|
-
try {
|
|
17
|
-
const aliceClient = await harness.createClient({ userId: "alice" });
|
|
18
|
-
const { store: alice } = aliceClient;
|
|
19
|
-
await harness.createClient({ userId: "bob" });
|
|
20
|
-
({ container } = render(<App {...createTestAppProps(aliceClient)} />));
|
|
21
|
-
|
|
22
|
-
await waitFor(() => {
|
|
23
|
-
expect(container.querySelector("#app-heading")).toHaveTextContent(
|
|
24
|
-
"Hello",
|
|
25
|
-
);
|
|
26
|
-
});
|
|
27
|
-
await waitFor(() => {
|
|
28
|
-
expect(
|
|
29
|
-
container.querySelector('[data-testid="connected-player-count"]'),
|
|
30
|
-
).toHaveTextContent("2 connected players");
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
const control = document.createElement("button");
|
|
34
|
-
control.disabled = true;
|
|
35
|
-
control.setAttribute("data-state", "ready");
|
|
36
|
-
container.appendChild(control);
|
|
37
|
-
expect(control).toBeInTheDocument();
|
|
38
|
-
expect(control).toBeDisabled();
|
|
39
|
-
expect(control).toHaveAttribute("data-state", "ready");
|
|
40
|
-
expect(control).not.toHaveAttribute("aria-hidden");
|
|
41
|
-
|
|
42
|
-
await harness.addUser({ userId: "carol" });
|
|
43
|
-
const spectator = await alice.query((ctx: AppReadContext) =>
|
|
44
|
-
ctx.table("players").get("carol"),
|
|
45
|
-
);
|
|
46
|
-
expect(spectator).toEqual({ userId: "carol", mark: null });
|
|
47
|
-
await waitFor(() => {
|
|
48
|
-
expect(
|
|
49
|
-
container.querySelector('[data-testid="connected-player-count"]'),
|
|
50
|
-
).toHaveTextContent("3 connected players");
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
await harness.removeUser({ userId: "carol" });
|
|
54
|
-
await waitFor(() => {
|
|
55
|
-
expect(
|
|
56
|
-
container.querySelector('[data-testid="connected-player-count"]'),
|
|
57
|
-
).toHaveTextContent("2 connected players");
|
|
58
|
-
});
|
|
59
|
-
expect(await alice.query((ctx: AppReadContext) =>
|
|
60
|
-
ctx.table("$users").get("carol"),
|
|
61
|
-
)).toMatchObject({ removedAt: expect.any(Number) });
|
|
62
|
-
expect(await alice.query((ctx: AppReadContext) =>
|
|
63
|
-
ctx.table("players").get("carol"),
|
|
64
|
-
)).toEqual({ userId: "carol", mark: null });
|
|
65
|
-
} finally {
|
|
66
|
-
cleanup(); container.remove();
|
|
67
|
-
harness.dispose();
|
|
68
|
-
}
|
|
69
|
-
});
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
// owner: jyoung-q
|
|
2
|
-
import { expect, test } from "bun:test";
|
|
3
|
-
import { act, cleanup, render, waitFor } from "@testing-library/react";
|
|
4
|
-
import { App } from "./App";
|
|
5
|
-
import { createPoeTileTestHarness } from "joiner-sdk/v1/test-utils.js";
|
|
6
|
-
import type { AppReadContext } from "../client";
|
|
7
|
-
import { tileBackendConfig } from "../synced-store/backend-config";
|
|
8
|
-
import type { AppSchema } from "../synced-store/schema";
|
|
9
|
-
import { createTestAppProps } from "../tests/app-test-props";
|
|
10
|
-
|
|
11
|
-
test("renders with a real two-client store and configured DOM matchers", async () => {
|
|
12
|
-
const harness = createPoeTileTestHarness<AppSchema>({
|
|
13
|
-
store: { backendConfig: tileBackendConfig },
|
|
14
|
-
});
|
|
15
|
-
let container: HTMLElement = document.createElement("div");
|
|
16
|
-
try {
|
|
17
|
-
const aliceClient = await harness.createClient({ userId: "alice" });
|
|
18
|
-
const { store: alice } = aliceClient;
|
|
19
|
-
await harness.createClient({ userId: "bob" });
|
|
20
|
-
({ container } = render(<App {...createTestAppProps(aliceClient)} />));
|
|
21
|
-
|
|
22
|
-
await waitFor(() => {
|
|
23
|
-
expect(container.querySelector("#app-heading")).toHaveTextContent(
|
|
24
|
-
"Hello",
|
|
25
|
-
);
|
|
26
|
-
});
|
|
27
|
-
await waitFor(() => {
|
|
28
|
-
expect(
|
|
29
|
-
container.querySelector('[data-testid="connected-player-count"]'),
|
|
30
|
-
).toHaveTextContent("2 connected players");
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
const control = document.createElement("button");
|
|
34
|
-
control.disabled = true;
|
|
35
|
-
control.setAttribute("data-state", "ready");
|
|
36
|
-
container.appendChild(control);
|
|
37
|
-
expect(control).toBeInTheDocument();
|
|
38
|
-
expect(control).toBeDisabled();
|
|
39
|
-
expect(control).toHaveAttribute("data-state", "ready");
|
|
40
|
-
expect(control).not.toHaveAttribute("aria-hidden");
|
|
41
|
-
|
|
42
|
-
await act(async () => {
|
|
43
|
-
await harness.addUser({ userId: "carol" });
|
|
44
|
-
});
|
|
45
|
-
const spectator = await alice.query((ctx: AppReadContext) =>
|
|
46
|
-
ctx.table("players").get("carol"),
|
|
47
|
-
);
|
|
48
|
-
expect(spectator).toEqual({ userId: "carol", mark: null });
|
|
49
|
-
await waitFor(() => {
|
|
50
|
-
expect(
|
|
51
|
-
container.querySelector('[data-testid="connected-player-count"]'),
|
|
52
|
-
).toHaveTextContent("3 connected players");
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
await act(async () => {
|
|
56
|
-
await harness.removeUser({ userId: "carol" });
|
|
57
|
-
});
|
|
58
|
-
await waitFor(() => {
|
|
59
|
-
expect(
|
|
60
|
-
container.querySelector('[data-testid="connected-player-count"]'),
|
|
61
|
-
).toHaveTextContent("2 connected players");
|
|
62
|
-
});
|
|
63
|
-
expect(await alice.query((ctx: AppReadContext) =>
|
|
64
|
-
ctx.table("$users").get("carol"),
|
|
65
|
-
)).toMatchObject({ removedAt: expect.any(Number) });
|
|
66
|
-
expect(await alice.query((ctx: AppReadContext) =>
|
|
67
|
-
ctx.table("players").get("carol"),
|
|
68
|
-
)).toEqual({ userId: "carol", mark: null });
|
|
69
|
-
} finally {
|
|
70
|
-
cleanup(); container.remove();
|
|
71
|
-
harness.dispose();
|
|
72
|
-
}
|
|
73
|
-
});
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
// owner: jyoung-q
|
|
2
|
-
import { expect, test } from "bun:test";
|
|
3
|
-
import { createPoeTileTestHarness } from "joiner-sdk/v1/test-utils.js";
|
|
4
|
-
import type { AppReadContext } from "../client";
|
|
5
|
-
import { tileBackendConfig } from "./backend-config";
|
|
6
|
-
import type { AppSchema } from "./schema";
|
|
7
|
-
|
|
8
|
-
async function readRoster(ctx: AppReadContext) {
|
|
9
|
-
return {
|
|
10
|
-
players: await ctx.table("players").scan().values().toArray(),
|
|
11
|
-
users: await ctx.table("$users").scan().values().toArray(),
|
|
12
|
-
userInfo: await ctx.table("$userInfo").scan().values().toArray(),
|
|
13
|
-
permissions: await ctx.table("$permissions").scan().values().toArray(),
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
test("createClient populates system tables and runs auto-seating hooks", async () => {
|
|
18
|
-
const harness = createPoeTileTestHarness<AppSchema>({
|
|
19
|
-
store: { backendConfig: tileBackendConfig },
|
|
20
|
-
});
|
|
21
|
-
try {
|
|
22
|
-
const { store: alice } = await harness.createClient({
|
|
23
|
-
userId: "alice",
|
|
24
|
-
userInfo: {
|
|
25
|
-
displayName: "Alice Example",
|
|
26
|
-
profilePicture: "https://example.com/alice.png",
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
await harness.createClient({ userId: "bob" });
|
|
30
|
-
await harness.createClient({ userId: "carol" });
|
|
31
|
-
|
|
32
|
-
const roster = await alice.query(readRoster);
|
|
33
|
-
expect(roster.players).toEqual([
|
|
34
|
-
{ userId: "alice", mark: "X" },
|
|
35
|
-
{ userId: "bob", mark: "O" },
|
|
36
|
-
{ userId: "carol", mark: null },
|
|
37
|
-
]);
|
|
38
|
-
expect(roster.users.map((user) => user.userId)).toEqual([
|
|
39
|
-
"alice",
|
|
40
|
-
"bob",
|
|
41
|
-
"carol",
|
|
42
|
-
]);
|
|
43
|
-
expect(roster.userInfo.find((info) => info.userId === "alice")).toMatchObject({
|
|
44
|
-
displayName: "Alice Example",
|
|
45
|
-
profilePicture: "https://example.com/alice.png",
|
|
46
|
-
});
|
|
47
|
-
expect(roster.userInfo.find((info) => info.userId === "bob")?.displayName).toBe(
|
|
48
|
-
"bob",
|
|
49
|
-
);
|
|
50
|
-
expect(roster.permissions).toEqual([]);
|
|
51
|
-
} finally {
|
|
52
|
-
harness.dispose();
|
|
53
|
-
}
|
|
54
|
-
});
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
// owner: jyoung-q
|
|
2
|
-
/** @jsxImportSource solid-js */
|
|
3
|
-
import { expect, test } from "bun:test";
|
|
4
|
-
import { cleanup, render, waitFor } from "@solidjs/testing-library";
|
|
5
|
-
import { App } from "./App";
|
|
6
|
-
import { createPoeTileTestHarness } from "joiner-sdk/v1/test-utils.js";
|
|
7
|
-
import type { AppReadContext } from "../client";
|
|
8
|
-
import { tileBackendConfig } from "../synced-store/backend-config";
|
|
9
|
-
import type { AppSchema } from "../synced-store/schema";
|
|
10
|
-
import { createTestAppProps } from "../tests/app-test-props";
|
|
11
|
-
|
|
12
|
-
test("renders with a real two-client store and configured DOM matchers", async () => {
|
|
13
|
-
const harness = createPoeTileTestHarness<AppSchema>({
|
|
14
|
-
store: { backendConfig: tileBackendConfig },
|
|
15
|
-
});
|
|
16
|
-
let container: HTMLElement = document.createElement("div");
|
|
17
|
-
try {
|
|
18
|
-
const aliceClient = await harness.createClient({ userId: "alice" });
|
|
19
|
-
const { store: alice } = aliceClient;
|
|
20
|
-
await harness.createClient({ userId: "bob" });
|
|
21
|
-
({ container } = render(() => <App {...createTestAppProps(aliceClient)} />));
|
|
22
|
-
|
|
23
|
-
await waitFor(() => {
|
|
24
|
-
expect(container.querySelector("#app-heading")).toHaveTextContent(
|
|
25
|
-
"Hello",
|
|
26
|
-
);
|
|
27
|
-
});
|
|
28
|
-
await waitFor(() => {
|
|
29
|
-
expect(
|
|
30
|
-
container.querySelector('[data-testid="connected-player-count"]'),
|
|
31
|
-
).toHaveTextContent("2 connected players");
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
const control = document.createElement("button");
|
|
35
|
-
control.disabled = true;
|
|
36
|
-
control.setAttribute("data-state", "ready");
|
|
37
|
-
container.appendChild(control);
|
|
38
|
-
expect(control).toBeInTheDocument();
|
|
39
|
-
expect(control).toBeDisabled();
|
|
40
|
-
expect(control).toHaveAttribute("data-state", "ready");
|
|
41
|
-
expect(control).not.toHaveAttribute("aria-hidden");
|
|
42
|
-
|
|
43
|
-
await harness.addUser({ userId: "carol" });
|
|
44
|
-
const spectator = await alice.query((ctx: AppReadContext) =>
|
|
45
|
-
ctx.table("players").get("carol"),
|
|
46
|
-
);
|
|
47
|
-
expect(spectator).toEqual({ userId: "carol", mark: null });
|
|
48
|
-
await waitFor(() => {
|
|
49
|
-
expect(
|
|
50
|
-
container.querySelector('[data-testid="connected-player-count"]'),
|
|
51
|
-
).toHaveTextContent("3 connected players");
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
await harness.removeUser({ userId: "carol" });
|
|
55
|
-
await waitFor(() => {
|
|
56
|
-
expect(
|
|
57
|
-
container.querySelector('[data-testid="connected-player-count"]'),
|
|
58
|
-
).toHaveTextContent("2 connected players");
|
|
59
|
-
});
|
|
60
|
-
expect(await alice.query((ctx: AppReadContext) =>
|
|
61
|
-
ctx.table("$users").get("carol"),
|
|
62
|
-
)).toMatchObject({ removedAt: expect.any(Number) });
|
|
63
|
-
expect(await alice.query((ctx: AppReadContext) =>
|
|
64
|
-
ctx.table("players").get("carol"),
|
|
65
|
-
)).toEqual({ userId: "carol", mark: null });
|
|
66
|
-
} finally {
|
|
67
|
-
cleanup(); container.remove();
|
|
68
|
-
harness.dispose();
|
|
69
|
-
}
|
|
70
|
-
});
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
// owner: jyoung-q
|
|
2
|
-
import { expect, test } from "bun:test";
|
|
3
|
-
import { mountApp } from "./App";
|
|
4
|
-
import { createPoeTileTestHarness, tick } from "joiner-sdk/v1/test-utils.js";
|
|
5
|
-
import type { AppReadContext } from "../client";
|
|
6
|
-
import { tileBackendConfig } from "../synced-store/backend-config";
|
|
7
|
-
import type { AppSchema } from "../synced-store/schema";
|
|
8
|
-
import { createTestAppProps } from "../tests/app-test-props";
|
|
9
|
-
|
|
10
|
-
async function waitFor(
|
|
11
|
-
assertion: () => void,
|
|
12
|
-
timeoutMs = 2_000,
|
|
13
|
-
): Promise<void> {
|
|
14
|
-
const startedAt = Date.now();
|
|
15
|
-
while (true) {
|
|
16
|
-
try {
|
|
17
|
-
assertion();
|
|
18
|
-
return;
|
|
19
|
-
} catch (error) {
|
|
20
|
-
if (Date.now() - startedAt >= timeoutMs) throw error;
|
|
21
|
-
await tick();
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
test("renders with a real two-client store and configured DOM matchers", async () => {
|
|
27
|
-
const harness = createPoeTileTestHarness<AppSchema>({
|
|
28
|
-
store: { backendConfig: tileBackendConfig },
|
|
29
|
-
});
|
|
30
|
-
let container: HTMLElement = document.createElement("div");
|
|
31
|
-
try {
|
|
32
|
-
const aliceClient = await harness.createClient({ userId: "alice" });
|
|
33
|
-
const { store: alice } = aliceClient;
|
|
34
|
-
await harness.createClient({ userId: "bob" });
|
|
35
|
-
document.body.appendChild(container);
|
|
36
|
-
mountApp(container, createTestAppProps(aliceClient));
|
|
37
|
-
|
|
38
|
-
await waitFor(() => {
|
|
39
|
-
expect(container.querySelector("#app-heading")).toHaveTextContent(
|
|
40
|
-
"Hello",
|
|
41
|
-
);
|
|
42
|
-
});
|
|
43
|
-
await waitFor(() => {
|
|
44
|
-
expect(
|
|
45
|
-
container.querySelector('[data-testid="connected-player-count"]'),
|
|
46
|
-
).toHaveTextContent("2 connected players");
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
const control = document.createElement("button");
|
|
50
|
-
control.disabled = true;
|
|
51
|
-
control.setAttribute("data-state", "ready");
|
|
52
|
-
container.appendChild(control);
|
|
53
|
-
expect(control).toBeInTheDocument();
|
|
54
|
-
expect(control).toBeDisabled();
|
|
55
|
-
expect(control).toHaveAttribute("data-state", "ready");
|
|
56
|
-
expect(control).not.toHaveAttribute("aria-hidden");
|
|
57
|
-
|
|
58
|
-
await harness.addUser({ userId: "carol" });
|
|
59
|
-
const spectator = await alice.query((ctx: AppReadContext) =>
|
|
60
|
-
ctx.table("players").get("carol"),
|
|
61
|
-
);
|
|
62
|
-
expect(spectator).toEqual({ userId: "carol", mark: null });
|
|
63
|
-
await waitFor(() => {
|
|
64
|
-
expect(
|
|
65
|
-
container.querySelector('[data-testid="connected-player-count"]'),
|
|
66
|
-
).toHaveTextContent("3 connected players");
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
await harness.removeUser({ userId: "carol" });
|
|
70
|
-
await waitFor(() => {
|
|
71
|
-
expect(
|
|
72
|
-
container.querySelector('[data-testid="connected-player-count"]'),
|
|
73
|
-
).toHaveTextContent("2 connected players");
|
|
74
|
-
});
|
|
75
|
-
expect(await alice.query((ctx: AppReadContext) =>
|
|
76
|
-
ctx.table("$users").get("carol"),
|
|
77
|
-
)).toMatchObject({ removedAt: expect.any(Number) });
|
|
78
|
-
expect(await alice.query((ctx: AppReadContext) =>
|
|
79
|
-
ctx.table("players").get("carol"),
|
|
80
|
-
)).toEqual({ userId: "carol", mark: null });
|
|
81
|
-
} finally {
|
|
82
|
-
container.remove();
|
|
83
|
-
harness.dispose();
|
|
84
|
-
}
|
|
85
|
-
});
|
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
// owner: jyoung-q
|
|
2
|
-
/**
|
|
3
|
-
* Verifies that generated templates work: mutator tests pass and vite build succeeds.
|
|
4
|
-
*
|
|
5
|
-
* Prerequisites: run `bun run generate` first to scaffold templates into
|
|
6
|
-
* generated-apps/template-<name>/.
|
|
7
|
-
*
|
|
8
|
-
* Cleanup: run `bun run generate:cleanup` after to remove generated dirs.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { describe, expect, test } from "bun:test";
|
|
12
|
-
import { existsSync, rmSync, writeFileSync } from "node:fs";
|
|
13
|
-
import { join } from "node:path";
|
|
14
|
-
import { TEMPLATES } from "..";
|
|
15
|
-
import { GENERATED_APPS_DIR } from "../scripts/paths.ts";
|
|
16
|
-
|
|
17
|
-
function generatedDir(template: string): string {
|
|
18
|
-
return join(GENERATED_APPS_DIR, `template-${template}`);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function run(
|
|
22
|
-
cmd: string[],
|
|
23
|
-
cwd: string,
|
|
24
|
-
): { exitCode: number; stdout: string; stderr: string } {
|
|
25
|
-
const result = Bun.spawnSync(cmd, {
|
|
26
|
-
cwd,
|
|
27
|
-
env: process.env,
|
|
28
|
-
stdout: "pipe",
|
|
29
|
-
stderr: "pipe",
|
|
30
|
-
});
|
|
31
|
-
return {
|
|
32
|
-
exitCode: result.exitCode,
|
|
33
|
-
stdout: result.stdout.toString(),
|
|
34
|
-
stderr: result.stderr.toString(),
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function assertGenerated(dir: string): void {
|
|
39
|
-
if (!existsSync(dir)) {
|
|
40
|
-
throw new Error(
|
|
41
|
-
`Generated dir not found: ${dir}\nRun "bun run generate" in poe-tile-templates first.`,
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
describe("generated templates", () => {
|
|
47
|
-
test("checks and repairs the pinned Playwright browser cache before launching scaffolds", () => {
|
|
48
|
-
const dir = generatedDir(TEMPLATES[0]);
|
|
49
|
-
assertGenerated(dir);
|
|
50
|
-
|
|
51
|
-
// Resolve the scaffold's pinned version and verify its actual executable.
|
|
52
|
-
// A healthy cache needs no download; a partial cache still gets repaired.
|
|
53
|
-
const checkBrowser = () =>
|
|
54
|
-
run(
|
|
55
|
-
[
|
|
56
|
-
"bun",
|
|
57
|
-
"-e",
|
|
58
|
-
'const { chromium } = await import("@playwright/test"); const browser = await chromium.launch({ timeout: 10000 }); await browser.close();',
|
|
59
|
-
],
|
|
60
|
-
dir,
|
|
61
|
-
);
|
|
62
|
-
const ready = checkBrowser();
|
|
63
|
-
if (ready.exitCode === 0) {
|
|
64
|
-
expect(ready.exitCode).toBe(0);
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Run from a generated scaffold so bunx resolves that scaffold's exact
|
|
69
|
-
// Playwright version. --force repairs runner caches where the revision
|
|
70
|
-
// directory exists but its headless-shell executable is missing.
|
|
71
|
-
const result = run(
|
|
72
|
-
["bunx", "playwright", "install", "--force", "chromium-headless-shell"],
|
|
73
|
-
dir,
|
|
74
|
-
);
|
|
75
|
-
if (result.exitCode !== 0) {
|
|
76
|
-
throw new Error(
|
|
77
|
-
`Playwright browser install failed:\n${result.stdout}\n${result.stderr}`,
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
const repaired = checkBrowser();
|
|
81
|
-
if (repaired.exitCode !== 0) {
|
|
82
|
-
throw new Error(
|
|
83
|
-
`Playwright browser launch failed after repair:\n${repaired.stdout}\n${repaired.stderr}`,
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
expect(repaired.exitCode).toBe(0);
|
|
87
|
-
}, 120_000);
|
|
88
|
-
|
|
89
|
-
for (const template of TEMPLATES) {
|
|
90
|
-
// `generate.ts` mirrors the `poe-tiles tiles init` CLI defaults
|
|
91
|
-
// (`--skills`, `--blank`), so the scaffold a real user gets from the
|
|
92
|
-
// getting-started guide must ship these SDK skills. Asserting their
|
|
93
|
-
// presence here means any regression that drops the bundled-resource
|
|
94
|
-
// fallback, the `_claude` rename, or the skills directory itself
|
|
95
|
-
// fails CI before we ship a CLI that hands users a broken setup.
|
|
96
|
-
test(`${template}: scaffold ships .claude/skills/{tile-creator,synced-store}`, () => {
|
|
97
|
-
const dir = generatedDir(template);
|
|
98
|
-
assertGenerated(dir);
|
|
99
|
-
expect(existsSync(join(dir, "bunfig.toml"))).toBe(true);
|
|
100
|
-
expect(existsSync(join(dir, ".claude/settings.json"))).toBe(true);
|
|
101
|
-
expect(
|
|
102
|
-
existsSync(join(dir, ".claude/skills/tile-creator/SKILL.md")),
|
|
103
|
-
).toBe(true);
|
|
104
|
-
expect(
|
|
105
|
-
existsSync(join(dir, ".claude/skills/synced-store/SKILL.md")),
|
|
106
|
-
).toBe(true);
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
test(`${template}: bun run test passes`, () => {
|
|
110
|
-
const dir = generatedDir(template);
|
|
111
|
-
assertGenerated(dir);
|
|
112
|
-
|
|
113
|
-
// Invokes scaffold's own `test` script — covers mutator tests AND
|
|
114
|
-
// happy-dom UI tests (App.test.happydom.tsx) with `--conditions browser`.
|
|
115
|
-
// Calling `bun test` directly here would skip happy-dom setup + browser
|
|
116
|
-
// conditions and let UI regressions slip past CI.
|
|
117
|
-
const result = run(["bun", "run", "test"], dir);
|
|
118
|
-
|
|
119
|
-
if (result.exitCode !== 0) {
|
|
120
|
-
throw new Error(
|
|
121
|
-
`bun run test failed for ${template}:\n${result.stdout}\n${result.stderr}`,
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
expect(result.exitCode).toBe(0);
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
test(`${template}: build + playwright e2e tests pass`, () => {
|
|
128
|
-
const dir = generatedDir(template);
|
|
129
|
-
assertGenerated(dir);
|
|
130
|
-
|
|
131
|
-
// Build first — playwright needs dist/
|
|
132
|
-
const buildResult = run(["bun", "run", "build"], dir);
|
|
133
|
-
if (buildResult.exitCode !== 0) {
|
|
134
|
-
throw new Error(
|
|
135
|
-
`Build failed for ${template}:\n${buildResult.stdout}\n${buildResult.stderr}`,
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
expect(existsSync(join(dir, "dist/index.html"))).toBe(true);
|
|
139
|
-
// `tile-frontend.js` is intentionally NOT on disk: the poeTile() vite
|
|
140
|
-
// plugin inlines the entry chunk into `index.html` as a poe-chunk
|
|
141
|
-
// and deletes the standalone file in writeBundle. See
|
|
142
|
-
// `packages/poe-tiles-sdk/src/vite-plugin.ts` writeBundle hook.
|
|
143
|
-
expect(existsSync(join(dir, "dist/synced-store-backend-config.js"))).toBe(
|
|
144
|
-
true,
|
|
145
|
-
);
|
|
146
|
-
expect(
|
|
147
|
-
existsSync(join(dir, "dist/synced-store-backend-config.quickjs")),
|
|
148
|
-
).toBe(true);
|
|
149
|
-
|
|
150
|
-
// Playwright E2E
|
|
151
|
-
const e2eResult = run(["bunx", "playwright", "test"], dir);
|
|
152
|
-
if (e2eResult.exitCode !== 0) {
|
|
153
|
-
throw new Error(
|
|
154
|
-
`Playwright tests failed for ${template}:\n${e2eResult.stdout}\n${e2eResult.stderr}`,
|
|
155
|
-
);
|
|
156
|
-
}
|
|
157
|
-
expect(e2eResult.exitCode).toBe(0);
|
|
158
|
-
}, 30_000);
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
describe("generated store-less templates (tiles init --no-store)", () => {
|
|
163
|
-
for (const template of TEMPLATES) {
|
|
164
|
-
const dir = generatedDir(`${template}-no-store`);
|
|
165
|
-
|
|
166
|
-
test(`${template} --no-store: ships no synced-store files`, () => {
|
|
167
|
-
assertGenerated(dir);
|
|
168
|
-
expect(existsSync(join(dir, "synced-store"))).toBe(false);
|
|
169
|
-
expect(existsSync(join(dir, "client.ts"))).toBe(false);
|
|
170
|
-
expect(existsSync(join(dir, "tile/src/backend.ts"))).toBe(false);
|
|
171
|
-
expect(existsSync(join(dir, "tests/e2e.test.playwright.ts"))).toBe(false);
|
|
172
|
-
expect(existsSync(join(dir, "ui/App.test.happydom.tsx"))).toBe(true);
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
test(`${template} --no-store: type-check and bun run test pass`, () => {
|
|
176
|
-
assertGenerated(dir);
|
|
177
|
-
const typeCheck = run(["bun", "run", "type-check"], dir);
|
|
178
|
-
if (typeCheck.exitCode !== 0) {
|
|
179
|
-
throw new Error(
|
|
180
|
-
`type-check failed for ${template} --no-store:\n${typeCheck.stdout}\n${typeCheck.stderr}`,
|
|
181
|
-
);
|
|
182
|
-
}
|
|
183
|
-
const result = run(["bun", "run", "test"], dir);
|
|
184
|
-
if (result.exitCode !== 0) {
|
|
185
|
-
throw new Error(
|
|
186
|
-
`bun run test failed for ${template} --no-store:\n${result.stdout}\n${result.stderr}`,
|
|
187
|
-
);
|
|
188
|
-
}
|
|
189
|
-
expect(result.exitCode).toBe(0);
|
|
190
|
-
}, 60_000);
|
|
191
|
-
|
|
192
|
-
test(`${template} --no-store: build emits no backend artifact and the viewport check passes`, () => {
|
|
193
|
-
assertGenerated(dir);
|
|
194
|
-
const buildResult = run(["bun", "run", "build"], dir);
|
|
195
|
-
if (buildResult.exitCode !== 0) {
|
|
196
|
-
throw new Error(
|
|
197
|
-
`Build failed for ${template} --no-store:\n${buildResult.stdout}\n${buildResult.stderr}`,
|
|
198
|
-
);
|
|
199
|
-
}
|
|
200
|
-
expect(existsSync(join(dir, "dist/index.html"))).toBe(true);
|
|
201
|
-
// No backend entry, so the poeTile() plugin builds no backend config.
|
|
202
|
-
expect(existsSync(join(dir, "dist/synced-store-backend-config.js"))).toBe(
|
|
203
|
-
false,
|
|
204
|
-
);
|
|
205
|
-
expect(
|
|
206
|
-
existsSync(join(dir, "dist/synced-store-backend-config.quickjs")),
|
|
207
|
-
).toBe(false);
|
|
208
|
-
|
|
209
|
-
// The remaining Playwright spec is the mobile-viewport check; it
|
|
210
|
-
// proves the store-less entry mounts the UI inside `#root`.
|
|
211
|
-
const e2eResult = run(["bunx", "playwright", "test"], dir);
|
|
212
|
-
if (e2eResult.exitCode !== 0) {
|
|
213
|
-
throw new Error(
|
|
214
|
-
`Playwright tests failed for ${template} --no-store:\n${e2eResult.stdout}\n${e2eResult.stderr}`,
|
|
215
|
-
);
|
|
216
|
-
}
|
|
217
|
-
expect(e2eResult.exitCode).toBe(0);
|
|
218
|
-
}, 60_000);
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
/** Runs `bun run type-check` in `dir` with `file` written, then removes it. */
|
|
223
|
-
function typeCheckWith({
|
|
224
|
-
dir,
|
|
225
|
-
file,
|
|
226
|
-
}: {
|
|
227
|
-
dir: string;
|
|
228
|
-
file: { path: string; text: string };
|
|
229
|
-
}): { exitCode: number; stdout: string; stderr: string } {
|
|
230
|
-
const path = join(dir, file.path);
|
|
231
|
-
writeFileSync(path, file.text);
|
|
232
|
-
try {
|
|
233
|
-
return run(["bun", "run", "type-check"], dir);
|
|
234
|
-
} finally {
|
|
235
|
-
rmSync(path, { force: true });
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
describe("generated templates enforce the /finish-prototype source rules", () => {
|
|
240
|
-
for (const template of TEMPLATES) {
|
|
241
|
-
// A conversion scaffolds with the default `--skills`, so the copied
|
|
242
|
-
// skills (which quote the suppression comments) sit beside the tile
|
|
243
|
-
// source. The untouched scaffold must still pass, and a `?url` asset
|
|
244
|
-
// import must type-check without a suppression.
|
|
245
|
-
test(`${template}: type-check passes on the scaffold with a ?url import`, () => {
|
|
246
|
-
const dir = generatedDir(template);
|
|
247
|
-
assertGenerated(dir);
|
|
248
|
-
const result = typeCheckWith({
|
|
249
|
-
dir,
|
|
250
|
-
file: {
|
|
251
|
-
path: "ui/url-import-probe.ts",
|
|
252
|
-
text: 'import iconUrl from "../assets/icon.png?url";\nexport const probe: string = iconUrl;\n',
|
|
253
|
-
},
|
|
254
|
-
});
|
|
255
|
-
if (result.exitCode !== 0) {
|
|
256
|
-
throw new Error(
|
|
257
|
-
`type-check failed for ${template}:\n${result.stdout}\n${result.stderr}`,
|
|
258
|
-
);
|
|
259
|
-
}
|
|
260
|
-
}, 60_000);
|
|
261
|
-
|
|
262
|
-
test(`${template}: type-check fails before tsc when a file turns checking off`, () => {
|
|
263
|
-
const dir = generatedDir(template);
|
|
264
|
-
assertGenerated(dir);
|
|
265
|
-
const result = typeCheckWith({
|
|
266
|
-
dir,
|
|
267
|
-
file: {
|
|
268
|
-
path: "ui/unchecked-probe.ts",
|
|
269
|
-
text: "// @ts-nocheck\nexport const probe = 1;\n",
|
|
270
|
-
},
|
|
271
|
-
});
|
|
272
|
-
expect(result.exitCode).toBe(1);
|
|
273
|
-
expect(result.stderr).toContain(
|
|
274
|
-
"ui/unchecked-probe.ts:1: @ts-nocheck hides type errors.",
|
|
275
|
-
);
|
|
276
|
-
}, 60_000);
|
|
277
|
-
}
|
|
278
|
-
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { expect, test } from "bun:test";
|
|
2
|
-
import { readFileSync } from "node:fs";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
|
|
5
|
-
test("generated tiles require the Happy DOM version pinned for workspace tests", () => {
|
|
6
|
-
const templatesPackageDir = join(import.meta.dir, "..");
|
|
7
|
-
const templatePackage = JSON.parse(
|
|
8
|
-
readFileSync(join(templatesPackageDir, "base/package.json"), "utf8"),
|
|
9
|
-
) as { devDependencies: { "happy-dom": string } };
|
|
10
|
-
const syncpackConfig = JSON.parse(
|
|
11
|
-
readFileSync(join(templatesPackageDir, "../../.syncpackrc.json"), "utf8"),
|
|
12
|
-
) as {
|
|
13
|
-
versionGroups: { dependencies?: string[]; pinVersion?: string }[];
|
|
14
|
-
};
|
|
15
|
-
const happyDomPin = syncpackConfig.versionGroups.find(
|
|
16
|
-
(group) =>
|
|
17
|
-
typeof group.pinVersion === "string" &&
|
|
18
|
-
group.dependencies?.includes("happy-dom"),
|
|
19
|
-
)?.pinVersion;
|
|
20
|
-
|
|
21
|
-
// External apps pin the tested version; workspace tests may use compatible
|
|
22
|
-
// patch releases. Keep their baseline equal without floating the scaffold.
|
|
23
|
-
expect(happyDomPin).toBeTruthy();
|
|
24
|
-
const templatePin = templatePackage.devDependencies["happy-dom"];
|
|
25
|
-
expect(templatePin).toMatch(/^\d+\.\d+\.\d+$/);
|
|
26
|
-
expect(happyDomPin).toBe(`^${templatePin}`);
|
|
27
|
-
});
|