@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,103 @@
|
|
|
1
|
+
import { expect, test } from "@playwright/test";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import {
|
|
4
|
+
TestServer,
|
|
5
|
+
waitForBlobFrame,
|
|
6
|
+
} from "joiner-sdk/v1/test-utils/playwright.js";
|
|
7
|
+
import { openTwoUserTile, waitForVisualReady } from "./multiplayer";
|
|
8
|
+
|
|
9
|
+
test("visual readiness ignores looping decoration but bounds unfinished finite animations", async ({
|
|
10
|
+
page,
|
|
11
|
+
}) => {
|
|
12
|
+
await page.setContent('<main id="ready">Ready</main>');
|
|
13
|
+
await page.evaluate(() => {
|
|
14
|
+
const element = document.querySelector("main")!;
|
|
15
|
+
element.animate([{ opacity: 1 }, { opacity: 0.8 }], {
|
|
16
|
+
duration: 1000,
|
|
17
|
+
iterations: Infinity,
|
|
18
|
+
});
|
|
19
|
+
const finite = element.animate(
|
|
20
|
+
[{ transform: "scale(1)" }, { transform: "scale(.9)" }],
|
|
21
|
+
{ duration: 1000, iterations: 2 },
|
|
22
|
+
);
|
|
23
|
+
finite.pause();
|
|
24
|
+
});
|
|
25
|
+
// The browser predicate can consume the deadline before Playwright formats
|
|
26
|
+
// our diagnostic. Assert bounded rejection, then successful recovery below.
|
|
27
|
+
await expect(
|
|
28
|
+
waitForVisualReady({
|
|
29
|
+
frame: page.mainFrame(),
|
|
30
|
+
readySelector: "#ready",
|
|
31
|
+
timeoutMs: 100,
|
|
32
|
+
}),
|
|
33
|
+
).rejects.toThrow();
|
|
34
|
+
await page.evaluate(() => {
|
|
35
|
+
for (const animation of document.getAnimations()) {
|
|
36
|
+
if (Number.isFinite(animation.effect?.getComputedTiming().endTime))
|
|
37
|
+
animation.finish();
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
await waitForVisualReady({
|
|
41
|
+
frame: page.mainFrame(),
|
|
42
|
+
readySelector: "#ready",
|
|
43
|
+
timeoutMs: 1000,
|
|
44
|
+
});
|
|
45
|
+
expect(
|
|
46
|
+
await page.evaluate(() =>
|
|
47
|
+
document
|
|
48
|
+
.getAnimations()
|
|
49
|
+
.some((animation) => animation.playState === "running"),
|
|
50
|
+
),
|
|
51
|
+
).toBe(true);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test("both members are admitted before either client waits for a shared readiness state", async ({
|
|
55
|
+
browser,
|
|
56
|
+
}) => {
|
|
57
|
+
const server = new TestServer();
|
|
58
|
+
await server.start();
|
|
59
|
+
try {
|
|
60
|
+
const tileTypeId = "multiplayer-fixture-probe";
|
|
61
|
+
await server.registerTile({
|
|
62
|
+
typeId: tileTypeId,
|
|
63
|
+
content: {
|
|
64
|
+
type: "directory",
|
|
65
|
+
dir: fileURLToPath(new URL("../dist", import.meta.url)),
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
const users = await openTwoUserTile({
|
|
69
|
+
server,
|
|
70
|
+
browser,
|
|
71
|
+
tileTypeId,
|
|
72
|
+
instanceId: crypto.randomUUID(),
|
|
73
|
+
readySelector:
|
|
74
|
+
'[data-testid="connected-player-count"]:text-is("2 connected players")',
|
|
75
|
+
contextOptions: {
|
|
76
|
+
viewport: { width: 390, height: 760 },
|
|
77
|
+
colorScheme: "dark",
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
try {
|
|
81
|
+
expect(users.alice.page.viewportSize()).toEqual({
|
|
82
|
+
width: 390,
|
|
83
|
+
height: 760,
|
|
84
|
+
});
|
|
85
|
+
expect(users.alice.context).not.toBe(users.bob.context);
|
|
86
|
+
expect(
|
|
87
|
+
new URL(users.alice.page.url()).searchParams.get("use_indexed_db"),
|
|
88
|
+
).toBe("1");
|
|
89
|
+
await users.alice.page.reload();
|
|
90
|
+
const returned = await waitForBlobFrame(users.alice.page);
|
|
91
|
+
await expect(
|
|
92
|
+
returned.locator('[data-testid="connected-player-count"]'),
|
|
93
|
+
).toHaveText("2 connected players");
|
|
94
|
+
await expect(
|
|
95
|
+
users.bob.frame.locator('[data-testid="connected-player-count"]'),
|
|
96
|
+
).toHaveText("2 connected players");
|
|
97
|
+
} finally {
|
|
98
|
+
await users.close();
|
|
99
|
+
}
|
|
100
|
+
} finally {
|
|
101
|
+
await server.closeAndWaitForTesting();
|
|
102
|
+
}
|
|
103
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// owner: jyoung-q
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { copyFileSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import type { TemplateName } from "../..";
|
|
6
|
+
|
|
7
|
+
/** Demo-specific assertions belong to scaffold maintenance, not generated apps. */
|
|
8
|
+
export function installStarterDemoTests(
|
|
9
|
+
appDir: string,
|
|
10
|
+
template: TemplateName,
|
|
11
|
+
) {
|
|
12
|
+
copyFileSync(
|
|
13
|
+
join(import.meta.dir, "starter-demo", `${template}.tsx.txt`),
|
|
14
|
+
join(appDir, "ui/starter-demo.test.happydom.tsx"),
|
|
15
|
+
);
|
|
16
|
+
copyFileSync(
|
|
17
|
+
join(import.meta.dir, "starter-demo/seating.ts.txt"),
|
|
18
|
+
join(appDir, "synced-store/starter-demo.test.ts"),
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Replace the app-owned schema without editing any generated tests. */
|
|
23
|
+
export function replaceStarterSchema(appDir: string, template: TemplateName) {
|
|
24
|
+
rmSync(join(appDir, "ui/starter-demo.test.happydom.tsx"));
|
|
25
|
+
rmSync(join(appDir, "synced-store/starter-demo.test.ts"));
|
|
26
|
+
const extension = ["react", "preact", "solidjs"].includes(template)
|
|
27
|
+
? "tsx"
|
|
28
|
+
: "ts";
|
|
29
|
+
for (const [path, edits] of [
|
|
30
|
+
[
|
|
31
|
+
"synced-store/schema.ts",
|
|
32
|
+
[
|
|
33
|
+
[
|
|
34
|
+
"players: { schema: table(playerRow) }",
|
|
35
|
+
"participants: { schema: table(playerRow) }",
|
|
36
|
+
],
|
|
37
|
+
[
|
|
38
|
+
'mark: z.enum(["X", "O"]).nullable(),',
|
|
39
|
+
'symbol: z.enum(["X", "O"]).nullable(),\n\tscore: z.number(),',
|
|
40
|
+
],
|
|
41
|
+
],
|
|
42
|
+
],
|
|
43
|
+
[
|
|
44
|
+
"synced-store/hooks.ts",
|
|
45
|
+
[
|
|
46
|
+
['table("players")', 'table("participants")'],
|
|
47
|
+
["player.mark", "player.symbol"],
|
|
48
|
+
[
|
|
49
|
+
"value: { userId, mark },",
|
|
50
|
+
"value: { userId, symbol: mark, score: 0 },",
|
|
51
|
+
],
|
|
52
|
+
],
|
|
53
|
+
],
|
|
54
|
+
[`ui/App.${extension}`, [['table("players")', 'table("participants")']]],
|
|
55
|
+
] as const) {
|
|
56
|
+
const file = join(appDir, path);
|
|
57
|
+
let source = readFileSync(file, "utf8");
|
|
58
|
+
for (const [before, after] of edits) {
|
|
59
|
+
assert(
|
|
60
|
+
source.includes(before),
|
|
61
|
+
`Missing starter extension point: ${path}: ${before}`,
|
|
62
|
+
);
|
|
63
|
+
source = source.replaceAll(before, after);
|
|
64
|
+
}
|
|
65
|
+
writeFileSync(file, source);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,85 @@
|
|
|
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
|
+
});
|