@suffolklitlab/alkiln 5.0.0-playground-2 → 5.0.0-pre-3
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.
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
In this PR, I have:
|
|
2
|
+
|
|
3
|
+
* [ ] Added tests for any new features or bug fixes (if relevant)
|
|
4
|
+
* [ ] Added my changes to the CHANGELOG.md at the top, under the "Unreleased" section
|
|
5
|
+
* [ ] Ensured issues that this PR closes will be [automatically closed](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)
|
|
6
|
+
|
|
7
|
+
### Reason for this PR
|
|
8
|
+
|
|
9
|
+
<Insert reasons for this PR>
|
|
10
|
+
|
|
11
|
+
### Links to any solved or related issues
|
|
12
|
+
|
|
13
|
+
<Insert links>
|
|
14
|
+
|
|
15
|
+
### Any manual testing I have done to ensure my PR is working
|
|
16
|
+
|
|
17
|
+
<Insert description>
|
package/CHANGELOG.md
CHANGED
|
@@ -39,8 +39,8 @@ Format:
|
|
|
39
39
|
-
|
|
40
40
|
-->
|
|
41
41
|
## [Unreleased]
|
|
42
|
-
|
|
43
42
|
### Added
|
|
43
|
+
- added additional functionality to the sign method to allow developers to take a name argument to sign on canvas: issue #596
|
|
44
44
|
- A new script: `alkiln-run`, which acts like `npm run cucumber`, but can
|
|
45
45
|
be run in any directory, not just in an npm package.
|
|
46
46
|
- Additional environment variables and their validation to allow for tests that run on a developer's server/Playground instead of through GitHub. Also, other functionality for that purpose. [Issue #661](https://github.com/SuffolkLITLab/ALKiln/issues/661)
|
|
@@ -54,6 +54,10 @@ Format:
|
|
|
54
54
|
e.g. `alkiln-setup`, `alkiln-run`, `alkiln-takedown`
|
|
55
55
|
- don't print the ["publish this cucumber report" message](https://github.com/cucumber/cucumber-js/blob/main/docs/configuration.md#options)
|
|
56
56
|
- Adjusted validation of some environment variables to account for Playground vs. GitHub or local test runs. [Issue #661](https://github.com/SuffolkLITLab/ALKiln/issues/661)
|
|
57
|
+
- Project name prefix now includes ALKiln in it for clarity
|
|
58
|
+
|
|
59
|
+
### Fixed
|
|
60
|
+
- Projects created in da each have a unique name. https://github.com/SuffolkLITLab/ALKiln/issues/663
|
|
57
61
|
|
|
58
62
|
### Security
|
|
59
63
|
- Pass docassemble API keys through HTTP headers instead of as parameters.
|
|
@@ -225,16 +225,17 @@ da_i.loop_to_create_project = async function( creation_options ) {
|
|
|
225
225
|
let wait_seconds = creation_options.wait_seconds || 5;
|
|
226
226
|
|
|
227
227
|
let project_name = null;
|
|
228
|
-
|
|
228
|
+
// Unlikely, but 2 devs could run locally and create the same Project name
|
|
229
|
+
let num_tries = 0;
|
|
229
230
|
|
|
230
231
|
// Try to create a project. If the project name is already taken, increment and loop again.
|
|
231
|
-
while (
|
|
232
|
-
|
|
232
|
+
while ( num_tries <= max_tries ) {
|
|
233
|
+
num_tries++;
|
|
233
234
|
try {
|
|
234
235
|
|
|
235
236
|
// Try next name that could be unique. Must remove all non-valid characters
|
|
236
237
|
// TODO: This sanitization is already done in session_vars, so remove it from here
|
|
237
|
-
project_name = session_vars.get_project_base_name().replace(/[^A-Za-z0-9]/g, '') +
|
|
238
|
+
project_name = session_vars.get_project_base_name().replace(/[^A-Za-z0-9]/g, '') + `${Date.now()}`;
|
|
238
239
|
log.info({ pre: `Trying to create a docassemble Project with the name ${ project_name }` });
|
|
239
240
|
let response = await _da_REST.create_project( project_name, timeout );
|
|
240
241
|
log.info({ pre: `The docassemble server is ready. Created a Project named ${ project_name }` });
|
|
@@ -247,7 +248,7 @@ da_i.loop_to_create_project = async function( creation_options ) {
|
|
|
247
248
|
|
|
248
249
|
if ( response && response.data ) {
|
|
249
250
|
if ( response.data.includes( `Invalid project` ) ) {
|
|
250
|
-
if (
|
|
251
|
+
if ( num_tries < max_tries ) {
|
|
251
252
|
// A non-unique project name. Try the next project name.
|
|
252
253
|
continue;
|
|
253
254
|
|
|
@@ -275,11 +276,11 @@ da_i.loop_to_create_project = async function( creation_options ) {
|
|
|
275
276
|
|
|
276
277
|
// If it's a timeout error, server is busy. Try again after waiting.
|
|
277
278
|
// Why are we using `max_tries` for timeout error as well?
|
|
278
|
-
if ( is_timeout_error( error ) &&
|
|
279
|
+
if ( is_timeout_error( error ) && num_tries < max_tries ) {
|
|
279
280
|
log.info({ pre: `The docassemble server was busy when we tried to `
|
|
280
|
-
+ `create the Project. Attempt ${
|
|
281
|
+
+ `create the Project. Attempt ${ num_tries } of `
|
|
281
282
|
+ `${ max_tries }. Will try again in ${ wait_seconds } seconds.` });
|
|
282
|
-
|
|
283
|
+
num_tries--; // Don't count this try
|
|
283
284
|
await time.waitForTimeout( wait_seconds * 1000 );
|
|
284
285
|
continue;
|
|
285
286
|
|
package/lib/docassemble/setup.js
CHANGED
|
@@ -25,6 +25,7 @@ const setup = async () => {
|
|
|
25
25
|
// avoids showing confusing node errors to users that they shouldn't have to fix
|
|
26
26
|
try {
|
|
27
27
|
project_name = await da_i.loop_to_create_project();
|
|
28
|
+
log.info({type: `setup`, pre: `Created a Project named ${ project_name }`});
|
|
28
29
|
} catch (error) {
|
|
29
30
|
log.error({type: `setup`, pre: `an unexpected error occurred while trying to create a docassemble project in the user's account`, data: JSON.stringify(error, null, 4)})
|
|
30
31
|
// we don't re-throw the exception, so make sure to exit with 1 to let Github Actions know the script failed
|
package/lib/scope.js
CHANGED
|
@@ -1871,16 +1871,26 @@ module.exports = {
|
|
|
1871
1871
|
}, 500)
|
|
1872
1872
|
},
|
|
1873
1873
|
|
|
1874
|
-
draw_signature: async function ( scope ) {
|
|
1874
|
+
draw_signature: async function ( scope, name ) {
|
|
1875
1875
|
/* On a signature page, there should only be a single signature canvas
|
|
1876
1876
|
* and a continue button. Draw in the #dasigcanvas element. `<canvas>`
|
|
1877
1877
|
* takes a while to load. */
|
|
1878
|
-
let
|
|
1878
|
+
let canvas = await scope.page.waitForSelector( `#dasigcanvas` );
|
|
1879
1879
|
let msg = `Could not find a signature field.`;
|
|
1880
|
-
if ( !
|
|
1881
|
-
expect(
|
|
1882
|
-
|
|
1883
|
-
|
|
1880
|
+
if ( !canvas ) { await scope.addToReport(scope, { type: `error`, value: msg }); }
|
|
1881
|
+
expect( canvas, msg ).to.exist;
|
|
1882
|
+
|
|
1883
|
+
// Provides functionality to draw name arg on canvas
|
|
1884
|
+
if (name !== undefined) {
|
|
1885
|
+
await scope.page.$eval(`#dasigcanvas`, (canvas, name) => {
|
|
1886
|
+
const ctx = canvas.getContext("2d");
|
|
1887
|
+
ctx.font = "24px serif";
|
|
1888
|
+
ctx.fillText(name, 10, 50);
|
|
1889
|
+
}, name);
|
|
1890
|
+
}
|
|
1891
|
+
let bounding_box = await canvas.boundingBox();
|
|
1892
|
+
// We draw the dot because it allows the developer to tap continue
|
|
1893
|
+
// Docassemble does not allow to tap continue unless the user interacts with the canvas
|
|
1884
1894
|
await scope.page.mouse.move(bounding_box.x + bounding_box.width / 2, bounding_box.y + bounding_box.height / 2);
|
|
1885
1895
|
await scope.page.mouse.down();
|
|
1886
1896
|
// await scope.page.mouse.move(1, 1); // Too big? Wait a while before drawing?
|
|
@@ -2405,9 +2415,9 @@ module.exports = {
|
|
|
2405
2415
|
await scope.afterStep(scope, {waitForShowIf: true});
|
|
2406
2416
|
}, // Ends scope.steps.tap_term()
|
|
2407
2417
|
|
|
2408
|
-
sign: async ( scope ) => {
|
|
2418
|
+
sign: async ( scope, name ) => {
|
|
2409
2419
|
/** Sign on a signature page. */
|
|
2410
|
-
await scope.draw_signature( scope );
|
|
2420
|
+
await scope.draw_signature( scope, name );
|
|
2411
2421
|
await scope.afterStep(scope);
|
|
2412
2422
|
}, // Ends scope.steps.sign()
|
|
2413
2423
|
|
package/lib/steps.js
CHANGED
|
@@ -979,13 +979,21 @@ When('I tap the defined text link {string}', { timeout: -1 }, async ( phrase ) =
|
|
|
979
979
|
await scope.steps.tap_term( scope, phrase );
|
|
980
980
|
});
|
|
981
981
|
|
|
982
|
-
Then(
|
|
982
|
+
Then(/^I sign$/, { timeout: -1 }, async () => {
|
|
983
983
|
return wrapPromiseWithTimeout(
|
|
984
984
|
scope.steps.sign( scope ),
|
|
985
985
|
scope.timeout
|
|
986
986
|
);
|
|
987
987
|
});
|
|
988
988
|
|
|
989
|
+
Then('I sign with the name {string}', { timeout: -1 }, async ( name ) => {
|
|
990
|
+
/* Signs with the string argument */
|
|
991
|
+
return wrapPromiseWithTimeout(
|
|
992
|
+
scope.steps.sign( scope, name ),
|
|
993
|
+
scope.timeout
|
|
994
|
+
);
|
|
995
|
+
});
|
|
996
|
+
|
|
989
997
|
When(/I download "([^"]+)"$/, { timeout: -1 }, async ( filename ) => {
|
|
990
998
|
/* Taps the link that leads to the given filename to trigger downloading.
|
|
991
999
|
* and waits till the file has been downloaded before allowing the tests to continue.
|
|
@@ -93,7 +93,7 @@ session_vars.get_package_name = function () {
|
|
|
93
93
|
};
|
|
94
94
|
|
|
95
95
|
session_vars.get_project_base_name = function () {
|
|
96
|
-
let name = `
|
|
96
|
+
let name = `ALKilnTest${ session_vars.get_package_name() }${ session_vars.get_branch_name() }`;
|
|
97
97
|
let sanitized_name = name.replace( /[^A-Za-z0-9]/g, '' );
|
|
98
98
|
return sanitized_name;
|
|
99
99
|
};
|
package/package.json
CHANGED