@suffolklitlab/alkiln 4.8.0 → 4.9.0
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/CHANGELOG.md +5 -0
- package/lib/docassemble/setup.js +0 -5
- package/lib/scope.js +51 -12
- package/lib/steps.js +10 -11
- package/package.json +1 -1
- package/tests/features/establishing_steps.feature +25 -0
- package/tests/features/reports.feature +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -40,6 +40,11 @@ Format:
|
|
|
40
40
|
-->
|
|
41
41
|
<!-- ## [Unreleased] -->
|
|
42
42
|
|
|
43
|
+
## [4.9.0] - 2022-09-01
|
|
44
|
+
### Changed
|
|
45
|
+
- Allow devs to test an arbitrary interview. See https://github.com/SuffolkLITLab/ALKiln/issues/600.
|
|
46
|
+
- Create artifacts folder even when setup has been skipped. See https://github.com/SuffolkLITLab/ALKiln/issues/600.
|
|
47
|
+
|
|
43
48
|
## [4.8.0] - 2022-08-30
|
|
44
49
|
### Changed
|
|
45
50
|
- Date for filenames. Format date in y-m-d format instead of d-m-y that it had by default. Include ms.
|
package/lib/docassemble/setup.js
CHANGED
|
@@ -31,11 +31,6 @@ const setup = async () => {
|
|
|
31
31
|
await da_i.wait_for_server_to_restart( task_id );
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
// Make the folder to store all the files for this run of the tests
|
|
35
|
-
const artifacts_path_name = files.make_artifacts_folder();
|
|
36
|
-
// Save its name in a file. `session_vars` can get it back later.
|
|
37
|
-
session_vars.save_artifacts_path_name( artifacts_path_name );
|
|
38
|
-
|
|
39
34
|
// Finish
|
|
40
35
|
log.info({ type: `setup`, pre: `Success! Test setup has finished successfully.` });
|
|
41
36
|
}; // Ends setup();
|
package/lib/scope.js
CHANGED
|
@@ -752,10 +752,27 @@ module.exports = {
|
|
|
752
752
|
/* Try to load the page. Should we also pass a `timeout` arg or just
|
|
753
753
|
* use scope.timeout? */
|
|
754
754
|
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
755
|
+
await scope.addToReport(scope,{
|
|
756
|
+
type: `row`,
|
|
757
|
+
value: `Trying to load the interview`
|
|
758
|
+
});
|
|
759
|
+
|
|
760
|
+
let interview_url = null;
|
|
761
|
+
// If the file is already a full url, just use that arbitrary url
|
|
762
|
+
if ( /^http/.test( file_name ) ) {
|
|
763
|
+
interview_url = file_name;
|
|
764
|
+
|
|
765
|
+
// If the filename is not a full url
|
|
766
|
+
} else {
|
|
767
|
+
// If the filename is just the name of the interview without `.yml`, add `.yml` to the end
|
|
768
|
+
if ( !file_name.includes('.yml') ) { file_name = `${ file_name }.yml` }
|
|
769
|
+
// Otherwise, the filename might have url args, so leave it alone
|
|
770
|
+
|
|
771
|
+
// Add the server address to the filename
|
|
772
|
+
let base_url = await get_base_interview_url();
|
|
773
|
+
interview_url = `${ base_url }${ file_name }`;
|
|
774
|
+
}
|
|
775
|
+
if ( session_vars.get_debug() ) { console.log( `interview_url:`, interview_url ); }
|
|
759
776
|
|
|
760
777
|
if ( !scope.page ) { scope.page = await scope.browser.newPage(); }
|
|
761
778
|
|
|
@@ -766,17 +783,19 @@ module.exports = {
|
|
|
766
783
|
|
|
767
784
|
} catch ( error ) {
|
|
768
785
|
|
|
786
|
+
// If the page didn't load because it took to long to load
|
|
769
787
|
if ( error.name === `TimeoutError` ) {
|
|
770
788
|
|
|
771
|
-
let non_reload_report_msg = `Timeout error occurred when ALKiln tried to go to the interview url
|
|
789
|
+
let non_reload_report_msg = `Timeout error occurred when ALKiln tried to go to the interview url`;
|
|
772
790
|
await scope.handle_page_timeout_error( scope, { non_reload_report_msg, error });
|
|
773
791
|
|
|
792
|
+
// If the page didn't load because of any other reason
|
|
774
793
|
} else {
|
|
775
794
|
|
|
776
795
|
// Throw any non-timeout error
|
|
777
796
|
scope.addToReport( scope, {
|
|
778
797
|
type: `error`,
|
|
779
|
-
value: `Error occurred when ALKiln tried to go to the interview url
|
|
798
|
+
value: `Error occurred when ALKiln tried to go to the interview url`
|
|
780
799
|
});
|
|
781
800
|
throw( error );
|
|
782
801
|
} // ends if error is timeout error
|
|
@@ -794,35 +813,55 @@ module.exports = {
|
|
|
794
813
|
}, // Ends scope.load()
|
|
795
814
|
|
|
796
815
|
getLoadData: async function ( scope ) {
|
|
797
|
-
/* Return
|
|
798
|
-
*
|
|
816
|
+
/* Return elements that could load on the page, like #daMainQuestion
|
|
817
|
+
* and #da-retry. If there's a system error on the page, return its main text.
|
|
799
818
|
*
|
|
800
819
|
* If server isn't loaded yet, it should get the browser timeout error,
|
|
801
|
-
* which won't match
|
|
820
|
+
* which won't match those selectors and this will timeout and error. */
|
|
802
821
|
let result = { error: ``, elem: null };
|
|
803
822
|
|
|
823
|
+
// Wait for at least one of these to appear
|
|
804
824
|
let winner = await Promise.race([
|
|
805
825
|
// Signature page
|
|
806
826
|
scope.page.waitForSelector( `#dasigpage`, { timeout: scope.timeout }),
|
|
807
827
|
// Any other valid page
|
|
808
828
|
scope.page.waitForSelector( `#daMainQuestion`, { timeout: scope.timeout }),
|
|
809
829
|
scope.page.waitForSelector( `#da-retry`, { timeout: scope.timeout }),
|
|
810
|
-
])
|
|
830
|
+
]).catch( function ( error ) {
|
|
831
|
+
// With any error in here, stop execution of the test
|
|
832
|
+
|
|
833
|
+
// If none of them appear before this times out
|
|
834
|
+
if ( error.name.includes(`TimeoutError`) ) {
|
|
835
|
+
|
|
836
|
+
result.error = `ALKiln could not find any interview question page with the given information`;
|
|
837
|
+
return result;
|
|
838
|
+
|
|
839
|
+
// or if they cause some other kind of error
|
|
840
|
+
} else {
|
|
841
|
+
throw error;
|
|
842
|
+
} // ends if error.name.includes(`TimeoutError`)
|
|
843
|
+
}); // ends Promise.race()
|
|
811
844
|
|
|
812
845
|
result.elem = winner;
|
|
813
846
|
|
|
847
|
+
// If a page was loaded, but there's a specific type of error on the page
|
|
848
|
+
// throw an error
|
|
814
849
|
let error_id_elem = await scope.page.$( `#da-retry` );
|
|
815
850
|
if ( error_id_elem ) {
|
|
851
|
+
|
|
852
|
+
// If it's a specific type of error, we can show the developer its text
|
|
816
853
|
let error_elem = await scope.page.$( `blockquote` );
|
|
817
854
|
if (error_elem !== null) {
|
|
818
855
|
let error_handle = await error_elem.getProperty( `textContent` );
|
|
819
856
|
let system_error_text = await error_handle.jsonValue();
|
|
820
857
|
|
|
821
858
|
result.error = system_error_text;
|
|
859
|
+
|
|
860
|
+
// Error types we haven't accounted for
|
|
822
861
|
} else {
|
|
823
862
|
result.error = "Docassemble ran into an error on the page, but ALKiln does not know what the error is. If a screenshot was taken, check the screenshot";
|
|
824
|
-
}
|
|
825
|
-
}
|
|
863
|
+
} // ends if error_elem !== null
|
|
864
|
+
} // ends if error_id_elem
|
|
826
865
|
|
|
827
866
|
return result;
|
|
828
867
|
}, // Ends scope.getLoadData()
|
package/lib/steps.js
CHANGED
|
@@ -85,18 +85,17 @@ BeforeAll(async () => {
|
|
|
85
85
|
|
|
86
86
|
// Store path names for files and docs created for the tests
|
|
87
87
|
scope.paths = {};
|
|
88
|
-
// Test setup should have created this filepath. Run setup if there's a problem with this.
|
|
89
|
-
scope.paths.artifacts = session_vars.get_artifacts_path_name();
|
|
90
|
-
// For GitHub tests, use the artifacts folder that was created during setup
|
|
91
|
-
// For local tests, make a new folder for each time scenarios start
|
|
92
|
-
if ( !session_vars.is_dev_env() ) {
|
|
93
|
-
// Make a new folder to store all the files for this run of the tests
|
|
94
|
-
scope.paths.artifacts = files.make_artifacts_folder();
|
|
95
|
-
// Save its name in a file. `session_vars` can get it back later.
|
|
96
|
-
session_vars.save_artifacts_path_name( scope.paths.artifacts );
|
|
97
|
-
}
|
|
98
|
-
scope.paths.report = `${ scope.paths.artifacts }/report.txt`;
|
|
99
88
|
|
|
89
|
+
// TODO: figure out how to test file and folder creation stuff,
|
|
90
|
+
// especially when setup is excluded from the flow.
|
|
91
|
+
|
|
92
|
+
// Make the folder to store all the files for this run of the tests
|
|
93
|
+
scope.paths.artifacts = files.make_artifacts_folder();
|
|
94
|
+
// Save its name in a file. `session_vars` can get it back later.
|
|
95
|
+
// This is used by at least clean_reports.js.
|
|
96
|
+
session_vars.save_artifacts_path_name( scope.paths.artifacts );
|
|
97
|
+
|
|
98
|
+
scope.paths.report = `${ scope.paths.artifacts }/report.txt`;
|
|
100
99
|
scope.paths.debug_log = `${ scope.paths.artifacts }/${ log.debug_log_file }`;
|
|
101
100
|
fs.writeFileSync( scope.paths.debug_log, "" );
|
|
102
101
|
});
|
package/package.json
CHANGED
|
@@ -35,3 +35,28 @@ Scenario: Interview name includes url args with a wait
|
|
|
35
35
|
Scenario: I sign in
|
|
36
36
|
Given I sign in with the email "USER1_EMAIL" and the password "USER1_PASSWORD"
|
|
37
37
|
And I start the interview at "all_tests"
|
|
38
|
+
|
|
39
|
+
@fast @e7 @arbitraryurl
|
|
40
|
+
Scenario: I want to go to a full arbitrary url
|
|
41
|
+
Given the max seconds for each step in this scenario is 5
|
|
42
|
+
And the Scenario report should include:
|
|
43
|
+
"""
|
|
44
|
+
Trying to load the interview
|
|
45
|
+
"""
|
|
46
|
+
Given I start the interview at "https://apps-test.suffolklitlab.org/start/demo/questions"
|
|
47
|
+
Then I should see the phrase "What language do you speak?"
|
|
48
|
+
|
|
49
|
+
# WARNING: This Scenario may fail if the file moves or changes too much
|
|
50
|
+
@fast @failing @e8 @rfe8 @arbitraryurl
|
|
51
|
+
Scenario: Fail with no interview at arbitrary url
|
|
52
|
+
Given the final Scenario status should be "failed"
|
|
53
|
+
And the Scenario report should include:
|
|
54
|
+
"""
|
|
55
|
+
Trying to load the interview
|
|
56
|
+
"""
|
|
57
|
+
And the Scenario report should include:
|
|
58
|
+
"""
|
|
59
|
+
ALKiln could not find any interview question page
|
|
60
|
+
"""
|
|
61
|
+
And the max seconds for each step in this scenario is 5
|
|
62
|
+
Then I start the interview at "https://apps-test.suffolklitlab.org/list"
|
|
@@ -444,6 +444,7 @@ Scenario: Report still shows page id when I tap to continue without setting any
|
|
|
444
444
|
Scenario: Report still shows page id when I tap to continue without setting any fields
|
|
445
445
|
Tags: @reports @fast @rp1
|
|
446
446
|
---------------
|
|
447
|
+
Trying to load the interview
|
|
447
448
|
screen id: upload-files
|
|
448
449
|
screen id: group-of-complex-fields
|
|
449
450
|
| double_quote_dict['double_quote_key']['dq_two'] | true | |
|