@redrockswebdevelopment/formstack-form-testing 0.1.36 → 0.1.37
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 +27 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +95 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -78,7 +78,7 @@ export const liveFormFieldTypeCoverage = {
|
|
|
78
78
|
domInteraction: true,
|
|
79
79
|
domAssertion: true,
|
|
80
80
|
reason: "Email fields behave like text fields with validation-specific assertions.",
|
|
81
|
-
recommendedHelpers: ["
|
|
81
|
+
recommendedHelpers: ["setLiveFormTextValue", "fillEmail", "waitForLiveFormValidationState"],
|
|
82
82
|
},
|
|
83
83
|
file: {
|
|
84
84
|
kind: "file",
|
|
@@ -114,7 +114,7 @@ export const liveFormFieldTypeCoverage = {
|
|
|
114
114
|
domInteraction: true,
|
|
115
115
|
domAssertion: true,
|
|
116
116
|
reason: "Number fields use simple value payloads; use validation assertions for numeric constraints.",
|
|
117
|
-
recommendedHelpers: ["
|
|
117
|
+
recommendedHelpers: ["setLiveFormTextValue", "fillNumber", "waitForLiveFormValidationState"],
|
|
118
118
|
},
|
|
119
119
|
pagebreak: {
|
|
120
120
|
kind: "pagebreak",
|
|
@@ -142,7 +142,7 @@ export const liveFormFieldTypeCoverage = {
|
|
|
142
142
|
domInteraction: true,
|
|
143
143
|
domAssertion: true,
|
|
144
144
|
reason: "Phone fields use simple value payloads; use DOM and validation assertions for formatting behavior.",
|
|
145
|
-
recommendedHelpers: ["
|
|
145
|
+
recommendedHelpers: ["setLiveFormTextValue", "fillPhone", "waitForLiveFormValidationState"],
|
|
146
146
|
},
|
|
147
147
|
product: {
|
|
148
148
|
kind: "product",
|
|
@@ -205,7 +205,7 @@ export const liveFormFieldTypeCoverage = {
|
|
|
205
205
|
domInteraction: true,
|
|
206
206
|
domAssertion: true,
|
|
207
207
|
reason: "Textarea fields use simple value payloads and stable DOM fill operations.",
|
|
208
|
-
recommendedHelpers: ["
|
|
208
|
+
recommendedHelpers: ["setLiveFormTextValue", "fillTextarea", "readLiveFormDomFieldState"],
|
|
209
209
|
},
|
|
210
210
|
text: {
|
|
211
211
|
kind: "text",
|
|
@@ -214,7 +214,7 @@ export const liveFormFieldTypeCoverage = {
|
|
|
214
214
|
domInteraction: true,
|
|
215
215
|
domAssertion: true,
|
|
216
216
|
reason: "Text fields use simple value payloads and stable DOM fill operations.",
|
|
217
|
-
recommendedHelpers: ["
|
|
217
|
+
recommendedHelpers: ["setLiveFormTextValue", "fillText", "readLiveFormDomFieldState"],
|
|
218
218
|
},
|
|
219
219
|
unknown: {
|
|
220
220
|
kind: "unknown",
|
|
@@ -4284,6 +4284,49 @@ export async function setLiveFormCheckboxValues(page, options) {
|
|
|
4284
4284
|
(commitControl?.ready ?? true),
|
|
4285
4285
|
};
|
|
4286
4286
|
}
|
|
4287
|
+
export async function setLiveFormTextValue(page, options) {
|
|
4288
|
+
const value = String(options.value);
|
|
4289
|
+
const fieldKind = options.fieldKind ?? "text";
|
|
4290
|
+
const transaction = await performLiveFormFieldTransaction(page, {
|
|
4291
|
+
write: {
|
|
4292
|
+
...(options.write ?? {}),
|
|
4293
|
+
target: options.target,
|
|
4294
|
+
value,
|
|
4295
|
+
notify: options.write?.notify ?? true,
|
|
4296
|
+
},
|
|
4297
|
+
fieldKind,
|
|
4298
|
+
waitForEvent: options.waitForEvent ?? true,
|
|
4299
|
+
dispatchDomEvents: options.dispatchDomEvents ?? "auto",
|
|
4300
|
+
afterQuiet: options.afterQuiet ?? { quietMs: 200, timeoutMs: 5_000 },
|
|
4301
|
+
...(options.afterValidation === undefined ? {} : { afterValidation: options.afterValidation }),
|
|
4302
|
+
});
|
|
4303
|
+
const dom = await waitForLiveFormDomFieldState(page, {
|
|
4304
|
+
...options.target,
|
|
4305
|
+
expectedValue: value,
|
|
4306
|
+
...(options.controlSelector === undefined ? {} : { controlSelector: options.controlSelector }),
|
|
4307
|
+
...(options.write?.timeoutMs === undefined ? {} : { timeoutMs: options.write.timeoutMs }),
|
|
4308
|
+
});
|
|
4309
|
+
const visibilityTargets = [
|
|
4310
|
+
...(options.expectVisible ?? []).map((target) => ({ ...target, visible: true })),
|
|
4311
|
+
...(options.expectHidden ?? []).map((target) => ({ ...target, visible: false })),
|
|
4312
|
+
];
|
|
4313
|
+
const visibility = visibilityTargets.length > 0
|
|
4314
|
+
? await waitForLiveFormVisibility(page, { targets: visibilityTargets })
|
|
4315
|
+
: undefined;
|
|
4316
|
+
return {
|
|
4317
|
+
value,
|
|
4318
|
+
transaction,
|
|
4319
|
+
dom,
|
|
4320
|
+
...(visibility ? { visibility } : {}),
|
|
4321
|
+
ok: transaction.write.valueMatched &&
|
|
4322
|
+
(transaction.event?.matched ?? true) &&
|
|
4323
|
+
(transaction.domDispatch ? transaction.domDispatch.matchedControlCount >= 1 : true) &&
|
|
4324
|
+
(transaction.quiet?.quiet ?? true) &&
|
|
4325
|
+
((transaction.validation?.inlineErrors.length ?? 0) === 0) &&
|
|
4326
|
+
dom.matched &&
|
|
4327
|
+
(visibility?.matched ?? true),
|
|
4328
|
+
};
|
|
4329
|
+
}
|
|
4287
4330
|
export async function setLiveFormChoiceValue(page, options) {
|
|
4288
4331
|
const payload = normalizeLiveFormChoiceValue(options.value);
|
|
4289
4332
|
const value = payload.value;
|
|
@@ -4722,6 +4765,18 @@ export async function answerProgressiveLiveFormField(page, options) {
|
|
|
4722
4765
|
...(validationOptions ? { afterValidation: validationOptions } : {}),
|
|
4723
4766
|
})
|
|
4724
4767
|
: undefined;
|
|
4768
|
+
const textTransaction = !checkboxTransaction && !choiceTransaction && !selectTransaction && !matrixTransaction && !nameTransaction && !addressTransaction && !productTransaction && !ratingTransaction && !dateTimeTransaction && ["text", "textarea", "email", "phone", "number"].includes(options.fieldKind ?? "")
|
|
4769
|
+
? await setLiveFormTextValue(page, {
|
|
4770
|
+
target: options.target,
|
|
4771
|
+
value: options.value,
|
|
4772
|
+
fieldKind: options.fieldKind,
|
|
4773
|
+
...(options.write === undefined ? {} : { write: options.write }),
|
|
4774
|
+
waitForEvent: options.waitForEvent ?? true,
|
|
4775
|
+
dispatchDomEvents: options.dispatchDomEvents ?? "auto",
|
|
4776
|
+
afterQuiet: options.afterQuiet ?? true,
|
|
4777
|
+
...(validationOptions ? { afterValidation: validationOptions } : {}),
|
|
4778
|
+
})
|
|
4779
|
+
: undefined;
|
|
4725
4780
|
const transaction = checkboxTransaction
|
|
4726
4781
|
? checkboxTransaction.transaction
|
|
4727
4782
|
: choiceTransaction
|
|
@@ -4740,19 +4795,21 @@ export async function answerProgressiveLiveFormField(page, options) {
|
|
|
4740
4795
|
? ratingTransaction.transaction
|
|
4741
4796
|
: dateTimeTransaction
|
|
4742
4797
|
? dateTimeTransaction.transaction
|
|
4743
|
-
:
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4798
|
+
: textTransaction
|
|
4799
|
+
? textTransaction.transaction
|
|
4800
|
+
: await performLiveFormFieldTransaction(page, {
|
|
4801
|
+
write: {
|
|
4802
|
+
...(options.write ?? {}),
|
|
4803
|
+
target: options.target,
|
|
4804
|
+
value: options.value,
|
|
4805
|
+
notify: options.write?.notify ?? true,
|
|
4806
|
+
},
|
|
4807
|
+
...(options.fieldKind ? { fieldKind: options.fieldKind } : {}),
|
|
4808
|
+
waitForEvent: options.waitForEvent ?? true,
|
|
4809
|
+
dispatchDomEvents: options.dispatchDomEvents ?? "auto",
|
|
4810
|
+
afterQuiet: options.afterQuiet ?? true,
|
|
4811
|
+
...(validationOptions ? { afterValidation: validationOptions } : {}),
|
|
4812
|
+
});
|
|
4756
4813
|
const visibilityTargets = [
|
|
4757
4814
|
...(options.expectVisible ?? []),
|
|
4758
4815
|
...(options.expectHidden ?? []).map((target) => ({ ...target, visible: false })),
|
|
@@ -6482,6 +6539,26 @@ export const liveFormFieldRecipes = {
|
|
|
6482
6539
|
});
|
|
6483
6540
|
},
|
|
6484
6541
|
}),
|
|
6542
|
+
setTextApi: (name, internalLabel, value, options = {}) => ({
|
|
6543
|
+
name,
|
|
6544
|
+
run: async (harness) => {
|
|
6545
|
+
await setLiveFormTextValue(harness.page, {
|
|
6546
|
+
target: { internalLabel },
|
|
6547
|
+
value,
|
|
6548
|
+
fieldKind: options.fieldKind && ["text", "textarea", "email", "phone", "number"].includes(options.fieldKind)
|
|
6549
|
+
? options.fieldKind
|
|
6550
|
+
: "text",
|
|
6551
|
+
write: { notify: options.notify ?? true },
|
|
6552
|
+
waitForEvent: options.waitForEvent ?? (options.notify ?? true),
|
|
6553
|
+
dispatchDomEvents: options.dispatchDomEvents ?? "auto",
|
|
6554
|
+
afterQuiet: options.waitForQuiet ?? true,
|
|
6555
|
+
});
|
|
6556
|
+
},
|
|
6557
|
+
}),
|
|
6558
|
+
setTextareaApi: (name, internalLabel, value, options = {}) => liveFormFieldRecipes.setTextApi(name, internalLabel, value, { ...options, fieldKind: "textarea" }),
|
|
6559
|
+
setEmailApi: (name, internalLabel, value, options = {}) => liveFormFieldRecipes.setTextApi(name, internalLabel, value, { ...options, fieldKind: "email" }),
|
|
6560
|
+
setPhoneApi: (name, internalLabel, value, options = {}) => liveFormFieldRecipes.setTextApi(name, internalLabel, value, { ...options, fieldKind: "phone" }),
|
|
6561
|
+
setNumberApi: (name, internalLabel, value, options = {}) => liveFormFieldRecipes.setTextApi(name, internalLabel, value, { ...options, fieldKind: "number" }),
|
|
6485
6562
|
setChoiceApi: (name, internalLabel, value, options = {}) => ({
|
|
6486
6563
|
name,
|
|
6487
6564
|
run: async (harness) => {
|