@orieljs/testing 0.1.0-alpha.1 → 0.1.0-alpha.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/index.js CHANGED
@@ -279,7 +279,7 @@ import { AuthFactory as AuthFactory2 } from "@orieljs/contracts";
279
279
  // Http/HttpClient.ts
280
280
  import {
281
281
  AuthFactory,
282
- ConfigRepository as ConfigRepository2,
282
+ ConfigRepository as ConfigRepository3,
283
283
  Encrypter as Encrypter2,
284
284
  ExceptionHandler,
285
285
  HttpKernel,
@@ -313,7 +313,407 @@ function clonePlain(value) {
313
313
 
314
314
  // TestResponse.ts
315
315
  import { Encrypter, UrlGenerator } from "@orieljs/contracts";
316
+ import { Arr as Arr3 } from "@orieljs/support";
317
+
318
+ // Fluent/AssertableInertia.ts
319
+ import { existsSync } from "fs";
320
+ import { join } from "path";
321
+ import { ConfigRepository as ConfigRepository2 } from "@orieljs/contracts";
322
+ import { Arr as Arr2 } from "@orieljs/support";
323
+
324
+ // Fluent/AssertableJson.ts
316
325
  import { Arr } from "@orieljs/support";
326
+ function typeOf(value) {
327
+ if (value === null) return ["null"];
328
+ if (Array.isArray(value)) return ["array"];
329
+ switch (typeof value) {
330
+ case "string":
331
+ return ["string"];
332
+ case "boolean":
333
+ return ["boolean"];
334
+ case "number":
335
+ return Number.isInteger(value) ? ["integer", "number"] : ["double", "float", "number"];
336
+ case "object":
337
+ return ["array", "object"];
338
+ default:
339
+ return [typeof value];
340
+ }
341
+ }
342
+ var AssertableJson = class _AssertableJson {
343
+ constructor(props, path = void 0) {
344
+ this.props = props;
345
+ this.path = path;
346
+ }
347
+ props;
348
+ path;
349
+ interactedKeys = [];
350
+ static fromJson(json) {
351
+ return new _AssertableJson(json);
352
+ }
353
+ /** A child scope of the same class (subclasses override to keep their extra state out of scopes). */
354
+ newScope(props, path) {
355
+ return new _AssertableJson(props, path);
356
+ }
357
+ dotPath(key = "") {
358
+ if (this.path === void 0) return key;
359
+ return key === "" ? this.path : `${this.path}.${key}`;
360
+ }
361
+ /** The value at `key` in this scope, or the whole scope. */
362
+ prop(key) {
363
+ if (key !== void 0 && this.hasOwnKey(key)) return this.props[key];
364
+ return Arr.get(this.props, key);
365
+ }
366
+ /** A literal key of this scope wins over a dot path, like Laravel's Arr::get (keys such as 'items.0.name'). */
367
+ hasOwnKey(key) {
368
+ return typeof this.props === "object" && this.props !== null && Object.hasOwn(this.props, key);
369
+ }
370
+ exists(key) {
371
+ return this.hasOwnKey(key) || Arr.has(this.props, key);
372
+ }
373
+ interactsWith(key) {
374
+ const prop = this.hasOwnKey(String(key)) ? String(key) : String(key).split(".")[0];
375
+ if (!this.interactedKeys.includes(prop)) this.interactedKeys.push(prop);
376
+ }
377
+ /** Every property of the scope was checked (called when a scope ends). */
378
+ interacted() {
379
+ const props = this.prop();
380
+ const keys = typeof props === "object" && props !== null ? Object.keys(props) : [];
381
+ const unexpected = keys.filter((key) => !this.interactedKeys.includes(key));
382
+ assert(
383
+ unexpected.length === 0,
384
+ this.path === void 0 ? "Unexpected properties were found on the root level." : `Unexpected properties were found in scope [${this.path}].`,
385
+ { actual: unexpected, expected: [] }
386
+ );
387
+ }
388
+ /** Allow the properties this scope didn't check. */
389
+ etc() {
390
+ const props = this.prop();
391
+ this.interactedKeys = typeof props === "object" && props !== null ? Object.keys(props) : [];
392
+ return this;
393
+ }
394
+ // Has ------------------------------------------------------------------------------------------------------
395
+ /** has('key'), has('key', 3), has('key', json => …), has('key', 3, first => …), or has(3) for the root size. */
396
+ has(key, length, callback) {
397
+ if (typeof key === "number" && length === void 0) return this.count(key);
398
+ const name = String(key);
399
+ assert(this.exists(name), `Property [${this.dotPath(name)}] does not exist.`);
400
+ this.interactsWith(name);
401
+ if (callback !== void 0) {
402
+ return this.has(name, (scope) => {
403
+ if (typeof length === "number") scope.count(length);
404
+ scope.first(callback).etc();
405
+ });
406
+ }
407
+ if (typeof length === "function") return this.scope(name, length);
408
+ if (typeof length === "number") return this.count(name, length);
409
+ return this;
410
+ }
411
+ /** hasAll(['a', 'b']) or hasAll({ items: 3 }). */
412
+ hasAll(keys) {
413
+ if (typeof keys === "string" || Array.isArray(keys)) {
414
+ for (const key of [keys].flat()) this.has(key);
415
+ return this;
416
+ }
417
+ for (const [key, length] of Object.entries(keys)) this.has(key, length);
418
+ return this;
419
+ }
420
+ hasAny(keys) {
421
+ const list = [keys].flat();
422
+ const present = list.filter((key) => this.exists(key));
423
+ assert(present.length > 0, `None of properties [${list.map((key) => this.dotPath(key)).join(", ")}] exist.`);
424
+ for (const key of present) this.interactsWith(key);
425
+ return this;
426
+ }
427
+ missing(key) {
428
+ assert(!this.exists(key), `Property [${this.dotPath(key)}] was found while it was expected to be missing.`);
429
+ return this;
430
+ }
431
+ missingAll(keys) {
432
+ for (const key of [keys].flat()) this.missing(key);
433
+ return this;
434
+ }
435
+ /** count(3) checks this scope's size; count('items', 3) a property's. */
436
+ count(key, length) {
437
+ if (typeof key === "number") {
438
+ const size2 = sizeOf(this.prop());
439
+ assert(size2 === key, this.path === void 0 ? "Root level does not have the expected size." : `Property [${this.path}] does not have the expected size.`, { actual: size2, expected: key });
440
+ return this;
441
+ }
442
+ this.has(key);
443
+ const size = sizeOf(this.prop(key));
444
+ assert(size === length, `Property [${this.dotPath(key)}] does not have the expected size.`, { actual: size, expected: length });
445
+ return this;
446
+ }
447
+ countBetween(key, min, max) {
448
+ this.has(key);
449
+ const size = sizeOf(this.prop(key));
450
+ assert(size >= min && size <= max, `Property [${this.dotPath(key)}] size is not between ${min} and ${max}.`, { actual: size });
451
+ return this;
452
+ }
453
+ // Matching -------------------------------------------------------------------------------------------------
454
+ /** where('name', 'Ann'), or where('name', value => value.startsWith('A')). Objects compare ignoring key order. */
455
+ where(key, expected) {
456
+ this.has(key);
457
+ const actual = this.prop(key);
458
+ if (typeof expected === "function") {
459
+ assert(expected(actual), `Property [${this.dotPath(key)}] was marked as invalid using a closure.`);
460
+ return this;
461
+ }
462
+ const normalized = toPlain(expected);
463
+ assert(equals(normalized, actual), `Property [${this.dotPath(key)}] does not match the expected value.`, { actual, expected: normalized });
464
+ return this;
465
+ }
466
+ whereNot(key, expected) {
467
+ this.has(key);
468
+ const actual = this.prop(key);
469
+ if (typeof expected === "function") {
470
+ assert(!expected(actual), `Property [${this.dotPath(key)}] was marked as invalid using a closure.`);
471
+ return this;
472
+ }
473
+ assert(!equals(toPlain(expected), actual), `Property [${this.dotPath(key)}] contains a value that should be missing: [${key}, ${format(expected)}]`);
474
+ return this;
475
+ }
476
+ whereNull(key) {
477
+ this.has(key);
478
+ const actual = this.prop(key);
479
+ assert(actual === null, `Property [${this.dotPath(key)}] should be null.`, { actual, expected: null });
480
+ return this;
481
+ }
482
+ whereNotNull(key) {
483
+ this.has(key);
484
+ assert(this.prop(key) !== null, `Property [${this.dotPath(key)}] should not be null.`);
485
+ return this;
486
+ }
487
+ whereAll(bindings) {
488
+ for (const [key, value] of Object.entries(bindings)) this.where(key, value);
489
+ return this;
490
+ }
491
+ /** whereType('id', 'integer'), whereType('name', 'string|null'), whereType('tags', ['array', 'null']). */
492
+ whereType(key, expected) {
493
+ this.has(key);
494
+ const types = typeof expected === "string" ? expected.split("|") : expected;
495
+ const actual = typeOf(this.prop(key));
496
+ assert(
497
+ types.some((type) => actual.includes(type)),
498
+ `Property [${this.dotPath(key)}] is not of expected type [${types.join("|")}].`,
499
+ { actual: actual[0], expected: types.join("|") }
500
+ );
501
+ return this;
502
+ }
503
+ whereAllType(bindings) {
504
+ for (const [key, type] of Object.entries(bindings)) this.whereType(key, type);
505
+ return this;
506
+ }
507
+ /** The list contains every expected value (or one passing the callback); a string contains the substring. */
508
+ whereContains(key, expected) {
509
+ this.has(key);
510
+ const actual = this.prop(key);
511
+ if (typeof actual === "string") {
512
+ assert(actual.includes(String(expected)), `Property [${this.dotPath(key)}] does not contain [${format(expected)}].`);
513
+ return this;
514
+ }
515
+ const values = typeof actual === "object" && actual !== null ? Object.values(actual) : [actual];
516
+ const wanted = Array.isArray(expected) ? expected : [expected];
517
+ const missing = wanted.filter(
518
+ (item) => typeof item === "function" ? !values.some((value) => item(value)) : !values.some((value) => equals(toPlain(item), value))
519
+ );
520
+ assert(missing.length === 0, `Property [${this.dotPath(key)}] does not contain [${missing.map(format).join(", ")}].`, { actual });
521
+ return this;
522
+ }
523
+ // Scoping --------------------------------------------------------------------------------------------------
524
+ scope(key, callback) {
525
+ const props = this.prop(key);
526
+ const path = this.dotPath(key);
527
+ assert(typeof props === "object" && props !== null, `Property [${path}] is not scopeable.`);
528
+ const scope = this.newScope(props, path);
529
+ callback(scope);
530
+ scope.interacted();
531
+ return this;
532
+ }
533
+ first(callback) {
534
+ const props = this.prop();
535
+ const keys = typeof props === "object" && props !== null ? Object.keys(props) : [];
536
+ if (keys.length === 0) {
537
+ fail(this.path === void 0 ? "Cannot scope directly onto the first element of the root level because it is empty." : `Cannot scope directly onto the first element of property [${this.path}] because it is empty.`);
538
+ }
539
+ this.interactsWith(keys[0]);
540
+ return this.scope(keys[0], callback);
541
+ }
542
+ each(callback) {
543
+ const props = this.prop();
544
+ const keys = typeof props === "object" && props !== null ? Object.keys(props) : [];
545
+ if (keys.length === 0) {
546
+ fail(this.path === void 0 ? "Cannot scope directly onto each element of the root level because it is empty." : `Cannot scope directly onto each element of property [${this.path}] because it is empty.`);
547
+ }
548
+ for (const key of keys) {
549
+ this.interactsWith(key);
550
+ this.scope(key, callback);
551
+ }
552
+ return this;
553
+ }
554
+ // Helpers --------------------------------------------------------------------------------------------------
555
+ when(condition, callback, otherwise) {
556
+ if (condition) callback(this);
557
+ else otherwise?.(this);
558
+ return this;
559
+ }
560
+ dump(key) {
561
+ console.log(format(this.prop(key)));
562
+ return this;
563
+ }
564
+ toArray() {
565
+ return this.prop();
566
+ }
567
+ };
568
+ function sizeOf(value) {
569
+ if (Array.isArray(value)) return value.length;
570
+ if (typeof value === "object" && value !== null) return Object.keys(value).length;
571
+ if (typeof value === "string") return value.length;
572
+ return 0;
573
+ }
574
+ function toPlain(value) {
575
+ return value === void 0 ? void 0 : JSON.parse(JSON.stringify(value));
576
+ }
577
+
578
+ // Fluent/AssertableInertia.ts
579
+ function inertiaPageOf(response) {
580
+ let page;
581
+ try {
582
+ if (response.headers.has("X-Inertia")) page = JSON.parse(response.content);
583
+ else {
584
+ const match = /<script data-page="[^"]*" type="application\/json">([\s\S]*?)<\/script>/.exec(response.content);
585
+ page = match === null ? void 0 : JSON.parse(match[1]);
586
+ }
587
+ } catch {
588
+ page = void 0;
589
+ }
590
+ const valid = typeof page === "object" && page !== null && ["component", "props", "url", "version"].every((key) => Object.hasOwn(page, key));
591
+ if (!valid) fail("Not a valid Inertia response.");
592
+ return page;
593
+ }
594
+ var AssertableInertia = class _AssertableInertia extends AssertableJson {
595
+ #page;
596
+ #response;
597
+ static fromTestResponse(response) {
598
+ const page = inertiaPageOf(response);
599
+ const instance = new _AssertableInertia(page.props);
600
+ instance.#page = page;
601
+ instance.#response = response;
602
+ return instance;
603
+ }
604
+ /** Scopes are plain AssertableJson: the page-level methods only make sense at the root. */
605
+ newScope(props, path) {
606
+ return new AssertableJson(props, path);
607
+ }
608
+ get page() {
609
+ if (this.#page === void 0) fail("This assertion is only available on the page root.");
610
+ return this.#page;
611
+ }
612
+ /** The component name; the page file must exist unless `shouldExist` is false (inertia.testing.ensure_pages_exist). */
613
+ component(value, shouldExist) {
614
+ const actual = this.page.component;
615
+ assert(actual === value, "Unexpected Inertia page component.", { actual, expected: value });
616
+ const app = this.#app();
617
+ const config = app?.bound(ConfigRepository2) ? app.make(ConfigRepository2) : void 0;
618
+ if (shouldExist === true || shouldExist === void 0 && config?.get("inertia.testing.ensure_pages_exist", true) !== false) {
619
+ const paths = config?.get("inertia.pages.paths", []) ?? [];
620
+ const extensions = config?.get("inertia.pages.extensions", []) ?? [];
621
+ const exists = paths.some((path) => extensions.some((extension) => existsSync(join(path, `${value}.${extension}`))));
622
+ if (!exists) fail(`Inertia page component file [${value}] does not exist.`);
623
+ }
624
+ return this;
625
+ }
626
+ url(value) {
627
+ assert(this.page.url === value, "Unexpected Inertia page url.", { actual: this.page.url, expected: value });
628
+ return this;
629
+ }
630
+ version(value) {
631
+ assert(this.page.version === value, "Unexpected Inertia asset version.", { actual: this.page.version, expected: value });
632
+ return this;
633
+ }
634
+ /** The flash data has `key` (dot paths allowed), equal to `expected` when given. */
635
+ hasFlash(key, ...expected) {
636
+ _AssertableInertia.assertFlashHas(this.page.flash ?? {}, key, ...expected);
637
+ return this;
638
+ }
639
+ missingFlash(key) {
640
+ _AssertableInertia.assertFlashMissing(this.page.flash ?? {}, key);
641
+ return this;
642
+ }
643
+ static assertFlashHas(flash, key, ...expected) {
644
+ assert(Arr2.has(flash, key), `Inertia Flash Data is missing key [${key}].`);
645
+ if (expected.length > 0) {
646
+ const actual = Arr2.get(flash, key);
647
+ assert(equals(actual, expected[0]), `Inertia Flash Data [${key}] does not match expected value.`, { actual, expected: expected[0] });
648
+ }
649
+ }
650
+ static assertFlashMissing(flash, key) {
651
+ assert(!Arr2.has(flash, key), `Inertia Flash Data has unexpected key [${key}].`);
652
+ }
653
+ /**
654
+ * Requests the page again as a partial reload (only/except) and checks it is the same page. Uses the test's
655
+ * HTTP client, so the session and cookies carry over.
656
+ */
657
+ async reload(callback, only, except) {
658
+ const client = this.#response?.context.client;
659
+ if (client === void 0) fail("reload() needs a response from the test HTTP client.");
660
+ const headers = {
661
+ "X-Inertia": "true",
662
+ "X-Requested-With": "XMLHttpRequest",
663
+ "X-Inertia-Version": this.page.version
664
+ };
665
+ const onlyList = only === void 0 ? void 0 : [only].flat().join(",");
666
+ const exceptList = except === void 0 ? void 0 : [except].flat().join(",");
667
+ if (onlyList !== void 0 || exceptList !== void 0) headers["X-Inertia-Partial-Component"] = this.page.component;
668
+ if (onlyList !== void 0) headers["X-Inertia-Partial-Data"] = onlyList;
669
+ if (exceptList !== void 0) headers["X-Inertia-Partial-Except"] = exceptList;
670
+ const response = await client.request("GET", this.page.url, { headers });
671
+ const reloaded = _AssertableInertia.fromTestResponse(response);
672
+ reloaded.component(this.page.component, false).url(this.page.url).version(this.page.version);
673
+ await callback?.(reloaded);
674
+ return this;
675
+ }
676
+ reloadOnly(only, callback) {
677
+ return this.reload(
678
+ async (page) => {
679
+ page.hasAll(typeof only === "string" ? only.split(",") : only);
680
+ await callback?.(page);
681
+ },
682
+ only
683
+ );
684
+ }
685
+ reloadExcept(except, callback) {
686
+ return this.reload(
687
+ async (page) => {
688
+ page.missingAll(typeof except === "string" ? except.split(",") : except);
689
+ await callback?.(page);
690
+ },
691
+ void 0,
692
+ except
693
+ );
694
+ }
695
+ /** Loads the deferred props of every group (or the given groups) in one partial reload. */
696
+ loadDeferredProps(groupsOrCallback, callback) {
697
+ const deferred = this.page.deferredProps ?? {};
698
+ const groups = typeof groupsOrCallback === "function" ? Object.keys(deferred) : [groupsOrCallback].flat();
699
+ const props = groups.flatMap((group) => deferred[group] ?? []);
700
+ return this.reloadOnly(props.join(","), typeof groupsOrCallback === "function" ? groupsOrCallback : callback);
701
+ }
702
+ toArray() {
703
+ return {
704
+ component: this.page.component,
705
+ props: this.prop(),
706
+ url: this.page.url,
707
+ version: this.page.version,
708
+ flash: this.page.flash ?? {},
709
+ ...this.page.encryptHistory === true ? { encryptHistory: true } : {},
710
+ ...this.page.clearHistory === true ? { clearHistory: true } : {}
711
+ };
712
+ }
713
+ #app() {
714
+ return this.#response?.context.app;
715
+ }
716
+ };
317
717
 
318
718
  // Http/cookies.ts
319
719
  import { createHmac } from "crypto";
@@ -413,7 +813,7 @@ var TestResponse = class _TestResponse {
413
813
  ${this.excerpt()}`);
414
814
  }
415
815
  }
416
- return Arr.get(this.decoded.value, path);
816
+ return Arr3.get(this.decoded.value, path);
417
817
  }
418
818
  dump(path) {
419
819
  console.log(path === void 0 ? this.content : this.json(path));
@@ -591,12 +991,44 @@ ${this.excerpt(text)}`);
591
991
  return this.inOrder(stripTags(this.content), this.needles(values, escape));
592
992
  }
