@yomotech/view-toolkit 1.0.43 → 1.0.45

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.
@@ -635,6 +635,15 @@ function assertFieldSettings(schema, fallback, option, context) {
635
635
  throw new Error('Invalid field layout: ' + errors.join(' '));
636
636
  }
637
637
 
638
+ // Faramarz Yousefian and Agent Toni (Claude Opus 5.5) 2026-10-26
639
+ // - new: the app's test data (.liveforge/test-data.json, TEST_DATA_FILE): steps name its values as {{data.customer.firstName}};
640
+ // withTestData puts them in before a run (both runners), testDataRefs lists them, checkTestFlow(flow, data) reports
641
+ // dataUnknown / dataRefInvalid
642
+ // - new: steps for scenarios through an app (OFFENE-PUNKTE 114): menu (a menu entry), scroll (n pages on in the
643
+ // list), openRecord (a record by position or name), close (the page X), cart (the header's cart); expect page,
644
+ // records / recordsAtLeast, samePlace (back at the same place), cartCount (absolute or "+1"), toast. One
645
+ // description, two runners: the app's test runner (preview) and viewdefinition-e2e (real taps on iPhone, iPad,
646
+ // Pixel 9, Pixel Tablet). New check codes: scrollOutOfRange, recordMissing, notTrue, countNotNumber
638
647
  // Faramarz Yousefian and Agent Toni (Claude Opus 5.5) 2026-10-19
639
648
  // - new: the format of an app's test flows (#166). Every app brings its own test suite in its hidden
640
649
  // system folder .liveforge/tests/ - one JSON file per flow. The same steps are run by the test
