@suffolklitlab/alkiln 5.8.0 → 5.8.1-feat2columns2
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/.github/workflows/github_server.yml +3 -2
- package/.github/workflows/playground.yml +1 -1
- package/CHANGELOG.md +12 -0
- package/action.yml +29 -14
- package/action_for_github_server/action.yml +37 -21
- package/lib/scope.js +290 -122
- package/lib/steps.js +126 -0
- package/lib/utils/log.js +16 -5
- package/package.json +1 -1
- package/tests/unit_tests/fields.fixtures.js +477 -103
- package/tests/unit_tests/getAllFields.test.js +22 -8
- package/tests/unit_tests/getMatchingRows.test.js +44 -2
- package/tests/unit_tests/html.fixtures.js +66 -4
- package/tests/unit_tests/matches.fixtures.js +20 -2
- package/tests/unit_tests/tables.fixtures.js +22 -5
|
@@ -33,8 +33,8 @@ chai.config.truncateThreshold = 0
|
|
|
33
33
|
it(`creates the right data for standard fields`, async function() {
|
|
34
34
|
// 18 fields (03/15/21)
|
|
35
35
|
let result = await getAllFields( scope, { html: html.standard });
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
// console.log(`=================\n${ JSON.stringify(fields.standard, null, 2) }`);
|
|
37
|
+
// console.log(`-----------------\n${ JSON.stringify(result, null, 2) }`);
|
|
38
38
|
expect( result ).to.deep.equalInAnyOrder( fields.standard );
|
|
39
39
|
});
|
|
40
40
|
|
|
@@ -79,21 +79,35 @@ it(`creates the right data for an event action button`, async function() {
|
|
|
79
79
|
// ============================
|
|
80
80
|
// Proxy vars (x, i, j, ...)
|
|
81
81
|
// ============================
|
|
82
|
-
// x[i].name.first
|
|
83
|
-
it(`creates the right data for
|
|
82
|
+
// x[i].name.first where i = 0
|
|
83
|
+
it(`creates the right data for x[i] target variable where "i" is 0`, async function() {
|
|
84
84
|
let result = await getAllFields( scope, { html: html.proxies_xi });
|
|
85
85
|
expect( result ).to.deep.equalInAnyOrder( fields.proxies_xi );
|
|
86
86
|
});
|
|
87
87
|
|
|
88
|
-
//
|
|
89
|
-
|
|
90
|
-
it(`creates the right data for a multi-proxy name (x[i]) again for consistency`, async function() {
|
|
91
|
-
// same data as `proxies_xi`, but have this here for consistency
|
|
88
|
+
// x[i].name.first where i = 1
|
|
89
|
+
it(`creates the right data for x[i] target variable where "i" is 1`, async function() {
|
|
92
90
|
let result = await getAllFields( scope, { html: html.proxies_multi });
|
|
93
91
|
expect( result ).to.deep.equalInAnyOrder( fields.proxies_multi );
|
|
94
92
|
});
|
|
95
93
|
|
|
96
94
|
|
|
95
|
+
// ============================
|
|
96
|
+
// Proxy vars (x, i, j, ...)
|
|
97
|
+
// ============================
|
|
98
|
+
// x[i].name.first where i = 0
|
|
99
|
+
it(`creates the right data for x[i] proxy substitution where "i" is 0`, async function() {
|
|
100
|
+
let result = await getAllFields( scope, { html: html.proxy_substitution_i_is_0 });
|
|
101
|
+
expect( result ).to.deep.equalInAnyOrder( fields.proxy_substitution_i_is_0 );
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// x[i].name.first where i = 1
|
|
105
|
+
it(`creates the right data for x[i] target variable where "i" is 1`, async function() {
|
|
106
|
+
let result = await getAllFields( scope, { html: html.proxy_substitution_i_is_1 });
|
|
107
|
+
expect( result ).to.deep.equalInAnyOrder( fields.proxy_substitution_i_is_1 );
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
|
|
97
111
|
// ============================
|
|
98
112
|
// Signature
|
|
99
113
|
// ============================
|
|
@@ -38,6 +38,8 @@ describe("Matches: For standard fields", async function() {
|
|
|
38
38
|
let name = getSafeName( field );
|
|
39
39
|
let result = await getMatchingRows( scope, { field, var_data: tables.standard });
|
|
40
40
|
it( `finds the right matches for ${ name }`, async function() {
|
|
41
|
+
// console.log(`=================\n${ JSON.stringify(curr_matches) }`);
|
|
42
|
+
// console.log(`-----------------\n${ JSON.stringify(result) }`);
|
|
41
43
|
expect( result ).to.deep.equal( curr_matches );
|
|
42
44
|
});
|
|
43
45
|
}
|
|
@@ -194,10 +196,10 @@ describe(`For mulitple rows with the same proxies`, async function() {
|
|
|
194
196
|
describe(`For a second proxy loop page,`, async function() {
|
|
195
197
|
for ( let test_i = 0; test_i < fields.proxies_multi.length; test_i++ ) {
|
|
196
198
|
let field = fields.proxies_multi[ test_i ];
|
|
197
|
-
let curr_matches = matches.
|
|
199
|
+
let curr_matches = matches.proxies_missing_table_row[ test_i ];
|
|
198
200
|
let name = getSafeName( field );
|
|
199
201
|
it( `does not find any matches when table row for second loop page is missing`, async function() {
|
|
200
|
-
let result = await getMatchingRows( scope, { field, var_data: tables.
|
|
202
|
+
let result = await getMatchingRows( scope, { field, var_data: tables.proxies_missing_table_row });
|
|
201
203
|
expect( result ).to.deep.equal( curr_matches );
|
|
202
204
|
});
|
|
203
205
|
}
|
|
@@ -216,6 +218,46 @@ describe(`For a second proxy loop page,`, async function() {
|
|
|
216
218
|
}
|
|
217
219
|
});
|
|
218
220
|
|
|
221
|
+
// Proxy substitutes (no trigger) first loop (i = 0)
|
|
222
|
+
describe(`For proxy substitution where "i" = 0`, async function() {
|
|
223
|
+
for ( let test_i = 0; test_i < fields.proxy_substitution_i_is_0.length; test_i++ ) {
|
|
224
|
+
let field = fields.proxy_substitution_i_is_0[ test_i ];
|
|
225
|
+
let curr_matches = matches.proxy_substitution_i_is_0[ test_i ];
|
|
226
|
+
let name = getSafeName( field );
|
|
227
|
+
it( `finds the right matches for ${ name }`, async function() {
|
|
228
|
+
let result = await getMatchingRows( scope, { field, var_data: tables.proxy_substitution_i_is_0 });
|
|
229
|
+
expect( result ).to.deep.equal( curr_matches );
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
// Multiple proxies by the same name are on the list (because of a loop)
|
|
235
|
+
// Proxy substitutes (no trigger) second loop (i = 1)
|
|
236
|
+
describe(`For proxy substitutions with mulitple rows of "i" where "i" = 1`, async function() {
|
|
237
|
+
for ( let test_i = 0; test_i < fields.proxy_substitution_i_is_1.length; test_i++ ) {
|
|
238
|
+
let field = fields.proxy_substitution_i_is_1[ test_i ];
|
|
239
|
+
let curr_matches = matches.proxy_substitution_i_is_1[ test_i ];
|
|
240
|
+
let name = getSafeName( field );
|
|
241
|
+
it( `finds the right matches for ${ name }`, async function() {
|
|
242
|
+
let result = await getMatchingRows( scope, { field, var_data: tables.proxy_substitution_i_is_1 });
|
|
243
|
+
expect( result ).to.deep.equal( curr_matches );
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
// Proxy substitution (no trigger) missing table row for second loop (i = 1)
|
|
249
|
+
describe(`For a second loop page with a proxy substitution Story Table,`, async function() {
|
|
250
|
+
for ( let test_i = 0; test_i < fields.proxies_multi.length; test_i++ ) {
|
|
251
|
+
let field = fields.proxies_multi[ test_i ];
|
|
252
|
+
let curr_matches = matches.proxy_substitution_missing_table_row[ test_i ];
|
|
253
|
+
let name = getSafeName( field );
|
|
254
|
+
it( `finds no matches when the Story Table row for that loop is missing`, async function() {
|
|
255
|
+
let result = await getMatchingRows( scope, { field, var_data: tables.proxy_substitution_missing_table_row });
|
|
256
|
+
expect( result ).to.deep.equal( curr_matches );
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
|
|
219
261
|
|
|
220
262
|
// ============================
|
|
221
263
|
// Signature
|
|
@@ -505,7 +505,8 @@ html.buttons_event_action = `
|
|
|
505
505
|
// proxies correctly, but we don't need to worry about guessing the proxy
|
|
506
506
|
// name. See https://github.com/plocket/docassemble-cucumber/pull/221
|
|
507
507
|
|
|
508
|
-
//
|
|
508
|
+
// First loop (first time this question appears)
|
|
509
|
+
// x[i].name.first (i = 0)
|
|
509
510
|
html.proxies_xi = `
|
|
510
511
|
<div id="daquestion" aria-labelledby="dapagetitle" role="main" class="tab-pane fade show active offset-xl-3 offset-lg-3 col-xl-6 col-lg-6 offset-md-2 col-md-8">
|
|
511
512
|
<div data-variable="cHJveHlfbGlzdFswXS5uYW1lLmZpcnN0" id="trigger" aria-hidden="true" style="display: none;"></div>
|
|
@@ -534,9 +535,8 @@ html.proxies_xi = `
|
|
|
534
535
|
</form>
|
|
535
536
|
</div>`;
|
|
536
537
|
|
|
537
|
-
// Second
|
|
538
|
-
//
|
|
539
|
-
// x[i].name.first
|
|
538
|
+
// Second loop (second time this question appears)
|
|
539
|
+
// x[i].name.first (i = 1)
|
|
540
540
|
html.proxies_multi = `
|
|
541
541
|
<div id="daquestion" aria-labelledby="dapagetitle" role="main" class="tab-pane fade show active offset-xl-3 offset-lg-3 col-xl-6 col-lg-6 offset-md-2 col-md-8">
|
|
542
542
|
<div data-variable="cHJveHlfbGlzdFsxXS5uYW1lLmZpcnN0" id="trigger" aria-hidden="true" style="display: none;"></div>
|
|
@@ -565,6 +565,68 @@ html.proxies_multi = `
|
|
|
565
565
|
</form>
|
|
566
566
|
</div>`;
|
|
567
567
|
|
|
568
|
+
// Proxy substitution, no target variable
|
|
569
|
+
// First loop (first time this question appears)
|
|
570
|
+
// x[i].name.first (i = 0)
|
|
571
|
+
html.proxy_substitution_i_is_0 = `
|
|
572
|
+
<div id="daquestion" aria-labelledby="dapagetitle" role="main" class="tab-pane fade show active offset-lg-3 col-lg-6 offset-md-2 col-md-8">
|
|
573
|
+
<div id="alkiln_proxy_var_values" data-generic_object="cHJveHlfbGlzdA" data-index_var_i="MA" data-index_var_j="" data-index_var_k="" data-index_var_l="" data-index_var_m="" data-index_var_n="" aria-hidden="true" style="display: none;"></div>
|
|
574
|
+
<form aria-labelledby="daMainQuestion" action="/interview?i=docassemble.playground12ALKilnTestALKiln5822columns1706994311264:test_pdf.yml" id="daform" class="form-horizontal daformfields" method="POST" novalidate="novalidate">
|
|
575
|
+
<div class="da-page-header">
|
|
576
|
+
<h1 class="h3" id="daMainQuestion">Proxy var 1</h1>
|
|
577
|
+
<div class="daclear"></div>
|
|
578
|
+
</div>
|
|
579
|
+
<div class="da-container da-form-group row darequired da-field-container da-field-container-datatype-text">
|
|
580
|
+
<label for="eFtpXS5uYW1lLmZpcnN0" class="col-md-4 col-form-label da-form-label datext-right" >first proxy name</label>
|
|
581
|
+
<div class="col-md-8 dafieldpart">
|
|
582
|
+
<input alt="Input box" class="form-control" type="text" name="eFtpXS5uYW1lLmZpcnN0" id="eFtpXS5uYW1lLmZpcnN0" required=""/>
|
|
583
|
+
</div>
|
|
584
|
+
</div>
|
|
585
|
+
<fieldset class="da-button-set da-field-buttons">
|
|
586
|
+
<legend class="visually-hidden">Press one of the following buttons:</legend>
|
|
587
|
+
<button class="btn btn-da btn-primary" id="da-continue-button" type="submit">Continue</button>
|
|
588
|
+
</fieldset>
|
|
589
|
+
<input type="hidden" name="csrf_toke" value="ImNlMGRmOWY5NmQ4MGRjMjI0ZDQyNGFjMWRiYjdiODAzOTk2ZThhY2Ui.Zb7dOA.Fvil0jDP4mebaBoPmtM7sXv6wSQ"/>
|
|
590
|
+
<input type="hidden" name="_event" value="WyJwcm94eV9saXN0WzBdLm5hbWUuZmlyc3QiXQ"/>
|
|
591
|
+
<input type="hidden" name="_question_name" value="ID proxy vars"/>
|
|
592
|
+
<input type="hidden" name="_tracker" value="3"/>
|
|
593
|
+
<input type="hidden" name="_datatypes" value="eyJlRnRwWFM1dVlXMWxMbVpwY25OMCI6ICJ0ZXh0In0"/>
|
|
594
|
+
<input type="hidden" name="_visible" value="" />
|
|
595
|
+
<input type="hidden" name="_varnames" value="eyJYMlpwWld4a1h6QSI6ICJlRnRwWFM1dVlXMWxMbVpwY25OMCJ9"/>
|
|
596
|
+
</form>
|
|
597
|
+
</div>`;
|
|
598
|
+
|
|
599
|
+
// Proxy substitution, no target variable
|
|
600
|
+
// Second loop (second time this question appears)
|
|
601
|
+
// x[i].name.first (i = 1)
|
|
602
|
+
html.proxy_substitution_i_is_1 = `
|
|
603
|
+
<div id="daquestion" aria-labelledby="dapagetitle" role="main" class="tab-pane fade show active offset-lg-3 col-lg-6 offset-md-2 col-md-8">
|
|
604
|
+
<div id="alkiln_proxy_var_values" data-generic_object="cHJveHlfbGlzdA" data-index_var_i="MQ" data-index_var_j="" data-index_var_k="" data-index_var_l="" data-index_var_m="" data-index_var_n="" aria-hidden="true" style="display: none;"></div>
|
|
605
|
+
<form aria-labelledby="daMainQuestion" action="/interview?i=docassemble.playground12ALKilnTestALKiln5822columns1706994311264:test_pdf.yml" id="daform" class="form-horizontal daformfields" method="POST" novalidate="novalidate">
|
|
606
|
+
<div class="da-page-header">
|
|
607
|
+
<h1 class="h3" id="daMainQuestion">Proxy var 2</h1>
|
|
608
|
+
<div class="daclear"></div>
|
|
609
|
+
</div>
|
|
610
|
+
<div class="da-container da-form-group row darequired da-field-container da-field-container-datatype-text">
|
|
611
|
+
<label for="eFtpXS5uYW1lLmZpcnN0" class="col-md-4 col-form-label da-form-label datext-right">second proxy name</label>
|
|
612
|
+
<div class="col-md-8 dafieldpart">
|
|
613
|
+
<input alt="Input box" class="form-control" type="text" name="eFtpXS5uYW1lLmZpcnN0" id="eFtpXS5uYW1lLmZpcnN0" required="">
|
|
614
|
+
</div>
|
|
615
|
+
</div>
|
|
616
|
+
<fieldset class="da-button-set da-field-buttons">
|
|
617
|
+
<legend class="visually-hidden">Press one of the following buttons:</legend>
|
|
618
|
+
<button class="btn btn-da btn-primary" id="da-continue-button" type="submit">Continue</button>
|
|
619
|
+
</fieldset>
|
|
620
|
+
<input type="hidden" name="csrf_token" value="ImNlMGRmOWY5NmQ4MGRjMjI0ZDQyNGFjMWRiYjdiODAzOTk2ZThhY2Ui.Zb7fVw.D9gMWkXreNYpd_eKkSXwMUybSZ4">
|
|
621
|
+
<input type="hidden" name="_event" value="WyJwcm94eV9saXN0WzFdLm5hbWUuZmlyc3QiXQ">
|
|
622
|
+
<input type="hidden" name="_question_name" value="ID proxy vars">
|
|
623
|
+
<input type="hidden" name="_tracker" value="7">
|
|
624
|
+
<input type="hidden" name="_datatypes" value="eyJlRnRwWFM1dVlXMWxMbVpwY25OMCI6ICJ0ZXh0In0">
|
|
625
|
+
<input type="hidden" name="_visible" value="">
|
|
626
|
+
<input type="hidden" name="_varnames" value="eyJYMlpwWld4a1h6QSI6ICJlRnRwWFM1dVlXMWxMbVpwY25OMCJ9">
|
|
627
|
+
</form>
|
|
628
|
+
</div>`;
|
|
629
|
+
|
|
568
630
|
|
|
569
631
|
// ============================
|
|
570
632
|
// Signature
|
|
@@ -107,12 +107,12 @@ matches.proxies_xi = [
|
|
|
107
107
|
// Multiple proxies by the same name are on the list (because of a loop)
|
|
108
108
|
// x[i].name.first
|
|
109
109
|
matches.proxies_multi = [
|
|
110
|
-
[{"trigger":"proxy_list[1].name.first","var":"x[i].name.first","value":"Firstname"}],
|
|
110
|
+
[{"trigger":"proxy_list[1].name.first","var":"x[i].name.first","value":"2 Firstname"}],
|
|
111
111
|
[]
|
|
112
112
|
];
|
|
113
113
|
|
|
114
114
|
// Missing table row for second loop
|
|
115
|
-
matches.
|
|
115
|
+
matches.proxies_missing_table_row = [
|
|
116
116
|
[],
|
|
117
117
|
[]
|
|
118
118
|
];
|
|
@@ -123,6 +123,24 @@ matches.proxies_missing_trigger = [
|
|
|
123
123
|
[]
|
|
124
124
|
];
|
|
125
125
|
|
|
126
|
+
// Proxy substitutes (no trigger) i = 0
|
|
127
|
+
matches.proxy_substitution_i_is_0 = [
|
|
128
|
+
[{"trigger": "","var": "proxy_list[0].name.first","value":"Firstname"}],
|
|
129
|
+
[]
|
|
130
|
+
];
|
|
131
|
+
|
|
132
|
+
// Proxy substitutes (no trigger) i = 1 (3 loops possible)
|
|
133
|
+
matches.proxy_substitution_i_is_1 = [
|
|
134
|
+
[{"trigger": "","var":"proxy_list[1].name.first","value":"2 Firstname"}],
|
|
135
|
+
[]
|
|
136
|
+
];
|
|
137
|
+
|
|
138
|
+
// Proxy substitution (no trigger) missing table row for second loop (i = 1)
|
|
139
|
+
matches.proxy_substitution_missing_table_row = [
|
|
140
|
+
[],
|
|
141
|
+
[]
|
|
142
|
+
];
|
|
143
|
+
|
|
126
144
|
|
|
127
145
|
// ============================
|
|
128
146
|
// Signature
|
|
@@ -139,16 +139,16 @@ tables.proxies_xi = [
|
|
|
139
139
|
{ "trigger": "proxy_list[0].name.first", "var": "x[i].name.first", "value": "Firstname", },
|
|
140
140
|
];
|
|
141
141
|
|
|
142
|
-
// Multiple proxies by the same name are on the list
|
|
142
|
+
// Multiple proxies by the same name are on the list because of a loop (3 loops possible)
|
|
143
143
|
// x[i].name.first
|
|
144
144
|
tables.proxies_multi = [
|
|
145
|
-
{ "trigger": "proxy_list[0].name.first", "var": "x[i].name.first", "value": "Firstname", },
|
|
146
|
-
{ "trigger": "proxy_list[1].name.first", "var": "x[i].name.first", "value": "Firstname", },
|
|
147
|
-
{ "trigger": "proxy_list[2].name.first", "var": "x[i].name.first", "value": "Firstname", },
|
|
145
|
+
{ "trigger": "proxy_list[0].name.first", "var": "x[i].name.first", "value": "1 Firstname", },
|
|
146
|
+
{ "trigger": "proxy_list[1].name.first", "var": "x[i].name.first", "value": "2 Firstname", },
|
|
147
|
+
{ "trigger": "proxy_list[2].name.first", "var": "x[i].name.first", "value": "3 Firstname", },
|
|
148
148
|
];
|
|
149
149
|
|
|
150
150
|
// Missing table row for second loop
|
|
151
|
-
tables.
|
|
151
|
+
tables.proxies_missing_table_row = [
|
|
152
152
|
{ "trigger": "proxy_list[0].name.first", "var": "x[i].name.first", "value": "Firstname", "original": { "trigger": "proxy_list[0].name.first", "var": "x[i].name.first", "value": "Firstname" } },
|
|
153
153
|
];
|
|
154
154
|
|
|
@@ -157,6 +157,23 @@ tables.proxies_missing_trigger = [
|
|
|
157
157
|
{ "trigger": "", "var": "x[i].name.first", "value": "Firstname", "original": { "trigger": "", "var": "x[i].name.first", "value": "Firstname" }},
|
|
158
158
|
];
|
|
159
159
|
|
|
160
|
+
// Proxy substitutes (no trigger) i = 0
|
|
161
|
+
tables.proxy_substitution_i_is_0 = [
|
|
162
|
+
{ "trigger": "", "var": "proxy_list[0].name.first", "value": "Firstname", },
|
|
163
|
+
];
|
|
164
|
+
|
|
165
|
+
// Proxy substitutes (no trigger) i = 1 (3 loops possible)
|
|
166
|
+
tables.proxy_substitution_i_is_1 = [
|
|
167
|
+
{ "trigger": "", "var": "proxy_list[0].name.first", "value": "1 Firstname", },
|
|
168
|
+
{ "trigger": "", "var": "proxy_list[1].name.first", "value": "2 Firstname", },
|
|
169
|
+
{ "trigger": "", "var": "proxy_list[2].name.first", "value": "3 Firstname", },
|
|
170
|
+
];
|
|
171
|
+
|
|
172
|
+
// Proxy substitution (no trigger) missing table row for second loop (i = 1)
|
|
173
|
+
tables.proxy_substitution_missing_table_row = [
|
|
174
|
+
{ "trigger": "", "var": "proxy_list[0].name.first", "value": "Firstname", "original": { "trigger": "", "var": "proxy_list[0].name.first", "value": "Firstname" } },
|
|
175
|
+
];
|
|
176
|
+
|
|
160
177
|
|
|
161
178
|
// ============================
|
|
162
179
|
// Signature
|