593
993
  // JSON --------------------------------------------------------------------------------------------------
594
- /** The response JSON contains `data` (a subset match: extra keys in the response are fine). */
994
+ /**
995
+ * The response JSON contains `data` (a subset match: extra keys in the response are fine), or fluent
996
+ * assertions: assertJson(json => json.has('data', 3).etc()).
997
+ */
595
998
  assertJson(data) {
999
+ if (typeof data === "function") {
1000
+ const json = AssertableJson.fromJson(this.json());
1001
+ data(json);
1002
+ if (!Array.isArray(json.toArray())) json.interacted();
1003
+ return this;
1004
+ }
596
1005
  const actual = this.json();
597
1006
  assert(isSubset(data, actual), "Unable to find the expected JSON subset in the response.", { actual, expected: data });
598
1007
  return this;
599
1008
  }
1009
+ assertInertia(callback) {
1010
+ const page = AssertableInertia.fromTestResponse(this);
1011
+ const result = callback?.(page);
1012
+ if (typeof result?.then === "function") return Promise.resolve(result).then(() => this);
1013
+ return this;
1014
+ }
1015
+ /** The Inertia page object of this response. */
1016
+ inertiaPage() {
1017
+ return inertiaPageOf(this);
1018
+ }
1019
+ /** The page props, or one prop by dot path. */
1020
+ inertiaProps(key) {
1021
+ return Arr3.get(inertiaPageOf(this).props, key);
1022
+ }
1023
+ /** Inertia flash data waiting in the session for the next page (after a redirect). */
1024
+ assertInertiaFlash(key, ...expected) {
1025
+ AssertableInertia.assertFlashHas(this.session().get("inertia.flash_data", {}), key, ...expected);
1026
+ return this;
1027
+ }
1028
+ assertInertiaFlashMissing(key) {
1029
+ AssertableInertia.assertFlashMissing(this.session().get("inertia.flash_data", {}), key);
1030
+ return this;
1031
+ }
600
1032
  /** The response JSON equals `data` exactly (object key order is ignored). */
