@joiner-platform/cli 0.0.0-stage → 0.1.1
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/README.md +30 -2
- package/bundled-resources/poe-tile-templates/base/CLAUDE.md +72 -0
- package/bundled-resources/poe-tile-templates/base/README.md +7 -0
- package/bundled-resources/poe-tile-templates/base/_bunfig.toml +8 -0
- package/bundled-resources/poe-tile-templates/base/_gitignore +18 -0
- package/bundled-resources/poe-tile-templates/base/client.ts +12 -0
- package/bundled-resources/poe-tile-templates/base/package.json +36 -0
- package/bundled-resources/poe-tile-templates/base/playwright.config.ts +38 -0
- package/bundled-resources/poe-tile-templates/base/scripts/check-source.ts +148 -0
- package/bundled-resources/poe-tile-templates/base/scripts/dev.ts +19 -0
- package/bundled-resources/poe-tile-templates/base/scripts/doctor.sh +29 -0
- package/bundled-resources/poe-tile-templates/base/scripts/visual-check.ts +64 -0
- package/bundled-resources/poe-tile-templates/base/synced-store/backend-config.ts +9 -0
- package/bundled-resources/poe-tile-templates/base/synced-store/client-config.ts +8 -0
- package/bundled-resources/poe-tile-templates/base/synced-store/data/items.ts +16 -0
- package/bundled-resources/poe-tile-templates/base/synced-store/mutators/index.ts +10 -0
- package/bundled-resources/poe-tile-templates/base/synced-store/mutators/remove-todo.ts +5 -0
- package/bundled-resources/poe-tile-templates/base/synced-store/mutators/set-todo.ts +20 -0
- package/bundled-resources/poe-tile-templates/base/synced-store/mutators/types.ts +5 -0
- package/bundled-resources/poe-tile-templates/base/synced-store/mutators.test.ts +138 -0
- package/bundled-resources/poe-tile-templates/base/synced-store/schema.ts +40 -0
- package/bundled-resources/poe-tile-templates/base/tests/e2e.test.playwright.ts +92 -0
- package/bundled-resources/poe-tile-templates/base/tests/mobile-viewport.test.playwright.ts +111 -0
- package/bundled-resources/poe-tile-templates/base/tests/render-check.test.playwright.ts +128 -0
- package/bundled-resources/poe-tile-templates/base/tests/screenshot.test.playwright.ts +86 -0
- package/bundled-resources/poe-tile-templates/base/tests/setup-dom.ts +70 -0
- package/bundled-resources/poe-tile-templates/base/tile/src/backend.ts +3 -0
- package/bundled-resources/poe-tile-templates/base/tile/styles.css +47 -0
- package/bundled-resources/poe-tile-templates/base/tsconfig.json +13 -0
- package/bundled-resources/poe-tile-templates/coverage.config.json +6 -0
- package/bundled-resources/poe-tile-templates/index.ts +27 -0
- package/bundled-resources/poe-tile-templates/package.json +31 -0
- package/bundled-resources/poe-tile-templates/phaserjs/package.partial.json +6 -0
- package/bundled-resources/poe-tile-templates/phaserjs/tile/index.html +14 -0
- package/bundled-resources/poe-tile-templates/phaserjs/tile/src/entry.ts +35 -0
- package/bundled-resources/poe-tile-templates/phaserjs/ui/App.test.happydom.tsx +98 -0
- package/bundled-resources/poe-tile-templates/phaserjs/ui/App.ts +180 -0
- package/bundled-resources/poe-tile-templates/phaserjs/ui/phaser-scene.ts +174 -0
- package/bundled-resources/poe-tile-templates/phaserjs/vite.config.ts +28 -0
- package/bundled-resources/poe-tile-templates/preact/package.partial.json +9 -0
- package/bundled-resources/poe-tile-templates/preact/postcss.config.js +5 -0
- package/bundled-resources/poe-tile-templates/preact/tile/index.html +14 -0
- package/bundled-resources/poe-tile-templates/preact/tile/src/entry.tsx +36 -0
- package/bundled-resources/poe-tile-templates/preact/tile/styles.css +51 -0
- package/bundled-resources/poe-tile-templates/preact/tsconfig.json +15 -0
- package/bundled-resources/poe-tile-templates/preact/ui/App.test.happydom.tsx +69 -0
- package/bundled-resources/poe-tile-templates/preact/ui/App.tsx +116 -0
- package/bundled-resources/poe-tile-templates/preact/vite.config.ts +18 -0
- package/bundled-resources/poe-tile-templates/react/package.partial.json +12 -0
- package/bundled-resources/poe-tile-templates/react/postcss.config.js +5 -0
- package/bundled-resources/poe-tile-templates/react/tile/index.html +14 -0
- package/bundled-resources/poe-tile-templates/react/tile/src/entry.tsx +38 -0
- package/bundled-resources/poe-tile-templates/react/tile/styles.css +51 -0
- package/bundled-resources/poe-tile-templates/react/tsconfig.json +14 -0
- package/bundled-resources/poe-tile-templates/react/ui/App.test.happydom.tsx +71 -0
- package/bundled-resources/poe-tile-templates/react/ui/App.tsx +110 -0
- package/bundled-resources/poe-tile-templates/react/vite.config.ts +21 -0
- package/bundled-resources/poe-tile-templates/scripts/cleanup.ts +10 -0
- package/bundled-resources/poe-tile-templates/scripts/generate.ts +57 -0
- package/bundled-resources/poe-tile-templates/scripts/install-diagnostics.ts +52 -0
- package/bundled-resources/poe-tile-templates/scripts/paths.ts +7 -0
- package/bundled-resources/poe-tile-templates/scripts/sdk-dependency-key.ts +288 -0
- package/bundled-resources/poe-tile-templates/scripts/verify-all-sdks.ts +132 -0
- package/bundled-resources/poe-tile-templates/scripts/verify-local-sdk-command.ts +30 -0
- package/bundled-resources/poe-tile-templates/scripts/verify-local-sdk-tarball.ts +397 -0
- package/bundled-resources/poe-tile-templates/solidjs/_bunfig.toml +14 -0
- package/bundled-resources/poe-tile-templates/solidjs/package.partial.json +13 -0
- package/bundled-resources/poe-tile-templates/solidjs/postcss.config.js +5 -0
- package/bundled-resources/poe-tile-templates/solidjs/tests/solid-plugin.ts +49 -0
- package/bundled-resources/poe-tile-templates/solidjs/tile/index.html +14 -0
- package/bundled-resources/poe-tile-templates/solidjs/tile/src/entry.tsx +36 -0
- package/bundled-resources/poe-tile-templates/solidjs/tile/styles.css +51 -0
- package/bundled-resources/poe-tile-templates/solidjs/tsconfig.json +15 -0
- package/bundled-resources/poe-tile-templates/solidjs/ui/App.test.happydom.tsx +70 -0
- package/bundled-resources/poe-tile-templates/solidjs/ui/App.tsx +129 -0
- package/bundled-resources/poe-tile-templates/solidjs/vite.config.ts +18 -0
- package/bundled-resources/poe-tile-templates/tests/check-source.test.ts +131 -0
- package/bundled-resources/poe-tile-templates/tests/dev-script.test.slow.ts +166 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/customized-manager.ts +67 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/extended-mutators.ts.txt +106 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/multiplayer-verification.test.playwright.ts.txt +103 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/replace-starter-schema.ts +67 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/phaserjs.tsx.txt +85 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/preact.tsx.txt +69 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/react.tsx.txt +73 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/seating.ts.txt +54 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/solidjs.tsx.txt +70 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/vanilla-js.tsx.txt +85 -0
- package/bundled-resources/poe-tile-templates/tests/generated-templates.test.ts +278 -0
- package/bundled-resources/poe-tile-templates/tests/happy-dom-version.test.ts +27 -0
- package/bundled-resources/poe-tile-templates/tests/install-diagnostics.test.ts +99 -0
- package/bundled-resources/poe-tile-templates/tests/native-gesture-defaults.test.ts +23 -0
- package/bundled-resources/poe-tile-templates/tests/playwright-version.test.ts +84 -0
- package/bundled-resources/poe-tile-templates/tests/render-check-scaffold.test.ts +56 -0
- package/bundled-resources/poe-tile-templates/tests/sdk-dependency-key.test.ts +129 -0
- package/bundled-resources/poe-tile-templates/tests/visual-check.test.ts +90 -0
- package/bundled-resources/poe-tile-templates/vanilla-js/package.partial.json +3 -0
- package/bundled-resources/poe-tile-templates/vanilla-js/tile/index.html +14 -0
- package/bundled-resources/poe-tile-templates/vanilla-js/tile/src/entry.ts +35 -0
- package/bundled-resources/poe-tile-templates/vanilla-js/ui/App.test.happydom.tsx +96 -0
- package/bundled-resources/poe-tile-templates/vanilla-js/ui/App.ts +113 -0
- package/bundled-resources/poe-tile-templates/vanilla-js/vite.config.ts +17 -0
- package/cli.ts +134 -0
- package/index.ts +96 -0
- package/package.json +48 -5
- package/skills/audio-generation/.generated-by-poe-templated-docs +0 -0
- package/skills/audio-generation/SKILL.md +125 -0
- package/skills/finish-prototype/.generated-by-poe-templated-docs +0 -0
- package/skills/finish-prototype/SKILL.md +22 -0
- package/skills/help-me-build/.generated-by-poe-templated-docs +0 -0
- package/skills/help-me-build/SKILL.md +56 -0
- package/skills/image-generation/.generated-by-poe-templated-docs +0 -0
- package/skills/image-generation/SKILL.md +128 -0
- package/skills/one-shot/.generated-by-poe-templated-docs +0 -0
- package/skills/one-shot/SKILL.md +22 -0
- package/skills/platform-prototype/.generated-by-poe-templated-docs +0 -0
- package/skills/platform-prototype/SKILL.md +60 -0
- package/skills/platform-subagent/.generated-by-poe-templated-docs +0 -0
- package/skills/platform-subagent/SKILL.md +16 -0
- package/skills/poe-tiles-cli/.generated-by-poe-templated-docs +0 -0
- package/skills/poe-tiles-cli/SKILL.md +609 -0
- package/skills/poe-tiles-cli/references/device-motion.md +40 -0
- package/skills/poe-tiles-cli/references/player-updates.md +41 -0
- package/skills/prototype/.generated-by-poe-templated-docs +0 -0
- package/skills/prototype/SKILL.md +149 -0
- package/skills/publish/.generated-by-poe-templated-docs +0 -0
- package/skills/publish/SKILL.md +73 -0
- package/skills/synced-store/.generated-by-poe-templated-docs +0 -0
- package/skills/synced-store/SKILL.md +583 -0
- package/skills/synced-store/references/actions.md +85 -0
- package/skills/synced-store/references/api-patterns.md +245 -0
- package/skills/synced-store/references/architecture-scaling-and-performance.md +280 -0
- package/skills/synced-store/references/client-api-reference.md +263 -0
- package/skills/synced-store/references/data-visibility.md +95 -0
- package/skills/synced-store/references/external-stores.md +162 -0
- package/skills/synced-store/references/file-uploads.md +216 -0
- package/skills/synced-store/references/getting-user-info-of-members.md +228 -0
- package/skills/synced-store/references/limitations.md +72 -0
- package/skills/synced-store/references/live-data-limit-hook.md +131 -0
- package/skills/synced-store/references/mutator-rules.md +169 -0
- package/skills/synced-store/references/platform.md +49 -0
- package/skills/synced-store/references/schema-and-bindings.md +85 -0
- package/skills/synced-store/references/schema-libraries.md +57 -0
- package/skills/synced-store/references/schema-migrations.md +119 -0
- package/skills/synced-store/references/searchable-tables.md +27 -0
- package/skills/synced-store/references/server-forking.md +115 -0
- package/skills/synced-store/references/singleton-tables.md +61 -0
- package/skills/synced-store/references/sort-keys.md +253 -0
- package/skills/synced-store/references/ui-patterns.md +95 -0
- package/skills/tile-creator/.generated-by-poe-templated-docs +0 -0
- package/skills/tile-creator/SKILL.md +197 -0
- package/skills/tile-creator/references/assets.md +124 -0
- package/skills/tile-creator/references/backend-api.md +354 -0
- package/skills/tile-creator/references/cli-limitations.md +64 -0
- package/skills/tile-creator/references/cli.md +604 -0
- package/skills/tile-creator/references/client-api.md +2407 -0
- package/skills/tile-creator/references/composing-apps.md +166 -0
- package/skills/tile-creator/references/e2e-tests.md +55 -0
- package/skills/tile-creator/references/game-ux-best-practices.md +57 -0
- package/skills/tile-creator/references/migrating-pre-rename-tiles.md +79 -0
- package/skills/tile-creator/references/multiplayer-api-recipe.md +205 -0
- package/skills/tile-creator/references/native-results.md +100 -0
- package/skills/tile-creator/references/platform-integration.md +201 -0
- package/skills/tile-creator/references/power-report.md +199 -0
- package/skills/tile-creator/references/publish-rollout.md +166 -0
- package/skills/tile-creator/references/publishing.md +33 -0
- package/skills/tile-creator/references/push-notification-guidelines.md +58 -0
- package/skills/tile-creator/references/render-check.md +266 -0
- package/skills/tile-creator/references/running-the-client-api-on-a-server-owned-by-the-user.md +95 -0
- package/skills/tile-creator/references/safe-area-insets.md +79 -0
- package/skills/tile-creator/references/sandbox-limitations.md +32 -0
- package/skills/tile-creator/references/scaffolded-tile-folder-structure.md +48 -0
- package/skills/tile-creator/references/scaffolding-a-new-app.md +202 -0
- package/skills/tile-creator/references/simulations.md +125 -0
- package/skills/tile-creator/references/synced-store-client-reference.md +92 -0
- package/skills/tile-creator/references/troubleshooting.md +22 -0
- package/skills/tile-creator/references/turn-based-mutator.md +43 -0
- package/skills/tile-creator/references/user-erasure.md +14 -0
- package/skills/tile-creator/references/vite-plugin.md +166 -0
- package/skills/tile-creator/references/workspace-retention.md +72 -0
- package/src/admin-conversions-client.ts +28 -0
- package/src/admin-reviews-client.ts +36 -0
- package/src/api.generated.ts +1527 -0
- package/src/auth-token.ts +198 -0
- package/src/bounded-read.ts +35 -0
- package/src/bun-version.ts +33 -0
- package/src/checkout-base.ts +207 -0
- package/src/cli-bun-version.ts +16 -0
- package/src/cli-env.ts +28 -0
- package/src/cli-name.ts +23 -0
- package/src/client.ts +2474 -0
- package/src/collect-files.ts +226 -0
- package/src/commands/accounts.ts +55 -0
- package/src/commands/admin-abandon-conversion.ts +60 -0
- package/src/commands/admin-reviews.ts +66 -0
- package/src/commands/admin.ts +219 -0
- package/src/commands/auth.ts +89 -0
- package/src/commands/checkout-prototype.ts +67 -0
- package/src/commands/creator-source-capability.ts +11 -0
- package/src/commands/doctor-bun.ts +145 -0
- package/src/commands/doctor-command.ts +64 -0
- package/src/commands/doctor-package-json.ts +47 -0
- package/src/commands/doctor-sdk-pin.ts +156 -0
- package/src/commands/doctor-store-keys-lexer.ts +213 -0
- package/src/commands/doctor-store-keys-scan.ts +262 -0
- package/src/commands/doctor-store-keys.ts +196 -0
- package/src/commands/doctor.ts +371 -0
- package/src/commands/init/blank-scaffold-templates.ts +397 -0
- package/src/commands/init/index.ts +170 -0
- package/src/commands/init/internal-toolchain.ts +49 -0
- package/src/commands/init/manager-test-template.ts +107 -0
- package/src/commands/init/multiplayer-test-template.ts +217 -0
- package/src/commands/init/name-input.tsx +167 -0
- package/src/commands/init/no-store-scaffold-templates.ts +281 -0
- package/src/commands/init/no-store-scaffold.ts +134 -0
- package/src/commands/init/package-json-scripts.ts +72 -0
- package/src/commands/init/scaffold.ts +960 -0
- package/src/commands/init/sdk-tarball-url.generated.ts +4 -0
- package/src/commands/init/sdk-tarball-url.ts +31 -0
- package/src/commands/init/template-picker.tsx +147 -0
- package/src/commands/inspect-child-entry.ts +107 -0
- package/src/commands/inspect-contract.ts +87 -0
- package/src/commands/inspect-freshness.ts +217 -0
- package/src/commands/inspect-lock.ts +201 -0
- package/src/commands/inspect-options.ts +360 -0
- package/src/commands/inspect-orchestrate.ts +375 -0
- package/src/commands/inspect-process.ts +172 -0
- package/src/commands/inspect-ready.ts +65 -0
- package/src/commands/inspect-report.ts +235 -0
- package/src/commands/inspect-run-state.ts +296 -0
- package/src/commands/inspect-run.ts +157 -0
- package/src/commands/inspect-watchdog.ts +74 -0
- package/src/commands/install-joiner.ts +208 -0
- package/src/commands/login.ts +308 -0
- package/src/commands/models.ts +40 -0
- package/src/commands/parse-options.ts +36 -0
- package/src/commands/remix-package-json.ts +64 -0
- package/src/commands/remix.ts +379 -0
- package/src/commands/sdk-url.ts +141 -0
- package/src/commands/simulations.ts +133 -0
- package/src/commands/skills.ts +108 -0
- package/src/commands/store-files.ts +92 -0
- package/src/commands/stores.ts +703 -0
- package/src/commands/tiles-channel-commands.ts +115 -0
- package/src/commands/tiles-checkout.ts +351 -0
- package/src/commands/tiles-gallery-command.ts +95 -0
- package/src/commands/tiles-get-helpers.ts +27 -0
- package/src/commands/tiles-inspect.ts +276 -0
- package/src/commands/tiles-power-command.ts +308 -0
- package/src/commands/tiles-power-format.ts +396 -0
- package/src/commands/tiles-power-versions.ts +299 -0
- package/src/commands/tiles-publish-helpers.ts +145 -0
- package/src/commands/tiles-upload-command.ts +277 -0
- package/src/commands/tiles-version-commands.ts +201 -0
- package/src/commands/tiles-visibility-command.ts +103 -0
- package/src/commands/tiles.ts +257 -0
- package/src/commands/upgrade.ts +307 -0
- package/src/commit-in-progress.ts +42 -0
- package/src/creator-source-context.ts +97 -0
- package/src/creator-source-publish.ts +52 -0
- package/src/deferred-assets.ts +125 -0
- package/src/distribution.ts +28 -0
- package/src/errors.ts +61 -0
- package/src/install-command.ts +43 -0
- package/src/output.ts +62 -0
- package/src/poe-tile-config-files.ts +100 -0
- package/src/poe-tile-config-players.ts +168 -0
- package/src/poe-tile-config-remix.ts +166 -0
- package/src/poe-tile-config.ts +831 -0
- package/src/power-report-client.ts +55 -0
- package/src/prototype-startup.ts +21 -0
- package/src/publish-change-summary.ts +55 -0
- package/src/publish-overrides-validation.ts +49 -0
- package/src/publish-pack.ts +167 -0
- package/src/publish-phases.ts +57 -0
- package/src/publish-retry.ts +51 -0
- package/src/publish-tile-from-config.ts +434 -0
- package/src/recorder-stream.ts +169 -0
- package/src/remix-provenance.ts +156 -0
- package/src/resolve-client-credential.ts +71 -0
- package/src/resolve-media-uploads.ts +147 -0
- package/src/sdk-dependency.ts +54 -0
- package/src/sdk-skills.ts +85 -0
- package/src/should-skip-client-setup.ts +20 -0
- package/src/simulation-snapshot.ts +123 -0
- package/src/simulation-types.ts +74 -0
- package/src/simulations-client.ts +112 -0
- package/src/source-bundle.ts +466 -0
- package/src/staged-publish-cleanup.ts +44 -0
- package/src/staged-publish-deferred.ts +160 -0
- package/src/staged-publish.ts +401 -0
- package/src/store-file-upload.ts +268 -0
- package/src/store-request.ts +168 -0
- package/src/tar-canonical.ts +41 -0
- package/src/tar-extensions.ts +159 -0
- package/src/tar-extract.ts +193 -0
- package/src/tar-parse.ts +224 -0
- package/src/tar.ts +231 -0
- package/src/template-check-scripts.ts +18 -0
- package/src/tile-gallery-client.ts +82 -0
- package/src/types.ts +258 -0
- package/src/upload-concurrency.ts +54 -0
- package/src/whole-tile.ts +52 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { afterEach, describe, expect, test } from "bun:test";
|
|
2
|
+
import {
|
|
3
|
+
createPoeTileTestHarness,
|
|
4
|
+
waitForKeyExists,
|
|
5
|
+
waitForKeyMatch,
|
|
6
|
+
} from "joiner-sdk/v1/test-utils.js";
|
|
7
|
+
import { todoBackendConfig } from "./backend-config";
|
|
8
|
+
import type { TodoItem } from "./data/items";
|
|
9
|
+
import type { TodoSchema } from "./schema";
|
|
10
|
+
|
|
11
|
+
const harnesses: ReturnType<typeof createPoeTileTestHarness<TodoSchema>>[] = [];
|
|
12
|
+
afterEach(() => {
|
|
13
|
+
for (const harness of harnesses.splice(0)) harness.dispose();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
function createStore(): ReturnType<
|
|
17
|
+
typeof createPoeTileTestHarness<TodoSchema>
|
|
18
|
+
> {
|
|
19
|
+
const harness = createPoeTileTestHarness<TodoSchema>({
|
|
20
|
+
store: { backendConfig: todoBackendConfig },
|
|
21
|
+
});
|
|
22
|
+
harnesses.push(harness);
|
|
23
|
+
return harness;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Preserve the concrete schema when extending mutators; no store casts needed.
|
|
27
|
+
type TodoStore = Awaited<
|
|
28
|
+
ReturnType<ReturnType<typeof createStore>["createClient"]>
|
|
29
|
+
>["store"];
|
|
30
|
+
|
|
31
|
+
async function getItem(
|
|
32
|
+
store: TodoStore,
|
|
33
|
+
id: string,
|
|
34
|
+
): Promise<TodoItem | undefined> {
|
|
35
|
+
// This helper takes a store. Call getItem(store, id) directly; query callbacks
|
|
36
|
+
// receive a read context, not another store. Share ctx readers via TodoReadContext.
|
|
37
|
+
return store.query((tx) => tx.table("items").get(id));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
describe("todo-store mutators", () => {
|
|
41
|
+
test("setTodo creates a new todo with createdBy from ctx.userId", async () => {
|
|
42
|
+
const harness = createStore();
|
|
43
|
+
const { store } = await harness.createClient({ userId: "user-alice" });
|
|
44
|
+
await store.mutate.setTodo({
|
|
45
|
+
id: "todo-1",
|
|
46
|
+
text: "Buy milk",
|
|
47
|
+
completed: false,
|
|
48
|
+
createdAt: 1000,
|
|
49
|
+
order: 1,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const todo = await getItem(store, "todo-1");
|
|
53
|
+
expect(todo).toMatchObject({
|
|
54
|
+
id: "todo-1",
|
|
55
|
+
text: "Buy milk",
|
|
56
|
+
completed: false,
|
|
57
|
+
createdBy: "user-alice",
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test("setTodo merges with existing item and preserves createdBy", async () => {
|
|
62
|
+
const harness = createStore();
|
|
63
|
+
const { store } = await harness.createClient({ userId: "user-alice" });
|
|
64
|
+
await store.mutate.setTodo({
|
|
65
|
+
id: "todo-1",
|
|
66
|
+
text: "Buy milk",
|
|
67
|
+
completed: false,
|
|
68
|
+
createdAt: 1000,
|
|
69
|
+
order: 1,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// Another user updates the same todo
|
|
73
|
+
const { store: store2 } = await harness.createClient({
|
|
74
|
+
userId: "user-bob",
|
|
75
|
+
});
|
|
76
|
+
await store2.mutate.setTodo({ id: "todo-1", completed: true });
|
|
77
|
+
|
|
78
|
+
const todo = await getItem(store2, "todo-1");
|
|
79
|
+
expect(todo).toMatchObject({
|
|
80
|
+
text: "Buy milk",
|
|
81
|
+
completed: true,
|
|
82
|
+
createdBy: "user-alice",
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test("removeTodo deletes item", async () => {
|
|
87
|
+
const { store } = await createStore().createClient();
|
|
88
|
+
await store.mutate.setTodo({
|
|
89
|
+
id: "todo-1",
|
|
90
|
+
text: "Delete me",
|
|
91
|
+
createdAt: 1000,
|
|
92
|
+
order: 1,
|
|
93
|
+
});
|
|
94
|
+
await store.mutate.removeTodo({ id: "todo-1" });
|
|
95
|
+
|
|
96
|
+
const todo = await getItem(store, "todo-1");
|
|
97
|
+
expect(todo).toBeUndefined();
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// Multi-client tests where both clients exist before the mutations need
|
|
101
|
+
// to wait for state to propagate between clients. Without the explicit
|
|
102
|
+
// `waitForKeyExists` / `waitForKeyMatch` calls, bob's optimistic pass
|
|
103
|
+
// would race alice's confirmation and create a separate row instead of
|
|
104
|
+
// merging. (Single-client tests, and tests that create the second client
|
|
105
|
+
// *after* the first mutation, are fine — `createClient()` waits for
|
|
106
|
+
// server data on bootstrap.) See the full `waitFor*` family in
|
|
107
|
+
// `joiner-sdk/v1/test-utils.js` (`waitForValue`, `waitForKeyDeleted`,
|
|
108
|
+
// `waitForAllClients`, `waitFor`).
|
|
109
|
+
test("two pre-existing clients: bob's update merges with alice's row", async () => {
|
|
110
|
+
const harness = createStore();
|
|
111
|
+
const { store: alice } = await harness.createClient({ userId: "alice" });
|
|
112
|
+
const { store: bob } = await harness.createClient({ userId: "bob" });
|
|
113
|
+
|
|
114
|
+
await alice.mutate.setTodo({
|
|
115
|
+
id: "todo-1",
|
|
116
|
+
text: "Buy milk",
|
|
117
|
+
completed: false,
|
|
118
|
+
createdAt: 1000,
|
|
119
|
+
order: 1,
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
await waitForKeyExists(bob, { table: "items", key: "todo-1" });
|
|
123
|
+
|
|
124
|
+
await bob.mutate.setTodo({ id: "todo-1", completed: true });
|
|
125
|
+
|
|
126
|
+
await waitForKeyMatch<TodoItem>(alice, {
|
|
127
|
+
table: "items",
|
|
128
|
+
key: "todo-1",
|
|
129
|
+
match: (t) => t.completed === true,
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
expect(await getItem(alice, "todo-1")).toMatchObject({
|
|
133
|
+
text: "Buy milk",
|
|
134
|
+
completed: true,
|
|
135
|
+
createdBy: "alice",
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { defineSchema, table } from "joiner-sdk/v1/backend.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
export const todoSchema = defineSchema({
|
|
5
|
+
schemaVersion: 1,
|
|
6
|
+
tables: {
|
|
7
|
+
items: {
|
|
8
|
+
schema: table(
|
|
9
|
+
z.object({
|
|
10
|
+
id: z.string(),
|
|
11
|
+
text: z.string(),
|
|
12
|
+
completed: z.boolean(),
|
|
13
|
+
createdAt: z.number(),
|
|
14
|
+
createdBy: z.string(),
|
|
15
|
+
order: z.number(),
|
|
16
|
+
}),
|
|
17
|
+
),
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
mutators: {
|
|
21
|
+
setTodo: {
|
|
22
|
+
description: "Create or update a todo item",
|
|
23
|
+
input: z.object({
|
|
24
|
+
id: z.string(),
|
|
25
|
+
text: z.string().optional(),
|
|
26
|
+
completed: z.boolean().optional(),
|
|
27
|
+
createdAt: z.number().optional(),
|
|
28
|
+
order: z.number().optional(),
|
|
29
|
+
}),
|
|
30
|
+
},
|
|
31
|
+
removeTodo: {
|
|
32
|
+
description: "Remove a todo item",
|
|
33
|
+
input: z.object({
|
|
34
|
+
id: z.string(),
|
|
35
|
+
}),
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export type TodoSchema = typeof todoSchema;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { expect, test } from "@playwright/test";
|
|
5
|
+
import {
|
|
6
|
+
TestServer,
|
|
7
|
+
waitForBlobFrame,
|
|
8
|
+
} from "joiner-sdk/v1/test-utils/playwright.js";
|
|
9
|
+
import { openTwoUserTile } from "./multiplayer";
|
|
10
|
+
|
|
11
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
const DIST_DIR = join(__dirname, "../dist");
|
|
13
|
+
|
|
14
|
+
const server = new TestServer();
|
|
15
|
+
|
|
16
|
+
test.beforeAll(async () => {
|
|
17
|
+
if (!existsSync(join(DIST_DIR, "index.html"))) {
|
|
18
|
+
throw new Error('dist/index.html not found. Run "bun run build" first.');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
await server.start();
|
|
22
|
+
await server.registerTile({
|
|
23
|
+
typeId: "{{APP_NAME}}",
|
|
24
|
+
content: { type: "directory", dir: DIST_DIR },
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test.afterAll(() => {
|
|
29
|
+
server.close();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
function sessionUrl(config: {
|
|
33
|
+
instanceId: string;
|
|
34
|
+
userId?: string;
|
|
35
|
+
clientId?: string;
|
|
36
|
+
}): string {
|
|
37
|
+
return server.sessionUrl({
|
|
38
|
+
tileTypeId: "{{APP_NAME}}",
|
|
39
|
+
instanceId: config.instanceId,
|
|
40
|
+
userId: config.userId ?? "alice",
|
|
41
|
+
clientId: config.clientId ?? "client-alice",
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Adapt this browser journey when replacing the starter UI.
|
|
46
|
+
test.describe("Todo App E2E", () => {
|
|
47
|
+
test("app loads and renders", async ({ page }) => {
|
|
48
|
+
await page.goto(sessionUrl({ instanceId: "todo-load" }));
|
|
49
|
+
|
|
50
|
+
const frame = await waitForBlobFrame(page);
|
|
51
|
+
await expect(frame.locator("#todo-input")).toBeVisible({
|
|
52
|
+
timeout: 15_000,
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test("user adds a todo and sees it in the list", async ({ page }) => {
|
|
57
|
+
await page.goto(sessionUrl({ instanceId: "todo-add" }));
|
|
58
|
+
|
|
59
|
+
const frame = await waitForBlobFrame(page);
|
|
60
|
+
await expect(frame.locator("#todo-input")).toBeVisible({
|
|
61
|
+
timeout: 15_000,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
await frame.locator("#todo-input").fill("Buy milk");
|
|
65
|
+
await frame.locator("#add-btn").click();
|
|
66
|
+
|
|
67
|
+
await expect(frame.locator("#todo-list")).toContainText("Buy milk", {
|
|
68
|
+
timeout: 10_000,
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test("two users share one admitted tile instance", async ({ browser }) => {
|
|
73
|
+
const sessions = await openTwoUserTile({
|
|
74
|
+
server,
|
|
75
|
+
browser,
|
|
76
|
+
tileTypeId: "{{APP_NAME}}",
|
|
77
|
+
instanceId: "todo-two-users",
|
|
78
|
+
readySelector: "#todo-input",
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
try {
|
|
82
|
+
await sessions.alice.frame.locator("#todo-input").fill("Shared todo");
|
|
83
|
+
await sessions.alice.frame.locator("#add-btn").click();
|
|
84
|
+
await expect(sessions.bob.frame.locator("#todo-list")).toContainText(
|
|
85
|
+
"Shared todo",
|
|
86
|
+
{ timeout: 15_000 },
|
|
87
|
+
);
|
|
88
|
+
} finally {
|
|
89
|
+
await sessions.close();
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
});
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mobile viewport smoke test.
|
|
3
|
+
*
|
|
4
|
+
* Runs on the `mobile-viewport` Playwright project (iPhone 13 viewport, Chromium).
|
|
5
|
+
* What this test does and does NOT cover:
|
|
6
|
+
*
|
|
7
|
+
* 1. Asserts the viewport meta tag includes `viewport-fit=cover` — required
|
|
8
|
+
* for `env(safe-area-inset-*)` to return non-zero values on devices with
|
|
9
|
+
* notches / home indicators.
|
|
10
|
+
* 2. Asserts no `position: fixed`/`absolute` element has its bounding-rect
|
|
11
|
+
* bottom past the visible viewport. Catches bottom-pinned controls with
|
|
12
|
+
* over-large offsets, negative `bottom` values, and oversized heights or
|
|
13
|
+
* shifted `top`+`height` layouts.
|
|
14
|
+
*
|
|
15
|
+
* Note: Playwright's iPhone 13 emulation has a static viewport — there's no
|
|
16
|
+
* dynamic Safari toolbar — so on this runner `100vh === 100dvh` and a
|
|
17
|
+
* `top: 0; height: 100vh` shell will NOT trigger Assertion 2 here. The real
|
|
18
|
+
* `100vh`-vs-`100dvh` regression must be caught on real iOS Safari.
|
|
19
|
+
*
|
|
20
|
+
* The test runs against whatever index.html the framework template ships
|
|
21
|
+
* (vanilla-js / react / preact / solidjs) and whichever boot path the
|
|
22
|
+
* scaffolder chose (todo example or `--blank`). We use `#root > *` as the
|
|
23
|
+
* readiness signal because both modes mount their UI inside `#root` (todo
|
|
24
|
+
* renders `#todo-input`, `--blank` renders `#app-heading`); waiting for any
|
|
25
|
+
* direct child keeps the test mode-agnostic.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
import { existsSync } from "node:fs";
|
|
29
|
+
import { dirname, join } from "node:path";
|
|
30
|
+
import { fileURLToPath } from "node:url";
|
|
31
|
+
import { expect, test } from "@playwright/test";
|
|
32
|
+
import {
|
|
33
|
+
TestServer,
|
|
34
|
+
waitForBlobFrame,
|
|
35
|
+
} from "joiner-sdk/v1/test-utils/playwright.js";
|
|
36
|
+
|
|
37
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
38
|
+
const DIST_DIR = join(__dirname, "../dist");
|
|
39
|
+
|
|
40
|
+
const server = new TestServer();
|
|
41
|
+
|
|
42
|
+
test.beforeAll(async () => {
|
|
43
|
+
if (!existsSync(join(DIST_DIR, "index.html"))) {
|
|
44
|
+
throw new Error('dist/index.html not found. Run "bun run build" first.');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
await server.start();
|
|
48
|
+
await server.registerTile({
|
|
49
|
+
typeId: "{{APP_NAME}}",
|
|
50
|
+
content: { type: "directory", dir: DIST_DIR },
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test.afterAll(() => {
|
|
55
|
+
server.close();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
function sessionUrl(config: { instanceId: string }): string {
|
|
59
|
+
return server.sessionUrl({
|
|
60
|
+
tileTypeId: "{{APP_NAME}}",
|
|
61
|
+
instanceId: config.instanceId,
|
|
62
|
+
userId: "alice",
|
|
63
|
+
clientId: "client-alice",
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
test.describe("Mobile viewport smoke test", () => {
|
|
68
|
+
test("declares viewport-fit=cover and no positioned element overflows the visible iPhone-13 viewport", async ({
|
|
69
|
+
page,
|
|
70
|
+
}) => {
|
|
71
|
+
await page.goto(sessionUrl({ instanceId: "mobile-viewport-smoke" }));
|
|
72
|
+
|
|
73
|
+
const frame = await waitForBlobFrame(page);
|
|
74
|
+
await expect(frame.locator("#root > *").first()).toBeVisible({
|
|
75
|
+
timeout: 15_000,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const viewportContent = await frame.evaluate(() => {
|
|
79
|
+
const meta = document.querySelector(
|
|
80
|
+
'meta[name="viewport"]',
|
|
81
|
+
) as HTMLMetaElement | null;
|
|
82
|
+
return meta?.content ?? "";
|
|
83
|
+
});
|
|
84
|
+
expect(viewportContent).toContain("viewport-fit=cover");
|
|
85
|
+
|
|
86
|
+
const offscreenElements = await frame.evaluate(() => {
|
|
87
|
+
const viewportHeight = window.innerHeight;
|
|
88
|
+
const isPositioned = (el: Element): boolean => {
|
|
89
|
+
const position = window.getComputedStyle(el).position;
|
|
90
|
+
return position === "fixed" || position === "absolute";
|
|
91
|
+
};
|
|
92
|
+
const isVisibleOverflow = (rect: DOMRect): boolean =>
|
|
93
|
+
rect.width > 0 && rect.height > 0 && rect.bottom > viewportHeight + 2;
|
|
94
|
+
return [...document.querySelectorAll("*")]
|
|
95
|
+
.filter(isPositioned)
|
|
96
|
+
.map((el) => ({ el, rect: el.getBoundingClientRect() }))
|
|
97
|
+
.filter(({ rect }) => isVisibleOverflow(rect))
|
|
98
|
+
.map(({ el, rect }) => ({
|
|
99
|
+
selector: el.tagName.toLowerCase() + (el.id ? `#${el.id}` : ""),
|
|
100
|
+
rectBottom: rect.bottom,
|
|
101
|
+
viewportHeight,
|
|
102
|
+
}));
|
|
103
|
+
});
|
|
104
|
+
expect(
|
|
105
|
+
offscreenElements,
|
|
106
|
+
`Positioned elements rendered below the visible viewport: ${JSON.stringify(
|
|
107
|
+
offscreenElements,
|
|
108
|
+
)}`,
|
|
109
|
+
).toEqual([]);
|
|
110
|
+
});
|
|
111
|
+
});
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Finds the battery-hungry rendering patterns the production power report
|
|
3
|
+
// measures, before the tile has a single player. Drive via:
|
|
4
|
+
// bun run render-check
|
|
5
|
+
// which builds the tile, installs Chromium, and runs this file under the
|
|
6
|
+
// `mobile-viewport` project (iPhone 13 on Chromium). It prints a table, writes
|
|
7
|
+
// `.visual-checks/render-check.json`, and fails on findings. Set
|
|
8
|
+
// `RENDER_CHECK_REPORT_ONLY=1` to print the report without failing on them.
|
|
9
|
+
// The `tile-creator` skill's render-check reference explains every code.
|
|
10
|
+
|
|
11
|
+
import { existsSync, writeFileSync } from "node:fs";
|
|
12
|
+
import { dirname, join } from "node:path";
|
|
13
|
+
import { fileURLToPath } from "node:url";
|
|
14
|
+
import { expect, test } from "@playwright/test";
|
|
15
|
+
import { TestServer } from "joiner-sdk/v1/test-utils/playwright.js";
|
|
16
|
+
import {
|
|
17
|
+
checkRenderCost,
|
|
18
|
+
formatRenderCheckReport,
|
|
19
|
+
partialCauses,
|
|
20
|
+
type RenderCheckReport,
|
|
21
|
+
type RenderCheckScreen,
|
|
22
|
+
renderCheckDeadlineMs,
|
|
23
|
+
renderCheckTimeoutMs,
|
|
24
|
+
} from "joiner-sdk/v1/test-utils/render-check.js";
|
|
25
|
+
import { visualCheckPath } from "../scripts/visual-check";
|
|
26
|
+
|
|
27
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
28
|
+
const TILE_DIR = join(__dirname, "..");
|
|
29
|
+
const DIST_DIR = join(TILE_DIR, "dist");
|
|
30
|
+
|
|
31
|
+
// Destructured rather than read as `process.env["RENDER_CHECK"]`: biome's
|
|
32
|
+
// `useLiteralKeys` rejects the computed string key, and dot access would break
|
|
33
|
+
// type-check under the monorepo tsconfig's `noPropertyAccessFromIndexSignature`.
|
|
34
|
+
const { RENDER_CHECK, RENDER_CHECK_REPORT_ONLY } = process.env;
|
|
35
|
+
|
|
36
|
+
test.skip(
|
|
37
|
+
!RENDER_CHECK,
|
|
38
|
+
"Render check — run `bun run render-check`, not the default suite.",
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
// The screens the check walks, in order, through the tile's real UI. Replace
|
|
42
|
+
// the single opening screen with the tile's real screens and their kinds:
|
|
43
|
+
// `idle` for a menu, game-over card, pause or how-to overlay (nothing should
|
|
44
|
+
// move there); `play` for active play, with `exercise` to keep playing it
|
|
45
|
+
// while it is measured (taps, drags, held keys, until `ctx.signal` fires) and
|
|
46
|
+
// `assert` to confirm the screen is still showing after the hold and after
|
|
47
|
+
// the probes. Each `reach` starts from whatever state the previous screen
|
|
48
|
+
// left, on the same page, so the list is an ordered walk. A screen the
|
|
49
|
+
// player leaves open and comes back to (a farm, a lobby, a collection, a
|
|
50
|
+
// board between moves) is `idle`, reached in the fullest state a player can
|
|
51
|
+
// own. Keep `kind: "unknown"` only for a screen you have not classified: it
|
|
52
|
+
// is measured and probed, but judged by the screen-agnostic rules alone.
|
|
53
|
+
const screens: RenderCheckScreen[] = [
|
|
54
|
+
{ name: "opening screen", kind: "unknown", reach: async () => {} },
|
|
55
|
+
];
|
|
56
|
+
|
|
57
|
+
const server = new TestServer();
|
|
58
|
+
let latest: RenderCheckReport | null = null;
|
|
59
|
+
|
|
60
|
+
test.setTimeout(renderCheckTimeoutMs(screens.length));
|
|
61
|
+
|
|
62
|
+
test.beforeAll(async () => {
|
|
63
|
+
if (!existsSync(join(DIST_DIR, "index.html"))) {
|
|
64
|
+
throw new Error('dist/index.html not found. Run "bun run build" first.');
|
|
65
|
+
}
|
|
66
|
+
await server.start();
|
|
67
|
+
await server.registerTile({
|
|
68
|
+
typeId: "{{APP_NAME}}",
|
|
69
|
+
content: { type: "directory", dir: DIST_DIR },
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test.afterAll(async () => {
|
|
74
|
+
await server.closeAndWaitForTesting();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
async function attach(report: RenderCheckReport): Promise<void> {
|
|
78
|
+
const json = JSON.stringify(report, null, 2);
|
|
79
|
+
writeFileSync(visualCheckPath("render-check.json", TILE_DIR), json);
|
|
80
|
+
await test
|
|
81
|
+
.info()
|
|
82
|
+
.attach("render-check", { body: json, contentType: "application/json" });
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// A run that Playwright's timeout ends still leaves the last progress
|
|
86
|
+
// snapshot behind as evidence.
|
|
87
|
+
test.afterEach(async () => {
|
|
88
|
+
if (latest) await attach(latest);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test("render check", async ({ page }) => {
|
|
92
|
+
const report = await checkRenderCost(
|
|
93
|
+
{ page, server },
|
|
94
|
+
{
|
|
95
|
+
sessionUrl: server.sessionUrl({
|
|
96
|
+
tileTypeId: "{{APP_NAME}}",
|
|
97
|
+
instanceId: "render-check",
|
|
98
|
+
userId: "alice",
|
|
99
|
+
clientId: "client-alice",
|
|
100
|
+
}),
|
|
101
|
+
screens,
|
|
102
|
+
tileRootDir: TILE_DIR,
|
|
103
|
+
deadlineMs: renderCheckDeadlineMs(screens.length),
|
|
104
|
+
onProgress: (snapshot) => {
|
|
105
|
+
latest = snapshot;
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
);
|
|
109
|
+
latest = null;
|
|
110
|
+
console.log(formatRenderCheckReport(report));
|
|
111
|
+
await attach(report);
|
|
112
|
+
// A worker-rendered canvas is the only unobservable state to skip on; a tile
|
|
113
|
+
// page or frame that never mounts must fail, or the check proves nothing.
|
|
114
|
+
const offMainThread =
|
|
115
|
+
report.status === "unobservable" &&
|
|
116
|
+
(report.reason ?? "").includes("transferControlToOffscreen");
|
|
117
|
+
test.skip(
|
|
118
|
+
report.status === "inconclusive" || offMainThread,
|
|
119
|
+
`render check ${report.status}: ${report.reason ?? ""}`,
|
|
120
|
+
);
|
|
121
|
+
expect(report.status, report.reason ?? "").not.toBe("unobservable");
|
|
122
|
+
if (RENDER_CHECK_REPORT_ONLY) return;
|
|
123
|
+
const message = [
|
|
124
|
+
...report.findings.map((f) => `${f.code} [${f.screen}]: ${f.sentence}`),
|
|
125
|
+
...(report.partial ? [`partial: ${partialCauses(report).join("; ")}`] : []),
|
|
126
|
+
].join("\n");
|
|
127
|
+
expect(report.findings, message).toEqual([]);
|
|
128
|
+
});
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Captures a square screenshot that can replace the default `profilePicture`
|
|
3
|
+
// in `.poe-tile.json`. Drive via:
|
|
4
|
+
// bun run regenerate-screenshot
|
|
5
|
+
// which builds the app and writes `assets/screenshot.png`. If you point
|
|
6
|
+
// `profilePicture` at that file, commit it with the rest of the tile.
|
|
7
|
+
|
|
8
|
+
import { existsSync, mkdirSync } from "node:fs";
|
|
9
|
+
import { dirname, join } from "node:path";
|
|
10
|
+
import { fileURLToPath } from "node:url";
|
|
11
|
+
import { test } from "@playwright/test";
|
|
12
|
+
import {
|
|
13
|
+
TestServer,
|
|
14
|
+
waitForBlobFrame,
|
|
15
|
+
} from "joiner-sdk/v1/test-utils/playwright.js";
|
|
16
|
+
|
|
17
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
18
|
+
const DIST_DIR = join(__dirname, "../dist");
|
|
19
|
+
const ASSETS_DIR = join(__dirname, "../assets");
|
|
20
|
+
const SCREENSHOT_PATH = join(ASSETS_DIR, "screenshot.png");
|
|
21
|
+
|
|
22
|
+
const server = new TestServer();
|
|
23
|
+
|
|
24
|
+
// This file is an asset generator, not a CI test: it boots a full TestServer
|
|
25
|
+
// + blob iframe purely to capture this tile's marketing screenshot
|
|
26
|
+
// (assets/screenshot.png). It asserts nothing your e2e
|
|
27
|
+
// suite doesn't already cover, so it is skipped in the default Playwright
|
|
28
|
+
// suite to keep CI fast. Regenerate the screenshot on demand with
|
|
29
|
+
// `bun run regenerate-screenshot`.
|
|
30
|
+
// Destructured rather than read as `process.env["REGEN_SCREENSHOTS"]`: biome's
|
|
31
|
+
// `useLiteralKeys` rejects the computed string key, and dot access would break
|
|
32
|
+
// type-check under the monorepo tsconfig's `noPropertyAccessFromIndexSignature`.
|
|
33
|
+
const { REGEN_SCREENSHOTS } = process.env;
|
|
34
|
+
|
|
35
|
+
test.skip(
|
|
36
|
+
!REGEN_SCREENSHOTS,
|
|
37
|
+
"Asset generator — run `bun run regenerate-screenshot`, not the default suite.",
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
test.beforeAll(async () => {
|
|
41
|
+
if (!existsSync(join(DIST_DIR, "index.html"))) {
|
|
42
|
+
throw new Error('dist/index.html not found. Run "bun run build" first.');
|
|
43
|
+
}
|
|
44
|
+
mkdirSync(ASSETS_DIR, { recursive: true });
|
|
45
|
+
await server.start();
|
|
46
|
+
await server.registerTile({
|
|
47
|
+
typeId: "{{APP_NAME}}",
|
|
48
|
+
content: { type: "directory", dir: DIST_DIR },
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test.afterAll(async () => {
|
|
53
|
+
await server.closeAndWaitForTesting();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// Square mobile viewport (360x360 CSS px) with 2x DPR. CSS pixels stay
|
|
57
|
+
// below Tailwind's `sm` breakpoint (640px) so apps render their actual
|
|
58
|
+
// mobile layout; the 2x DPR keeps the output PNG at 720x720.
|
|
59
|
+
test.use({
|
|
60
|
+
viewport: { width: 360, height: 360 },
|
|
61
|
+
deviceScaleFactor: 2,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test("capture profile picture", async ({ page }) => {
|
|
65
|
+
await page.goto(
|
|
66
|
+
server.sessionUrl({
|
|
67
|
+
tileTypeId: "{{APP_NAME}}",
|
|
68
|
+
instanceId: "screenshot",
|
|
69
|
+
userId: "alice",
|
|
70
|
+
clientId: "client-alice",
|
|
71
|
+
}),
|
|
72
|
+
);
|
|
73
|
+
const frame = await waitForBlobFrame(page);
|
|
74
|
+
// Replace `body` with something specific to your app (e.g.
|
|
75
|
+
// `[data-testid="my-app"]`) — `body` exists immediately and gives
|
|
76
|
+
// no real "mounted" signal.
|
|
77
|
+
await frame.locator("body").waitFor({ state: "attached", timeout: 15_000 });
|
|
78
|
+
// If your app uses a canvas / WebGL render loop, also wait for the
|
|
79
|
+
// scene to paint. Canonical pattern (see `poe-tiles/stack-it-up`):
|
|
80
|
+
// flip `data-scene-ready="1"` on the canvas host after the first
|
|
81
|
+
// render-loop tick, then wait on that selector here. Avoid
|
|
82
|
+
// `page.waitForTimeout(...)` — real-timing-dependent waits are
|
|
83
|
+
// flaky on slow CI runners (PRINCIPLES.md: "Tests need to be very
|
|
84
|
+
// fast and deterministic").
|
|
85
|
+
await page.screenshot({ path: SCREENSHOT_PATH, fullPage: false });
|
|
86
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test setup for happy-dom environment.
|
|
3
|
+
* Preloaded before tests run (see bunfig.toml) to provide a DOM for
|
|
4
|
+
* `*.test.happydom.tsx` files. Non-DOM tests (mutators, etc.) are unaffected.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { expect } from "bun:test";
|
|
8
|
+
import type { TestingLibraryMatchers } from "@testing-library/jest-dom/matchers";
|
|
9
|
+
import * as matchers from "@testing-library/jest-dom/matchers";
|
|
10
|
+
import { GlobalWindow } from "happy-dom";
|
|
11
|
+
|
|
12
|
+
declare module "bun:test" {
|
|
13
|
+
// `toBeEmpty` is omitted from both merges: bun ships its own, with a
|
|
14
|
+
// signature jest-dom's does not match, and an interface cannot extend two
|
|
15
|
+
// bases that declare the same property differently.
|
|
16
|
+
interface Matchers<T>
|
|
17
|
+
extends Omit<
|
|
18
|
+
TestingLibraryMatchers<typeof expect.stringContaining, T>,
|
|
19
|
+
"toBeEmpty"
|
|
20
|
+
> {}
|
|
21
|
+
interface AsymmetricMatchers
|
|
22
|
+
extends Omit<TestingLibraryMatchers<unknown, void>, "toBeEmpty"> {}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
expect.extend(matchers);
|
|
26
|
+
|
|
27
|
+
const window = new GlobalWindow();
|
|
28
|
+
|
|
29
|
+
Object.assign(globalThis, {
|
|
30
|
+
window,
|
|
31
|
+
document: window.document,
|
|
32
|
+
navigator: window.navigator,
|
|
33
|
+
location: window.location,
|
|
34
|
+
history: window.history,
|
|
35
|
+
Element: window.Element,
|
|
36
|
+
HTMLElement: window.HTMLElement,
|
|
37
|
+
HTMLDivElement: window.HTMLDivElement,
|
|
38
|
+
HTMLInputElement: window.HTMLInputElement,
|
|
39
|
+
HTMLButtonElement: window.HTMLButtonElement,
|
|
40
|
+
HTMLTextAreaElement: window.HTMLTextAreaElement,
|
|
41
|
+
Node: window.Node,
|
|
42
|
+
Event: window.Event,
|
|
43
|
+
CustomEvent: window.CustomEvent,
|
|
44
|
+
MouseEvent: window.MouseEvent,
|
|
45
|
+
KeyboardEvent: window.KeyboardEvent,
|
|
46
|
+
MutationObserver: window.MutationObserver,
|
|
47
|
+
DocumentFragment: window.DocumentFragment,
|
|
48
|
+
Blob: window.Blob,
|
|
49
|
+
URL: window.URL,
|
|
50
|
+
getComputedStyle: window.getComputedStyle.bind(window),
|
|
51
|
+
requestAnimationFrame: window.requestAnimationFrame.bind(window),
|
|
52
|
+
cancelAnimationFrame: window.cancelAnimationFrame.bind(window),
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
if (typeof globalThis.sessionStorage === "undefined") {
|
|
56
|
+
const storage = new Map<string, string>();
|
|
57
|
+
Object.defineProperty(globalThis, "sessionStorage", {
|
|
58
|
+
value: {
|
|
59
|
+
getItem: (key: string) => storage.get(key) ?? null,
|
|
60
|
+
setItem: (key: string, value: string) => storage.set(key, value),
|
|
61
|
+
removeItem: (key: string) => storage.delete(key),
|
|
62
|
+
clear: () => storage.clear(),
|
|
63
|
+
get length() {
|
|
64
|
+
return storage.size;
|
|
65
|
+
},
|
|
66
|
+
key: (index: number) => [...storage.keys()][index] ?? null,
|
|
67
|
+
},
|
|
68
|
+
writable: true,
|
|
69
|
+
});
|
|
70
|
+
}
|