@endora-commerce/contracts 0.109.0 → 0.111.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/accept-language.d.ts +31 -0
- package/dist/accept-language.js +64 -0
- package/dist/actor.d.ts +16 -0
- package/dist/addresses.d.ts +35 -0
- package/dist/addresses.js +8 -1
- package/dist/admin-actions.d.ts +2 -0
- package/dist/admin-actions.js +18 -0
- package/dist/admin-contributions.d.ts +99 -12
- package/dist/admin-contributions.js +36 -10
- package/dist/admin-roles.d.ts +17 -2
- package/dist/admin-users.d.ts +9 -0
- package/dist/admin.d.ts +114 -4
- package/dist/admin.js +98 -3
- package/dist/api-keys.d.ts +22 -0
- package/dist/api-keys.js +4 -0
- package/dist/assets-library.d.ts +45 -0
- package/dist/assets-library.js +20 -3
- package/dist/audit-logs.d.ts +12 -0
- package/dist/audit-logs.js +12 -0
- package/dist/auth.d.ts +9 -0
- package/dist/auth.js +9 -0
- package/dist/blog.d.ts +382 -22
- package/dist/blog.js +199 -17
- package/dist/carts.d.ts +423 -36
- package/dist/carts.js +150 -12
- package/dist/catalog.d.ts +379 -208
- package/dist/catalog.js +241 -163
- package/dist/cms-brand.d.ts +14 -14
- package/dist/cms.d.ts +71 -16
- package/dist/cms.js +15 -0
- package/dist/command-hooks.d.ts +301 -0
- package/dist/command-hooks.js +248 -0
- package/dist/common.d.ts +23 -6
- package/dist/common.js +25 -2
- package/dist/comparisons.d.ts +21 -14
- package/dist/comparisons.js +2 -1
- package/dist/credit-limits.d.ts +22 -0
- package/dist/credit-limits.js +35 -0
- package/dist/crm.d.ts +134 -78
- package/dist/crm.js +21 -5
- package/dist/custom-fields.d.ts +417 -49
- package/dist/custom-fields.js +142 -1
- package/dist/customer-accounts.d.ts +324 -22
- package/dist/customer-accounts.js +43 -0
- package/dist/customer-notifications.d.ts +143 -0
- package/dist/customer-notifications.js +41 -0
- package/dist/customers.d.ts +92 -73
- package/dist/customers.js +98 -10
- package/dist/dictionary.d.ts +53 -0
- package/dist/dictionary.js +25 -0
- package/dist/document-templates.d.ts +12 -12
- package/dist/email.d.ts +34 -0
- package/dist/email.js +6 -0
- package/dist/errors.d.ts +431 -3
- package/dist/errors.js +523 -3
- package/dist/forms-logic.d.ts +79 -0
- package/dist/forms-logic.fixtures.d.ts +52 -0
- package/dist/forms-logic.fixtures.js +610 -0
- package/dist/forms-logic.js +699 -0
- package/dist/forms.d.ts +9833 -0
- package/dist/forms.js +827 -0
- package/dist/i18n.d.ts +34 -0
- package/dist/i18n.js +15 -0
- package/dist/import-export.d.ts +180 -0
- package/dist/import-export.js +60 -0
- package/dist/index.d.ts +16 -1
- package/dist/index.js +30 -1
- package/dist/inventory.d.ts +9 -9
- package/dist/invoice-ledger.d.ts +13 -13
- package/dist/invoices.d.ts +126 -0
- package/dist/invoices.js +53 -0
- package/dist/line-bounds.d.ts +53 -0
- package/dist/line-bounds.js +65 -0
- package/dist/megamenu.d.ts +27 -27
- package/dist/mfa.d.ts +210 -4
- package/dist/mfa.js +136 -0
- package/dist/modules.d.ts +56 -8
- package/dist/modules.js +128 -3
- package/dist/money-decimal.d.ts +54 -0
- package/dist/money-decimal.js +95 -0
- package/dist/newsletter.d.ts +4 -4
- package/dist/orders.d.ts +246 -12
- package/dist/orders.js +140 -7
- package/dist/organization-hooks.d.ts +99 -0
- package/dist/organization-hooks.js +22 -0
- package/dist/organization-registry-lookup.d.ts +362 -0
- package/dist/organization-registry-lookup.js +196 -0
- package/dist/organization-roles.d.ts +341 -0
- package/dist/organization-roles.js +218 -0
- package/dist/organizations.d.ts +1074 -103
- package/dist/organizations.js +293 -28
- package/dist/page-builder-props.d.ts +56 -56
- package/dist/pim-connector.d.ts +7 -3
- package/dist/pim-connector.js +6 -2
- package/dist/pim-field-path.d.ts +5 -1
- package/dist/pim-field-path.js +37 -81
- package/dist/pim-locale-mapping.d.ts +131 -0
- package/dist/pim-locale-mapping.js +193 -0
- package/dist/price-books.d.ts +215 -63
- package/dist/price-books.js +47 -2
- package/dist/price-lists.d.ts +13 -10
- package/dist/product-feeds.d.ts +249 -100
- package/dist/product-feeds.js +46 -2
- package/dist/product-scope-model.d.ts +161 -0
- package/dist/product-scope-model.js +161 -0
- package/dist/product-scope-overrides.d.ts +0 -103
- package/dist/product-scope-overrides.js +0 -54
- package/dist/product-scoped-values.d.ts +2610 -0
- package/dist/product-scoped-values.js +425 -0
- package/dist/product-scopes.d.ts +199 -64
- package/dist/product-scopes.js +120 -23
- package/dist/product-tax-rates.d.ts +38 -0
- package/dist/product-tax-rates.js +45 -0
- package/dist/product-url-keys.d.ts +51 -45
- package/dist/product-url-keys.js +73 -39
- package/dist/product-value-resolver.d.ts +37 -60
- package/dist/product-value-resolver.js +36 -96
- package/dist/projects.d.ts +76 -28
- package/dist/projects.js +53 -9
- package/dist/promotions.d.ts +163 -11
- package/dist/promotions.js +23 -1
- package/dist/pwa.d.ts +41 -2
- package/dist/quick-order.d.ts +159 -9
- package/dist/quick-order.js +79 -4
- package/dist/quote-requests.d.ts +231 -17
- package/dist/quote-requests.js +111 -9
- package/dist/record-references.d.ts +15 -15
- package/dist/record-references.js +2 -3
- package/dist/record-rich-text.js +2 -1
- package/dist/returns.d.ts +214 -52
- package/dist/returns.js +143 -28
- package/dist/sales-channels.d.ts +34 -3
- package/dist/sales-channels.js +16 -1
- package/dist/saved-list-views.d.ts +28 -0
- package/dist/saved-list-views.js +14 -1
- package/dist/schema-extensions.d.ts +36 -0
- package/dist/schema-extensions.js +29 -0
- package/dist/scoped-write-encoding.d.ts +100 -0
- package/dist/scoped-write-encoding.js +135 -0
- package/dist/search.d.ts +18 -16
- package/dist/seo.d.ts +83 -30
- package/dist/seo.js +8 -1
- package/dist/settings.d.ts +173 -2
- package/dist/settings.js +53 -2
- package/dist/shopping-lists.d.ts +63 -4
- package/dist/shopping-lists.js +57 -3
- package/dist/storefront-cache-tags.d.ts +22 -0
- package/dist/storefront-cache-tags.js +12 -0
- package/dist/storefront-value-overrides.d.ts +18 -56
- package/dist/storefront-value-overrides.js +11 -86
- package/dist/tasks.d.ts +27 -27
- package/dist/taxes.d.ts +27 -0
- package/dist/taxes.js +4 -0
- package/dist/transactional-emails.d.ts +48 -22
- package/dist/webhooks.d.ts +75 -0
- package/dist/webhooks.js +24 -0
- package/package.json +5 -3
- package/dist/actor.d.ts.map +0 -1
- package/dist/actor.js.map +0 -1
- package/dist/addresses.d.ts.map +0 -1
- package/dist/addresses.js.map +0 -1
- package/dist/admin-actions.d.ts.map +0 -1
- package/dist/admin-actions.js.map +0 -1
- package/dist/admin-contributions.d.ts.map +0 -1
- package/dist/admin-contributions.js.map +0 -1
- package/dist/admin-feedback.d.ts.map +0 -1
- package/dist/admin-feedback.js.map +0 -1
- package/dist/admin-i18n.d.ts.map +0 -1
- package/dist/admin-i18n.js.map +0 -1
- package/dist/admin-name.d.ts.map +0 -1
- package/dist/admin-name.js.map +0 -1
- package/dist/admin-notifications.d.ts.map +0 -1
- package/dist/admin-notifications.js.map +0 -1
- package/dist/admin-preferences.d.ts.map +0 -1
- package/dist/admin-preferences.js.map +0 -1
- package/dist/admin-roles.d.ts.map +0 -1
- package/dist/admin-roles.js.map +0 -1
- package/dist/admin-search.d.ts.map +0 -1
- package/dist/admin-search.js.map +0 -1
- package/dist/admin-users.d.ts.map +0 -1
- package/dist/admin-users.js.map +0 -1
- package/dist/admin.d.ts.map +0 -1
- package/dist/admin.js.map +0 -1
- package/dist/analytics.d.ts.map +0 -1
- package/dist/analytics.js.map +0 -1
- package/dist/api-keys.d.ts.map +0 -1
- package/dist/api-keys.js.map +0 -1
- package/dist/assets-library.d.ts.map +0 -1
- package/dist/assets-library.js.map +0 -1
- package/dist/audit-logs.d.ts.map +0 -1
- package/dist/audit-logs.js.map +0 -1
- package/dist/auth.d.ts.map +0 -1
- package/dist/auth.js.map +0 -1
- package/dist/blog.d.ts.map +0 -1
- package/dist/blog.js.map +0 -1
- package/dist/capabilities.d.ts.map +0 -1
- package/dist/capabilities.js.map +0 -1
- package/dist/carts.d.ts.map +0 -1
- package/dist/carts.js.map +0 -1
- package/dist/catalog.d.ts.map +0 -1
- package/dist/catalog.js.map +0 -1
- package/dist/cms-brand.d.ts.map +0 -1
- package/dist/cms-brand.js.map +0 -1
- package/dist/cms-contact-form.d.ts.map +0 -1
- package/dist/cms-contact-form.js.map +0 -1
- package/dist/cms.d.ts.map +0 -1
- package/dist/cms.js.map +0 -1
- package/dist/common.d.ts.map +0 -1
- package/dist/common.js.map +0 -1
- package/dist/comparisons.d.ts.map +0 -1
- package/dist/comparisons.js.map +0 -1
- package/dist/credentials.d.ts.map +0 -1
- package/dist/credentials.js.map +0 -1
- package/dist/credit-limits.d.ts.map +0 -1
- package/dist/credit-limits.js.map +0 -1
- package/dist/crm-rich-text.d.ts.map +0 -1
- package/dist/crm-rich-text.js.map +0 -1
- package/dist/crm.d.ts.map +0 -1
- package/dist/crm.js.map +0 -1
- package/dist/currencies.d.ts.map +0 -1
- package/dist/currencies.js.map +0 -1
- package/dist/custom-fields.d.ts.map +0 -1
- package/dist/custom-fields.js.map +0 -1
- package/dist/customer-accounts.d.ts.map +0 -1
- package/dist/customer-accounts.js.map +0 -1
- package/dist/customers.d.ts.map +0 -1
- package/dist/customers.js.map +0 -1
- package/dist/dictionary.d.ts.map +0 -1
- package/dist/dictionary.js.map +0 -1
- package/dist/document-templates.d.ts.map +0 -1
- package/dist/document-templates.js.map +0 -1
- package/dist/document-values.d.ts.map +0 -1
- package/dist/document-values.js.map +0 -1
- package/dist/email-address.d.ts.map +0 -1
- package/dist/email-address.js.map +0 -1
- package/dist/email.d.ts.map +0 -1
- package/dist/email.js.map +0 -1
- package/dist/envelopes.d.ts.map +0 -1
- package/dist/envelopes.js.map +0 -1
- package/dist/environment-inputs.d.ts.map +0 -1
- package/dist/environment-inputs.js.map +0 -1
- package/dist/erp-connector.d.ts.map +0 -1
- package/dist/erp-connector.js.map +0 -1
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js.map +0 -1
- package/dist/google-analytics.d.ts.map +0 -1
- package/dist/google-analytics.js.map +0 -1
- package/dist/google-tag-manager.d.ts.map +0 -1
- package/dist/google-tag-manager.js.map +0 -1
- package/dist/i18n.d.ts.map +0 -1
- package/dist/i18n.js.map +0 -1
- package/dist/import-export.d.ts.map +0 -1
- package/dist/import-export.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/inventory.d.ts.map +0 -1
- package/dist/inventory.js.map +0 -1
- package/dist/invoice-ledger.d.ts.map +0 -1
- package/dist/invoice-ledger.js.map +0 -1
- package/dist/invoices.d.ts.map +0 -1
- package/dist/invoices.js.map +0 -1
- package/dist/kernel.d.ts.map +0 -1
- package/dist/kernel.js.map +0 -1
- package/dist/languages.d.ts.map +0 -1
- package/dist/languages.js.map +0 -1
- package/dist/line-groups.d.ts.map +0 -1
- package/dist/line-groups.js.map +0 -1
- package/dist/linkedin-ads.d.ts.map +0 -1
- package/dist/linkedin-ads.js.map +0 -1
- package/dist/localized-name.d.ts.map +0 -1
- package/dist/localized-name.js.map +0 -1
- package/dist/megamenu.d.ts.map +0 -1
- package/dist/megamenu.js.map +0 -1
- package/dist/meta-ads.d.ts.map +0 -1
- package/dist/meta-ads.js.map +0 -1
- package/dist/mfa.d.ts.map +0 -1
- package/dist/mfa.js.map +0 -1
- package/dist/modules.d.ts.map +0 -1
- package/dist/modules.js.map +0 -1
- package/dist/money-decimal.d.ts.map +0 -1
- package/dist/money-decimal.js.map +0 -1
- package/dist/money-input.d.ts.map +0 -1
- package/dist/money-input.js.map +0 -1
- package/dist/newsletter.d.ts.map +0 -1
- package/dist/newsletter.js.map +0 -1
- package/dist/order-minimums.d.ts.map +0 -1
- package/dist/order-minimums.js.map +0 -1
- package/dist/orders.d.ts.map +0 -1
- package/dist/orders.js.map +0 -1
- package/dist/organizations.d.ts.map +0 -1
- package/dist/organizations.js.map +0 -1
- package/dist/page-builder-props.d.ts.map +0 -1
- package/dist/page-builder-props.js.map +0 -1
- package/dist/page-builder-values.d.ts.map +0 -1
- package/dist/page-builder-values.js.map +0 -1
- package/dist/pagination.d.ts.map +0 -1
- package/dist/pagination.js.map +0 -1
- package/dist/payment-methods.d.ts.map +0 -1
- package/dist/payment-methods.js.map +0 -1
- package/dist/payment-return-url.d.ts.map +0 -1
- package/dist/payment-return-url.js.map +0 -1
- package/dist/payments.d.ts.map +0 -1
- package/dist/payments.js.map +0 -1
- package/dist/pim-connector.d.ts.map +0 -1
- package/dist/pim-connector.js.map +0 -1
- package/dist/pim-field-path.d.ts.map +0 -1
- package/dist/pim-field-path.js.map +0 -1
- package/dist/platform-info.d.ts.map +0 -1
- package/dist/platform-info.js.map +0 -1
- package/dist/platform-language.d.ts.map +0 -1
- package/dist/platform-language.js.map +0 -1
- package/dist/price-book-decimal.d.ts.map +0 -1
- package/dist/price-book-decimal.js.map +0 -1
- package/dist/price-books.d.ts.map +0 -1
- package/dist/price-books.js.map +0 -1
- package/dist/price-lists.d.ts.map +0 -1
- package/dist/price-lists.js.map +0 -1
- package/dist/product-feeds.d.ts.map +0 -1
- package/dist/product-feeds.js.map +0 -1
- package/dist/product-scope-overrides.d.ts.map +0 -1
- package/dist/product-scope-overrides.js.map +0 -1
- package/dist/product-scopes.d.ts.map +0 -1
- package/dist/product-scopes.js.map +0 -1
- package/dist/product-summary-text.d.ts.map +0 -1
- package/dist/product-summary-text.js.map +0 -1
- package/dist/product-url-keys.d.ts.map +0 -1
- package/dist/product-url-keys.js.map +0 -1
- package/dist/product-value-resolver.d.ts.map +0 -1
- package/dist/product-value-resolver.js.map +0 -1
- package/dist/projects.d.ts.map +0 -1
- package/dist/projects.js.map +0 -1
- package/dist/promotions.d.ts.map +0 -1
- package/dist/promotions.js.map +0 -1
- package/dist/prompt-actions.d.ts.map +0 -1
- package/dist/prompt-actions.js.map +0 -1
- package/dist/pwa.d.ts.map +0 -1
- package/dist/pwa.js.map +0 -1
- package/dist/quick-order.d.ts.map +0 -1
- package/dist/quick-order.js.map +0 -1
- package/dist/quote-requests.d.ts.map +0 -1
- package/dist/quote-requests.js.map +0 -1
- package/dist/record-references.d.ts.map +0 -1
- package/dist/record-references.js.map +0 -1
- package/dist/record-rich-text.d.ts.map +0 -1
- package/dist/record-rich-text.js.map +0 -1
- package/dist/returns.d.ts.map +0 -1
- package/dist/returns.js.map +0 -1
- package/dist/sales-channels.d.ts.map +0 -1
- package/dist/sales-channels.js.map +0 -1
- package/dist/saved-list-views.d.ts.map +0 -1
- package/dist/saved-list-views.js.map +0 -1
- package/dist/scope-notice.d.ts.map +0 -1
- package/dist/scope-notice.js.map +0 -1
- package/dist/scoped-translations.d.ts +0 -48
- package/dist/scoped-translations.d.ts.map +0 -1
- package/dist/scoped-translations.js +0 -78
- package/dist/scoped-translations.js.map +0 -1
- package/dist/search.d.ts.map +0 -1
- package/dist/search.js.map +0 -1
- package/dist/seo.d.ts.map +0 -1
- package/dist/seo.js.map +0 -1
- package/dist/settings.d.ts.map +0 -1
- package/dist/settings.js.map +0 -1
- package/dist/shipments.d.ts.map +0 -1
- package/dist/shipments.js.map +0 -1
- package/dist/shipping-methods.d.ts.map +0 -1
- package/dist/shipping-methods.js.map +0 -1
- package/dist/shopping-lists.d.ts.map +0 -1
- package/dist/shopping-lists.js.map +0 -1
- package/dist/storefront-cache-tags.d.ts.map +0 -1
- package/dist/storefront-cache-tags.js.map +0 -1
- package/dist/storefront-language-path.d.ts.map +0 -1
- package/dist/storefront-language-path.js.map +0 -1
- package/dist/storefront-value-overrides.d.ts.map +0 -1
- package/dist/storefront-value-overrides.js.map +0 -1
- package/dist/tasks.d.ts.map +0 -1
- package/dist/tasks.js.map +0 -1
- package/dist/taxes.d.ts.map +0 -1
- package/dist/taxes.js.map +0 -1
- package/dist/text-normalization.d.ts.map +0 -1
- package/dist/text-normalization.js.map +0 -1
- package/dist/transactional-emails.d.ts.map +0 -1
- package/dist/transactional-emails.js.map +0 -1
- package/dist/webhooks.d.ts.map +0 -1
- package/dist/webhooks.js.map +0 -1
|
@@ -0,0 +1,610 @@
|
|
|
1
|
+
/** A definition with the neutral behaviour and restrictions; only the sections vary. */
|
|
2
|
+
export function fixtureDefinition(sections, texts = {}) {
|
|
3
|
+
return {
|
|
4
|
+
schemaVersion: 1,
|
|
5
|
+
sections: [...sections],
|
|
6
|
+
behaviour: {
|
|
7
|
+
confirmation: { type: 'message' },
|
|
8
|
+
captchaRequired: false,
|
|
9
|
+
confirmationEmail: { enabled: false, includeSummary: false },
|
|
10
|
+
},
|
|
11
|
+
restrictions: { maxEntries: null, availableFrom: null, availableUntil: null, signedInOnly: false },
|
|
12
|
+
texts,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
const ADDRESS_PARTS = {
|
|
16
|
+
street: { enabled: true, required: true },
|
|
17
|
+
line2: { enabled: false, required: false },
|
|
18
|
+
postalCode: { enabled: true, required: false },
|
|
19
|
+
city: { enabled: true, required: true },
|
|
20
|
+
country: { enabled: true, required: false },
|
|
21
|
+
};
|
|
22
|
+
/** `(a = x ∧ b = y) ∨ (a = z)` on `c` — the `and` connective inside groups, `or` between them. */
|
|
23
|
+
const AND_DEFINITION = fixtureDefinition([
|
|
24
|
+
{
|
|
25
|
+
id: 's1',
|
|
26
|
+
columns: 1,
|
|
27
|
+
fields: [
|
|
28
|
+
{ id: 'fa', type: 'text', key: 'a' },
|
|
29
|
+
{ id: 'fb', type: 'text', key: 'b' },
|
|
30
|
+
{
|
|
31
|
+
id: 'fc',
|
|
32
|
+
type: 'text',
|
|
33
|
+
key: 'c',
|
|
34
|
+
visibility: {
|
|
35
|
+
connective: 'and',
|
|
36
|
+
groups: [
|
|
37
|
+
[
|
|
38
|
+
{ fieldId: 'fa', operator: 'equals', value: 'x' },
|
|
39
|
+
{ fieldId: 'fb', operator: 'equals', value: 'y' },
|
|
40
|
+
],
|
|
41
|
+
[{ fieldId: 'fa', operator: 'equals', value: 'z' }],
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
]);
|
|
48
|
+
/** `(a = x ∨ n > 5) ∧ (n < 100)` on `c` — the `or` connective inside groups, `and` between them. */
|
|
49
|
+
const OR_DEFINITION = fixtureDefinition([
|
|
50
|
+
{
|
|
51
|
+
id: 's1',
|
|
52
|
+
columns: 1,
|
|
53
|
+
fields: [
|
|
54
|
+
{ id: 'fa', type: 'text', key: 'a' },
|
|
55
|
+
{ id: 'fn', type: 'number', key: 'n' },
|
|
56
|
+
{
|
|
57
|
+
id: 'fc',
|
|
58
|
+
type: 'text',
|
|
59
|
+
key: 'c',
|
|
60
|
+
visibility: {
|
|
61
|
+
connective: 'or',
|
|
62
|
+
groups: [
|
|
63
|
+
[
|
|
64
|
+
{ fieldId: 'fa', operator: 'equals', value: 'x' },
|
|
65
|
+
{ fieldId: 'fn', operator: 'greater_than', value: 5 },
|
|
66
|
+
],
|
|
67
|
+
[{ fieldId: 'fn', operator: 'less_than', value: 100 }],
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
]);
|
|
74
|
+
/** A section shown only when `a` is `show`; its fields go with it. */
|
|
75
|
+
const SECTION_RULE_DEFINITION = fixtureDefinition([
|
|
76
|
+
{ id: 's1', columns: 1, fields: [{ id: 'fa', type: 'radio', key: 'a', options: [
|
|
77
|
+
{ id: 'o1', value: 'show' },
|
|
78
|
+
{ id: 'o2', value: 'hide' },
|
|
79
|
+
] }] },
|
|
80
|
+
{
|
|
81
|
+
id: 's2',
|
|
82
|
+
columns: 2,
|
|
83
|
+
visibility: { connective: 'and', groups: [[{ fieldId: 'fa', operator: 'equals', value: 'show' }]] },
|
|
84
|
+
fields: [
|
|
85
|
+
{ id: 'fd', type: 'text', key: 'd' },
|
|
86
|
+
{ id: 'fe', type: 'email', key: 'e' },
|
|
87
|
+
],
|
|
88
|
+
},
|
|
89
|
+
]);
|
|
90
|
+
/** `b` shown when `a` is `x`; `c` shown when `b` is empty; `g` shown when `b` is not `filled`. */
|
|
91
|
+
const HIDDEN_AS_EMPTY_FIELDS = [
|
|
92
|
+
{ id: 'fa', type: 'text', key: 'a' },
|
|
93
|
+
{
|
|
94
|
+
id: 'fb',
|
|
95
|
+
type: 'text',
|
|
96
|
+
key: 'b',
|
|
97
|
+
visibility: { connective: 'and', groups: [[{ fieldId: 'fa', operator: 'equals', value: 'x' }]] },
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
id: 'fc',
|
|
101
|
+
type: 'text',
|
|
102
|
+
key: 'c',
|
|
103
|
+
visibility: { connective: 'and', groups: [[{ fieldId: 'fb', operator: 'is_empty' }]] },
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
id: 'fg',
|
|
107
|
+
type: 'text',
|
|
108
|
+
key: 'g',
|
|
109
|
+
visibility: { connective: 'and', groups: [[{ fieldId: 'fb', operator: 'not_equals', value: 'filled' }]] },
|
|
110
|
+
},
|
|
111
|
+
];
|
|
112
|
+
const HIDDEN_AS_EMPTY_DEFINITION = fixtureDefinition([
|
|
113
|
+
{ id: 's1', columns: 1, fields: [...HIDDEN_AS_EMPTY_FIELDS] },
|
|
114
|
+
]);
|
|
115
|
+
/** The same rules with the dependants written **before** what they depend on (B4). */
|
|
116
|
+
const HIDDEN_AS_EMPTY_REVERSED = fixtureDefinition([
|
|
117
|
+
{ id: 's1', columns: 1, fields: [...HIDDEN_AS_EMPTY_FIELDS].reverse() },
|
|
118
|
+
]);
|
|
119
|
+
/** `a` and `b` each shown only when the other is filled — a cycle `definitionIssues` refuses. */
|
|
120
|
+
const CYCLE_DEFINITION = fixtureDefinition([
|
|
121
|
+
{
|
|
122
|
+
id: 's1',
|
|
123
|
+
columns: 1,
|
|
124
|
+
fields: [
|
|
125
|
+
{
|
|
126
|
+
id: 'fa',
|
|
127
|
+
type: 'text',
|
|
128
|
+
key: 'a',
|
|
129
|
+
visibility: { connective: 'and', groups: [[{ fieldId: 'fb', operator: 'is_not_empty' }]] },
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
id: 'fb',
|
|
133
|
+
type: 'text',
|
|
134
|
+
key: 'b',
|
|
135
|
+
visibility: { connective: 'and', groups: [[{ fieldId: 'fa', operator: 'is_not_empty' }]] },
|
|
136
|
+
},
|
|
137
|
+
{ id: 'fz', type: 'text', key: 'z' },
|
|
138
|
+
],
|
|
139
|
+
},
|
|
140
|
+
]);
|
|
141
|
+
/** A checkbox group, a single checkbox and a date, each driving a field. */
|
|
142
|
+
const TYPED_CONDITIONS_DEFINITION = fixtureDefinition([
|
|
143
|
+
{
|
|
144
|
+
id: 's1',
|
|
145
|
+
columns: 1,
|
|
146
|
+
fields: [
|
|
147
|
+
{
|
|
148
|
+
id: 'ftopics',
|
|
149
|
+
type: 'checkboxes',
|
|
150
|
+
key: 'topics',
|
|
151
|
+
options: [
|
|
152
|
+
{ id: 'o1', value: 'sales' },
|
|
153
|
+
{ id: 'o2', value: 'support' },
|
|
154
|
+
],
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
id: 'fsupport',
|
|
158
|
+
type: 'textarea',
|
|
159
|
+
key: 'support_detail',
|
|
160
|
+
visibility: {
|
|
161
|
+
connective: 'and',
|
|
162
|
+
groups: [[{ fieldId: 'ftopics', operator: 'contains', value: 'support' }]],
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
{ id: 'fagree', type: 'checkbox', key: 'company' },
|
|
166
|
+
{
|
|
167
|
+
id: 'fvat',
|
|
168
|
+
type: 'text',
|
|
169
|
+
key: 'vat',
|
|
170
|
+
visibility: { connective: 'and', groups: [[{ fieldId: 'fagree', operator: 'equals', value: 'true' }]] },
|
|
171
|
+
},
|
|
172
|
+
{ id: 'fdate', type: 'datetime', key: 'visit', mode: 'date' },
|
|
173
|
+
{
|
|
174
|
+
id: 'flate',
|
|
175
|
+
type: 'text',
|
|
176
|
+
key: 'late_reason',
|
|
177
|
+
visibility: {
|
|
178
|
+
connective: 'and',
|
|
179
|
+
groups: [[{ fieldId: 'fdate', operator: 'greater_than', value: '2026-12-01' }]],
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
],
|
|
183
|
+
},
|
|
184
|
+
]);
|
|
185
|
+
export const FORMS_VISIBILITY_FIXTURES = [
|
|
186
|
+
{
|
|
187
|
+
name: 'and inside a group, or between groups: first group holds',
|
|
188
|
+
behaviour: 'FR-030',
|
|
189
|
+
definition: AND_DEFINITION,
|
|
190
|
+
answers: { a: 'x', b: 'y' },
|
|
191
|
+
expected: { sections: ['s1'], fields: ['fa', 'fb', 'fc'] },
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
name: 'and inside a group, or between groups: half of the first group holds',
|
|
195
|
+
behaviour: 'FR-030',
|
|
196
|
+
definition: AND_DEFINITION,
|
|
197
|
+
answers: { a: 'x', b: 'n' },
|
|
198
|
+
expected: { sections: ['s1'], fields: ['fa', 'fb'] },
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
name: 'and inside a group, or between groups: the second group holds alone',
|
|
202
|
+
behaviour: 'FR-030',
|
|
203
|
+
definition: AND_DEFINITION,
|
|
204
|
+
answers: { a: 'z' },
|
|
205
|
+
expected: { sections: ['s1'], fields: ['fa', 'fb', 'fc'] },
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
name: 'or inside a group, and between groups: a coerced number satisfies both groups',
|
|
209
|
+
behaviour: 'FR-030, B2',
|
|
210
|
+
definition: OR_DEFINITION,
|
|
211
|
+
answers: { a: 'no', n: '10' },
|
|
212
|
+
expected: { sections: ['s1'], fields: ['fa', 'fn', 'fc'] },
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
name: 'or inside a group, and between groups: the second group fails',
|
|
216
|
+
behaviour: 'FR-030, B2',
|
|
217
|
+
definition: OR_DEFINITION,
|
|
218
|
+
answers: { a: 'x', n: '150' },
|
|
219
|
+
expected: { sections: ['s1'], fields: ['fa', 'fn'] },
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
name: 'or inside a group: a comma decimal is a number',
|
|
223
|
+
behaviour: 'B2, B5',
|
|
224
|
+
definition: OR_DEFINITION,
|
|
225
|
+
answers: { a: 'no', n: '5,5' },
|
|
226
|
+
expected: { sections: ['s1'], fields: ['fa', 'fn', 'fc'] },
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
name: 'a section rule shows the section and its fields',
|
|
230
|
+
behaviour: 'US3-2',
|
|
231
|
+
definition: SECTION_RULE_DEFINITION,
|
|
232
|
+
answers: { a: 'show' },
|
|
233
|
+
expected: { sections: ['s1', 's2'], fields: ['fa', 'fd', 'fe'] },
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
name: 'a section rule hides the section and every field in it',
|
|
237
|
+
behaviour: 'US3-2',
|
|
238
|
+
definition: SECTION_RULE_DEFINITION,
|
|
239
|
+
answers: { a: 'hide', d: 'typed anyway' },
|
|
240
|
+
expected: { sections: ['s1'], fields: ['fa'] },
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
name: 'a hidden field counts as empty in a dependent condition',
|
|
244
|
+
behaviour: 'B3, US3-6',
|
|
245
|
+
definition: HIDDEN_AS_EMPTY_DEFINITION,
|
|
246
|
+
answers: { a: 'no', b: 'filled' },
|
|
247
|
+
expected: { sections: ['s1'], fields: ['fa', 'fc', 'fg'] },
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
name: 'a visible filled field is not empty',
|
|
251
|
+
behaviour: 'B3',
|
|
252
|
+
definition: HIDDEN_AS_EMPTY_DEFINITION,
|
|
253
|
+
answers: { a: 'x', b: 'filled' },
|
|
254
|
+
expected: { sections: ['s1'], fields: ['fa', 'fb'] },
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
name: 'order independence: dependants written first evaluate the same',
|
|
258
|
+
behaviour: 'B4',
|
|
259
|
+
definition: HIDDEN_AS_EMPTY_REVERSED,
|
|
260
|
+
answers: { a: 'no', b: 'filled' },
|
|
261
|
+
expected: { sections: ['s1'], fields: ['fa', 'fc', 'fg'] },
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
name: 'a cycle evaluates as hidden, defensively',
|
|
265
|
+
behaviour: 'B4',
|
|
266
|
+
definition: CYCLE_DEFINITION,
|
|
267
|
+
answers: { a: 'one', b: 'two' },
|
|
268
|
+
expected: { sections: ['s1'], fields: ['fz'] },
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
name: 'contains on a checkbox group, equals true on a checkbox, greater than on a date',
|
|
272
|
+
behaviour: 'R-6',
|
|
273
|
+
definition: TYPED_CONDITIONS_DEFINITION,
|
|
274
|
+
answers: { topics: ['support'], company: 'on', visit: '2026-12-24' },
|
|
275
|
+
expected: { sections: ['s1'], fields: ['ftopics', 'fsupport', 'fagree', 'fvat', 'fdate', 'flate'] },
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
name: 'an unticked checkbox and an earlier date hide their dependants',
|
|
279
|
+
behaviour: 'R-6',
|
|
280
|
+
definition: TYPED_CONDITIONS_DEFINITION,
|
|
281
|
+
answers: { topics: ['sales'], visit: '2026-11-15' },
|
|
282
|
+
expected: { sections: ['s1'], fields: ['ftopics', 'fagree', 'fdate'] },
|
|
283
|
+
},
|
|
284
|
+
];
|
|
285
|
+
/** One field of every input type that validates, for the submission cases. */
|
|
286
|
+
const EVERY_TYPE_DEFINITION = fixtureDefinition([
|
|
287
|
+
{
|
|
288
|
+
id: 's1',
|
|
289
|
+
columns: 3,
|
|
290
|
+
fields: [
|
|
291
|
+
{ id: 'f1', type: 'text', key: 'name', required: true, minLength: 2, maxLength: 40 },
|
|
292
|
+
{ id: 'f2', type: 'email', key: 'email', required: true, submitterEmail: true },
|
|
293
|
+
{ id: 'f3', type: 'phone', key: 'phone' },
|
|
294
|
+
{ id: 'f4', type: 'number', key: 'quantity', min: 1, max: 10, step: 0.5 },
|
|
295
|
+
{ id: 'f5', type: 'textarea', key: 'message', maxLength: 200 },
|
|
296
|
+
{
|
|
297
|
+
id: 'f6',
|
|
298
|
+
type: 'select',
|
|
299
|
+
key: 'topic',
|
|
300
|
+
options: [
|
|
301
|
+
{ id: 'o1', value: 'sales' },
|
|
302
|
+
{ id: 'o2', value: 'support' },
|
|
303
|
+
],
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
id: 'f7',
|
|
307
|
+
type: 'radio',
|
|
308
|
+
key: 'contact_by',
|
|
309
|
+
options: [
|
|
310
|
+
{ id: 'o1', value: 'email' },
|
|
311
|
+
{ id: 'o2', value: 'phone' },
|
|
312
|
+
],
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
id: 'f8',
|
|
316
|
+
type: 'checkboxes',
|
|
317
|
+
key: 'interests',
|
|
318
|
+
minSelected: 1,
|
|
319
|
+
maxSelected: 2,
|
|
320
|
+
options: [
|
|
321
|
+
{ id: 'o1', value: 'doors' },
|
|
322
|
+
{ id: 'o2', value: 'windows' },
|
|
323
|
+
{ id: 'o3', value: 'gates' },
|
|
324
|
+
],
|
|
325
|
+
},
|
|
326
|
+
{ id: 'f9', type: 'checkbox', key: 'company' },
|
|
327
|
+
{ id: 'f10', type: 'datetime', key: 'visit', mode: 'date', earliest: '2026-01-01', latest: '2026-12-31' },
|
|
328
|
+
{ id: 'f11', type: 'country', key: 'country', allowedCountries: ['PL', 'DE'] },
|
|
329
|
+
{ id: 'f12', type: 'address', key: 'address', parts: ADDRESS_PARTS },
|
|
330
|
+
{ id: 'f13', type: 'hidden', key: 'campaign', source: 'query_param', paramName: 'utm_campaign' },
|
|
331
|
+
{ id: 'f14', type: 'privacy_consent', key: 'privacy', required: true },
|
|
332
|
+
{ id: 'f15', type: 'marketing_consent', key: 'marketing' },
|
|
333
|
+
{ id: 'f16', type: 'terms', key: 'terms', required: true },
|
|
334
|
+
{ id: 'f17', type: 'content' },
|
|
335
|
+
{ id: 'f18', type: 'section_break' },
|
|
336
|
+
],
|
|
337
|
+
},
|
|
338
|
+
]);
|
|
339
|
+
const EVERY_TYPE_VALID_RAW = {
|
|
340
|
+
name: ' Ann Smith ',
|
|
341
|
+
email: ' Ann@Example.COM ',
|
|
342
|
+
phone: '+48 600 100 200',
|
|
343
|
+
quantity: '2,5',
|
|
344
|
+
message: 'Line one\nLine two',
|
|
345
|
+
topic: 'support',
|
|
346
|
+
contact_by: 'email',
|
|
347
|
+
interests: ['doors', 'gates'],
|
|
348
|
+
company: 'on',
|
|
349
|
+
visit: '2026-06-30',
|
|
350
|
+
country: 'pl',
|
|
351
|
+
'address.street': 'Main 1',
|
|
352
|
+
'address.postalCode': '00-001',
|
|
353
|
+
'address.city': 'Warsaw',
|
|
354
|
+
'address.country': 'PL',
|
|
355
|
+
campaign: 'autumn',
|
|
356
|
+
privacy: 'on',
|
|
357
|
+
terms: 'true',
|
|
358
|
+
};
|
|
359
|
+
/** The patterns, and a hidden value over the cap. */
|
|
360
|
+
const PATTERN_DEFINITION = fixtureDefinition([
|
|
361
|
+
{
|
|
362
|
+
id: 's1',
|
|
363
|
+
columns: 1,
|
|
364
|
+
fields: [
|
|
365
|
+
{ id: 'p1', type: 'text', key: 'digits', pattern: 'digits' },
|
|
366
|
+
{ id: 'p2', type: 'text', key: 'letters', pattern: 'letters' },
|
|
367
|
+
{ id: 'p3', type: 'text', key: 'alnum', pattern: 'alphanumeric' },
|
|
368
|
+
{ id: 'p4', type: 'text', key: 'site', pattern: 'url' },
|
|
369
|
+
{ id: 'p5', type: 'hidden', key: 'page', source: 'page_url' },
|
|
370
|
+
],
|
|
371
|
+
},
|
|
372
|
+
]);
|
|
373
|
+
/** A required field behind a rule, for B2/B3 at the server. */
|
|
374
|
+
const CONDITIONAL_REQUIRED_DEFINITION = fixtureDefinition([
|
|
375
|
+
{
|
|
376
|
+
id: 's1',
|
|
377
|
+
columns: 1,
|
|
378
|
+
fields: [
|
|
379
|
+
{
|
|
380
|
+
id: 'fa',
|
|
381
|
+
type: 'radio',
|
|
382
|
+
key: 'kind',
|
|
383
|
+
required: true,
|
|
384
|
+
options: [
|
|
385
|
+
{ id: 'o1', value: 'person' },
|
|
386
|
+
{ id: 'o2', value: 'company' },
|
|
387
|
+
],
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
id: 'fb',
|
|
391
|
+
type: 'text',
|
|
392
|
+
key: 'company_name',
|
|
393
|
+
required: true,
|
|
394
|
+
visibility: { connective: 'and', groups: [[{ fieldId: 'fa', operator: 'equals', value: 'company' }]] },
|
|
395
|
+
},
|
|
396
|
+
],
|
|
397
|
+
},
|
|
398
|
+
]);
|
|
399
|
+
export const FORMS_SUBMISSION_FIXTURES = [
|
|
400
|
+
{
|
|
401
|
+
name: 'every input type, valid, normalised',
|
|
402
|
+
behaviour: 'B1, B5, B10, B11',
|
|
403
|
+
definition: EVERY_TYPE_DEFINITION,
|
|
404
|
+
raw: { ...EVERY_TYPE_VALID_RAW, bogus: 'ignored' },
|
|
405
|
+
knownCountries: ['PL', 'DE', 'FR'],
|
|
406
|
+
expected: {
|
|
407
|
+
ok: true,
|
|
408
|
+
answers: {
|
|
409
|
+
name: 'Ann Smith',
|
|
410
|
+
email: 'ann@example.com',
|
|
411
|
+
phone: '+48 600 100 200',
|
|
412
|
+
quantity: 2.5,
|
|
413
|
+
message: 'Line one\nLine two',
|
|
414
|
+
topic: 'support',
|
|
415
|
+
contact_by: 'email',
|
|
416
|
+
interests: ['doors', 'gates'],
|
|
417
|
+
company: true,
|
|
418
|
+
visit: '2026-06-30',
|
|
419
|
+
country: 'PL',
|
|
420
|
+
address: { street: 'Main 1', postalCode: '00-001', city: 'Warsaw', country: 'PL' },
|
|
421
|
+
campaign: 'autumn',
|
|
422
|
+
privacy: true,
|
|
423
|
+
marketing: false,
|
|
424
|
+
terms: true,
|
|
425
|
+
},
|
|
426
|
+
consents: [
|
|
427
|
+
{ fieldKey: 'privacy', kind: 'privacy', given: true },
|
|
428
|
+
{ fieldKey: 'marketing', kind: 'marketing', given: false },
|
|
429
|
+
{ fieldKey: 'terms', kind: 'terms', given: true },
|
|
430
|
+
],
|
|
431
|
+
},
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
// An empty optional field skips every check (`minSelected` included); an optional address with
|
|
435
|
+
// no part typed is skipped as a whole — its parts' `required` binds once any part is typed.
|
|
436
|
+
name: 'empty optional fields are not stored; required ones and the consents are refused',
|
|
437
|
+
behaviour: 'B6',
|
|
438
|
+
definition: EVERY_TYPE_DEFINITION,
|
|
439
|
+
raw: { name: ' ', email: '' },
|
|
440
|
+
knownCountries: ['PL'],
|
|
441
|
+
expected: {
|
|
442
|
+
ok: false,
|
|
443
|
+
errors: [
|
|
444
|
+
{ fieldKey: 'name', code: 'required' },
|
|
445
|
+
{ fieldKey: 'email', code: 'required' },
|
|
446
|
+
{ fieldKey: 'privacy', code: 'consent_required' },
|
|
447
|
+
{ fieldKey: 'terms', code: 'consent_required' },
|
|
448
|
+
],
|
|
449
|
+
},
|
|
450
|
+
},
|
|
451
|
+
{
|
|
452
|
+
name: 'coercion and limits refuse each malformed value with its own code',
|
|
453
|
+
behaviour: 'B5, B7, B8, B10',
|
|
454
|
+
definition: EVERY_TYPE_DEFINITION,
|
|
455
|
+
raw: {
|
|
456
|
+
...EVERY_TYPE_VALID_RAW,
|
|
457
|
+
name: 'A',
|
|
458
|
+
email: 'not-an-address',
|
|
459
|
+
phone: '12',
|
|
460
|
+
quantity: '1,2',
|
|
461
|
+
message: 'x'.repeat(201),
|
|
462
|
+
topic: 'billing',
|
|
463
|
+
contact_by: 'fax',
|
|
464
|
+
interests: ['doors', 'windows', 'gates'],
|
|
465
|
+
visit: '2026-02-31',
|
|
466
|
+
country: 'FR',
|
|
467
|
+
'address.country': 'XX',
|
|
468
|
+
},
|
|
469
|
+
knownCountries: ['PL', 'DE', 'FR'],
|
|
470
|
+
expected: {
|
|
471
|
+
ok: false,
|
|
472
|
+
errors: [
|
|
473
|
+
{ fieldKey: 'name', code: 'too_short' },
|
|
474
|
+
{ fieldKey: 'email', code: 'invalid_email' },
|
|
475
|
+
{ fieldKey: 'phone', code: 'invalid_phone' },
|
|
476
|
+
{ fieldKey: 'quantity', code: 'step_mismatch' },
|
|
477
|
+
{ fieldKey: 'message', code: 'too_long' },
|
|
478
|
+
{ fieldKey: 'topic', code: 'unknown_option' },
|
|
479
|
+
{ fieldKey: 'contact_by', code: 'unknown_option' },
|
|
480
|
+
{ fieldKey: 'interests', code: 'too_many' },
|
|
481
|
+
{ fieldKey: 'visit', code: 'invalid_date' },
|
|
482
|
+
{ fieldKey: 'country', code: 'invalid_country' },
|
|
483
|
+
{ fieldKey: 'address.country', code: 'invalid_country' },
|
|
484
|
+
],
|
|
485
|
+
},
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
name: 'bounds: below the minimum, above the maximum, too early, a line break in a single line',
|
|
489
|
+
behaviour: 'B5, B7',
|
|
490
|
+
definition: EVERY_TYPE_DEFINITION,
|
|
491
|
+
raw: {
|
|
492
|
+
...EVERY_TYPE_VALID_RAW,
|
|
493
|
+
name: 'Ann\nSmith',
|
|
494
|
+
quantity: '0.5',
|
|
495
|
+
visit: '2025-12-31',
|
|
496
|
+
country: 'DE',
|
|
497
|
+
},
|
|
498
|
+
knownCountries: ['PL'],
|
|
499
|
+
expected: {
|
|
500
|
+
ok: false,
|
|
501
|
+
errors: [
|
|
502
|
+
{ fieldKey: 'name', code: 'single_line' },
|
|
503
|
+
{ fieldKey: 'quantity', code: 'below_min' },
|
|
504
|
+
{ fieldKey: 'visit', code: 'too_early' },
|
|
505
|
+
{ fieldKey: 'country', code: 'invalid_country' },
|
|
506
|
+
],
|
|
507
|
+
},
|
|
508
|
+
},
|
|
509
|
+
{
|
|
510
|
+
name: 'above the maximum, too late, not a number',
|
|
511
|
+
behaviour: 'B5, B7',
|
|
512
|
+
definition: EVERY_TYPE_DEFINITION,
|
|
513
|
+
raw: { ...EVERY_TYPE_VALID_RAW, quantity: '11', visit: '2027-01-01', phone: 'call me' },
|
|
514
|
+
knownCountries: ['PL', 'DE'],
|
|
515
|
+
expected: {
|
|
516
|
+
ok: false,
|
|
517
|
+
errors: [
|
|
518
|
+
{ fieldKey: 'phone', code: 'invalid_phone' },
|
|
519
|
+
{ fieldKey: 'quantity', code: 'above_max' },
|
|
520
|
+
{ fieldKey: 'visit', code: 'too_late' },
|
|
521
|
+
],
|
|
522
|
+
},
|
|
523
|
+
},
|
|
524
|
+
{
|
|
525
|
+
name: 'an address with one part typed requires its required parts',
|
|
526
|
+
behaviour: 'B6',
|
|
527
|
+
definition: EVERY_TYPE_DEFINITION,
|
|
528
|
+
raw: {
|
|
529
|
+
...EVERY_TYPE_VALID_RAW,
|
|
530
|
+
'address.street': '',
|
|
531
|
+
'address.city': ' ',
|
|
532
|
+
'address.line2': 'ignored: the part is not enabled',
|
|
533
|
+
},
|
|
534
|
+
knownCountries: ['PL', 'DE'],
|
|
535
|
+
expected: {
|
|
536
|
+
ok: false,
|
|
537
|
+
errors: [
|
|
538
|
+
{ fieldKey: 'address.street', code: 'required' },
|
|
539
|
+
{ fieldKey: 'address.city', code: 'required' },
|
|
540
|
+
],
|
|
541
|
+
},
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
name: 'a number that is not one',
|
|
545
|
+
behaviour: 'B5',
|
|
546
|
+
definition: EVERY_TYPE_DEFINITION,
|
|
547
|
+
raw: { ...EVERY_TYPE_VALID_RAW, quantity: 'two' },
|
|
548
|
+
knownCountries: ['PL'],
|
|
549
|
+
expected: { ok: false, errors: [{ fieldKey: 'quantity', code: 'invalid_number' }] },
|
|
550
|
+
},
|
|
551
|
+
{
|
|
552
|
+
name: 'patterns refuse; a hidden value over the cap is truncated, not refused',
|
|
553
|
+
behaviour: 'B7, B9',
|
|
554
|
+
definition: PATTERN_DEFINITION,
|
|
555
|
+
raw: { digits: '12a', letters: 'Zażółć1', alnum: 'abc-1', site: 'ftp://example.com', page: 'x'.repeat(1200) },
|
|
556
|
+
knownCountries: [],
|
|
557
|
+
expected: {
|
|
558
|
+
ok: false,
|
|
559
|
+
errors: [
|
|
560
|
+
{ fieldKey: 'digits', code: 'pattern' },
|
|
561
|
+
{ fieldKey: 'letters', code: 'pattern' },
|
|
562
|
+
{ fieldKey: 'alnum', code: 'pattern' },
|
|
563
|
+
{ fieldKey: 'site', code: 'pattern' },
|
|
564
|
+
],
|
|
565
|
+
},
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
name: 'patterns accept Unicode letters and an absolute https address',
|
|
569
|
+
behaviour: 'B7, B9',
|
|
570
|
+
definition: PATTERN_DEFINITION,
|
|
571
|
+
raw: { digits: '0042', letters: 'Zażółć', alnum: 'Gęś42', site: 'https://example.com/a?b=1', page: 'x'.repeat(1200) },
|
|
572
|
+
knownCountries: [],
|
|
573
|
+
expected: {
|
|
574
|
+
ok: true,
|
|
575
|
+
answers: {
|
|
576
|
+
digits: '0042',
|
|
577
|
+
letters: 'Zażółć',
|
|
578
|
+
alnum: 'Gęś42',
|
|
579
|
+
site: 'https://example.com/a?b=1',
|
|
580
|
+
page: 'x'.repeat(1000),
|
|
581
|
+
},
|
|
582
|
+
consents: [],
|
|
583
|
+
},
|
|
584
|
+
},
|
|
585
|
+
{
|
|
586
|
+
name: 'a value posted for a hidden field is dropped; a hidden required field is not required',
|
|
587
|
+
behaviour: 'B2, B3, US3-3',
|
|
588
|
+
definition: CONDITIONAL_REQUIRED_DEFINITION,
|
|
589
|
+
raw: { kind: 'person', company_name: 'Smuggled Ltd' },
|
|
590
|
+
knownCountries: [],
|
|
591
|
+
expected: { ok: true, answers: { kind: 'person' }, consents: [] },
|
|
592
|
+
},
|
|
593
|
+
{
|
|
594
|
+
name: 'a required field becomes required once its rule shows it',
|
|
595
|
+
behaviour: 'B6',
|
|
596
|
+
definition: CONDITIONAL_REQUIRED_DEFINITION,
|
|
597
|
+
raw: { kind: 'company' },
|
|
598
|
+
knownCountries: [],
|
|
599
|
+
expected: { ok: false, errors: [{ fieldKey: 'company_name', code: 'required' }] },
|
|
600
|
+
},
|
|
601
|
+
{
|
|
602
|
+
name: 'a section rule drops the values of every field in it',
|
|
603
|
+
behaviour: 'B2, US3-2',
|
|
604
|
+
definition: SECTION_RULE_DEFINITION,
|
|
605
|
+
raw: { a: 'hide', d: 'typed anyway', e: 'x@example.com' },
|
|
606
|
+
knownCountries: [],
|
|
607
|
+
expected: { ok: true, answers: { a: 'hide' }, consents: [] },
|
|
608
|
+
},
|
|
609
|
+
];
|
|
610
|
+
//# sourceMappingURL=forms-logic.fixtures.js.map
|