601
1033
  assertExactJson(data) {
602
1034
  const actual = this.json();
@@ -605,7 +1037,7 @@ ${this.excerpt(text)}`);
605
1037
  }
606
1038
  /** The value at `path` equals `expected` (strictly), or passes the predicate. */
607
1039
  assertJsonPath(path, expected) {
608
- assert(Arr.has(this.json(), path), `Failed asserting that the JSON has the path [${path}].`, { actual: this.json() });
1040
+ assert(Arr3.has(this.json(), path), `Failed asserting that the JSON has the path [${path}].`, { actual: this.json() });
609
1041
  const actual = this.json(path);
610
1042
  if (typeof expected === "function") {
611
1043
  assert(expected(actual) === true, `Failed asserting that the value at [${path}] passes the given check (got ${format(actual)}).`);
@@ -615,7 +1047,7 @@ ${this.excerpt(text)}`);
615
1047
  return this;
616
1048
  }
617
1049
  assertJsonMissingPath(path) {
618
- assert(!Arr.has(this.json(), path), `Failed asserting that the JSON does not have the path [${path}].`);
1050
+ assert(!Arr3.has(this.json(), path), `Failed asserting that the JSON does not have the path [${path}].`);
619
1051
  return this;
620
1052
  }
621
1053
  /** Each key/value pair appears somewhere in the JSON (Laravel's assertJsonFragment). */
