@sealcode/sealgen 0.15.29 → 0.15.30

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 CHANGED
@@ -1,55 +1,66 @@
1
- <testsuite name="Mocha Tests" tests="53" failures="0" errors="0" skipped="0" timestamp="Thu, 02 May 2024 10:22:17 GMT" time="21.049">
2
- <testcase classname="add route test" name="creates minimal sealious app" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/add-route.test.js" time="8.525"/>
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.68"/>
5
- <testcase classname="photo-control basic tests" name="sends the old photo if it wasn&#x27;t changed and it has an initial value" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/controls/photo.test.js" time="0.319"/>
6
- <testcase classname="boolean field" name="validation logic" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/fields/boolean.test.js" time="0.001"/>
7
- <testcase classname="boolean field" name="parse function" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/fields/boolean.test.js" time="0"/>
8
- <testcase classname="email field" name="validation logic" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/fields/email.test.js" time="0.001"/>
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&#x27;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&#x27;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&#x27;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="file field" name="should handle as imple upload scenario" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/fields/file.test.js" time="0.355"/>
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&#x27;t call &#x60;isValueValid&#x60; and &#x60;parse&#x60; 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.001"/>
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&#x27;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.19"/>
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.012"/>
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.011"/>
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.012"/>
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.016"/>
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.008"/>
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.003"/>
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.22"/>
29
- <testcase classname="form test validation e2e validation message" name="doesn&#x27;t show when correct input is given" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/form.test.js" time="0.621"/>
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.217"/>
31
- <testcase classname="form test validation e2e field specific validation message" name="doesn&#x27;t show up when correct input is given" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/form.test.js" time="0.137"/>
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.033"/>
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.557"/>
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.003"/>
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.564"/>
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.009"/>
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="0.381"/>
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.008"/>
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.58"/>
40
- <testcase classname="multiform test canAccess deny access to both forms" name="check wether it&#x27;s possible to submit through http" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="0.005"/>
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.495"/>
42
- <testcase classname="multiform test canAccess allow access to one form, deny to the other" name="check wether it&#x27;s possible to submit to form1 through http" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="0.003"/>
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.323"/>
44
- <testcase classname="multiform test canAccess allow access to one form, deny to the other" name="check wether it&#x27;s possible to submit to form2 through http" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="0.003"/>
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.118"/>
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="0.862"/>
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.205"/>
48
- <testcase classname="multiform test validation e2e field specific validation js enabled" name="validation message doesn&#x27;t show when correct input is given" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="0.106"/>
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.194"/>
50
- <testcase classname="multiform test validation e2e field specific validation js disabled" name="validation message doesn&#x27;t show when correct input is given" file="/home/kuba/projects/sealcode/sealgen/lib-instrumented/forms/multiform.test.js" time="0.138"/>
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.132"/>
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&#x27;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&#x27;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&#x27;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&#x27;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&#x27;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&#x27;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&#x27;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.006"/>
54
- <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"/>
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>
@@ -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
+ }
@@ -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
- export declare function formTemplate(action_name: string, newfilefullpath: string): Promise<string>;
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 {};
@@ -13,7 +13,7 @@ export declare class RealAppTest {
13
13
  close(): Promise<void>;
14
14
  runSealgenCommand(command: string): Promise<void>;
15
15
  throwIfItKillsTheApp<T>(cb: () => Promise<T>): Promise<T>;
16
- httpGet(path: string): Promise<{
16
+ httpGET(path: string): Promise<{
17
17
  status: number;
18
18
  response: string;
19
19
  }>;
@@ -21,4 +21,5 @@ export declare class RealAppTest {
21
21
  status: number;
22
22
  response: string;
23
23
  }>;
24
+ addFile(target_path: string, content: string): Promise<void>;
24
25
  }
@@ -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(file_path, collectionTemplate(collection_name));
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
  }
