@aethervtt/shard-testing 0.0.1 → 0.2.0

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/dist/index.d.ts CHANGED
@@ -28,12 +28,31 @@ export declare class Game {
28
28
  release: (name: string) => void;
29
29
  /** Press for one frame. */
30
30
  press: (name: string) => Promise<void>;
31
+ /**
32
+ * Plays pointer gestures in CSS pixels (`{ drag }`, `{ pinch }`, `{ wheel }`, `{ tap }`,
33
+ * `{ wait }`) and steps until they're done (0060): camera controls and object drags.
34
+ */
35
+ gesture: (...gestures: Json[]) => Promise<void>;
31
36
  };
32
37
  /**
33
38
  * Sounds started, stopped, and dropped (audio plugin) from frame `since`, as `audio.log` returns
34
39
  * them: `{ frame, event, clip, entity, path, bus, position, gain, pan, reason }`.
35
40
  */
36
41
  audioLog(since?: number): Promise<Json[]>;
42
+ /** Audio inspection and cursor-aware traces; assertions remain ordinary test assertions. */
43
+ readonly audio: {
44
+ describe: () => Promise<Json>;
45
+ events: (cursor?: number) => Promise<Json>;
46
+ music: (cursor?: number) => Promise<Json>;
47
+ mix: () => Promise<Json>;
48
+ log: (cursor?: number) => Promise<{
49
+ entries: Json[];
50
+ oldestCursor: number;
51
+ nextCursor: number;
52
+ truncated: boolean;
53
+ }>;
54
+ parameter: (instance: number, name: string, value: string | number) => Promise<Json>;
55
+ };
37
56
  /** UI (ui plugin): read the HUD as data and press buttons by path, without pixel coordinates. */
38
57
  readonly ui: {
39
58
  /** `ui.describe`: every tree with rects, text, widget state, focus, and anchors. */
@@ -83,7 +102,10 @@ export declare class Game {
83
102
  private inject;
84
103
  private resolve;
85
104
  }
86
- /** A gameplay test. Each test gets a fresh game; the GPU is shared across a file. */
105
+ /**
106
+ * A gameplay test. Each test gets a fresh game; the GPU is shared across a file. `timeout` is
107
+ * scaled like `timeout()` from test-env (5x in CI, which renders on a software GPU).
108
+ */
87
109
  export declare function test(name: string, fn: (ctx: {
88
110
  game: Game;
89
111
  }) => Promise<void> | void, timeout?: number): void;
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { mkdir, writeFile } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
3
  import { findComponent, ShardError } from "@aethervtt/shard-core";
4
+ import { timeout as scaled } from "@aethervtt/shard-core/test-env";
4
5
  import { createNodeGpuContext } from "@aethervtt/shard-gpu/node";
5
6
  import { openProject } from "@aethervtt/shard-node";
6
7
  import { findEntityByPath } from "@aethervtt/shard-scene";
@@ -68,6 +69,14 @@ class Game {
68
69
  this.inject(name, true);
69
70
  await this.step(1);
70
71
  this.inject(name, false);
72
+ },
73
+ /**
74
+ * Plays pointer gestures in CSS pixels (`{ drag }`, `{ pinch }`, `{ wheel }`, `{ tap }`,
75
+ * `{ wait }`) and steps until they're done (0060): camera controls and object drags.
76
+ */
77
+ gesture: async (...gestures) => {
78
+ const { frames } = await this.call("input.simulate", { gestures });
79
+ await this.step(frames);
71
80
  }
72
81
  };
73
82
  /**
@@ -77,6 +86,15 @@ class Game {
77
86
  async audioLog(since = 0) {
78
87
  return (await this.call("audio.log", { since })).entries;
79
88
  }
89
+ /** Audio inspection and cursor-aware traces; assertions remain ordinary test assertions. */
90
+ audio = {
91
+ describe: async () => this.call("audio.describe"),
92
+ events: async (cursor = 0) => this.call("audio.events.inspect", { cursor }),
93
+ music: async (cursor = 0) => this.call("audio.music.inspect", { cursor }),
94
+ mix: async () => this.call("audio.mix.inspect"),
95
+ log: async (cursor = 0) => this.call("audio.log", { cursor }),
96
+ parameter: async (instance, name, value) => this.call("audio.parameter.set", { instance, name, value })
97
+ };
80
98
  /** UI (ui plugin): read the HUD as data and press buttons by path, without pixel coordinates. */
81
99
  ui = {
82
100
  /** `ui.describe`: every tree with rects, text, widget state, focus, and anchors. */
@@ -194,7 +212,7 @@ function test(name, fn, timeout = 3e4) {
194
212
  open.push(project);
195
213
  await fn({ game: new Game(project) });
196
214
  },
197
- timeout
215
+ scaled(timeout)
198
216
  );
199
217
  }
200
218
  test.skip = (name, _fn) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aethervtt/shard-testing",
3
- "version": "0.0.1",
3
+ "version": "0.2.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -16,13 +16,13 @@
16
16
  "README.md"
17
17
  ],
18
18
  "dependencies": {
19
- "@aethervtt/shard-core": "0.0.1",
20
- "@aethervtt/shard-gpu": "0.0.1",
21
- "@aethervtt/shard-node": "0.0.1",
22
- "@aethervtt/shard-protocol": "0.0.1",
23
- "@aethervtt/shard-runtime": "0.0.1",
19
+ "@aethervtt/shard-core": "0.2.0",
20
+ "@aethervtt/shard-gpu": "0.2.0",
21
+ "@aethervtt/shard-node": "0.2.0",
22
+ "@aethervtt/shard-protocol": "0.2.0",
23
+ "@aethervtt/shard-runtime": "0.2.0",
24
24
  "vitest": "^5.0.1",
25
- "@aethervtt/shard-scene": "0.0.1"
25
+ "@aethervtt/shard-scene": "0.2.0"
26
26
  },
27
27
  "repository": {
28
28
  "type": "git",
@@ -34,6 +34,6 @@
34
34
  "provenance": true
35
35
  },
36
36
  "shard": {
37
- "buildSha": "d6c5c6aef4675575c878b02cf2c8f738b4190229"
37
+ "buildSha": "32c22a3944ed23f5d1baa90bf7cc9fae724f5fd8"
38
38
  }
39
39
  }