@@ -665,7 +1097,7 @@ ${this.excerpt()}`);
665
1097
  /** No validation errors in the JSON (or none for these keys). */
666
1098
  assertJsonMissingValidationErrors(keys, responseKey = "errors") {
667
1099
  if (this.content === "") return this;
668
- const errors = Arr.get(this.json(), responseKey);
1100
+ const errors = Arr3.get(this.json(), responseKey);
669
1101
  if (errors === void 0 || errors === null) return this;
670
1102
  const unexpected = keys === void 0 ? Object.keys(errors) : [keys].flat().filter((key) => Object.hasOwn(errors, key));
671
1103
  assert(unexpected.length === 0, `Found unexpected validation error(s) for [${unexpected.join(", ")}]: ${format(errors)}`);
@@ -827,8 +1259,8 @@ ${JSON.stringify(errors, null, 2)}`, { actual: errors, expected: {} });
827
1259
  assertViewHas(key, value) {
828
1260
  if (typeof key !== "string") return this.assertViewHasAll(key);
829
1261
  const data = this.viewDataOf(this.ensureView());
830
- assert(Arr.has(data, key), `Failed asserting that the view has key [${key}].`, { actual: Object.keys(data) });
831
- const actual = Arr.get(data, key);
1262
+ assert(Arr3.has(data, key), `Failed asserting that the view has key [${key}].`, { actual: Object.keys(data) });
1263
+ const actual = Arr3.get(data, key);
832
1264
  if (typeof value === "function") assert(value(actual) === true, `View data [${key}] does not pass the given check.`);
833
1265
  else if (value !== void 0) assert(equals(actual, value), `View data [${key}] does not match the expected value.`, { actual, expected: value });
834
1266
  return this;
@@ -839,12 +1271,12 @@ ${JSON.stringify(errors, null, 2)}`, { actual: errors, expected: {} });
839
1271
  return this;
840
1272
  }
841
1273
  assertViewMissing(key) {
842
- assert(!Arr.has(this.viewDataOf(this.ensureView()), key), `Failed asserting that the view does not have key [${key}].`);
1274
+ assert(!Arr3.has(this.viewDataOf(this.ensureView()), key), `Failed asserting that the view does not have key [${key}].`);
843
1275
  return this;
844
1276
  }
845
1277
  /** The data the view received (dot path), or all of it. */
846
1278
  viewData(key) {
847
- return Arr.get(this.viewDataOf(this.ensureView()), key);
1279
+ return Arr3.get(this.viewDataOf(this.ensureView()), key);
848
1280
  }
849
1281
  // Internals ---------------------------------------------------------------------------------------------
850
1282
  absolute(url) {
@@ -1018,7 +1450,7 @@ var HttpClient = class {
1018
1450
  await app.boot();
1019
1451
  setClientAddress(request, "127.0.0.1");
1020
1452
  const scope = app.createScope();
1021
- const context = { request, app };
1453
+ const context = { request, app, client: this };
1022
1454
  const response = await scope.run(async () => {
1023
1455
  await this.beforeRequest(scope, context);
1024
1456
  this.previousUrl = void 0;
@@ -1110,7 +1542,7 @@ var HttpClient = class {
1110
1542
  return new Request(url, { method: verb, headers, body });
1111
1543
  }
1112
1544
  baseUrl() {
1113
- const configured = this.app.bound(ConfigRepository2) ? this.app.make(ConfigRepository2).get("app.url") : void 0;
1545
+ const configured = this.app.bound(ConfigRepository3) ? this.app.make(ConfigRepository3).get("app.url") : void 0;
1114
1546
  return typeof configured === "string" && configured !== "" ? configured : "http://localhost";
1115
1547
  }
1116
1548
  cookieHeader() {
@@ -2306,7 +2738,7 @@ var NotificationFake = class _NotificationFake {
2306
2738
 
2307
2739
  // Fakes/StorageFake.ts
2308
2740
  import { randomBytes } from "crypto";
2309
- import { ConfigRepository as ConfigRepository3, FilesystemManager } from "@orieljs/contracts";
2741
+ import { ConfigRepository as ConfigRepository4, FilesystemManager } from "@orieljs/contracts";
2310
2742
  var FakeDiskError = class extends Error {
2311
2743
  constructor(name, message, path) {
2312
2744
  super(message);
@@ -2516,7 +2948,7 @@ var StorageFake = class _StorageFake {
2516
2948
  disks = /* @__PURE__ */ new Map();
2517
2949
  static fake(disk) {
2518
2950
  const current = bound(FilesystemManager);
2519
- const config = bound(ConfigRepository3);
2951
+ const config = bound(ConfigRepository4);
2520
2952
  const fake = current instanceof _StorageFake ? current : install(FilesystemManager, new _StorageFake(current, config?.get("filesystems.default", "local") ?? "local"));
2521
2953
  const name = disk ?? fake.defaultDisk;
2522
2954
  const faked = new FakeDisk(name);
@@ -2648,6 +3080,8 @@ var FakeFile = {
2648
3080
  };
2649
3081
  export {
2650
3082
  AnonymousNotifiable,
3083
+ AssertableInertia,
3084
+ AssertableJson,
2651
3085
  BusFake,
2652
3086
  DatabaseMigrations,
2653
3087
  DatabaseTransactions,
@@ -2680,6 +3114,7 @@ export {
2680
3114
  encryptCookie,
2681
3115
  flatten,
2682
3116
  guessMimeType,
3117
+ inertiaPageOf,
2683
3118
  install,
2684
3119
  isExpired,
2685
3120
  isQueueable,