@@ -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.httpGet(path);
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,53 @@
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
+ const path = "/sample";
41
+ await test_app.runSealgenCommand(`add-route --url=${path} --action=Sample --mode=page`);
42
+ await test_app.start();
43
+ await test_app.httpPOST(`/api/v1/collections/articles`, { title: "article 1" });
44
+ await test_app.httpPOST(`/api/v1/collections/articles`, { title: "article 2" });
45
+ await page.goto(`http://localhost:${test_app.app_port}/some-form/`);
46
+ await page.locator("html").click();
47
+ await PlaywritghtExpect(page.getByLabel("article")).toBeVisible();
48
+ await page.getByLabel("article").selectOption({ label: "article 2" });
49
+ await page.getByRole("button", { name: "Wy\u015Blij" }).click();
50
+ await test_app.close();
51
+ }).timeout(100 * 1e3);
52
+ });
53
+ //# sourceMappingURL=single-reference.test.js.map
@@ -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.httpGet(url);
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
- function collectionTemplate(collection_name) {
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
- content: new FieldTypes.Text(),
7
+ ${fields_string}
7
8
  };
8
9
  defaultPolicy = new Policies.Public();
9
10
  }
@@ -1,7 +1,34 @@
1
1
  import Prettier from "prettier";
2
2
  import { curryImportPath } from "../utils/import-path.js";
3
3
  import { getPrettierConfig } from "../utils/prettier.js";
4
- async function formTemplate(action_name, newfilefullpath) {
4
+ const defaults = {
5
+ postimport: ``,
6
+ fields: `
7
+ email: new Fields.CollectionField(true, Users.fields.email),
8
+ password: new Fields.SimpleFormField(true),`,
9
+ controls: `
10
+ new Controls.SimpleInput(fields.email, { label: "Email:", type: "email" }),
11
+ new Controls.SimpleInput(fields.password, {
12
+ label: "Password:",
13
+ type: "password",
14
+ }),`,
15
+ validate_method: `async validateValues(
16
+ ctx: Context,
17
+ data: Record<string, FormDataValue>
18
+ ): Promise<{ valid: boolean; error: string }> {
19
+ // just a silly example, please remove this with better logic
20
+ const { parsed: email } = await this.fields.email.getValue(ctx, data);
21
+ const { parsed: password } = await this.fields.password.getValue(ctx, data);
22
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
23
+ if ((password || "").length > ((email as string) || "").length) {
24
+ return { valid: false, error: "Password cannot be longer than email" };
25
+ } else {
26
+ return { valid: true, error: "" };
27
+ }
28
+ }`
29
+ };
30
+ async function formTemplate(action_name, newfilefullpath, _params = defaults) {
31
+ const params = { ...defaults, ..._params };
5
32
  const rel = curryImportPath(newfilefullpath);
6
33
  const content = `import type { Context } from "koa";
7
34
  import type { FormData, FormDataValue } from "@sealcode/sealgen";
@@ -9,11 +36,12 @@ import { Form, Fields, Controls, fieldsToShape } from "@sealcode/sealgen";
9
36
  import html from "${rel("src/back/html.js")}";
10
37
  import { Users } from "${rel("src/back/collections/collections.js")}";
11
38
 
39
+ ${params.postimport}
40
+
12
41
  export const actionName = "${action_name}";
13
42
 
14
43
  const fields = {
15
- email: new Fields.CollectionField(true, Users.fields.email),
16
- password: new Fields.SimpleFormField(true),
44
+ ${params.fields}
17
45
  };
18
46
 
19
47
  export const ${action_name}Shape = fieldsToShape(fields);
@@ -23,27 +51,9 @@ export default new (class ${action_name}Form extends Form<typeof fields, void> {
23
51
  fields = fields;
24
52
 
25
53
  controls = [
26
- new Controls.SimpleInput(fields.email, { label: "Email:", type: "email" }),
27
- new Controls.SimpleInput(fields.password, {
28
- label: "Password:",
29
- type: "password",
30
- }),
54
+ ${params.controls}
31
55
  ];
32
56
 
33
- async validateValues(
34
- ctx: Context,
35
- data: Record<string, FormDataValue>
36
- ): Promise<{ valid: boolean; error: string }> {
37
- // just a silly example, please remove this with better logic
38
- const { parsed: email } = await this.fields.email.getValue(ctx, data);
39
- const { parsed: password } = await this.fields.password.getValue(ctx, data);
40
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
41
- if ((password || "").length > ((email as string) || "").length) {
42
- return { valid: false, error: "Password cannot be longer than email" };
43
- } else {
44
- return { valid: true, error: "" };
45
- }
46
- }
47
57
 
48
58
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
49
59
  async canAccess(_: Context) {
@@ -3,6 +3,8 @@ import { spawn } from "child_process";
3
3
  import getPort from "get-port";
4
4
  import waitPort from "wait-port";
5
5
  import { promises as fs } from "fs";
6
+ import path from "node:path";
7
+ import chalk from "chalk";
6
8
  import _locreq from "locreq";
7
9
  import { module_dirname } from "../utils/module-dirname.js";
8
10
  import EventEmitter from "events";
@@ -69,6 +71,11 @@ class RealAppTest {
69
71
  output: "silent",
70
72
  timeout: 6e3
71
73
  });
74
+ console.log(
75
+ chalk.yellow(
76
+ `App is listening on http://localhost:${this.app_port}`
77
+ )
78
+ );
72
79
  }
