From 502ca15765d27d18197d175aa3991b92147b7353 Mon Sep 17 00:00:00 2001 From: eyelidlessness Date: Thu, 9 May 2024 13:33:42 -0700 Subject: [PATCH] Minimal port of XFormParserTest.java MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There may be additional test logic we can repurpose into `Scenario` APIs or testing other layers, but this at least tests: - Any of the tests from the “vat” exercising `Scenario` APIs - Initialization of all other forms under test in the “vat” A few failures, and behavior clarifications, come out of this as well. --- .../resources/countNonEmptyForm-alt.xml | 52 ++ .../resources/template-repeat-alt.xml | 37 + packages/scenario/test/actions-events.test.ts | 16 + .../scenario/test/label-hint-text.test.ts | 157 ++++ packages/scenario/test/repeat.test.ts | 55 ++ .../test/smoketests/form-init.test.ts | 748 ++++++++++++++++++ 6 files changed, 1065 insertions(+) create mode 100644 packages/scenario/resources/countNonEmptyForm-alt.xml create mode 100644 packages/scenario/resources/template-repeat-alt.xml create mode 100644 packages/scenario/test/label-hint-text.test.ts create mode 100644 packages/scenario/test/smoketests/form-init.test.ts diff --git a/packages/scenario/resources/countNonEmptyForm-alt.xml b/packages/scenario/resources/countNonEmptyForm-alt.xml new file mode 100644 index 00000000..61176c5a --- /dev/null +++ b/packages/scenario/resources/countNonEmptyForm-alt.xml @@ -0,0 +1,52 @@ + + + + CountNonEmpty (+ namespaces) + + + +
+ + 1 + +
+
+ + 2 + +
+
+ + + +
+
+ + + +
+ + +
+
+ + + +
+
+ + + + + + + + + + + +
diff --git a/packages/scenario/resources/template-repeat-alt.xml b/packages/scenario/resources/template-repeat-alt.xml new file mode 100644 index 00000000..82609f4b --- /dev/null +++ b/packages/scenario/resources/template-repeat-alt.xml @@ -0,0 +1,37 @@ + + + + Repeat with template + + + + + John Doe + spouse + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/scenario/test/actions-events.test.ts b/packages/scenario/test/actions-events.test.ts index fdef21b5..dce07cd9 100644 --- a/packages/scenario/test/actions-events.test.ts +++ b/packages/scenario/test/actions-events.test.ts @@ -2079,4 +2079,20 @@ describe('Actions/Events', () => { }); }); }); + + describe('XFormParserTest.java', () => { + /** + * **PORTING NOTES** + * + * - `getValue().getValue().toString()` -> `currentState.value` + * + * - Fails pending feature support + */ + it.fails('sets [default] value[s] [~~]with strings[~~]', async () => { + const scenario = await Scenario.init('default_test.xml'); + + expect(scenario.getAnswerNode('/data/string_val').currentState.value).toBe('string-value'); + expect(scenario.getAnswerNode('/data/inline_val').currentState.value).toBe('inline-value'); + }); + }); }); diff --git a/packages/scenario/test/label-hint-text.test.ts b/packages/scenario/test/label-hint-text.test.ts new file mode 100644 index 00000000..b804ccfd --- /dev/null +++ b/packages/scenario/test/label-hint-text.test.ts @@ -0,0 +1,157 @@ +import { + bind, + body, + head, + html, + input, + mainInstance, + model, + t, + title, +} from '@odk-web-forms/common/test/fixtures/xform-dsl/index.ts'; +import { describe, expect, it } from 'vitest'; +import { Scenario } from '../src/jr/Scenario.ts'; + +interface TitleOptions { + readonly temporarilyAddFormTitleElement: boolean; +} + +describe('`