@@ -647,11 +656,14 @@ function assertFieldSettings(schema, fallback, option, context) {
647
656
  // - new: expect blocked - a writing button is there and the flow may not press it
648
657
  const TESTS_DIR = '.liveforge/tests';
649
658
  const RESULTS_DIR = '.liveforge/results';
659
+ /** The app's test data, shared by its tests: { customer: { firstName: "Max" }, card: { number: "4242…" } } */
660
+ const TEST_DATA_FILE = '.liveforge/test-data.json';
650
661
  const TEST_DEVICES = ['phone', 'tablet', 'laptop', 'desktop'];
651
662
  const ORIENTATIONS = ['portrait', 'landscape'];
652
- const STEP_KINDS = ['open', 'tap', 'type', 'pick', 'press', 'rotate', 'device', 'wait', 'expect'];
663
+ const STEP_KINDS = ['open', 'menu', 'tap', 'type', 'pick', 'press', 'scroll', 'openRecord', 'close', 'cart', 'rotate', 'device', 'wait', 'expect'];
653
664
  /** What an expect step can check - one of them per step. */
654
- const EXPECT_KINDS = ['value', 'shows', 'keyboard', 'list', 'message', 'visible', 'hidden', 'locked', 'blocked', 'inFrame'];
665
+ const EXPECT_KINDS = ['value', 'shows', 'keyboard', 'list', 'message', 'visible', 'hidden', 'locked', 'blocked', 'inFrame',
666
+ 'page', 'records', 'recordsAtLeast', 'samePlace', 'cartCount', 'toast'];
655
667
  /** What has to stay inside the page frame (safe areas, top gap). */
656
668
  const FRAME_PARTS = ['keyboard', 'dialog', 'calendar', 'list', 'menu'];
657
669
  const LIST_STATES = ['open', 'closed'];
@@ -693,11 +705,90 @@ function stepKind(step) {
693
705
  }
694
706
  const text = (v) => typeof v === 'string' && v.trim().length > 0;
695
707
  /** The problems of a flow; an empty list means it can run. */
696
- function checkTestFlow(flow) {
708
+ /** Step and check keys that hold a number. */
709
+ const NUMBER_KEYS = new Set(['scroll', 'openRecord', 'wait', 'records', 'recordsAtLeast', 'cartCount']);
710
+ /** {{data.customer.firstName}} - a value of the test data; anything else in braces is no test data. */
711
+ const DATA_REF = /\{\{\s*([^}]*?)\s*\}\}/g;
712
+ function stringsOf(node, out = []) {
713
+ if (typeof node === 'string')
714
+ out.push(node);
715
+ else if (Array.isArray(node))
716
+ node.forEach((v) => stringsOf(v, out));
717
+ else if (node && typeof node === 'object')
718
+ Object.values(node).forEach((v) => stringsOf(v, out));
719
+ return out;
720
+ }
721
+ function dataValue(data, ref) {
722
+ return ref.split('.').reduce((v, k) => (v && typeof v === 'object' ? v[k] : undefined), data);
723
+ }
724
+ /** The test data a flow uses, per step: [{ step, ref: "customer.firstName" }]; ref without "data.". */
725
+ function testDataRefs(flow) {
726
+ const refs = [];
727
+ (Array.isArray(flow?.steps) ? flow.steps : []).forEach((step, i) => {
728
+ for (const text of stringsOf(step)) {
729
+ for (const m of text.matchAll(DATA_REF))
730
+ refs.push({ step: i + 1, ref: m[1].replace(/^data\./, ''), raw: m[1] });
731
+ }
732
+ });
733
+ return refs;
734
+ }
735
+ /**
736
+ * The flow with its test data put in: "{{data.customer.firstName}}" -> "Max"; a whole value that is one placeholder
737
+ * keeps the data's type (a number stays a number). Both runners call it before a run; missing lists what is not in data.
738
+ */
739
+ function withTestData(flow, data) {
740
+ const missing = [];
741
+ const put = (node) => {
742
+ if (typeof node === 'string') {
743
+ const whole = /^\{\{\s*data\.([^}]+?)\s*\}\}$/.exec(node);
744
+ if (whole) {
745
+ const v = dataValue(data, whole[1]);
746
+ if (v === undefined)
747
+ missing.push(whole[1]);
748
+ return v === undefined ? node : v;
749
+ }
750
+ return node.replace(DATA_REF, (all, ref) => {
751
+ if (!ref.startsWith('data.'))
752
+ return all;
753
+ const v = dataValue(data, ref.slice(5));
754
+ if (v === undefined || typeof v === 'object') {
755
+ missing.push(ref.slice(5));
756
+ return all;
757
+ }
758
+ return String(v);
759
+ });
760
+ }
761
+ if (Array.isArray(node))
762
+ return node.map(put);
763
+ if (node && typeof node === 'object')
764
+ return Object.fromEntries(Object.entries(node).map(([k, v]) => [k, put(v)]));
765
+ return node;
766
+ };
767
+ return { flow: { ...flow, steps: put(flow.steps) }, missing: [...new Set(missing)] };
768
+ }
769
+ /**
770
+ * The problems of a flow; an empty list means it can run. With the app's test data, a placeholder that names nothing
771
+ * in it is a problem too (dataUnknown); a placeholder that is no {{data.…}} is one always (dataRefInvalid).
772
+ */
773
+ function checkTestFlow(flow, data) {
697
774
  const problems = [];
698
775
  const add = (code, step, params) => problems.push({ code, step, params });
699
776
  if (!flow || typeof flow !== 'object' || Array.isArray(flow))
700
777
  return [{ code: 'notAnObject' }];
778
+ for (const r of testDataRefs(flow)) {
779
+ if (!r.raw.startsWith('data.'))
780
+ add('dataRefInvalid', r.step, { ref: r.raw });
781
+ else if (data !== undefined && dataValue(data, r.ref) === undefined)
782
+ add('dataUnknown', r.step, { ref: r.ref });
783
+ }
784
+ // the form is checked with the data put in; a placeholder still standing where a number belongs counts as one
785
+ if (Array.isArray(flow.steps)) {
786
+ const filled = withTestData(flow, data ?? {}).flow;
787
+ const asNumber = (node) => Array.isArray(node) ? node.map(asNumber)
788
+ : node && typeof node === 'object' ? Object.fromEntries(Object.entries(node).map(([k, v]) => [k, typeof v === 'string' && NUMBER_KEYS.has(k) && /^\{\{\s*data\.[^}]+\}\}$/.test(v) ? 1 : asNumber(v)]))
789
+ : node;
790
+ flow = { ...flow, steps: asNumber(filled.steps) };
791
+ }
701
792
  if (!text(flow.name))
702
793
  add('nameMissing');
703
794
  if (flow.books !== undefined && typeof flow.books !== 'boolean')