73
80
  async close() {
74
81
  try {
@@ -114,18 +121,19 @@ class RealAppTest {
114
121
  this.emitter.removeListener("process_error", error_handler);
115
122
  });
116
123
  }
117
- async httpGet(path) {
124
+ async httpGET(path2) {
118
125
  return this.throwIfItKillsTheApp(async () => {
119
- const ret = await fetch(`http://localhost:${this.app_port}${path}`);
126
+ const ret = await fetch(`http://localhost:${this.app_port}${path2}`);
120
127
  const status = ret.status;
121
128
  const response = await ret.text();
122
129
  return { status, response };
123
130
  });
124
131
  }
125
- async httpPOST(path, body) {
132
+ async httpPOST(path2, body) {
133
+ console.debug("POST", path2, body);
126
134
  return this.throwIfItKillsTheApp(async () => {
127
135
  const ret = await fetch(
128
- `http://localhost:${this.app_port}${path}`,
136
+ `http://localhost:${this.app_port}${path2}`,
129
137
  {
130
138
  method: "POST",
131
139
  headers: { "Content-Type": "application/json" },
@@ -134,11 +142,21 @@ class RealAppTest {
134
142
  );
135
143
  const status = ret.status;
136
144
  const response = await ret.text();
137
- console.log("request done!");
138
- console.log({ response });
145
+ console.debug("request done!");
146
+ console.debug({ response });
139
147
  return { status, response };
140
148
  });
141
149
  }
150
+ async addFile(target_path, content) {
151
+ console.log(
152
+ chalk.yellow("Inserting file at path"),
153
+ chalk.green(target_path),
154
+ "with content\n",
155
+ content,
156
+ "\n\n\n\n=====\n"
157
+ );
158
+ await fs.writeFile(path.resolve(this.app_path, target_path), content);
159
+ }
142
160
  }
143
161
  export {
144
162
  RealAppTest,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sealcode/sealgen",
3
- "version": "0.15.29",
3
+ "version": "0.15.30",
4
4
  "description": "Module to automate adding routes and collections to a sealious application",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",
@@ -40,6 +40,7 @@
40
40
  "@typescript-eslint/eslint-plugin": "^5.58.0",
41
41
  "@typescript-eslint/parser": "^5.58.0",
42
42
  "axios": "^1.6.7",
43
+ "chalk": "^5.3.0",
43
44
  "eslint": "^7.32.0",
44
45
  "eslint-config-prettier": "^8.3.0",
45
46
  "eslint-plugin-prettier": "^3.4.1",
@@ -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
 
10
11
  export async function addCollection(
11
12
  params: Record<string, string | boolean> = {}
@@ -40,7 +41,10 @@ export async function addCollection(
40
41
  return;
41
42
  }
42
43
  await fs.mkdir(resolve(file_path, "../"), { recursive: true });
43
- await fs.writeFile(file_path, collectionTemplate(collection_name));
44
+ await fs.writeFile(
45
+ file_path,
46
+ await formatWithPrettier(collectionTemplate(collection_name))
47
+ );
44
48
  // eslint-disable-next-line no-console
45
49
  console.log(`${file_path} created`);
46
50
  await generateCollections();
@@ -7,7 +7,7 @@ describe("add route test", () => {
7
7
  const path = "/sample";
8
8
  await test_app.runSealgenCommand(`add-route --url=${path} --action=Sample --mode=page`);
9
9
  await test_app.start();
10
- const res = await test_app.httpGet(path);
10
+ const res = await test_app.httpGET(path);
11
11
  if (res.status != 200) {
12
12
  throw new Error("url generated by add-route exists but doesn't return 200");
13
13
  }
@@ -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,64 @@
1
+ import { Page } from "playwright";
2
+ import { collectionTemplate } from "../../templates/collection.js";
3
+ import { formTemplate } from "../../templates/form.js";
4
+ import { RealAppTest } from "../../test_utils/test-on-real-app.js";
5
+ import { getBrowser } from "../../utils/browser-creator.js";
6
+ import { expect as PlaywritghtExpect } from "@playwright/test";
7
+
8
+ describe("single-reference.test", () => {
9
+ let page: Page;
10
+ before(async () => {
11
+ const browser = await getBrowser();
12
+ const context = await browser.newContext();
13
+ page = await context.newPage();
14
+ });
15
+
16
+ after(async () => {
17
+ await page.close();
18
+ });
19
+
20
+ it("creates minimal sealious app and adds a simple route that works", async function () {
21
+ const test_app = await RealAppTest.init();
22
+
23
+ // add possiblity to modify templates (form and collection) and create test case
24
+
25
+ await test_app.addFile(
26
+ "src/back/collections/articles.ts",
27
+ collectionTemplate("articles", `title: new FieldTypes.Text(),`)
28
+ );
29
+
30
+ await test_app.addFile(
31
+ "src/back/collections/comments.ts",
32
+ collectionTemplate(
33
+ "comments",
34
+ `text: new FieldTypes.Text(),
35
+ article: new FieldTypes.SingleReference("articles"),`
36
+ )
37
+ );
38
+
39
+ const form_file_path = "src/back/routes/some-form.form.ts";
40
+ await test_app.addFile(
41
+ form_file_path,
42
+ await formTemplate("SomeForm", form_file_path, {
43
+ postimport: `import {Comments} from "../collections/collections.js";`,
44
+ fields: `article: new Fields.CollectionField(true, Comments.fields.article),`,
45
+ controls: `new Controls.SingleReferenceDropdown(fields.article, {getLabel: item=>item.get("title")}),`,
46
+ validate_method: "",
47
+ })
48
+ );
49
+
50
+ const path = "/sample";
51
+ await test_app.runSealgenCommand(`add-route --url=${path} --action=Sample --mode=page`);
52
+ await test_app.start();
53
+ await test_app.httpPOST(`/api/v1/collections/articles`, { title: "article 1" });
54
+ await test_app.httpPOST(`/api/v1/collections/articles`, { title: "article 2" });
55
+
56
+ await page.goto(`http://localhost:${test_app.app_port}/some-form/`);
57
+ await page.locator("html").click();
58
+ await PlaywritghtExpect(page.getByLabel("article")).toBeVisible();
59
+ await page.getByLabel("article").selectOption({ label: "article 2" });
60
+ await page.getByRole("button", { name: "Wyślij" }).click();
61
+
62
+ await test_app.close();
63
+ }).timeout(100 * 1000);
64
+ });
@@ -0,0 +1,36 @@
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
+
6
+ export class SingleReferenceDropdown<
7
+ F extends SealiousSingleReference,
8
+ Required extends boolean
9
+ > extends FreeformDropdown {
10
+ constructor(
11
+ public field: CollectionField<F, Required>,
12
+ public options: DropdownOptions & {
13
+ getLabel?: (item: CollectionItem<Collection>) => string;
14
+ } = {
15
+ label: field.name,
16
+ autosubmit: false,
17
+ autocomplete: true,
18
+ }
19
+ ) {
20
+ super(
21
+ field,
22
+ async (ctx) => {
23
+ const { items } = await ctx.$app.collections[
24
+ field.sealiousField.target_collection
25
+ ]
26
+ .list(ctx.$context)
27
+ .fetch();
28
+ return items.map((item) => ({
29
+ value: item.id,
30
+ label: options.getLabel ? options.getLabel(item) : item.id,
31
+ }));
32
+ },
33
+ options
34
+ );
35
+ }
36
+ }
@@ -15,7 +15,7 @@ describe("sealious-list test", () => {
15
15
  content: "some-content",
16
16
  });
17
17
  assert(res_post.status == 201);
18
- const res = await test_app.httpGet(url);
18
+ const res = await test_app.httpGET(url);
19
19
  if (res.status != 200) {
20
20
  throw new Error("url generated by add-route exists but doesn't return 200");
21
21
  }
@@ -1,9 +1,14 @@
1
- export function collectionTemplate(collection_name: string) {
1
+ import { toPascalCase } from "js-convert-case";
2
+
3
+ export function collectionTemplate(
4
+ collection_name: string,
5
+ fields_string = `content: new FieldTypes.Text(),`
6
+ ) {
2
7
  return `import { Collection, FieldTypes, Policies } from "sealious";
3
8
 
4
- export default class ${collection_name} extends Collection {
9
+ export default class ${toPascalCase(collection_name)} extends Collection {
5
10
  fields = {
6
- content: new FieldTypes.Text(),
11
+ ${fields_string}
7
12
  };
8
13
  defaultPolicy = new Policies.Public();
9
14
  }
@@ -2,10 +2,39 @@ import Prettier from "prettier";
2
2
  import { curryImportPath } from "../utils/import-path.js";
3
3
  import { getPrettierConfig } from "../utils/prettier.js";
4
4
 
5
+ const defaults = {
6
+ postimport: ``,
7
+ fields: `
8
+ email: new Fields.CollectionField(true, Users.fields.email),
9
+ password: new Fields.SimpleFormField(true),`,
10
+ controls: `
11
+ new Controls.SimpleInput(fields.email, { label: "Email:", type: "email" }),
12
+ new Controls.SimpleInput(fields.password, {
13
+ label: "Password:",
14
+ type: "password",
15
+ }),`,
16
+ validate_method: `async validateValues(
17
+ ctx: Context,
18
+ data: Record<string, FormDataValue>
19
+ ): Promise<{ valid: boolean; error: string }> {
20
+ // just a silly example, please remove this with better logic
21
+ const { parsed: email } = await this.fields.email.getValue(ctx, data);
22
+ const { parsed: password } = await this.fields.password.getValue(ctx, data);
23
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
24
+ if ((password || "").length > ((email as string) || "").length) {
25
+ return { valid: false, error: "Password cannot be longer than email" };
26
+ } else {
27
+ return { valid: true, error: "" };
28
+ }
29
+ }`,
30
+ };
31
+
5
32
  export async function formTemplate(
6
33
  action_name: string,
7
- newfilefullpath: string
34
+ newfilefullpath: string,
35
+ _params: Partial<typeof defaults> = defaults
8
36
  ): Promise<string> {
37
+ const params = { ...defaults, ..._params };
9
38
  const rel = curryImportPath(newfilefullpath);
10
39
  const content = `import type { Context } from "koa";
11
40
  import type { FormData, FormDataValue } from "@sealcode/sealgen";
@@ -13,11 +42,12 @@ import { Form, Fields, Controls, fieldsToShape } from "@sealcode/sealgen";
13
42
  import html from "${rel("src/back/html.js")}";
14
43
  import { Users } from "${rel("src/back/collections/collections.js")}";
15
44
 
45
+ ${params.postimport}
46
+
16
47
  export const actionName = "${action_name}";
17
48
 
18
49
  const fields = {
19
- email: new Fields.CollectionField(true, Users.fields.email),
20
- password: new Fields.SimpleFormField(true),
50
+ ${params.fields}
21
51
  };
22
52
 
23
53
  export const ${action_name}Shape = fieldsToShape(fields);
@@ -27,27 +57,9 @@ export default new (class ${action_name}Form extends Form<typeof fields, void> {
27
57
  fields = fields;
28
58
 
29
59
  controls = [
30
- new Controls.SimpleInput(fields.email, { label: "Email:", type: "email" }),
31
- new Controls.SimpleInput(fields.password, {
32
- label: "Password:",
33
- type: "password",
34
- }),
60
+ ${params.controls}
35
61
  ];
36
62
 
37
- async validateValues(
38
- ctx: Context,
39
- data: Record<string, FormDataValue>
40
- ): Promise<{ valid: boolean; error: string }> {
41
- // just a silly example, please remove this with better logic
42
- const { parsed: email } = await this.fields.email.getValue(ctx, data);
43
- const { parsed: password } = await this.fields.password.getValue(ctx, data);
44
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
45
- if ((password || "").length > ((email as string) || "").length) {
46
- return { valid: false, error: "Password cannot be longer than email" };
47
- } else {
48
- return { valid: true, error: "" };
49
- }
50
- }
51
63
 
52
64
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
53
65
  async canAccess(_: Context) {
@@ -5,6 +5,8 @@ import { spawn } from "child_process";
5
5
  import getPort from "get-port";
6
6
  import waitPort from "wait-port";
7
7
  import { promises as fs } from "fs";
8
+ import path from "node:path";
9
+ import chalk from "chalk";
8
10
 
9
11
  import _locreq from "locreq";
10
12
  import { module_dirname } from "../utils/module-dirname.js";
@@ -83,6 +85,11 @@ export class RealAppTest {
83
85
  output: "silent",
84
86
  timeout: 6000,
85
87
  });
88
+ console.log(
89
+ chalk.yellow(
90
+ `App is listening on http://localhost:${this.app_port}`
91
+ )
92
+ );
86
93
  }
87
94
 
88
95
  async close() {
@@ -134,7 +141,7 @@ export class RealAppTest {
134
141
  });
135
142
  }
136
143
 
137
- async httpGet(path: string): Promise<{ status: number; response: string }> {
144
+ async httpGET(path: string): Promise<{ status: number; response: string }> {
138
145
  return this.throwIfItKillsTheApp(async () => {
139
146
  const ret = await fetch(`http://localhost:${this.app_port}${path}`);
140
147
  const status = ret.status;
@@ -147,6 +154,7 @@ export class RealAppTest {
147
154
  path: string,
148
155
  body: Record<string, unknown>
149
156
  ): Promise<{ status: number; response: string }> {
157
+ console.debug("POST", path, body);
150
158
  return this.throwIfItKillsTheApp(async () => {
151
159
  const ret = await fetch(
152
160
  `http://localhost:${this.app_port}${path}`,
@@ -159,9 +167,20 @@ export class RealAppTest {
159
167
  const status = ret.status;
160
168
  const response = await ret.text();
161
169
 
162
- console.log("request done!");
163
- console.log({ response });
170
+ console.debug("request done!");
171
+ console.debug({ response });
164
172
  return { status, response };
165
173
  });
166
174
  }
175
+
176
+ async addFile(target_path: string, content: string) {
177
+ console.log(
178
+ chalk.yellow("Inserting file at path"),
179
+ chalk.green(target_path),
180
+ "with content\n",
181
+ content,
182
+ "\n\n\n\n=====\n"
183
+ );
184
+ await fs.writeFile(path.resolve(this.app_path, target_path), content);
185
+ }
167
186
  }