@sealcode/sealgen 0.15.29 → 0.15.31
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/.xunit +54 -43
- package/@types/src/add-list-route.test.d.ts +1 -0
- package/@types/src/forms/controls/controls.d.ts +1 -0
- package/@types/src/forms/controls/single-reference.d.ts +13 -0
- package/@types/src/forms/controls/single-reference.test.d.ts +1 -0
- package/@types/src/page/default-list-filters.d.ts +14 -3
- package/@types/src/page/list.d.ts +1 -1
- package/@types/src/templates/collection.d.ts +1 -1
- package/@types/src/templates/form.d.ts +8 -1
- package/@types/src/test_utils/test-on-real-app.d.ts +4 -1
- package/lib/add-collection.js +5 -1
- package/lib/add-list-route.test.js +38 -0
- package/lib/add-route.test.js +1 -1
- package/lib/forms/controls/controls.js +1 -0
- package/lib/forms/controls/single-reference.js +26 -0
- package/lib/forms/controls/single-reference.test.js +51 -0
- package/lib/page/default-list-filters.js +40 -33
- package/lib/page/list.js +6 -6
- package/lib/page/sealious-list.js +5 -0
- package/lib/page/sealious-list.test.js +1 -1
- package/lib/templates/collection.js +4 -3
- package/lib/templates/form.js +32 -22
- package/lib/templates/list.js +31 -12
- package/lib/test_utils/test-on-real-app.js +33 -6
- package/package.json +2 -1
- package/src/add-collection.ts +5 -1
- package/src/add-list-route.test.ts +45 -0
- package/src/add-route.test.ts +1 -1
- package/src/forms/controls/controls.ts +1 -0
- package/src/forms/controls/single-reference.test.ts +62 -0
- package/src/forms/controls/single-reference.ts +36 -0
- package/src/page/default-list-filters.ts +45 -33
- package/src/page/list.ts +8 -8
- package/src/page/sealious-list.test.ts +1 -1
- package/src/page/sealious-list.ts +5 -0
- package/src/templates/collection.ts +8 -3
- package/src/templates/form.ts +34 -22
- package/src/templates/list.ts +31 -12
- package/src/test_utils/test-on-real-app.ts +35 -3
package/.xunit
CHANGED
|
@@ -1,55 +1,66 @@
|
|
|
1
|
-
<testsuite name="Mocha Tests" tests="
|
|
2
|
-
<testcase classname="add route test" name="creates minimal sealious app" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/add-route.test.js" time="
|
|
1
|
+
<testsuite name="Mocha Tests" tests="64" failures="0" errors="0" skipped="0" timestamp="Sat, 15 Jun 2024 17:21:47 GMT" time="56.338">
|
|
2
|
+
<testcase classname="add route test" name="creates minimal sealious app and adds a simple route that works" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/add-route.test.js" time="11.639"/>
|
|
3
3
|
<testcase classname="empty test" name="empty test" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/example.test.js" time="0"/>
|
|
4
|
-
<testcase classname="checkboxed-list basic tests" name="sends the values" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/controls/checkboxed-list-input.test.js" time="1.
|
|
5
|
-
<testcase classname="
|
|
6
|
-
<testcase classname="
|
|
7
|
-
<testcase classname="
|
|
8
|
-
<testcase classname="
|
|
4
|
+
<testcase classname="checkboxed-list basic tests" name="sends the values" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/controls/checkboxed-list-input.test.js" time="1.926"/>
|
|
5
|
+
<testcase classname="checkboxed-list basic tests" name="renders the label" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/controls/checkboxed-list-input.test.js" time="0.423"/>
|
|
6
|
+
<testcase classname="checkboxed-list basic tests behavior with (non)required" name="allows to send a form when no value is selected and fiels is not required" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/controls/checkboxed-list-input.test.js" time="0.45"/>
|
|
7
|
+
<testcase classname="checkboxed-list basic tests behavior with (non)required" name="does not allow to send a form when no value is selected and field IS required" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/controls/checkboxed-list-input.test.js" time="0.549"/>
|
|
8
|
+
<testcase classname="checkboxed-list basic tests behavior with (non)required" name="allows to send a form when no value is selected and field IS required" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/controls/checkboxed-list-input.test.js" time="0.514"/>
|
|
9
|
+
<testcase classname="file-control basic tests" name="doesn't require image input if it already has old-value" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/controls/file.test.js" time="0.47"/>
|
|
10
|
+
<testcase classname="photo-control basic tests" name="sends the old photo if it wasn't changed and it has an initial value" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/controls/photo.test.js" time="0.396"/>
|
|
11
|
+
<testcase classname="photo-control basic tests" name="doesn't require image input if it already has old-value" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/controls/photo.test.js" time="0.367"/>
|
|
12
|
+
<testcase classname="single-reference.test" name="creates minimal sealious app and adds a simple route that works" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/controls/single-reference.test.js" time="11.981"/>
|
|
13
|
+
<testcase classname="boolean field" name="validation logic" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/fields/boolean.test.js" time="0"/>
|
|
14
|
+
<testcase classname="boolean field" name="parse function" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/fields/boolean.test.js" time="0.001"/>
|
|
15
|
+
<testcase classname="email field" name="validation logic" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/fields/email.test.js" time="0"/>
|
|
9
16
|
<testcase classname="email field" name="parse function" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/fields/email.test.js" time="0"/>
|
|
10
17
|
<testcase classname="enum-multiple field" name="validation logic" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/fields/enum-multiple.test.js" time="0"/>
|
|
11
18
|
<testcase classname="enum-multiple field" name="parse function" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/fields/enum-multiple.test.js" time="0"/>
|
|
12
19
|
<testcase classname="enum field" name="validation logic" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/fields/enum.test.js" time="0"/>
|
|
13
20
|
<testcase classname="enum field" name="parse function" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/fields/enum.test.js" time="0.001"/>
|
|
14
|
-
<testcase classname="
|
|
21
|
+
<testcase classname="basic field basic tests" name="sends the values" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/fields/field.test.js" time="0.265"/>
|
|
22
|
+
<testcase classname="basic field basic tests" name="Doesn't call `isValueValid` and `parse` if the value is empty" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/fields/field.test.js" time="0.368"/>
|
|
23
|
+
<testcase classname="basic field basic tests" name="Accepts a form where non-required values are empty" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/fields/field.test.js" time="0.448"/>
|
|
24
|
+
<testcase classname="file field" name="should handle as imple upload scenario" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/fields/file.test.js" time="0.442"/>
|
|
15
25
|
<testcase classname="number field" name="validation logic" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/fields/number.test.js" time="0.001"/>
|
|
16
26
|
<testcase classname="number field" name="parse function" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/fields/number.test.js" time="0"/>
|
|
17
|
-
<testcase classname="pick-from-list field" name="validation logic" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/fields/pick-from-list.test.js" time="0"/>
|
|
27
|
+
<testcase classname="pick-from-list field" name="validation logic" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/fields/pick-from-list.test.js" time="0.001"/>
|
|
18
28
|
<testcase classname="regexp field" name="validation logic" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/fields/regexp.test.js" time="0"/>
|
|
19
|
-
<testcase classname="regexp field" name="parse function" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/fields/regexp.test.js" time="0
|
|
29
|
+
<testcase classname="regexp field" name="parse function" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/fields/regexp.test.js" time="0"/>
|
|
20
30
|
<testcase classname="form test basic tests" name="does not allow to submit an empty form when there's a required field" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/form.test.js" time="0.589"/>
|
|
21
|
-
<testcase classname="form test basic tests" name="allows to submit a form when all required fields have a value" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/form.test.js" time="0.
|
|
22
|
-
<testcase classname="form test basic tests" name="does not allow submitting an empty form by circumventing HTML-based validation" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/form.test.js" time="0.
|
|
23
|
-
<testcase classname="form test canAccess tests" name="allows visit when configured when canAccess returns true" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/form.test.js" time="0.
|
|
24
|
-
<testcase classname="form test canAccess tests" name="passes the context to canAccess (false case)" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/form.test.js" time="0.
|
|
25
|
-
<testcase classname="form test canAccess tests" name="passes the context to canAccess (true case)" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/form.test.js" time="0.
|
|
26
|
-
<testcase classname="form test canAccess tests declines access when canAccess returns false" name="prevents the form from rendering" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/form.test.js" time="0.
|
|
27
|
-
<testcase classname="form test canAccess tests declines access when canAccess returns false" name="does not allow submitting of the form through axios" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/form.test.js" time="0.
|
|
28
|
-
<testcase classname="form test validation e2e validation message" name="shows up when incorrect input is given" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/form.test.js" time="0.
|
|
29
|
-
<testcase classname="form test validation e2e validation message" name="doesn't show when correct input is given" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/form.test.js" time="0.
|
|
30
|
-
<testcase classname="form test validation e2e field specific validation message" name="shows up when incorrect input is given" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/form.test.js" time="0.
|
|
31
|
-
<testcase classname="form test validation e2e field specific validation message" name="doesn't show up when correct input is given" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/form.test.js" time="0.
|
|
32
|
-
<testcase classname="form test getInitialValues tests" name="fills the form with values from getInitialValues" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/form.test.js" time="0.
|
|
33
|
-
<testcase classname="multiform test basic tests turbolinks + js enabled" name="checking whether only one submit handler is run" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="0.
|
|
34
|
-
<testcase classname="multiform test basic tests turbolinks + js enabled" name="checking whether the input in the not submitted form prevails" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="0.
|
|
35
|
-
<testcase classname="multiform test basic tests turbolinks + js disabled" name="checking whether only one submit handler is run" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="0.
|
|
36
|
-
<testcase classname="multiform test basic tests turbolinks + js disabled" name="checking whether the input in the not submitted form prevails" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="0.
|
|
37
|
-
<testcase classname="multiform test canAccess allow access to both forms when both canAccess return true" name="check wether it renders" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="
|
|
38
|
-
<testcase classname="multiform test canAccess allow access to both forms when both canAccess return true" name="check wether you can submit through http (axios)" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="0.
|
|
39
|
-
<testcase classname="multiform test canAccess deny access to both forms" name="check wether forms didnt render" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="0.
|
|
40
|
-
<testcase classname="multiform test canAccess deny access to both forms" name="check wether it's possible to submit through http" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="0.
|
|
41
|
-
<testcase classname="multiform test canAccess allow access to one form, deny to the other" name="check wether form1 renders" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="0.
|
|
42
|
-
<testcase classname="multiform test canAccess allow access to one form, deny to the other" name="check wether it's possible to submit to form1 through http" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="0.
|
|
43
|
-
<testcase classname="multiform test canAccess allow access to one form, deny to the other" name="check wether form2 does not render" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="0.
|
|
44
|
-
<testcase classname="multiform test canAccess allow access to one form, deny to the other" name="check wether it's possible to submit to form2 through http" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="0.
|
|
45
|
-
<testcase classname="multiform test validation e2e basic tests" name="js enabled" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="1.
|
|
46
|
-
<testcase classname="multiform test validation e2e basic tests" name="js disabled" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="
|
|
47
|
-
<testcase classname="multiform test validation e2e field specific validation js enabled" name="validation message shows when incorrect input is given" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="0.
|
|
48
|
-
<testcase classname="multiform test validation e2e field specific validation js enabled" name="validation message doesn't show when correct input is given" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="0.
|
|
49
|
-
<testcase classname="multiform test validation e2e field specific validation js disabled" name="validation message shows when incorrect input is given" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="0.
|
|
50
|
-
<testcase classname="multiform test validation e2e field specific validation js disabled" name="validation message doesn't show when correct input is given" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="0.
|
|
51
|
-
<testcase classname="generate routes" name="handles a url with params" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/generate-routes.test.js" time="0.
|
|
31
|
+
<testcase classname="form test basic tests" name="allows to submit a form when all required fields have a value" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/form.test.js" time="0.24"/>
|
|
32
|
+
<testcase classname="form test basic tests" name="does not allow submitting an empty form by circumventing HTML-based validation" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/form.test.js" time="0.019"/>
|
|
33
|
+
<testcase classname="form test canAccess tests" name="allows visit when configured when canAccess returns true" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/form.test.js" time="0.019"/>
|
|
34
|
+
<testcase classname="form test canAccess tests" name="passes the context to canAccess (false case)" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/form.test.js" time="0.023"/>
|
|
35
|
+
<testcase classname="form test canAccess tests" name="passes the context to canAccess (true case)" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/form.test.js" time="0.024"/>
|
|
36
|
+
<testcase classname="form test canAccess tests declines access when canAccess returns false" name="prevents the form from rendering" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/form.test.js" time="0.017"/>
|
|
37
|
+
<testcase classname="form test canAccess tests declines access when canAccess returns false" name="does not allow submitting of the form through axios" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/form.test.js" time="0.006"/>
|
|
38
|
+
<testcase classname="form test validation e2e validation message" name="shows up when incorrect input is given" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/form.test.js" time="0.234"/>
|
|
39
|
+
<testcase classname="form test validation e2e validation message" name="doesn't show when correct input is given" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/form.test.js" time="0.661"/>
|
|
40
|
+
<testcase classname="form test validation e2e field specific validation message" name="shows up when incorrect input is given" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/form.test.js" time="0.248"/>
|
|
41
|
+
<testcase classname="form test validation e2e field specific validation message" name="doesn't show up when correct input is given" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/form.test.js" time="0.157"/>
|
|
42
|
+
<testcase classname="form test getInitialValues tests" name="fills the form with values from getInitialValues" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/form.test.js" time="0.058"/>
|
|
43
|
+
<testcase classname="multiform test basic tests turbolinks + js enabled" name="checking whether only one submit handler is run" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="0.602"/>
|
|
44
|
+
<testcase classname="multiform test basic tests turbolinks + js enabled" name="checking whether the input in the not submitted form prevails" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="0.009"/>
|
|
45
|
+
<testcase classname="multiform test basic tests turbolinks + js disabled" name="checking whether only one submit handler is run" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="0.582"/>
|
|
46
|
+
<testcase classname="multiform test basic tests turbolinks + js disabled" name="checking whether the input in the not submitted form prevails" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="0.005"/>
|
|
47
|
+
<testcase classname="multiform test canAccess allow access to both forms when both canAccess return true" name="check wether it renders" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="1.07"/>
|
|
48
|
+
<testcase classname="multiform test canAccess allow access to both forms when both canAccess return true" name="check wether you can submit through http (axios)" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="0.014"/>
|
|
49
|
+
<testcase classname="multiform test canAccess deny access to both forms" name="check wether forms didnt render" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="0.574"/>
|
|
50
|
+
<testcase classname="multiform test canAccess deny access to both forms" name="check wether it's possible to submit through http" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="0.007"/>
|
|
51
|
+
<testcase classname="multiform test canAccess allow access to one form, deny to the other" name="check wether form1 renders" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="0.343"/>
|
|
52
|
+
<testcase classname="multiform test canAccess allow access to one form, deny to the other" name="check wether it's possible to submit to form1 through http" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="0.005"/>
|
|
53
|
+
<testcase classname="multiform test canAccess allow access to one form, deny to the other" name="check wether form2 does not render" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="0.341"/>
|
|
54
|
+
<testcase classname="multiform test canAccess allow access to one form, deny to the other" name="check wether it's possible to submit to form2 through http" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="0.005"/>
|
|
55
|
+
<testcase classname="multiform test validation e2e basic tests" name="js enabled" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="1.282"/>
|
|
56
|
+
<testcase classname="multiform test validation e2e basic tests" name="js disabled" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="1.044"/>
|
|
57
|
+
<testcase classname="multiform test validation e2e field specific validation js enabled" name="validation message shows when incorrect input is given" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="0.252"/>
|
|
58
|
+
<testcase classname="multiform test validation e2e field specific validation js enabled" name="validation message doesn't show when correct input is given" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="0.156"/>
|
|
59
|
+
<testcase classname="multiform test validation e2e field specific validation js disabled" name="validation message shows when incorrect input is given" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="0.233"/>
|
|
60
|
+
<testcase classname="multiform test validation e2e field specific validation js disabled" name="validation message doesn't show when correct input is given" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="0.157"/>
|
|
61
|
+
<testcase classname="generate routes" name="handles a url with params" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/generate-routes.test.js" time="0.014"/>
|
|
52
62
|
<testcase classname="generate routes" name="handles polish characters in the url" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/generate-routes.test.js" time="0"/>
|
|
53
|
-
<testcase classname="generate routes" name="handles a url with params and diacritics" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/generate-routes.test.js" time="0.
|
|
54
|
-
<testcase classname="
|
|
63
|
+
<testcase classname="generate routes" name="handles a url with params and diacritics" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/generate-routes.test.js" time="0.008"/>
|
|
64
|
+
<testcase classname="sealious-list test" name="creates minimal sealious app and adds a simple route that works" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/page/sealious-list.test.js" time="13.455"/>
|
|
65
|
+
<testcase classname="stateful page" name="handles a basic case with action buttons" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/page/stateful-page.test.js" time="0.001"/>
|
|
55
66
|
</testsuite>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -4,6 +4,7 @@ export { EditableCollectionSubset } from "./editable-collection-subset.js";
|
|
|
4
4
|
export { Frame } from "./frame.js";
|
|
5
5
|
export { CheckboxedListInput } from "./checkboxed-list-input.js";
|
|
6
6
|
export * from "./dropdown.js";
|
|
7
|
+
export * from "./single-reference.js";
|
|
7
8
|
export { SimpleInput } from "./simple-input.js";
|
|
8
9
|
export { FormHeader } from "./form-header.js";
|
|
9
10
|
export { FormParagraph } from "./form-paragraph.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import SealiousSingleReference from "sealious/@types/src/app/base-chips/field-types/single-reference.js";
|
|
2
|
+
import { CollectionField } from "../fields/collection-field.js";
|
|
3
|
+
import { DropdownOptions, FreeformDropdown } from "./dropdown.js";
|
|
4
|
+
import { Collection, CollectionItem } from "sealious";
|
|
5
|
+
export declare class SingleReferenceDropdown<F extends SealiousSingleReference, Required extends boolean> extends FreeformDropdown {
|
|
6
|
+
field: CollectionField<F, Required>;
|
|
7
|
+
options: DropdownOptions & {
|
|
8
|
+
getLabel?: (item: CollectionItem<Collection>) => string;
|
|
9
|
+
};
|
|
10
|
+
constructor(field: CollectionField<F, Required>, options?: DropdownOptions & {
|
|
11
|
+
getLabel?: (item: CollectionItem<Collection>) => string;
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { Field } from "sealious";
|
|
2
2
|
import { FlatTemplatable } from "tempstream";
|
|
3
3
|
export type ListFilterRender = (value: string, field: Field<any>) => FlatTemplatable;
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
export type DefaultListFilter = {
|
|
5
|
+
render: ListFilterRender;
|
|
6
|
+
prepareValue?: (filter_value: unknown) => unknown;
|
|
7
|
+
};
|
|
8
|
+
export declare const BooleanListFilter: {
|
|
9
|
+
render: (value: string, field: Field<any>) => string;
|
|
10
|
+
};
|
|
11
|
+
export declare const SimpleTextFilter: {
|
|
12
|
+
render: (value: string, field: Field<any>) => string;
|
|
13
|
+
prepareValue: (value: string) => {
|
|
14
|
+
regex: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export declare const DefaultListFilters: Record<string, DefaultListFilter>;
|
|
@@ -32,7 +32,6 @@ export declare abstract class ListPage<ItemType, F extends typeof BaseListPageFi
|
|
|
32
32
|
itemsPerPage: number | null;
|
|
33
33
|
}>;
|
|
34
34
|
renderItems(ctx: Context, values?: Record<string, FormDataValue>, items?: ItemType[]): Promise<FlatTemplatable>;
|
|
35
|
-
render(ctx: Context): Promise<FlatTemplatable>;
|
|
36
35
|
renderPagination(ctx: Context, values: Record<string, FormDataValue>): Promise<FlatTemplatable>;
|
|
37
36
|
private renderPageButton;
|
|
38
37
|
getFilterValues(ctx: Context): Promise<Record<string, unknown>>;
|
|
@@ -45,4 +44,5 @@ export declare abstract class ListPage<ItemType, F extends typeof BaseListPageFi
|
|
|
45
44
|
field: string;
|
|
46
45
|
label?: string;
|
|
47
46
|
}[]): FlatTemplatable;
|
|
47
|
+
render(ctx: Context): Promise<FlatTemplatable>;
|
|
48
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function collectionTemplate(collection_name: string): string;
|
|
1
|
+
export declare function collectionTemplate(collection_name: string, fields_string?: string): string;
|
|
@@ -1 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
declare const defaults: {
|
|
2
|
+
postimport: string;
|
|
3
|
+
fields: string;
|
|
4
|
+
controls: string;
|
|
5
|
+
validate_method: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function formTemplate(action_name: string, newfilefullpath: string, _params?: Partial<typeof defaults>): Promise<string>;
|
|
8
|
+
export {};
|
|
@@ -12,8 +12,9 @@ export declare class RealAppTest {
|
|
|
12
12
|
start(): Promise<void>;
|
|
13
13
|
close(): Promise<void>;
|
|
14
14
|
runSealgenCommand(command: string): Promise<void>;
|
|
15
|
+
build(): Promise<void>;
|
|
15
16
|
throwIfItKillsTheApp<T>(cb: () => Promise<T>): Promise<T>;
|
|
16
|
-
|
|
17
|
+
httpGET(path: string): Promise<{
|
|
17
18
|
status: number;
|
|
18
19
|
response: string;
|
|
19
20
|
}>;
|
|
@@ -21,4 +22,6 @@ export declare class RealAppTest {
|
|
|
21
22
|
status: number;
|
|
22
23
|
response: string;
|
|
23
24
|
}>;
|
|
25
|
+
addFile(target_path: string, content: string): Promise<void>;
|
|
26
|
+
fullURL(path: string): string;
|
|
24
27
|
}
|
package/lib/add-collection.js
CHANGED
|
@@ -6,6 +6,7 @@ import { generateCollections } from "./generate-collections.js";
|
|
|
6
6
|
import { toKebabCase, toPascalCase } from "js-convert-case";
|
|
7
7
|
const target_locreq = _locreq(process.cwd());
|
|
8
8
|
import prompts from "prompts";
|
|
9
|
+
import { formatWithPrettier } from "./utils/prettier.js";
|
|
9
10
|
async function addCollection(params = {}) {
|
|
10
11
|
prompts.override(params);
|
|
11
12
|
const response = await prompts([
|
|
@@ -31,7 +32,10 @@ async function addCollection(params = {}) {
|
|
|
31
32
|
return;
|
|
32
33
|
}
|
|
33
34
|
await fs.mkdir(resolve(file_path, "../"), { recursive: true });
|
|
34
|
-
await fs.writeFile(
|
|
35
|
+
await fs.writeFile(
|
|
36
|
+
file_path,
|
|
37
|
+
await formatWithPrettier(collectionTemplate(collection_name))
|
|
38
|
+
);
|
|
35
39
|
console.log(`${file_path} created`);
|
|
36
40
|
await generateCollections();
|
|
37
41
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { getBrowser } from "./utils/browser-creator.js";
|
|
2
|
+
import { RealAppTest } from "./test_utils/test-on-real-app.js";
|
|
3
|
+
import { collectionTemplate } from "./templates/collection.js";
|
|
4
|
+
import assert from "node:assert";
|
|
5
|
+
describe("single-reference.test", () => {
|
|
6
|
+
let page;
|
|
7
|
+
before(async () => {
|
|
8
|
+
const browser = await getBrowser();
|
|
9
|
+
const context = await browser.newContext();
|
|
10
|
+
page = await context.newPage();
|
|
11
|
+
});
|
|
12
|
+
after(async () => {
|
|
13
|
+
await page.close();
|
|
14
|
+
});
|
|
15
|
+
it("creates an item list page with working partial string search for text fields", async function() {
|
|
16
|
+
const test_app = await RealAppTest.init();
|
|
17
|
+
await test_app.addFile(
|
|
18
|
+
"src/back/collections/articles.ts",
|
|
19
|
+
collectionTemplate("articles", `title: new FieldTypes.Text(),`)
|
|
20
|
+
);
|
|
21
|
+
await test_app.runSealgenCommand(
|
|
22
|
+
`add-route --action=ListArticles --mode=list --url=/list-articles --collection=articles`
|
|
23
|
+
);
|
|
24
|
+
await test_app.start();
|
|
25
|
+
await test_app.httpPOST(`/api/v1/collections/articles`, { title: "article ABC" });
|
|
26
|
+
await test_app.httpPOST(`/api/v1/collections/articles`, { title: "article DEF" });
|
|
27
|
+
await page.goto(test_app.fullURL(`list-articles/`));
|
|
28
|
+
await page.getByLabel("title").click();
|
|
29
|
+
await page.getByLabel("title").fill("ABC");
|
|
30
|
+
await page.getByLabel("title").press("Enter");
|
|
31
|
+
await page.getByRole("cell", { name: "article ABC" }).click();
|
|
32
|
+
const { response } = await test_app.httpGET(`/list-articles/?page=1&filter%5Btitle%5D=ABC`);
|
|
33
|
+
assert(response.includes("article ABC"));
|
|
34
|
+
assert(!response.includes("article DEF"));
|
|
35
|
+
await test_app.close();
|
|
36
|
+
}).timeout(100 * 1e3);
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=add-list-route.test.js.map
|
package/lib/add-route.test.js
CHANGED
|
@@ -5,7 +5,7 @@ describe("add route test", () => {
|
|
|
5
5
|
const path = "/sample";
|
|
6
6
|
await test_app.runSealgenCommand(`add-route --url=${path} --action=Sample --mode=page`);
|
|
7
7
|
await test_app.start();
|
|
8
|
-
const res = await test_app.
|
|
8
|
+
const res = await test_app.httpGET(path);
|
|
9
9
|
if (res.status != 200) {
|
|
10
10
|
throw new Error("url generated by add-route exists but doesn't return 200");
|
|
11
11
|
}
|
|
@@ -4,6 +4,7 @@ import { EditableCollectionSubset } from "./editable-collection-subset.js";
|
|
|
4
4
|
import { Frame } from "./frame.js";
|
|
5
5
|
import { CheckboxedListInput } from "./checkboxed-list-input.js";
|
|
6
6
|
export * from "./dropdown.js";
|
|
7
|
+
export * from "./single-reference.js";
|
|
7
8
|
import { SimpleInput } from "./simple-input.js";
|
|
8
9
|
import { FormHeader } from "./form-header.js";
|
|
9
10
|
import { FormParagraph } from "./form-paragraph.js";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { FreeformDropdown } from "./dropdown.js";
|
|
2
|
+
class SingleReferenceDropdown extends FreeformDropdown {
|
|
3
|
+
constructor(field, options = {
|
|
4
|
+
label: field.name,
|
|
5
|
+
autosubmit: false,
|
|
6
|
+
autocomplete: true
|
|
7
|
+
}) {
|
|
8
|
+
super(
|
|
9
|
+
field,
|
|
10
|
+
async (ctx) => {
|
|
11
|
+
const { items } = await ctx.$app.collections[field.sealiousField.target_collection].list(ctx.$context).fetch();
|
|
12
|
+
return items.map((item) => ({
|
|
13
|
+
value: item.id,
|
|
14
|
+
label: options.getLabel ? options.getLabel(item) : item.id
|
|
15
|
+
}));
|
|
16
|
+
},
|
|
17
|
+
options
|
|
18
|
+
);
|
|
19
|
+
this.field = field;
|
|
20
|
+
this.options = options;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
SingleReferenceDropdown
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=single-reference.js.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { collectionTemplate } from "../../templates/collection.js";
|
|
2
|
+
import { formTemplate } from "../../templates/form.js";
|
|
3
|
+
import { RealAppTest } from "../../test_utils/test-on-real-app.js";
|
|
4
|
+
import { getBrowser } from "../../utils/browser-creator.js";
|
|
5
|
+
import { expect as PlaywritghtExpect } from "@playwright/test";
|
|
6
|
+
describe("single-reference.test", () => {
|
|
7
|
+
let page;
|
|
8
|
+
before(async () => {
|
|
9
|
+
const browser = await getBrowser();
|
|
10
|
+
const context = await browser.newContext();
|
|
11
|
+
page = await context.newPage();
|
|
12
|
+
});
|
|
13
|
+
after(async () => {
|
|
14
|
+
await page.close();
|
|
15
|
+
});
|
|
16
|
+
it("creates minimal sealious app and adds a simple route that works", async function() {
|
|
17
|
+
const test_app = await RealAppTest.init();
|
|
18
|
+
await test_app.addFile(
|
|
19
|
+
"src/back/collections/articles.ts",
|
|
20
|
+
collectionTemplate("articles", `title: new FieldTypes.Text(),`)
|
|
21
|
+
);
|
|
22
|
+
await test_app.addFile(
|
|
23
|
+
"src/back/collections/comments.ts",
|
|
24
|
+
collectionTemplate(
|
|
25
|
+
"comments",
|
|
26
|
+
`text: new FieldTypes.Text(),
|
|
27
|
+
article: new FieldTypes.SingleReference("articles"),`
|
|
28
|
+
)
|
|
29
|
+
);
|
|
30
|
+
const form_file_path = "src/back/routes/some-form.form.ts";
|
|
31
|
+
await test_app.addFile(
|
|
32
|
+
form_file_path,
|
|
33
|
+
await formTemplate("SomeForm", form_file_path, {
|
|
34
|
+
postimport: `import {Comments} from "../collections/collections.js";`,
|
|
35
|
+
fields: `article: new Fields.CollectionField(true, Comments.fields.article),`,
|
|
36
|
+
controls: `new Controls.SingleReferenceDropdown(fields.article, {getLabel: item=>item.get("title")}),`,
|
|
37
|
+
validate_method: ""
|
|
38
|
+
})
|
|
39
|
+
);
|
|
40
|
+
await test_app.start();
|
|
41
|
+
await test_app.httpPOST(`/api/v1/collections/articles`, { title: "article 1" });
|
|
42
|
+
await test_app.httpPOST(`/api/v1/collections/articles`, { title: "article 2" });
|
|
43
|
+
await page.goto(`http://localhost:${test_app.app_port}/some-form/`);
|
|
44
|
+
await page.locator("html").click();
|
|
45
|
+
await PlaywritghtExpect(page.getByLabel("article")).toBeVisible();
|
|
46
|
+
await page.getByLabel("article").selectOption({ label: "article 2" });
|
|
47
|
+
await page.getByRole("button", { name: "Wy\u015Blij" }).click();
|
|
48
|
+
await test_app.close();
|
|
49
|
+
}).timeout(100 * 1e3);
|
|
50
|
+
});
|
|
51
|
+
//# sourceMappingURL=single-reference.test.js.map
|
|
@@ -1,37 +1,44 @@
|
|
|
1
|
-
const BooleanListFilter =
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
<
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
const BooleanListFilter = {
|
|
2
|
+
render: (value, field) => {
|
|
3
|
+
return (
|
|
4
|
+
/* HTML */
|
|
5
|
+
`<label>
|
|
6
|
+
${field.name}
|
|
7
|
+
<select name="filter[${field.name}]" autocomplete="off">
|
|
8
|
+
<option value="true" ${value == "true" ? "selected" : ""}>
|
|
9
|
+
True
|
|
10
|
+
</option>
|
|
11
|
+
<option value="false" ${value == "false" ? "selected" : ""}>
|
|
12
|
+
False
|
|
13
|
+
</option>
|
|
14
|
+
<option
|
|
15
|
+
value=""
|
|
16
|
+
${value == "null" || value == "" || value == "undefined" || value == void 0 ? "selected" : ""}
|
|
17
|
+
>
|
|
18
|
+
-
|
|
19
|
+
</option>
|
|
20
|
+
</select>
|
|
21
|
+
</label>`
|
|
22
|
+
);
|
|
23
|
+
}
|
|
22
24
|
};
|
|
23
|
-
const SimpleTextFilter =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
const SimpleTextFilter = {
|
|
26
|
+
render: (value, field) => {
|
|
27
|
+
return (
|
|
28
|
+
/* HTML */
|
|
29
|
+
`<label>
|
|
30
|
+
${field.name}
|
|
31
|
+
<input
|
|
32
|
+
type="text"
|
|
33
|
+
name="filter[${field.name}]"
|
|
34
|
+
${value ? `value="${value}"` : value}
|
|
35
|
+
/>
|
|
36
|
+
</label>`
|
|
37
|
+
);
|
|
38
|
+
},
|
|
39
|
+
prepareValue: (value) => {
|
|
40
|
+
return { regex: `.*${value}.*` };
|
|
41
|
+
}
|
|
35
42
|
};
|
|
36
43
|
const DefaultListFilters = {
|
|
37
44
|
boolean: BooleanListFilter,
|
package/lib/page/list.js
CHANGED
|
@@ -66,12 +66,6 @@ class ListPage extends Page {
|
|
|
66
66
|
(items2) => items2.map((item, index) => this.renderItem(ctx, item, index))
|
|
67
67
|
)}`;
|
|
68
68
|
}
|
|
69
|
-
async render(ctx) {
|
|
70
|
-
const values = await this.extractRawValues(ctx);
|
|
71
|
-
return tempstream`${this.renderPagination(ctx, values)}
|
|
72
|
-
${this.renderFilters(ctx)}
|
|
73
|
-
${this.renderListContainer(ctx, this.renderItems(ctx, values))}`;
|
|
74
|
-
}
|
|
75
69
|
async renderPagination(ctx, values) {
|
|
76
70
|
const { itemsPerPage, page } = await this.getPaginationConfig(ctx);
|
|
77
71
|
const totalIems = await this.getTotalPages(
|
|
@@ -198,6 +192,12 @@ ${this.renderListContainer(ctx, this.renderItems(ctx, values))}`;
|
|
|
198
192
|
</tr>
|
|
199
193
|
</thead>`;
|
|
200
194
|
}
|
|
195
|
+
async render(ctx) {
|
|
196
|
+
const values = await this.extractRawValues(ctx);
|
|
197
|
+
return tempstream`${this.renderPagination(ctx, values)}
|
|
198
|
+
${this.renderFilters(ctx)}
|
|
199
|
+
${this.renderListContainer(ctx, this.renderItems(ctx, values))}`;
|
|
200
|
+
}
|
|
201
201
|
}
|
|
202
202
|
export {
|
|
203
203
|
BaseListPageFields,
|
|
@@ -53,6 +53,11 @@ class SealiousItemListPage extends ListPage {
|
|
|
53
53
|
_filter_values,
|
|
54
54
|
predicates.record(predicates.string, predicates.string)
|
|
55
55
|
) ? _filter_values : {};
|
|
56
|
+
for (const key in filter_values) {
|
|
57
|
+
if (filter_values[key] == "") {
|
|
58
|
+
delete filter_values[key];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
56
61
|
return filter_values;
|
|
57
62
|
}
|
|
58
63
|
renderListContainer(_, content) {
|
|
@@ -13,7 +13,7 @@ describe("sealious-list test", () => {
|
|
|
13
13
|
content: "some-content"
|
|
14
14
|
});
|
|
15
15
|
assert(res_post.status == 201);
|
|
16
|
-
const res = await test_app.
|
|
16
|
+
const res = await test_app.httpGET(url);
|
|
17
17
|
if (res.status != 200) {
|
|
18
18
|
throw new Error("url generated by add-route exists but doesn't return 200");
|
|
19
19
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { toPascalCase } from "js-convert-case";
|
|
2
|
+
function collectionTemplate(collection_name, fields_string = `content: new FieldTypes.Text(),`) {
|
|
2
3
|
return `import { Collection, FieldTypes, Policies } from "sealious";
|
|
3
4
|
|
|
4
|
-
export default class ${collection_name} extends Collection {
|
|
5
|
+
export default class ${toPascalCase(collection_name)} extends Collection {
|
|
5
6
|
fields = {
|
|
6
|
-
|
|
7
|
+
${fields_string}
|
|
7
8
|
};
|
|
8
9
|
defaultPolicy = new Policies.Public();
|
|
9
10
|
}
|