@ripplo/testing 0.5.2 → 0.5.3

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/actions.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  readVariable,
3
3
  toSpecLocator,
4
4
  toStringValueRef
5
- } from "./chunk-YJ4KB56W.js";
5
+ } from "./chunk-2YLI7VD4.js";
6
6
  import "./chunk-DCJBLS2U.js";
7
7
  import {
8
8
  createStep
@@ -14,10 +14,16 @@ var Fixture = class {
14
14
  kind = "fixture";
15
15
  name;
16
16
  constructor(name) {
17
- if (name.length === 0) {
17
+ const raw = name;
18
+ if (typeof raw !== "string") {
19
+ throw new TypeError(
20
+ `fixture(name) requires a string name \u2014 got ${raw == null ? String(raw) : typeof raw}`
21
+ );
22
+ }
23
+ if (raw.length === 0) {
18
24
  throw new Error("fixture(name) requires a non-empty name");
19
25
  }
20
- this.name = name;
26
+ this.name = raw;
21
27
  }
22
28
  };
23
29
  function fixture(name) {
@@ -65,8 +71,32 @@ function hover(locator) {
65
71
  function press(key) {
66
72
  return createStep({ key, type: "press" });
67
73
  }
74
+ function describeFilesArg(files) {
75
+ if (typeof files === "string") {
76
+ return `string "${files}"`;
77
+ }
78
+ return typeof files;
79
+ }
80
+ function normalizeUploadFiles(files) {
81
+ if (files instanceof Fixture) {
82
+ return [files];
83
+ }
84
+ if (!Array.isArray(files)) {
85
+ throw new TypeError(
86
+ `upload() expected a Fixture or an array of Fixtures \u2014 got ${describeFilesArg(files)}. Wrap the filename with fixture(): upload(loc, fixture("file.png"))`
87
+ );
88
+ }
89
+ return files.map((f, i) => {
90
+ if (!(f instanceof Fixture)) {
91
+ throw new TypeError(
92
+ `upload() files[${String(i)}] is not a Fixture \u2014 wrap it with fixture(): upload(loc, fixture("file.png"))`
93
+ );
94
+ }
95
+ return f;
96
+ });
97
+ }
68
98
  function upload(locator, files, options) {
69
- const list = files instanceof Fixture ? [files] : [...files];
99
+ const list = normalizeUploadFiles(files);
70
100
  return createStep({
71
101
  files: list.map((f) => f.name),
72
102
  locator: toSpecLocator(locator),
package/dist/assert.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  import {
6
6
  toSpecLocator,
7
7
  toStringValueRef
8
- } from "./chunk-YJ4KB56W.js";
8
+ } from "./chunk-2YLI7VD4.js";
9
9
  import "./chunk-DCJBLS2U.js";
10
10
  import {
11
11
  createStep
@@ -38,6 +38,13 @@ function toStringValueRef(value) {
38
38
  if (typeof value === "string") {
39
39
  return { type: "static", value };
40
40
  }
41
+ if (!isVariable(value)) {
42
+ const raw = value;
43
+ const got = raw == null ? String(raw) : typeof raw;
44
+ throw new TypeError(
45
+ `Expected a string or variable() \u2014 got ${got}. Wrap dynamic values with variable("name") and pair them with extract().`
46
+ );
47
+ }
41
48
  return { name: readVariable(value), type: "variable" };
42
49
  }
43
50
  function extract(locator, target) {
package/dist/control.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  readVariable,
5
5
  toStringValueRef,
6
6
  variable
7
- } from "./chunk-YJ4KB56W.js";
7
+ } from "./chunk-2YLI7VD4.js";
8
8
  import "./chunk-DCJBLS2U.js";
9
9
  import "./chunk-MGATMMCZ.js";
10
10
  import "./chunk-4MGIQFAJ.js";
@@ -714,8 +714,9 @@ declare function hashFixturesIntoCompileResult({ cwd, result, }: HashFixturesPar
714
714
  type LockfileComparison = "match" | "missing" | "stale";
715
715
  interface CompareLockfileParams {
716
716
  readonly compiled: CompileResult;
717
+ readonly cwd: string;
717
718
  readonly existing: Lockfile | null;
718
719
  }
719
- declare function compareCompileToLockfile({ compiled, existing, }: CompareLockfileParams): LockfileComparison;
720
+ declare function compareCompileToLockfile({ compiled, cwd, existing, }: CompareLockfileParams): Promise<LockfileComparison>;
720
721
 
721
722
  export { type CompareLockfileParams, FIXTURES_RELATIVE_PATH, type FixtureEntry, LOCKFILE_RELATIVE_PATH, type Lockfile, type LockfileComparison, type ReadLockfileParams, type WriteLockfileParams, compareCompileToLockfile, compileResultToLockfile, hashFixturesIntoCompileResult, lockfileCodec, readLockfile, serializeLockfile, writeLockfile };
package/dist/lockfile.js CHANGED
@@ -642,14 +642,16 @@ function collectFixtureReferences(result) {
642
642
  });
643
643
  return names;
644
644
  }
645
- function compareCompileToLockfile({
645
+ async function compareCompileToLockfile({
646
646
  compiled,
647
+ cwd,
647
648
  existing
648
649
  }) {
649
650
  if (existing == null) {
650
651
  return "missing";
651
652
  }
652
- const fresh = serializeLockfile(compileResultToLockfile(compiled));
653
+ const hydrated = await hashFixturesIntoCompileResult({ cwd, result: compiled });
654
+ const fresh = serializeLockfile(compileResultToLockfile(hydrated));
653
655
  const current = serializeLockfile(existing);
654
656
  return fresh === current ? "match" : "stale";
655
657
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ripplo/testing",
3
3
  "description": "TypeScript DSL for defining and running Ripplo e2e workflow tests",
4
- "version": "0.5.2",
4
+ "version": "0.5.3",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"
@@ -99,8 +99,8 @@
99
99
  "tsup": "^8.5.1",
100
100
  "typescript": "catalog:",
101
101
  "vitest": "^4.1.4",
102
- "@ripplo/eslint-config": "0.0.0",
103
- "@ripplo/spec": "^0.0.0"
102
+ "@ripplo/spec": "^0.0.0",
103
+ "@ripplo/eslint-config": "0.0.0"
104
104
  },
105
105
  "peerDependencies": {
106
106
  "@nestjs/common": "^10.0.0 || ^11.0.0",