@@ -726,11 +817,25 @@ function checkTestFlow(flow) {
726
817
  const kind = kinds[0];
727
818
  switch (kind) {
728
819
  case 'open':
820
+ case 'menu':
729
821
  case 'tap':
730
822
  case 'press':
731
823
  if (!text(step[kind]))
732
824
  add('stepNameMissing', n, { kind });
733
825
  break;
826
+ case 'scroll':
827
+ if (!Number.isInteger(step.scroll) || step.scroll < 1 || step.scroll > 20)
828
+ add('scrollOutOfRange', n);
829
+ break;
830
+ case 'openRecord':
831
+ if (!(Number.isInteger(step.openRecord) && step.openRecord >= 1) && !text(step.openRecord))
832
+ add('recordMissing', n);
833
+ break;
834
+ case 'close':
835
+ case 'cart':
836
+ if (step[kind] !== true)
837
+ add('notTrue', n, { kind });
838
+ break;
734
839
  case 'type':
735
840
  if (typeof step.type !== 'string')
736
841
  add('typeNotText', n);
@@ -787,6 +892,14 @@ function checkExpect(e, n, add) {
787
892
  add('stepNameMissing', n, { kind });
788
893
  if (kind === 'inFrame' && !FRAME_PARTS.includes(e.inFrame))
789
894
  add('unknownFramePart', n, { part: String(e.inFrame) });
895
+ if ((kind === 'page' || kind === 'toast') && !text(e[kind]))
896
+ add('stepNameMissing', n, { kind });
897
+ if ((kind === 'records' || kind === 'recordsAtLeast') && !(Number.isInteger(e[kind]) && e[kind] >= 0))
898
+ add('countNotNumber', n, { kind });
899
+ if (kind === 'samePlace' && e.samePlace !== true)
900
+ add('notTrue', n, { kind });
901
+ if (kind === 'cartCount' && !(Number.isInteger(e.cartCount) && e.cartCount >= 0) && !/^[+-]\d+$/.test(String(e.cartCount)))
902
+ add('countNotNumber', n, { kind });
790
903
  }
791
904
 
792
905
  // Faramarz Yousefian and Agent Toni (Claude Opus 5.5) 2026-10-23
@@ -1328,5 +1441,5 @@ function appSettingsMenu(menu, center, context = {}) {
1328
1441
  * Generated bundle index. Do not edit.
1329
1442
  */
1330
1443
 
1331
- export { APP_SETTINGS, APP_SETTINGS_PATH, APP_SETTING_BLOCKS, BASIC_TYPES, CONTROLS, CONTROL_TYPES, DATA_FORMATS, DATA_OBJECT_KEYS, DATA_OBJECT_NAME_PLACES, DATA_OBJECT_PLACES, DEFAULT_DEVICES, DISPLAY_FORMATS, DOCUMENT_KINDS, EXPECT_KINDS, FRAME_PARTS, KEYBOARD_CONTROLS, KEYBOARD_TYPES, LIST_STATES, LOGIN_FLAGS, LOGIN_METHODS, LOGIN_STORAGES, LOGIN_WHEN, MENU_DECIDED_BY, MENU_ENTRY_KINDS, MENU_SWITCHABLE, NUMBER_STYLES, ORIENTATIONS, PAGINATION_ALIGNS, PAGINATION_PLACEMENTS, PAGINATION_TYPES, PLACEHOLDER_CONTROLS, RESULTS_DIR, RESULTS_KEEP, SETTING_MENU_TEXTS, START_PAGE_KEYS, START_PAGE_PATH, STEP_KINDS, SYSTEM_KEYBOARDS, TEMPORAL_TRANSFER, TERMS_DOCUMENTS, TESTS_DIR, TEST_DEVICES, TYPE_ALIASES, appSettingsMenu, assertFieldSettings, baseType, basicType, canonicalControl, checkAppSettings, checkPagePagination, checkTestFlow, clone, controlChoicesFor, controlsFor, dataSettings, defaultKeyboard, displaySettings, effectiveControl, effectiveFormat, flowDevices, keyboardFor, languageName, loginMethod, normalizeFormat, pageOf, paginationFor, parseDevice, readAppSettings, renameDataObject, resolveProperty, resultsToDelete, rolesOf, rulesFor, startPage, startPageFor, stepKind, temporalPart, validateSettings, validationSettings };
1444
+ export { APP_SETTINGS, APP_SETTINGS_PATH, APP_SETTING_BLOCKS, BASIC_TYPES, CONTROLS, CONTROL_TYPES, DATA_FORMATS, DATA_OBJECT_KEYS, DATA_OBJECT_NAME_PLACES, DATA_OBJECT_PLACES, DEFAULT_DEVICES, DISPLAY_FORMATS, DOCUMENT_KINDS, EXPECT_KINDS, FRAME_PARTS, KEYBOARD_CONTROLS, KEYBOARD_TYPES, LIST_STATES, LOGIN_FLAGS, LOGIN_METHODS, LOGIN_STORAGES, LOGIN_WHEN, MENU_DECIDED_BY, MENU_ENTRY_KINDS, MENU_SWITCHABLE, NUMBER_STYLES, ORIENTATIONS, PAGINATION_ALIGNS, PAGINATION_PLACEMENTS, PAGINATION_TYPES, PLACEHOLDER_CONTROLS, RESULTS_DIR, RESULTS_KEEP, SETTING_MENU_TEXTS, START_PAGE_KEYS, START_PAGE_PATH, STEP_KINDS, SYSTEM_KEYBOARDS, TEMPORAL_TRANSFER, TERMS_DOCUMENTS, TESTS_DIR, TEST_DATA_FILE, TEST_DEVICES, TYPE_ALIASES, appSettingsMenu, assertFieldSettings, baseType, basicType, canonicalControl, checkAppSettings, checkPagePagination, checkTestFlow, clone, controlChoicesFor, controlsFor, dataSettings, defaultKeyboard, displaySettings, effectiveControl, effectiveFormat, flowDevices, keyboardFor, languageName, loginMethod, normalizeFormat, pageOf, paginationFor, parseDevice, readAppSettings, renameDataObject, resolveProperty, resultsToDelete, rolesOf, rulesFor, startPage, startPageFor, stepKind, temporalPart, testDataRefs, validateSettings, validationSettings, withTestData };
1332
1445
  //# sourceMappingURL=yomotech-view-toolkit-catalog.mjs.map