Skip to content

Commit

Permalink
Add support for cht-core 3.13 (including parse-timestamp-to-date) (#153)
Browse files Browse the repository at this point in the history
* Adds support for cht-core v3.13
* Makes 3.13 Enketo wireup the "default" which adds parse-timestamp-to-date
* Fixes a regression to the npm run explore command from the test refactoring in Support for cht-core v3.12 and the cht-script-api #151
  • Loading branch information
kennsippell authored Jan 4, 2022
1 parent 764ca93 commit 562ed5b
Show file tree
Hide file tree
Showing 15 changed files with 65,732 additions and 63,178 deletions.
3 changes: 2 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"name": "Build Assets (test collateral)",
"program": "${workspaceFolder}/project-explorer/build-assets.js",
"args": [
"--path=${workspaceFolder}/test/collateral"
"--appSettingPath=${workspaceFolder}/test/collateral/project-without-source",
"--formPath=${workspaceFolder}/test/collateral"
]
},
{
Expand Down
10 changes: 10 additions & 0 deletions all-chts-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,14 @@ module.exports = {
Lineage: require('cht-core-3-12/shared-libs/lineage'),
ChtScriptApi: require('cht-core-3-12/shared-libs/cht-script-api'),
},
'3.13': {
ddocs: require('./build/cht-core-3-13-ddocs.json'),
RegistrationUtils: require('cht-core-3-13/shared-libs/registration-utils'),
CalendarInterval: require('cht-core-3-13/shared-libs/calendar-interval'),
RulesEngineCore: require('cht-core-3-13/shared-libs/rules-engine'),
RulesEmitter: require('cht-core-3-13/shared-libs/rules-engine/src/rules-emitter'),
nootils: require('cht-core-3-13/shared-libs/rules-engine/node_modules/medic-nootils'),
Lineage: require('cht-core-3-13/shared-libs/lineage'),
ChtScriptApi: require('cht-core-3-13/shared-libs/cht-script-api'),
},
};
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ trap exit_on_error EXIT
npm ci
rm -Rf dist build
rm -Rf node_modules/enketo-core/node_modules/
patch -f node_modules/enketo-core/src/js/Form.js < node_modules/cht-core-3-11/webapp/patches/enketo-inputs-always-relevant.patch
patch -f node_modules/enketo-core/src/js/Form.js < node_modules/cht-core-3-13/webapp/patches/enketo-inputs-always-relevant.patch
patch -f node_modules/enketo-core/src/js/page.js < patches/enketo-handle-no-active-pages.patch
node ./compile-ddocs.js

Expand Down
128,122 changes: 64,970 additions & 63,152 deletions dist/all-chts-bundle.dev.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/all-chts-bundle.dev.js.map

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions dist/form-host.dev.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions ext/OpenrosaXpathEvaluatorBinding.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ var _ = require('underscore'),
openrosaExtensions = require('openrosa-xpath-extensions'),

/* This file changed from v3.6 > v3.7, but not v3.7 > v3.11 */
medicExtensions = require('cht-core-3-11/webapp/src/js/enketo/medic-xpath-extensions'),
translator = require('cht-core-3-11/webapp/src/js/enketo/translator');
medicExtensions = require('cht-core-3-13/webapp/src/js/enketo/medic-xpath-extensions'),
translator = require('cht-core-3-13/webapp/src/js/enketo/translator');

module.exports = function() {
// re-implement XPathJS ourselves!
Expand Down
2 changes: 1 addition & 1 deletion harness.defaults.json.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"coreVersion": "3.11.0",
"coreVersion": "3.13.0",
"user": "user_contact_id",
"subject": "patient_id",

Expand Down
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"test": "npx mocha test/*.spec.js --timeout 25000 --slow 500",
"build": "npm run docs && ./build.sh",
"docs": "npx jsdoc src/*.js src/**/*.js ./JSDOC.md -d docs",
"explore": "node ./project-explorer/build-assets.js --path=./test/collateral && cd project-explorer && webpack && google-chrome ./project-explorer.html",
"explore": "node ./project-explorer/build-assets.js --path=./test/collateral/project-without-source --formPath=./test/collateral && cd project-explorer && webpack && google-chrome ./project-explorer.html",
"eslint": "npx eslint .",
"travis": "npm run build && npm run eslint && npm test"
},
Expand All @@ -30,6 +30,7 @@
"cht-core-3-10": "git+https://github.com/medic/cht-core.git#3.10.x",
"cht-core-3-11": "git+https://github.com/medic/cht-core.git#3.11.x",
"cht-core-3-12": "git+https://github.com/medic/cht-core.git#3.12.x",
"cht-core-3-13": "git+https://github.com/medic/cht-core.git#3.13.x",
"cht-core-3-9": "git+https://github.com/medic/cht-core.git#3.9.x",
"couchdb-compile": "^1.11.0",
"enketo-core": "4.41.6",
Expand Down
23 changes: 15 additions & 8 deletions project-explorer/build-assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,27 @@ const jsonToXml = require('pojo2xml');
const usage = `Usage: build-assets --path=[DIRECTORY]
Builds the content of a project folder for user in project explorer.
--path path to the medic project folder
--output path where the built assets will be written (optional)
--path path to the medic project folder (app_settings.json)
--formPath path to folder containing app/*.xml or contact/*.xml (defaults to path)
--output path where the built assets will be written (optional)
`;

const argv = require('minimist')(process.argv.slice(2));
const pathToProject = path.resolve(argv.path);
const formPath = argv.formPath ? path.resolve(argv.formPath) : pathToProject;

if (!pathToProject) {
console.error(usage);
return -1;
}

if (!fs.existsSync(pathToProject)) {
console.error(`Could not locate project folder at: ${path.resolve(pathToProject)}`);
console.error(`Could not locate project folder at: ${pathToProject}`);
return -1;
}

if (!fs.existsSync(formPath)) {
console.error(`Could not locate form folder at: ${formPath}`);
return -1;
}

Expand All @@ -45,14 +52,14 @@ if (!fs.existsSync(pathToProject)) {
fs.writeFileSync(harnessDefaultDestinationPath, fileContent);

const appFormPaths = [
pathToProject,
path.join(pathToProject, 'forms'),
path.join(pathToProject, 'forms/app'),
path.join(pathToProject, 'forms/collect'),
formPath,
path.join(formPath, 'forms'),
path.join(formPath, 'forms/app'),
path.join(formPath, 'forms/collect'),
];

const contactFormPaths = [
path.join(pathToProject, 'forms/contact')
path.join(formPath, 'forms/contact')
];

const getFilesInFolders = directoriesToScan => {
Expand Down
13 changes: 13 additions & 0 deletions test/app-forms.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,17 @@ describe('forms that have caused bugs', () => {
const result2 = await harness.fillForm('empty', [1]);
expect(result2.errors).to.not.be.empty;
});

it('#148 - Support for parse-timestamp-to-date (added in 3.13)', async () => {
await harness.setNow('2000-01-01');
await harness.loadForm('covid19_rdt_provision');
await harness.page.evaluate(() => window.$$('input[name$="preview_session_state"]').removeAttr('data-required'));
const result = await harness.fillForm(
['nasal', 'asymptomatic'],
['nasal', undefined, '2000-04-01', ''],
[],
);
expect(result.errors).to.be.empty;
expect(result.report.fields.preview_time_expired).to.include('Mar, 1972');
});
});
Loading

0 comments on commit 562ed5b

Please sign in to comment.