spana-test 0.2.0 → 0.3.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/README.md +47 -12
- package/dist/accessibility-audit-RS3VIWRT.js +140 -0
- package/dist/accessibility-audit-RS3VIWRT.js.map +1 -0
- package/dist/agent/index.d.ts +8 -26
- package/dist/agent/index.js +12 -15
- package/dist/{allure-PTTVORQ6.js → allure-RNMEYTXS.js} +42 -2
- package/dist/allure-RNMEYTXS.js.map +1 -0
- package/dist/appium-server-66GVUL24.js +119 -0
- package/dist/appium-server-66GVUL24.js.map +1 -0
- package/dist/baseline-manager-5TIUCNP5.js +38 -0
- package/dist/baseline-manager-5TIUCNP5.js.map +1 -0
- package/dist/{chunk-S2XNAKSO.js → chunk-24KSKK2I.js} +536 -334
- package/dist/chunk-24KSKK2I.js.map +1 -0
- package/dist/chunk-3J4NG7JU.js +80 -0
- package/dist/chunk-3J4NG7JU.js.map +1 -0
- package/dist/{chunk-MRH7SK52.js → chunk-3TRMQCUT.js} +3 -2
- package/dist/chunk-3TRMQCUT.js.map +1 -0
- package/dist/{chunk-SFBRFB2N.js → chunk-4OHBO7LD.js} +19 -12
- package/dist/chunk-4OHBO7LD.js.map +1 -0
- package/dist/chunk-5245YBLL.js +127 -0
- package/dist/chunk-5245YBLL.js.map +1 -0
- package/dist/{chunk-S4R4OR7T.js → chunk-7IA2XG3G.js} +66 -71
- package/dist/chunk-7IA2XG3G.js.map +1 -0
- package/dist/{chunk-L7MFJF46.js → chunk-7VOWF42B.js} +29 -5
- package/dist/chunk-7VOWF42B.js.map +1 -0
- package/dist/{chunk-AEKDFFPJ.js → chunk-DSTUWLSW.js} +15 -4
- package/dist/chunk-DSTUWLSW.js.map +1 -0
- package/dist/{chunk-P7JQRLP4.js → chunk-FJAJ4YNC.js} +14 -2
- package/dist/chunk-FJAJ4YNC.js.map +1 -0
- package/dist/chunk-IHVZKQQW.js +24 -0
- package/dist/chunk-IHVZKQQW.js.map +1 -0
- package/dist/{chunk-WQ4GXUUE.js → chunk-KAKHFSVA.js} +212 -34
- package/dist/chunk-KAKHFSVA.js.map +1 -0
- package/dist/chunk-OBCFACUW.js +28 -0
- package/dist/chunk-OBCFACUW.js.map +1 -0
- package/dist/{chunk-3YR4GUGE.js → chunk-QPIE3IMG.js} +65 -70
- package/dist/chunk-QPIE3IMG.js.map +1 -0
- package/dist/{chunk-VNYF5BHX.js → chunk-X2TJP7LB.js} +1 -3
- package/dist/{chunk-YBZCOQXJ.js → chunk-YXQEPVEW.js} +127 -66
- package/dist/chunk-YXQEPVEW.js.map +1 -0
- package/dist/cli.js +40 -25
- package/dist/cli.js.map +1 -1
- package/dist/{compiler-74VGKZO6.js → compiler-X6WTFMYF.js} +15 -7
- package/dist/compiler-X6WTFMYF.js.map +1 -0
- package/dist/config-loader-QM72GKEL.js +9 -0
- package/dist/{console-XWKUTP3D.js → console-7UW7VROK.js} +71 -1
- package/dist/console-7UW7VROK.js.map +1 -0
- package/dist/{discover-KZKXHZZA.js → discover-NPNF6SWQ.js} +4 -3
- package/dist/doctor-command-C3SEQGRQ.js +71 -0
- package/dist/doctor-command-C3SEQGRQ.js.map +1 -0
- package/dist/{flow-BUC9Mf8W.d.ts → flow-CW0_j7tw.d.ts} +47 -29
- package/dist/gherkin/steps.d.ts +2 -2
- package/dist/{html-GE6Q4DCG.js → html-F3X3XPSX.js} +78 -7
- package/dist/html-F3X3XPSX.js.map +1 -0
- package/dist/index.d.ts +4 -8
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/{init-command-GVMRXIMY.js → init-command-U66XCM66.js} +19 -34
- package/dist/init-command-U66XCM66.js.map +1 -0
- package/dist/init-flow-command-PR7J5FBM.js +37 -0
- package/dist/init-flow-command-PR7J5FBM.js.map +1 -0
- package/dist/{installer-YZJ4DV3F.js → installer-W5DITECS.js} +3 -4
- package/dist/{ios-ZW6XVNLG.js → ios-3GRECXAP.js} +3 -4
- package/dist/json-JMRPUVY2.js +20 -0
- package/dist/json-JMRPUVY2.js.map +1 -0
- package/dist/machine-6H25TRTU.js +16 -0
- package/dist/{provider-A57C3MU6.js → provider-YIPU5K42.js} +2 -2
- package/dist/{runner-UXNHVVGG.js → runner-6HK62Q7B.js} +2 -2
- package/dist/screenshot-compare-JFHH2WR4.js +75 -0
- package/dist/screenshot-compare-JFHH2WR4.js.map +1 -0
- package/dist/{server-W7OA3DDN.js → server-MZERO364.js} +362 -55
- package/dist/server-MZERO364.js.map +1 -0
- package/dist/session-3UZ5WAAD.js +17 -0
- package/dist/{coordinator-BbUjvvnX.d.ts → storybook-BK2JE4ld.d.ts} +95 -31
- package/dist/{studio-command-6VHTHDUK.js → studio-command-5BUER2RH.js} +2 -2
- package/dist/{test-command-AHMOZLV4.js → test-command-2PXTHASW.js} +871 -562
- package/dist/test-command-2PXTHASW.js.map +1 -0
- package/dist/{validator-35624P7S.js → validator-HZ2A3NEI.js} +3 -6
- package/dist/validator-HZ2A3NEI.js.map +1 -0
- package/package.json +6 -1
- package/studio-dist/assets/index-C-Io44gy.js +193 -0
- package/studio-dist/assets/index-DfM9lK4p.css +1 -0
- package/studio-dist/index.html +2 -2
- package/dist/allure-PTTVORQ6.js.map +0 -1
- package/dist/chunk-3YR4GUGE.js.map +0 -1
- package/dist/chunk-AEKDFFPJ.js.map +0 -1
- package/dist/chunk-BF37W5EG.js +0 -125
- package/dist/chunk-BF37W5EG.js.map +0 -1
- package/dist/chunk-EXLUY7KT.js +0 -21
- package/dist/chunk-EXLUY7KT.js.map +0 -1
- package/dist/chunk-FNDOEMOL.js +0 -62
- package/dist/chunk-FNDOEMOL.js.map +0 -1
- package/dist/chunk-HWFDXIXR.js +0 -183
- package/dist/chunk-HWFDXIXR.js.map +0 -1
- package/dist/chunk-IJIASIX5.js +0 -314
- package/dist/chunk-IJIASIX5.js.map +0 -1
- package/dist/chunk-L7MFJF46.js.map +0 -1
- package/dist/chunk-MRH7SK52.js.map +0 -1
- package/dist/chunk-P7JQRLP4.js.map +0 -1
- package/dist/chunk-S2XNAKSO.js.map +0 -1
- package/dist/chunk-S4R4OR7T.js.map +0 -1
- package/dist/chunk-SFBRFB2N.js.map +0 -1
- package/dist/chunk-WBU34APM.js +0 -38
- package/dist/chunk-WBU34APM.js.map +0 -1
- package/dist/chunk-WQ4GXUUE.js.map +0 -1
- package/dist/chunk-YBZCOQXJ.js.map +0 -1
- package/dist/compiler-74VGKZO6.js.map +0 -1
- package/dist/config-loader-BJJ3IJJ7.js +0 -9
- package/dist/console-XWKUTP3D.js.map +0 -1
- package/dist/doctor-command-T2UX5RV5.js +0 -732
- package/dist/doctor-command-T2UX5RV5.js.map +0 -1
- package/dist/html-GE6Q4DCG.js.map +0 -1
- package/dist/init-command-GVMRXIMY.js.map +0 -1
- package/dist/init-flow-command-R76AXF4Z.js +0 -34
- package/dist/init-flow-command-R76AXF4Z.js.map +0 -1
- package/dist/json-KS67BZYU.js +0 -39
- package/dist/json-KS67BZYU.js.map +0 -1
- package/dist/server-W7OA3DDN.js.map +0 -1
- package/dist/session-TMNOKYLG.js +0 -17
- package/dist/test-command-AHMOZLV4.js.map +0 -1
- package/studio-dist/assets/index-DC6DIXfl.js +0 -188
- package/studio-dist/assets/index-DDKsnBwD.css +0 -1
- /package/dist/{chunk-VNYF5BHX.js.map → chunk-X2TJP7LB.js.map} +0 -0
- /package/dist/{config-loader-BJJ3IJJ7.js.map → config-loader-QM72GKEL.js.map} +0 -0
- /package/dist/{discover-KZKXHZZA.js.map → discover-NPNF6SWQ.js.map} +0 -0
- /package/dist/{installer-YZJ4DV3F.js.map → installer-W5DITECS.js.map} +0 -0
- /package/dist/{ios-ZW6XVNLG.js.map → ios-3GRECXAP.js.map} +0 -0
- /package/dist/{provider-A57C3MU6.js.map → machine-6H25TRTU.js.map} +0 -0
- /package/dist/{runner-UXNHVVGG.js.map → provider-YIPU5K42.js.map} +0 -0
- /package/dist/{session-TMNOKYLG.js.map → runner-6HK62Q7B.js.map} +0 -0
- /package/dist/{validator-35624P7S.js.map → session-3UZ5WAAD.js.map} +0 -0
- /package/dist/{studio-command-6VHTHDUK.js.map → studio-command-5BUER2RH.js.map} +0 -0
|
@@ -19,34 +19,25 @@ var TextMismatchError = class extends Schema.TaggedError()(
|
|
|
19
19
|
}
|
|
20
20
|
) {
|
|
21
21
|
};
|
|
22
|
-
var TimeoutError = class extends Schema.TaggedError()(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
timeoutMs: Schema.Number
|
|
28
|
-
}
|
|
29
|
-
) {
|
|
22
|
+
var TimeoutError = class extends Schema.TaggedError()("TimeoutError", {
|
|
23
|
+
message: Schema.String,
|
|
24
|
+
operation: Schema.String,
|
|
25
|
+
timeoutMs: Schema.Number
|
|
26
|
+
}) {
|
|
30
27
|
};
|
|
31
|
-
var WaitTimeoutError = class extends Schema.TaggedError()(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
timeoutMs: Schema.Number
|
|
37
|
-
}
|
|
38
|
-
) {
|
|
28
|
+
var WaitTimeoutError = class extends Schema.TaggedError()("WaitTimeoutError", {
|
|
29
|
+
message: Schema.String,
|
|
30
|
+
selector: Schema.Unknown,
|
|
31
|
+
timeoutMs: Schema.Number
|
|
32
|
+
}) {
|
|
39
33
|
};
|
|
40
|
-
var DriverError = class extends Schema.TaggedError()(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
stderr: Schema.optional(Schema.String)
|
|
48
|
-
}
|
|
49
|
-
) {
|
|
34
|
+
var DriverError = class extends Schema.TaggedError()("DriverError", {
|
|
35
|
+
message: Schema.String,
|
|
36
|
+
command: Schema.optional(Schema.String),
|
|
37
|
+
exitCode: Schema.optional(Schema.Number),
|
|
38
|
+
stdout: Schema.optional(Schema.String),
|
|
39
|
+
stderr: Schema.optional(Schema.String)
|
|
40
|
+
}) {
|
|
50
41
|
};
|
|
51
42
|
var DeviceDisconnectedError = class extends Schema.TaggedError()(
|
|
52
43
|
"DeviceDisconnectedError",
|
|
@@ -57,14 +48,11 @@ var DeviceDisconnectedError = class extends Schema.TaggedError()(
|
|
|
57
48
|
}
|
|
58
49
|
) {
|
|
59
50
|
};
|
|
60
|
-
var AppCrashedError = class extends Schema.TaggedError()(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
platform: Schema.optional(Schema.String)
|
|
66
|
-
}
|
|
67
|
-
) {
|
|
51
|
+
var AppCrashedError = class extends Schema.TaggedError()("AppCrashedError", {
|
|
52
|
+
message: Schema.String,
|
|
53
|
+
appId: Schema.optional(Schema.String),
|
|
54
|
+
platform: Schema.optional(Schema.String)
|
|
55
|
+
}) {
|
|
68
56
|
};
|
|
69
57
|
var AppNotInstalledError = class extends Schema.TaggedError()(
|
|
70
58
|
"AppNotInstalledError",
|
|
@@ -75,13 +63,10 @@ var AppNotInstalledError = class extends Schema.TaggedError()(
|
|
|
75
63
|
}
|
|
76
64
|
) {
|
|
77
65
|
};
|
|
78
|
-
var FlowSyntaxError = class extends Schema.TaggedError()(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
filePath: Schema.String
|
|
83
|
-
}
|
|
84
|
-
) {
|
|
66
|
+
var FlowSyntaxError = class extends Schema.TaggedError()("FlowSyntaxError", {
|
|
67
|
+
message: Schema.String,
|
|
68
|
+
filePath: Schema.String
|
|
69
|
+
}) {
|
|
85
70
|
};
|
|
86
71
|
var DeviceNotFoundError = class extends Schema.TaggedError()(
|
|
87
72
|
"DeviceNotFoundError",
|
|
@@ -92,29 +77,26 @@ var DeviceNotFoundError = class extends Schema.TaggedError()(
|
|
|
92
77
|
}
|
|
93
78
|
) {
|
|
94
79
|
};
|
|
95
|
-
var ConfigError = class extends Schema.TaggedError()(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
filePath: Schema.optional(Schema.String)
|
|
100
|
-
}
|
|
101
|
-
) {
|
|
80
|
+
var ConfigError = class extends Schema.TaggedError()("ConfigError", {
|
|
81
|
+
message: Schema.String,
|
|
82
|
+
filePath: Schema.optional(Schema.String)
|
|
83
|
+
}) {
|
|
102
84
|
};
|
|
103
85
|
|
|
104
86
|
// src/schemas/selector.ts
|
|
105
87
|
import { Schema as Schema2 } from "effect";
|
|
106
|
-
var
|
|
107
|
-
var
|
|
108
|
-
var
|
|
109
|
-
var
|
|
88
|
+
var _TestIDSelectorSchema = Schema2.Struct({ testID: Schema2.String });
|
|
89
|
+
var _TextSelectorSchema = Schema2.Struct({ text: Schema2.String });
|
|
90
|
+
var _AccessibilityLabelSelectorSchema = Schema2.Struct({ accessibilityLabel: Schema2.String });
|
|
91
|
+
var _PointSelectorSchema = Schema2.Struct({
|
|
110
92
|
point: Schema2.Struct({ x: Schema2.Number, y: Schema2.Number })
|
|
111
93
|
});
|
|
112
|
-
var
|
|
94
|
+
var SelectorSchema = Schema2.Union(
|
|
113
95
|
Schema2.String,
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
96
|
+
_TestIDSelectorSchema,
|
|
97
|
+
_TextSelectorSchema,
|
|
98
|
+
_AccessibilityLabelSelectorSchema,
|
|
99
|
+
_PointSelectorSchema
|
|
118
100
|
);
|
|
119
101
|
function isRelativeSelector(sel) {
|
|
120
102
|
return typeof sel === "object" && sel !== null && "selector" in sel;
|
|
@@ -627,6 +609,334 @@ function createCoordinator(driver, config) {
|
|
|
627
609
|
yield* driver.back();
|
|
628
610
|
yield* afterMutation();
|
|
629
611
|
});
|
|
612
|
+
const scaleGesture = (methodName, selector, opts) => Effect3.gen(function* () {
|
|
613
|
+
const element = yield* waitForActionElement(
|
|
614
|
+
driver,
|
|
615
|
+
selector,
|
|
616
|
+
parse,
|
|
617
|
+
{ ...defaults, ...opts },
|
|
618
|
+
cache
|
|
619
|
+
);
|
|
620
|
+
const { x, y } = centerOf(element);
|
|
621
|
+
const scale = opts?.scale ?? 0.5;
|
|
622
|
+
const duration = opts?.duration ?? 1500;
|
|
623
|
+
const fn = methodName === "pinch" ? driver.pinch : driver.zoom;
|
|
624
|
+
if (!fn) {
|
|
625
|
+
return yield* new DriverError({
|
|
626
|
+
message: `${methodName}() is only supported on mobile platforms (Android/iOS)`
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
yield* fn.call(driver, x, y, scale, duration);
|
|
630
|
+
yield* afterMutation();
|
|
631
|
+
});
|
|
632
|
+
const assertEnabledState = (selector, expectedEnabled, opts) => Effect3.gen(function* () {
|
|
633
|
+
const element = yield* waitForElement(
|
|
634
|
+
driver,
|
|
635
|
+
selector,
|
|
636
|
+
parse,
|
|
637
|
+
{ ...defaults, ...opts },
|
|
638
|
+
cache
|
|
639
|
+
);
|
|
640
|
+
const isEnabled = element.enabled !== false;
|
|
641
|
+
if (isEnabled !== expectedEnabled) {
|
|
642
|
+
const state = expectedEnabled ? "enabled" : "disabled";
|
|
643
|
+
const actual = expectedEnabled ? "disabled" : "enabled";
|
|
644
|
+
return yield* new TextMismatchError({
|
|
645
|
+
message: `Expected element to be ${state} but it is ${actual} \u2014 selector: ${formatSelector(selector)}`,
|
|
646
|
+
expected: state,
|
|
647
|
+
actual,
|
|
648
|
+
selector
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
});
|
|
652
|
+
const createAssertions = () => ({
|
|
653
|
+
assertVisible: (selector, opts) => waitForElement(driver, selector, parse, { ...defaults, ...opts }, cache),
|
|
654
|
+
assertHidden: (selector, opts) => waitForNotVisible(driver, selector, parse, { ...defaults, ...opts }, cache),
|
|
655
|
+
assertText: (selector, expected, opts) => pollUntilMatch(
|
|
656
|
+
selector,
|
|
657
|
+
opts,
|
|
658
|
+
(el) => ({ matched: el.text === expected, actual: el.text }),
|
|
659
|
+
(actual, timeout) => ({
|
|
660
|
+
message: `Expected text "${expected}" but got "${actual ?? "(no text)"}" after ${timeout}ms`,
|
|
661
|
+
expected
|
|
662
|
+
})
|
|
663
|
+
),
|
|
664
|
+
assertContainsText: (selector, expected, opts) => pollUntilMatch(
|
|
665
|
+
selector,
|
|
666
|
+
opts,
|
|
667
|
+
(el) => {
|
|
668
|
+
const actual = el.text ?? "";
|
|
669
|
+
return {
|
|
670
|
+
matched: actual.toLowerCase().includes(expected.toLowerCase()),
|
|
671
|
+
actual: el.text
|
|
672
|
+
};
|
|
673
|
+
},
|
|
674
|
+
(actual, timeout) => ({
|
|
675
|
+
message: `Expected text to contain "${expected}" but got "${actual ?? "(no text)"}" after ${timeout}ms`,
|
|
676
|
+
expected
|
|
677
|
+
})
|
|
678
|
+
),
|
|
679
|
+
assertEnabled: (selector, opts) => assertEnabledState(selector, true, opts),
|
|
680
|
+
assertDisabled: (selector, opts) => assertEnabledState(selector, false, opts),
|
|
681
|
+
getText: (selector, opts) => Effect3.gen(function* () {
|
|
682
|
+
const element = yield* waitForElement(
|
|
683
|
+
driver,
|
|
684
|
+
selector,
|
|
685
|
+
parse,
|
|
686
|
+
{ ...defaults, ...opts },
|
|
687
|
+
cache
|
|
688
|
+
);
|
|
689
|
+
return element.text ?? "";
|
|
690
|
+
}),
|
|
691
|
+
isElementEnabled: (selector, opts) => Effect3.gen(function* () {
|
|
692
|
+
const element = yield* waitForElement(
|
|
693
|
+
driver,
|
|
694
|
+
selector,
|
|
695
|
+
parse,
|
|
696
|
+
{ ...defaults, ...opts },
|
|
697
|
+
cache
|
|
698
|
+
);
|
|
699
|
+
return element.enabled !== false;
|
|
700
|
+
}),
|
|
701
|
+
assertValue: (selector, expected, opts) => {
|
|
702
|
+
const expectedStr = String(expected);
|
|
703
|
+
return pollUntilMatch(
|
|
704
|
+
selector,
|
|
705
|
+
opts,
|
|
706
|
+
(el) => {
|
|
707
|
+
const actual = el.value ?? "";
|
|
708
|
+
return { matched: actual === expectedStr, actual };
|
|
709
|
+
},
|
|
710
|
+
(actual, timeout) => ({
|
|
711
|
+
message: `Expected value "${expectedStr}" but got "${actual ?? "(no value)"}" after ${timeout}ms`,
|
|
712
|
+
expected: expectedStr
|
|
713
|
+
})
|
|
714
|
+
);
|
|
715
|
+
},
|
|
716
|
+
assertAttribute: (selector, name, expectedValue, opts) => pollUntilMatch(
|
|
717
|
+
selector,
|
|
718
|
+
opts,
|
|
719
|
+
(el) => {
|
|
720
|
+
const actual = el.attributes?.[name];
|
|
721
|
+
if (expectedValue === void 0) {
|
|
722
|
+
return { matched: actual !== void 0, actual };
|
|
723
|
+
}
|
|
724
|
+
return { matched: actual === expectedValue, actual };
|
|
725
|
+
},
|
|
726
|
+
(actual, timeout) => expectedValue === void 0 ? {
|
|
727
|
+
message: `Expected attribute "${name}" to exist but it was not found after ${timeout}ms`,
|
|
728
|
+
expected: name
|
|
729
|
+
} : {
|
|
730
|
+
message: `Expected attribute "${name}" to be "${expectedValue}" but got "${actual ?? "(not found)"}" after ${timeout}ms`,
|
|
731
|
+
expected: expectedValue
|
|
732
|
+
}
|
|
733
|
+
),
|
|
734
|
+
assertMatchesText: (selector, pattern, opts) => pollUntilMatch(
|
|
735
|
+
selector,
|
|
736
|
+
opts,
|
|
737
|
+
(el) => {
|
|
738
|
+
const actual = el.text ?? "";
|
|
739
|
+
return { matched: pattern.test(actual), actual };
|
|
740
|
+
},
|
|
741
|
+
(actual, timeout) => ({
|
|
742
|
+
message: `Expected text to match ${pattern} but got "${actual ?? "(no text)"}" after ${timeout}ms`,
|
|
743
|
+
expected: String(pattern)
|
|
744
|
+
})
|
|
745
|
+
),
|
|
746
|
+
getAttribute: (selector, name, opts) => Effect3.gen(function* () {
|
|
747
|
+
const element = yield* waitForElement(
|
|
748
|
+
driver,
|
|
749
|
+
selector,
|
|
750
|
+
parse,
|
|
751
|
+
{ ...defaults, ...opts },
|
|
752
|
+
cache
|
|
753
|
+
);
|
|
754
|
+
return element.attributes?.[name];
|
|
755
|
+
}),
|
|
756
|
+
assertScreenshot: (selector, name, flowFilePath, flowName, platform, options) => Effect3.gen(function* () {
|
|
757
|
+
const { resolveBaselinePath, readBaseline, writeBaseline } = yield* Effect3.promise(
|
|
758
|
+
() => import("./baseline-manager-5TIUCNP5.js")
|
|
759
|
+
);
|
|
760
|
+
const { cropToElement, applyMask, compareScreenshots } = yield* Effect3.promise(
|
|
761
|
+
() => import("./screenshot-compare-JFHH2WR4.js")
|
|
762
|
+
);
|
|
763
|
+
const raw = yield* driver.takeScreenshot();
|
|
764
|
+
let screenshotBuf;
|
|
765
|
+
if (selector !== void 0) {
|
|
766
|
+
const element = yield* waitForElement(driver, selector, parse, { ...defaults }, cache);
|
|
767
|
+
screenshotBuf = yield* Effect3.promise(() => cropToElement(raw, element.bounds));
|
|
768
|
+
} else {
|
|
769
|
+
screenshotBuf = Buffer.from(raw);
|
|
770
|
+
}
|
|
771
|
+
const baselinePath = resolveBaselinePath(
|
|
772
|
+
flowFilePath,
|
|
773
|
+
flowName,
|
|
774
|
+
platform,
|
|
775
|
+
name,
|
|
776
|
+
options.baselinesDir
|
|
777
|
+
);
|
|
778
|
+
if (options.updateBaselines) {
|
|
779
|
+
yield* Effect3.promise(() => Promise.resolve(writeBaseline(baselinePath, screenshotBuf)));
|
|
780
|
+
return;
|
|
781
|
+
}
|
|
782
|
+
const existing = readBaseline(baselinePath);
|
|
783
|
+
if (existing === null) {
|
|
784
|
+
yield* Effect3.promise(() => Promise.resolve(writeBaseline(baselinePath, screenshotBuf)));
|
|
785
|
+
return;
|
|
786
|
+
}
|
|
787
|
+
let actualBuf = screenshotBuf;
|
|
788
|
+
if (options.mask && options.mask.length > 0) {
|
|
789
|
+
actualBuf = yield* Effect3.promise(() => applyMask(screenshotBuf, options.mask));
|
|
790
|
+
}
|
|
791
|
+
const result = compareScreenshots(existing, actualBuf, {
|
|
792
|
+
threshold: options.threshold,
|
|
793
|
+
maxDiffPixelRatio: options.maxDiffPixelRatio
|
|
794
|
+
});
|
|
795
|
+
if (!result.match) {
|
|
796
|
+
const { writeFileSync, mkdirSync } = yield* Effect3.promise(() => import("fs"));
|
|
797
|
+
const { join } = yield* Effect3.promise(() => import("path"));
|
|
798
|
+
const outDir = options.outputDir ?? config.outputDir ?? "spana-output";
|
|
799
|
+
mkdirSync(outDir, { recursive: true });
|
|
800
|
+
const safeFlowName = flowName.toLowerCase().replaceAll(/[^a-z0-9]+/g, "-").replaceAll(/^-|-$/g, "");
|
|
801
|
+
const prefix = join(outDir, `${safeFlowName}-${platform}-${name}`);
|
|
802
|
+
writeFileSync(`${prefix}-expected.png`, existing);
|
|
803
|
+
writeFileSync(`${prefix}-actual.png`, actualBuf);
|
|
804
|
+
if (result.diffImage) {
|
|
805
|
+
writeFileSync(`${prefix}-diff.png`, result.diffImage);
|
|
806
|
+
}
|
|
807
|
+
const detail = result.sizeMismatch ? "image dimensions differ" : `${result.diffPixelCount} differing pixels (ratio: ${(result.diffPixelRatio * 100).toFixed(2)}%)`;
|
|
808
|
+
return yield* new DriverError({
|
|
809
|
+
message: `Screenshot mismatch for "${name}": ${detail}. Expected: ${prefix}-expected.png, Actual: ${prefix}-actual.png${result.diffImage ? `, Diff: ${prefix}-diff.png` : ""}`
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
}),
|
|
813
|
+
assertAccessibilityLabel: (selector, expected, opts) => pollUntilMatch(
|
|
814
|
+
selector,
|
|
815
|
+
opts,
|
|
816
|
+
(el) => {
|
|
817
|
+
const label = el.accessibilityLabel;
|
|
818
|
+
if (expected === void 0) {
|
|
819
|
+
return { matched: label !== void 0 && label.length > 0, actual: label };
|
|
820
|
+
}
|
|
821
|
+
return { matched: label === expected, actual: label };
|
|
822
|
+
},
|
|
823
|
+
(actual, timeout) => expected === void 0 ? {
|
|
824
|
+
message: `Expected element to have a non-empty accessibilityLabel but got "${actual ?? "(none)"}" after ${timeout}ms`,
|
|
825
|
+
expected: "(non-empty)"
|
|
826
|
+
} : {
|
|
827
|
+
message: `Expected accessibilityLabel "${expected}" but got "${actual ?? "(none)"}" after ${timeout}ms`,
|
|
828
|
+
expected
|
|
829
|
+
}
|
|
830
|
+
),
|
|
831
|
+
assertFocusable: (selector, platform, opts) => Effect3.gen(function* () {
|
|
832
|
+
const { isFocusable } = yield* Effect3.promise(
|
|
833
|
+
() => import("./accessibility-audit-RS3VIWRT.js")
|
|
834
|
+
);
|
|
835
|
+
yield* pollUntilMatch(
|
|
836
|
+
selector,
|
|
837
|
+
opts,
|
|
838
|
+
(el) => {
|
|
839
|
+
const focusable = isFocusable(el, {
|
|
840
|
+
platform
|
|
841
|
+
});
|
|
842
|
+
return { matched: focusable, actual: focusable ? "focusable" : "not focusable" };
|
|
843
|
+
},
|
|
844
|
+
(actual, timeout) => ({
|
|
845
|
+
message: `Expected element to be focusable but it was "${actual ?? "not focusable"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
|
|
846
|
+
expected: "focusable"
|
|
847
|
+
})
|
|
848
|
+
);
|
|
849
|
+
}),
|
|
850
|
+
assertRole: (selector, expectedRole, platform, opts) => Effect3.gen(function* () {
|
|
851
|
+
const { normalizeRole } = yield* Effect3.promise(
|
|
852
|
+
() => import("./accessibility-audit-RS3VIWRT.js")
|
|
853
|
+
);
|
|
854
|
+
yield* pollUntilMatch(
|
|
855
|
+
selector,
|
|
856
|
+
opts,
|
|
857
|
+
(el) => {
|
|
858
|
+
const actual = normalizeRole(
|
|
859
|
+
platform,
|
|
860
|
+
el.elementType ?? "",
|
|
861
|
+
el.attributes ?? {}
|
|
862
|
+
);
|
|
863
|
+
return { matched: actual === expectedRole, actual };
|
|
864
|
+
},
|
|
865
|
+
(actual, timeout) => ({
|
|
866
|
+
message: `Expected role "${expectedRole}" but got "${actual ?? "(unknown)"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
|
|
867
|
+
expected: expectedRole
|
|
868
|
+
})
|
|
869
|
+
);
|
|
870
|
+
}),
|
|
871
|
+
assertMinTouchTarget: (selector, minSize, opts) => pollUntilMatch(
|
|
872
|
+
selector,
|
|
873
|
+
opts,
|
|
874
|
+
(el) => {
|
|
875
|
+
const { width, height } = el.bounds;
|
|
876
|
+
const passed = width >= minSize && height >= minSize;
|
|
877
|
+
const actual = `${width}x${height}`;
|
|
878
|
+
return { matched: passed, actual };
|
|
879
|
+
},
|
|
880
|
+
(actual, timeout) => ({
|
|
881
|
+
message: `Expected touch target to be at least ${minSize}x${minSize}px but got "${actual ?? "(unknown)"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
|
|
882
|
+
expected: `${minSize}x${minSize}`
|
|
883
|
+
})
|
|
884
|
+
),
|
|
885
|
+
assertAccessibilityAudit: (platform, options = {}) => Effect3.gen(function* () {
|
|
886
|
+
if (platform !== "web") {
|
|
887
|
+
return yield* new DriverError({
|
|
888
|
+
message: `assertAccessibilityAudit() is only supported on web \u2014 platform "${platform}" is not supported`
|
|
889
|
+
});
|
|
890
|
+
}
|
|
891
|
+
const { readFileSync } = yield* Effect3.promise(() => import("fs"));
|
|
892
|
+
const { createRequire } = yield* Effect3.promise(() => import("module"));
|
|
893
|
+
const require2 = createRequire(import.meta.url);
|
|
894
|
+
const axePath = require2.resolve("axe-core/axe.js");
|
|
895
|
+
const axeSource = readFileSync(axePath, "utf-8");
|
|
896
|
+
const { filterViolations, formatViolationSummary } = yield* Effect3.promise(
|
|
897
|
+
() => import("./accessibility-audit-RS3VIWRT.js")
|
|
898
|
+
);
|
|
899
|
+
const axeContext = {};
|
|
900
|
+
if (options.targetSelector) {
|
|
901
|
+
axeContext["include"] = [[options.targetSelector]];
|
|
902
|
+
}
|
|
903
|
+
if (options.excludeSelectors && options.excludeSelectors.length > 0) {
|
|
904
|
+
axeContext["exclude"] = options.excludeSelectors.map((s) => [s]);
|
|
905
|
+
}
|
|
906
|
+
const serializedContext = Object.keys(axeContext).length > 0 ? JSON.stringify(axeContext) : "document";
|
|
907
|
+
const axeOptions = {};
|
|
908
|
+
if (options.rules && options.rules.length > 0) {
|
|
909
|
+
const rulesConfig = {};
|
|
910
|
+
for (const r of options.rules) rulesConfig[r] = { enabled: true };
|
|
911
|
+
axeOptions["rules"] = rulesConfig;
|
|
912
|
+
}
|
|
913
|
+
const script = `
|
|
914
|
+
(function() {
|
|
915
|
+
${axeSource}
|
|
916
|
+
return axe.run(${serializedContext}, ${JSON.stringify(axeOptions)});
|
|
917
|
+
})()
|
|
918
|
+
`;
|
|
919
|
+
const axeResult = yield* driver.evaluate(script);
|
|
920
|
+
const violations = axeResult.violations.map((v) => ({
|
|
921
|
+
ruleId: v.id,
|
|
922
|
+
severity: v.impact ?? "minor",
|
|
923
|
+
description: v.description,
|
|
924
|
+
helpUrl: v.helpUrl,
|
|
925
|
+
wcagCriteria: v.tags.filter((t) => t.startsWith("wcag")),
|
|
926
|
+
elements: v.nodes.map((n) => ({
|
|
927
|
+
selector: n.target.join(", "),
|
|
928
|
+
html: n.html,
|
|
929
|
+
failureSummary: n.failureSummary
|
|
930
|
+
}))
|
|
931
|
+
}));
|
|
932
|
+
const minSeverity = options.severity ?? "serious";
|
|
933
|
+
const filtered = filterViolations(violations, minSeverity);
|
|
934
|
+
if (filtered.length > 0) {
|
|
935
|
+
const summary = formatViolationSummary(filtered);
|
|
936
|
+
return yield* new DriverError({ message: summary });
|
|
937
|
+
}
|
|
938
|
+
})
|
|
939
|
+
});
|
|
630
940
|
return {
|
|
631
941
|
tap: (selector, opts) => Effect3.gen(function* () {
|
|
632
942
|
const element = yield* waitForActionElement(
|
|
@@ -776,44 +1086,8 @@ function createCoordinator(driver, config) {
|
|
|
776
1086
|
timeoutMs: totalTimeout
|
|
777
1087
|
});
|
|
778
1088
|
}),
|
|
779
|
-
pinch: (selector, opts) =>
|
|
780
|
-
|
|
781
|
-
driver,
|
|
782
|
-
selector,
|
|
783
|
-
parse,
|
|
784
|
-
{ ...defaults, ...opts },
|
|
785
|
-
cache
|
|
786
|
-
);
|
|
787
|
-
const { x, y } = centerOf(element);
|
|
788
|
-
const scale = opts?.scale ?? 0.5;
|
|
789
|
-
const duration = opts?.duration ?? 1500;
|
|
790
|
-
if (!driver.pinch) {
|
|
791
|
-
return yield* new DriverError({
|
|
792
|
-
message: "pinch() is only supported on mobile platforms (Android/iOS)"
|
|
793
|
-
});
|
|
794
|
-
}
|
|
795
|
-
yield* driver.pinch(x, y, scale, duration);
|
|
796
|
-
yield* afterMutation();
|
|
797
|
-
}),
|
|
798
|
-
zoom: (selector, opts) => Effect3.gen(function* () {
|
|
799
|
-
const element = yield* waitForActionElement(
|
|
800
|
-
driver,
|
|
801
|
-
selector,
|
|
802
|
-
parse,
|
|
803
|
-
{ ...defaults, ...opts },
|
|
804
|
-
cache
|
|
805
|
-
);
|
|
806
|
-
const { x, y } = centerOf(element);
|
|
807
|
-
const scale = opts?.scale ?? 0.5;
|
|
808
|
-
const duration = opts?.duration ?? 1500;
|
|
809
|
-
if (!driver.zoom) {
|
|
810
|
-
return yield* new DriverError({
|
|
811
|
-
message: "zoom() is only supported on mobile platforms (Android/iOS)"
|
|
812
|
-
});
|
|
813
|
-
}
|
|
814
|
-
yield* driver.zoom(x, y, scale, duration);
|
|
815
|
-
yield* afterMutation();
|
|
816
|
-
}),
|
|
1089
|
+
pinch: (selector, opts) => scaleGesture("pinch", selector, opts),
|
|
1090
|
+
zoom: (selector, opts) => scaleGesture("zoom", selector, opts),
|
|
817
1091
|
multiTouch: (sequences) => Effect3.gen(function* () {
|
|
818
1092
|
if (!driver.multiTouch) {
|
|
819
1093
|
return yield* new DriverError({
|
|
@@ -823,265 +1097,193 @@ function createCoordinator(driver, config) {
|
|
|
823
1097
|
yield* driver.multiTouch(sequences);
|
|
824
1098
|
yield* afterMutation();
|
|
825
1099
|
}),
|
|
826
|
-
|
|
827
|
-
assertHidden: (selector, opts) => waitForNotVisible(driver, selector, parse, { ...defaults, ...opts }, cache),
|
|
828
|
-
assertText: (selector, expected, opts) => pollUntilMatch(
|
|
829
|
-
selector,
|
|
830
|
-
opts,
|
|
831
|
-
(el) => ({ matched: el.text === expected, actual: el.text }),
|
|
832
|
-
(actual, timeout) => ({
|
|
833
|
-
message: `Expected text "${expected}" but got "${actual ?? "(no text)"}" after ${timeout}ms`,
|
|
834
|
-
expected
|
|
835
|
-
})
|
|
836
|
-
),
|
|
837
|
-
assertContainsText: (selector, expected, opts) => pollUntilMatch(
|
|
838
|
-
selector,
|
|
839
|
-
opts,
|
|
840
|
-
(el) => {
|
|
841
|
-
const actual = el.text ?? "";
|
|
842
|
-
return {
|
|
843
|
-
matched: actual.toLowerCase().includes(expected.toLowerCase()),
|
|
844
|
-
actual: el.text
|
|
845
|
-
};
|
|
846
|
-
},
|
|
847
|
-
(actual, timeout) => ({
|
|
848
|
-
message: `Expected text to contain "${expected}" but got "${actual ?? "(no text)"}" after ${timeout}ms`,
|
|
849
|
-
expected
|
|
850
|
-
})
|
|
851
|
-
),
|
|
852
|
-
assertEnabled: (selector, opts) => Effect3.gen(function* () {
|
|
853
|
-
const element = yield* waitForElement(
|
|
854
|
-
driver,
|
|
855
|
-
selector,
|
|
856
|
-
parse,
|
|
857
|
-
{ ...defaults, ...opts },
|
|
858
|
-
cache
|
|
859
|
-
);
|
|
860
|
-
if (element.enabled === false) {
|
|
861
|
-
return yield* new TextMismatchError({
|
|
862
|
-
message: `Expected element to be enabled but it is disabled \u2014 selector: ${formatSelector(selector)}`,
|
|
863
|
-
expected: "enabled",
|
|
864
|
-
actual: "disabled",
|
|
865
|
-
selector
|
|
866
|
-
});
|
|
867
|
-
}
|
|
868
|
-
}),
|
|
869
|
-
assertDisabled: (selector, opts) => Effect3.gen(function* () {
|
|
870
|
-
const element = yield* waitForElement(
|
|
871
|
-
driver,
|
|
872
|
-
selector,
|
|
873
|
-
parse,
|
|
874
|
-
{ ...defaults, ...opts },
|
|
875
|
-
cache
|
|
876
|
-
);
|
|
877
|
-
if (element.enabled !== false) {
|
|
878
|
-
return yield* new TextMismatchError({
|
|
879
|
-
message: `Expected element to be disabled but it is enabled \u2014 selector: ${formatSelector(selector)}`,
|
|
880
|
-
expected: "disabled",
|
|
881
|
-
actual: "enabled",
|
|
882
|
-
selector
|
|
883
|
-
});
|
|
884
|
-
}
|
|
885
|
-
}),
|
|
886
|
-
getText: (selector, opts) => Effect3.gen(function* () {
|
|
887
|
-
const element = yield* waitForElement(
|
|
888
|
-
driver,
|
|
889
|
-
selector,
|
|
890
|
-
parse,
|
|
891
|
-
{ ...defaults, ...opts },
|
|
892
|
-
cache
|
|
893
|
-
);
|
|
894
|
-
return element.text ?? "";
|
|
895
|
-
}),
|
|
896
|
-
isElementEnabled: (selector, opts) => Effect3.gen(function* () {
|
|
897
|
-
const element = yield* waitForElement(
|
|
898
|
-
driver,
|
|
899
|
-
selector,
|
|
900
|
-
parse,
|
|
901
|
-
{ ...defaults, ...opts },
|
|
902
|
-
cache
|
|
903
|
-
);
|
|
904
|
-
return element.enabled !== false;
|
|
905
|
-
}),
|
|
906
|
-
assertValue: (selector, expected, opts) => {
|
|
907
|
-
const expectedStr = String(expected);
|
|
908
|
-
return pollUntilMatch(
|
|
909
|
-
selector,
|
|
910
|
-
opts,
|
|
911
|
-
(el) => {
|
|
912
|
-
const actual = el.value ?? "";
|
|
913
|
-
return { matched: actual === expectedStr, actual };
|
|
914
|
-
},
|
|
915
|
-
(actual, timeout) => ({
|
|
916
|
-
message: `Expected value "${expectedStr}" but got "${actual ?? "(no value)"}" after ${timeout}ms`,
|
|
917
|
-
expected: expectedStr
|
|
918
|
-
})
|
|
919
|
-
);
|
|
920
|
-
},
|
|
921
|
-
assertAttribute: (selector, name, expectedValue, opts) => pollUntilMatch(
|
|
922
|
-
selector,
|
|
923
|
-
opts,
|
|
924
|
-
(el) => {
|
|
925
|
-
const actual = el.attributes?.[name];
|
|
926
|
-
if (expectedValue === void 0) {
|
|
927
|
-
return { matched: actual !== void 0, actual };
|
|
928
|
-
}
|
|
929
|
-
return { matched: actual === expectedValue, actual };
|
|
930
|
-
},
|
|
931
|
-
(actual, timeout) => expectedValue === void 0 ? {
|
|
932
|
-
message: `Expected attribute "${name}" to exist but it was not found after ${timeout}ms`,
|
|
933
|
-
expected: name
|
|
934
|
-
} : {
|
|
935
|
-
message: `Expected attribute "${name}" to be "${expectedValue}" but got "${actual ?? "(not found)"}" after ${timeout}ms`,
|
|
936
|
-
expected: expectedValue
|
|
937
|
-
}
|
|
938
|
-
),
|
|
939
|
-
assertMatchesText: (selector, pattern, opts) => pollUntilMatch(
|
|
940
|
-
selector,
|
|
941
|
-
opts,
|
|
942
|
-
(el) => {
|
|
943
|
-
const actual = el.text ?? "";
|
|
944
|
-
return { matched: pattern.test(actual), actual };
|
|
945
|
-
},
|
|
946
|
-
(actual, timeout) => ({
|
|
947
|
-
message: `Expected text to match ${pattern} but got "${actual ?? "(no text)"}" after ${timeout}ms`,
|
|
948
|
-
expected: String(pattern)
|
|
949
|
-
})
|
|
950
|
-
),
|
|
951
|
-
getAttribute: (selector, name, opts) => Effect3.gen(function* () {
|
|
952
|
-
const element = yield* waitForElement(
|
|
953
|
-
driver,
|
|
954
|
-
selector,
|
|
955
|
-
parse,
|
|
956
|
-
{ ...defaults, ...opts },
|
|
957
|
-
cache
|
|
958
|
-
);
|
|
959
|
-
return element.attributes?.[name];
|
|
960
|
-
})
|
|
1100
|
+
...createAssertions()
|
|
961
1101
|
};
|
|
962
1102
|
}
|
|
963
1103
|
|
|
1104
|
+
// src/api/storybook.ts
|
|
1105
|
+
function assertSafeStorybookToken(group, key, value) {
|
|
1106
|
+
if (/[;:=]/.test(key)) {
|
|
1107
|
+
throw new DriverError({
|
|
1108
|
+
message: `openStory() ${group} key "${key}" contains unsupported Storybook query characters (;, :, =).`
|
|
1109
|
+
});
|
|
1110
|
+
}
|
|
1111
|
+
if (typeof value === "string" && /[;:]/.test(value)) {
|
|
1112
|
+
throw new DriverError({
|
|
1113
|
+
message: `openStory() ${group}.${key} contains unsupported Storybook query characters (; or :).`
|
|
1114
|
+
});
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
function encodeStorybookValue(value) {
|
|
1118
|
+
if (value === null) {
|
|
1119
|
+
return "!null";
|
|
1120
|
+
}
|
|
1121
|
+
return String(value);
|
|
1122
|
+
}
|
|
1123
|
+
function encodeStorybookEntries(group, entries) {
|
|
1124
|
+
if (!entries) {
|
|
1125
|
+
return void 0;
|
|
1126
|
+
}
|
|
1127
|
+
const pairs = Object.entries(entries);
|
|
1128
|
+
if (pairs.length === 0) {
|
|
1129
|
+
return void 0;
|
|
1130
|
+
}
|
|
1131
|
+
return pairs.map(([key, value]) => {
|
|
1132
|
+
assertSafeStorybookToken(group, key, value);
|
|
1133
|
+
return `${key}:${encodeStorybookValue(value)}`;
|
|
1134
|
+
}).join(";");
|
|
1135
|
+
}
|
|
1136
|
+
function buildStorybookUrl(storyId, options, runtime) {
|
|
1137
|
+
const trimmedStoryId = storyId.trim();
|
|
1138
|
+
if (!trimmedStoryId) {
|
|
1139
|
+
throw new DriverError({ message: "openStory() requires a non-empty Storybook story ID." });
|
|
1140
|
+
}
|
|
1141
|
+
const baseUrl = options?.baseUrl ?? runtime.storybook?.url ?? runtime.appBaseUrl;
|
|
1142
|
+
if (!baseUrl) {
|
|
1143
|
+
throw new DriverError({
|
|
1144
|
+
message: "openStory() requires apps.web.url, execution.web.storybook.url, or options.baseUrl."
|
|
1145
|
+
});
|
|
1146
|
+
}
|
|
1147
|
+
let url;
|
|
1148
|
+
try {
|
|
1149
|
+
url = new URL(runtime.storybook?.iframePath ?? "/iframe.html", baseUrl);
|
|
1150
|
+
} catch (error) {
|
|
1151
|
+
throw new DriverError({
|
|
1152
|
+
message: `openStory() could not build a Storybook URL from "${baseUrl}": ${error instanceof Error ? error.message : String(error)}`
|
|
1153
|
+
});
|
|
1154
|
+
}
|
|
1155
|
+
url.searchParams.set("id", trimmedStoryId);
|
|
1156
|
+
url.searchParams.set("viewMode", options?.viewMode ?? "story");
|
|
1157
|
+
const args = encodeStorybookEntries("args", options?.args);
|
|
1158
|
+
if (args) {
|
|
1159
|
+
url.searchParams.set("args", args);
|
|
1160
|
+
}
|
|
1161
|
+
const globals = encodeStorybookEntries("globals", options?.globals);
|
|
1162
|
+
if (globals) {
|
|
1163
|
+
url.searchParams.set("globals", globals);
|
|
1164
|
+
}
|
|
1165
|
+
return url.toString();
|
|
1166
|
+
}
|
|
1167
|
+
|
|
964
1168
|
// src/drivers/raw-driver.ts
|
|
965
1169
|
import { Context, Effect as Effect4 } from "effect";
|
|
966
1170
|
var RawDriver = class extends Context.Tag("RawDriver")() {
|
|
967
1171
|
};
|
|
968
|
-
|
|
969
|
-
|
|
1172
|
+
|
|
1173
|
+
// src/drivers/launch-options.ts
|
|
1174
|
+
function mergeRecord(base, override) {
|
|
1175
|
+
if (!base && !override) return void 0;
|
|
1176
|
+
return { ...base, ...override };
|
|
970
1177
|
}
|
|
971
|
-
function
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
`${methodName} failed (${Date.now() - startedAt}ms): ${error.message}`
|
|
986
|
-
);
|
|
987
|
-
})
|
|
988
|
-
)
|
|
989
|
-
);
|
|
990
|
-
};
|
|
1178
|
+
function stringifyLaunchValue(value) {
|
|
1179
|
+
if (typeof value === "string") return value;
|
|
1180
|
+
if (typeof value === "number" || typeof value === "boolean" || value == null) {
|
|
1181
|
+
return String(value);
|
|
1182
|
+
}
|
|
1183
|
+
return JSON.stringify(value);
|
|
1184
|
+
}
|
|
1185
|
+
function splitLocale(locale) {
|
|
1186
|
+
if (!locale) return {};
|
|
1187
|
+
const [language, ...rest] = locale.split(/[-_]/).filter(Boolean);
|
|
1188
|
+
if (!language || rest.length === 0) {
|
|
1189
|
+
return {};
|
|
1190
|
+
}
|
|
1191
|
+
return { language, remainder: rest.join("_") };
|
|
991
1192
|
}
|
|
992
|
-
function
|
|
993
|
-
|
|
1193
|
+
function resolveAndroidDeviceState(deviceState) {
|
|
1194
|
+
if (!deviceState) return {};
|
|
1195
|
+
const split = splitLocale(deviceState.locale);
|
|
1196
|
+
return {
|
|
1197
|
+
language: deviceState.language ?? split.language,
|
|
1198
|
+
locale: split.remainder ?? deviceState.locale,
|
|
1199
|
+
timeZone: deviceState.timeZone
|
|
1200
|
+
};
|
|
994
1201
|
}
|
|
995
|
-
function
|
|
996
|
-
|
|
1202
|
+
function resolveIOSDeviceState(deviceState) {
|
|
1203
|
+
if (!deviceState) return {};
|
|
1204
|
+
const split = splitLocale(deviceState.locale);
|
|
1205
|
+
const language = deviceState.language ?? split.language;
|
|
1206
|
+
const locale = deviceState.locale && split.remainder && language ? `${language}_${split.remainder}` : deviceState.locale && !split.remainder && language ? `${language}_${deviceState.locale}` : deviceState.locale?.replaceAll("-", "_");
|
|
1207
|
+
return {
|
|
1208
|
+
language,
|
|
1209
|
+
locale,
|
|
1210
|
+
timeZone: deviceState.timeZone
|
|
1211
|
+
};
|
|
997
1212
|
}
|
|
998
|
-
function
|
|
999
|
-
|
|
1213
|
+
function mergeLaunchOptions(base, override) {
|
|
1214
|
+
if (!base && !override) return void 0;
|
|
1000
1215
|
return {
|
|
1001
|
-
...
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
})
|
|
1020
|
-
)
|
|
1216
|
+
...base,
|
|
1217
|
+
...override,
|
|
1218
|
+
launchArguments: mergeRecord(base?.launchArguments, override?.launchArguments),
|
|
1219
|
+
deviceState: mergeRecord(base?.deviceState, override?.deviceState)
|
|
1220
|
+
};
|
|
1221
|
+
}
|
|
1222
|
+
function hasLaunchDeviceState(deviceState) {
|
|
1223
|
+
return Boolean(deviceState?.language || deviceState?.locale || deviceState?.timeZone);
|
|
1224
|
+
}
|
|
1225
|
+
function deviceStateToAppiumCapabilities(platform, deviceState) {
|
|
1226
|
+
const normalizedState = platform === "android" ? resolveAndroidDeviceState(deviceState) : resolveIOSDeviceState(deviceState);
|
|
1227
|
+
if (!normalizedState.language && !normalizedState.locale && !normalizedState.timeZone) return {};
|
|
1228
|
+
if (platform === "android") {
|
|
1229
|
+
const hasLanguage = Boolean(normalizedState.language);
|
|
1230
|
+
const hasLocale = Boolean(normalizedState.locale);
|
|
1231
|
+
if (hasLanguage !== hasLocale) {
|
|
1232
|
+
throw new Error(
|
|
1233
|
+
"Appium Android deviceState requires both language and locale when either is provided."
|
|
1021
1234
|
);
|
|
1022
|
-
}
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
driver.setNetworkConditions
|
|
1062
|
-
),
|
|
1063
|
-
saveCookies: wrapOptionalMethod(logs, "saveCookies", driver.saveCookies),
|
|
1064
|
-
loadCookies: wrapOptionalMethod(logs, "loadCookies", driver.loadCookies),
|
|
1065
|
-
saveAuthState: wrapOptionalMethod(logs, "saveAuthState", driver.saveAuthState),
|
|
1066
|
-
loadAuthState: wrapOptionalMethod(logs, "loadAuthState", driver.loadAuthState),
|
|
1067
|
-
downloadFile: wrapOptionalMethod(logs, "downloadFile", driver.downloadFile),
|
|
1068
|
-
uploadFile: wrapOptionalMethod(logs, "uploadFile", driver.uploadFile),
|
|
1069
|
-
newTab: wrapOptionalMethod(logs, "newTab", driver.newTab),
|
|
1070
|
-
switchToTab: wrapOptionalMethod(logs, "switchToTab", driver.switchToTab),
|
|
1071
|
-
closeTab: wrapOptionalMethod(logs, "closeTab", driver.closeTab),
|
|
1072
|
-
getTabIds: wrapOptionalMethod(logs, "getTabIds", driver.getTabIds),
|
|
1073
|
-
getConsoleLogs: wrapOptionalMethod(logs, "getConsoleLogs", driver.getConsoleLogs),
|
|
1074
|
-
getJSErrors: wrapOptionalMethod(logs, "getJSErrors", driver.getJSErrors),
|
|
1075
|
-
getHAR: wrapOptionalMethod(logs, "getHAR", driver.getHAR)
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
const capabilities = {};
|
|
1238
|
+
if (normalizedState.language) {
|
|
1239
|
+
capabilities["appium:language"] = normalizedState.language;
|
|
1240
|
+
}
|
|
1241
|
+
if (normalizedState.locale) {
|
|
1242
|
+
capabilities["appium:locale"] = normalizedState.locale;
|
|
1243
|
+
}
|
|
1244
|
+
if (normalizedState.timeZone) {
|
|
1245
|
+
capabilities[platform === "ios" ? "appium:appTimeZone" : "appium:timeZone"] = normalizedState.timeZone;
|
|
1246
|
+
}
|
|
1247
|
+
return capabilities;
|
|
1248
|
+
}
|
|
1249
|
+
function buildIOSLaunchConfiguration(options) {
|
|
1250
|
+
if (!options) return void 0;
|
|
1251
|
+
const argumentsList = [];
|
|
1252
|
+
const environment = {};
|
|
1253
|
+
const normalizedState = resolveIOSDeviceState(options.deviceState);
|
|
1254
|
+
if (normalizedState.language) {
|
|
1255
|
+
argumentsList.push("-AppleLanguages", `(${normalizedState.language})`);
|
|
1256
|
+
}
|
|
1257
|
+
if (normalizedState.locale) {
|
|
1258
|
+
argumentsList.push("-AppleLocale", normalizedState.locale);
|
|
1259
|
+
}
|
|
1260
|
+
if (options.launchArguments) {
|
|
1261
|
+
for (const [key, value] of Object.entries(options.launchArguments)) {
|
|
1262
|
+
argumentsList.push(`-${key}`, stringifyLaunchValue(value));
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
if (normalizedState.timeZone) {
|
|
1266
|
+
environment.TZ = normalizedState.timeZone;
|
|
1267
|
+
}
|
|
1268
|
+
if (argumentsList.length === 0 && Object.keys(environment).length === 0) {
|
|
1269
|
+
return void 0;
|
|
1270
|
+
}
|
|
1271
|
+
return {
|
|
1272
|
+
arguments: argumentsList.length > 0 ? argumentsList : void 0,
|
|
1273
|
+
environment: Object.keys(environment).length > 0 ? environment : void 0
|
|
1076
1274
|
};
|
|
1077
1275
|
}
|
|
1078
1276
|
|
|
1079
1277
|
export {
|
|
1080
1278
|
DriverError,
|
|
1279
|
+
mergeLaunchOptions,
|
|
1280
|
+
hasLaunchDeviceState,
|
|
1281
|
+
deviceStateToAppiumCapabilities,
|
|
1282
|
+
buildIOSLaunchConfiguration,
|
|
1081
1283
|
splitGraphemes,
|
|
1082
1284
|
flattenElements,
|
|
1083
1285
|
waitForElement,
|
|
1084
1286
|
createCoordinator,
|
|
1085
|
-
|
|
1287
|
+
buildStorybookUrl
|
|
1086
1288
|
};
|
|
1087
|
-
//# sourceMappingURL=chunk-
|
|
1289
|
+
//# sourceMappingURL=chunk-24KSKK2I.js.map
|