diff --git a/src/fn/convert-training-forms.js b/src/fn/convert-training-forms.js
new file mode 100644
index 000000000..21de5183d
--- /dev/null
+++ b/src/fn/convert-training-forms.js
@@ -0,0 +1,17 @@
+const convertForms = require('../lib/convert-forms').execute;
+const environment = require('../lib/environment');
+const { TRAINING_FORMS_PATH } = require('../lib/project-paths');
+
+const convertTrainingForms = (forms) => {
+ return convertForms(environment.pathToProject, 'training', {
+ enketo: true,
+ forms: forms,
+ });
+};
+
+module.exports = {
+ requiresInstance: false,
+ convertTrainingForms,
+ TRAINING_FORMS_PATH,
+ execute: () => convertTrainingForms(environment.extraArgs)
+};
diff --git a/src/fn/upload-training-forms.js b/src/fn/upload-training-forms.js
new file mode 100644
index 000000000..ad867c765
--- /dev/null
+++ b/src/fn/upload-training-forms.js
@@ -0,0 +1,17 @@
+const environment = require('../lib/environment');
+const uploadForms = require('../lib/upload-forms').execute;
+const { TRAINING_FORMS_PATH } = require('../lib/project-paths');
+
+const uploadTrainingForms = (forms) => {
+ return uploadForms(environment.pathToProject, 'training', {
+ id_prefix: 'training:',
+ forms: forms,
+ });
+};
+
+module.exports = {
+ requiresInstance: true,
+ uploadTrainingForms,
+ TRAINING_FORMS_PATH,
+ execute: () => uploadTrainingForms(environment.extraArgs)
+};
diff --git a/src/fn/validate-training-forms.js b/src/fn/validate-training-forms.js
new file mode 100644
index 000000000..310649560
--- /dev/null
+++ b/src/fn/validate-training-forms.js
@@ -0,0 +1,12 @@
+const validateForms = require('../lib/validate-forms');
+const environment = require('../lib/environment');
+
+const validateTrainingForms = (forms) => {
+ return validateForms(environment.pathToProject, 'training', { forms });
+};
+
+module.exports = {
+ requiresInstance: false,
+ validateTrainingForms,
+ execute: () => validateTrainingForms(environment.extraArgs)
+};
diff --git a/src/fn/watch-project.js b/src/fn/watch-project.js
index 7a52ca2dd..72f1ac87b 100644
--- a/src/fn/watch-project.js
+++ b/src/fn/watch-project.js
@@ -8,14 +8,17 @@ const watcher = require('@parcel/watcher');
const { validateAppForms } = require('./validate-app-forms');
const { validateContactForms } = require('./validate-contact-forms');
const { validateCollectForms } = require('./validate-collect-forms');
+const { validateTrainingForms } = require('./validate-training-forms');
const { uploadAppForms } = require('./upload-app-forms');
const { uploadContactForms } = require('./upload-contact-forms');
const { uploadCollectForms } = require('./upload-collect-forms');
+const { uploadTrainingForms } = require('./upload-training-forms');
const convertForms = require('../lib/convert-forms');
const uploadForms = require('../lib/upload-forms');
const { deleteForms } = require('../fn/delete-forms');
const { convertAppForms, APP_FORMS_PATH } = require('./convert-app-forms');
const { convertContactForm, CONTACT_FORMS_PATH } = require('./convert-contact-forms');
+const { convertTrainingForms, TRAINING_FORMS_PATH } = require('./convert-training-forms');
const { convertCollectForms, COLLECT_FORMS_PATH } = require('./convert-collect-forms');
const { uploadAppSettings, APP_SETTINGS_DIR_PATH, APP_SETTINGS_JSON_PATH } = require('./upload-app-settings');
const { execute: compileAppSettings, configFileMatcher } = require('./compile-app-settings');
@@ -39,8 +42,10 @@ const uploadInitialState = async (api) => {
await uploadResources();
await runValidation(validateAppForms, environment.extraArgs);
await runValidation(validateContactForms, environment.extraArgs);
+ await runValidation(validateTrainingForms, environment.extraArgs);
await uploadAppForms(environment.extraArgs);
await uploadContactForms(environment.extraArgs);
+ await uploadTrainingForms(environment.extraArgs);
await uploadCustomTranslations();
await uploadAppSettings(api);
};
@@ -87,62 +92,64 @@ const deleteForm = (fileName, formDir) => {
return false;
};
-const processAppForm = (eventType, fileName) => {
- if (eventType === watcherEvents.DeleteEvent && deleteForm(fileName, APP_FORMS_PATH)) {
- return true;
+const getFormCommandContext = (parsedPath) => {
+ if (parsedPath.dir === path.join(environment.pathToProject, APP_FORMS_PATH)) {
+ return {
+ path: APP_FORMS_PATH,
+ validateForms: validateAppForms,
+ uploadForms: uploadAppForms,
+ convertForms: convertAppForms,
+ };
}
- let form = uploadForms.formFileMatcher(fileName);
- if (form) {
- eventQueue.enqueue(async () => {
- await runValidation(validateAppForms, [form]);
- await uploadAppForms([form]);
- return fileName;
- });
- return true;
+
+ if (parsedPath.dir === path.join(environment.pathToProject, TRAINING_FORMS_PATH)) {
+ return {
+ path: TRAINING_FORMS_PATH,
+ validateForms: validateTrainingForms,
+ uploadForms: uploadTrainingForms,
+ convertForms: convertTrainingForms,
+ };
}
- form = convertForms.formFileMatcher(fileName);
- if (form) {
- eventQueue.enqueue(async () => {
- await convertAppForms([form]);
- return fileName;
- });
- return true;
+ if (parsedPath.dir === path.join(environment.pathToProject, CONTACT_FORMS_PATH)) {
+ return {
+ path: CONTACT_FORMS_PATH,
+ validateForms: validateContactForms,
+ uploadForms: uploadContactForms,
+ convertForms: convertContactForm,
+ };
}
- return false;
-};
-const processAppFormMedia = (formMediaDir, fileName) => {
- const form = uploadForms.formMediaMatcher(formMediaDir);
- if (form) {
- eventQueue.enqueue(async () => {
- await runValidation(validateAppForms,[form]);
- await uploadAppForms([form]);
- return fileName;
- });
- return true;
+ if (parsedPath.dir === path.join(environment.pathToProject, COLLECT_FORMS_PATH)) {
+ return {
+ path: COLLECT_FORMS_PATH,
+ validateForms: validateCollectForms,
+ uploadForms: uploadCollectForms,
+ convertForms: convertCollectForms,
+ };
}
- return false;
+
+ return;
};
-const processContactForm = (eventType, fileName) => {
- if (eventType === watcherEvents.DeleteEvent && deleteForm(fileName, CONTACT_FORMS_PATH)) {
+const processForm = (eventType, fileName, commandContext) => {
+ if (eventType === watcherEvents.DeleteEvent && deleteForm(fileName, commandContext.path)) {
return true;
}
- let form = convertForms.formFileMatcher(fileName);
+ let form = uploadForms.formFileMatcher(fileName);
if (form) {
eventQueue.enqueue(async () => {
- await convertContactForm([form]);
+ await runValidation(commandContext.validateForms, [form]);
+ await commandContext.uploadForms([form]);
return fileName;
});
return true;
}
- form = uploadForms.formFileMatcher(fileName);
+ form = convertForms.formFileMatcher(fileName);
if (form) {
eventQueue.enqueue(async () => {
- await runValidation(validateContactForms,[form]);
- await uploadContactForms([form]);
+ await commandContext.convertForms([form]);
return fileName;
});
return true;
@@ -150,24 +157,34 @@ const processContactForm = (eventType, fileName) => {
return false;
};
-const processCollectForm = (eventType, fileName) => {
- if (eventType === watcherEvents.DeleteEvent && deleteForm(fileName, COLLECT_FORMS_PATH)) {
- return true;
+const getFormMediaCommandContext = (parsedPath) => {
+ if (parsedPath.dir.startsWith(path.join(environment.pathToProject, APP_FORMS_PATH))
+ && path.parse(parsedPath.dir).dir.endsWith(APP_FORMS_PATH)) {
+ // Check if the directory's immediate parent is forms/app
+ return {
+ validateForms: validateAppForms,
+ uploadForms: uploadAppForms,
+ };
}
- let form = uploadForms.formFileMatcher(fileName);
- if (form) {
- eventQueue.enqueue(async () => {
- await runValidation(validateCollectForms,[form]);
- await uploadCollectForms([form]);
- return fileName;
- });
- return true;
+
+ if (parsedPath.dir.startsWith(path.join(environment.pathToProject, TRAINING_FORMS_PATH))
+ && path.parse(parsedPath.dir).dir.endsWith(TRAINING_FORMS_PATH)) {
+ // Check if the directory's immediate parent is forms/training
+ return {
+ validateForms: validateTrainingForms,
+ uploadForms: uploadTrainingForms,
+ };
}
- form = convertForms.formFileMatcher(fileName);
+ return;
+};
+
+const processFormMedia = (formMediaDir, fileName, commandContext) => {
+ const form = uploadForms.formMediaMatcher(formMediaDir);
if (form) {
eventQueue.enqueue(async () => {
- await convertCollectForms([form]);
+ await runValidation(commandContext.validateForms,[form]);
+ await commandContext.uploadForms([form]);
return fileName;
});
return true;
@@ -212,29 +229,19 @@ const watchProject = {
const parsedPath = path.parse(changePath);
const fileName = parsedPath.base;
- if (parsedPath.dir === path.join(environment.pathToProject, APP_FORMS_PATH)) {
- processAppForm(event.type, fileName);
+ const formContext = getFormCommandContext(parsedPath);
+ if (formContext) {
+ processForm(event.type, fileName, formContext);
continue;
}
- if (parsedPath.dir.startsWith(path.join(environment.pathToProject, APP_FORMS_PATH))
- && path.parse(parsedPath.dir).dir.endsWith(APP_FORMS_PATH)) { // check if the directory's immediate parent is forms/app
+ const formMediaContext = getFormMediaCommandContext(parsedPath);
+ if (formMediaContext) {
const dirName = path.parse(parsedPath.dir).base;
- processAppFormMedia(dirName, fileName);
+ processFormMedia(dirName, fileName, formMediaContext);
continue;
}
- if (parsedPath.dir === path.join(environment.pathToProject, CONTACT_FORMS_PATH)) {
- processContactForm(event.type, fileName);
- continue;
- }
-
- if (parsedPath.dir === path.join(environment.pathToProject, COLLECT_FORMS_PATH)) {
- processCollectForm(event.type, fileName);
- continue;
- }
-
-
if (parsedPath.dir === path.join(environment.pathToProject, TRANSLATIONS_DIR_PATH)) {
eventQueue.enqueue(async () => {
await uploadCustomTranslations();
diff --git a/src/lib/main.js b/src/lib/main.js
index 5b92c661c..6594428fa 100755
--- a/src/lib/main.js
+++ b/src/lib/main.js
@@ -21,14 +21,17 @@ const defaultActions = [
'convert-app-forms',
'convert-collect-forms',
'convert-contact-forms',
+ 'convert-training-forms',
'validate-app-forms',
'validate-collect-forms',
'validate-contact-forms',
+ 'validate-training-forms',
'backup-all-forms',
'delete-all-forms',
'upload-app-forms',
'upload-collect-forms',
'upload-contact-forms',
+ 'upload-training-forms',
'upload-resources',
'upload-branding',
'upload-partners',
@@ -41,12 +44,15 @@ const defaultArchiveActions = [
'convert-app-forms',
'convert-collect-forms',
'convert-contact-forms',
+ 'convert-training-forms',
'validate-app-forms',
'validate-collect-forms',
'validate-contact-forms',
+ 'validate-training-forms',
'upload-app-forms',
'upload-collect-forms',
'upload-contact-forms',
+ 'upload-training-forms',
'upload-resources',
'upload-branding',
'upload-partners',
@@ -148,7 +154,8 @@ module.exports = async (argv, env) => {
const validateActions = [
'validate-app-forms',
'validate-collect-forms',
- 'validate-contact-forms'
+ 'validate-contact-forms',
+ 'validate-training-forms',
];
actions = actions.filter(action => !validateActions.includes(action));
} else {
@@ -161,6 +168,7 @@ module.exports = async (argv, env) => {
addFormValidationIfNecessary('app');
addFormValidationIfNecessary('collect');
addFormValidationIfNecessary('contact');
+ addFormValidationIfNecessary('training');
}
actions = actions.map(actionName => {
diff --git a/src/lib/project-paths.js b/src/lib/project-paths.js
index c8699ffa3..74241c355 100644
--- a/src/lib/project-paths.js
+++ b/src/lib/project-paths.js
@@ -6,6 +6,7 @@ module.exports = {
APP_FORMS_PATH: path.join('forms', 'app'),
CONTACT_FORMS_PATH: path.join('forms', 'contact'),
COLLECT_FORMS_PATH: path.join('forms', 'collect'),
+ TRAINING_FORMS_PATH: path.join('forms', 'training'),
TRANSLATIONS_DIR_PATH: 'translations',
RESOURCE_CONFIG_PATH: 'resources.json',
RESOURCES_DIR_PATH: 'resources'
diff --git a/test/data/convert-training-forms/forms/training/expected/new_actions_training.xml b/test/data/convert-training-forms/forms/training/expected/new_actions_training.xml
new file mode 100644
index 000000000..564fc7629
--- /dev/null
+++ b/test/data/convert-training-forms/forms/training/expected/new_actions_training.xml
@@ -0,0 +1,74 @@
+
+
+
+ new_actions_training
+
+
+
+
+ The "New Action" icon at the bottom of your app has changed to a big blue plus icon.
+
+
+ If you do not understand these changes, please contact your supervisor.
+
+
+ When you're ready, go ahead and start using your app.
+
+
+ There have been some changes to icons in your app. The next few screens will show you the difference.
+
+
+ Read each screen carefully and tap "Next" if you understand. If you need extra support, please contact your supervisor.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/data/convert-training-forms/forms/training/new_actions_training.xlsx b/test/data/convert-training-forms/forms/training/new_actions_training.xlsx
new file mode 100644
index 000000000..75e2b4817
Binary files /dev/null and b/test/data/convert-training-forms/forms/training/new_actions_training.xlsx differ
diff --git a/test/data/skeleton/forms/training/.gitkeep b/test/data/skeleton/forms/training/.gitkeep
new file mode 100644
index 000000000..e69de29bb
diff --git a/test/data/skeleton/sample-forms/training-form-media/training-media/.gitkeep b/test/data/skeleton/sample-forms/training-form-media/training-media/.gitkeep
new file mode 100644
index 000000000..e69de29bb
diff --git a/test/data/skeleton/sample-forms/training-form-media/training.xml b/test/data/skeleton/sample-forms/training-form-media/training.xml
new file mode 100644
index 000000000..247f584ba
--- /dev/null
+++ b/test/data/skeleton/sample-forms/training-form-media/training.xml
@@ -0,0 +1,74 @@
+
+
+
+ training
+
+
+
+
+ The "New Action" icon at the bottom of your app has changed to a big blue plus icon.
+
+
+ If you do not understand these changes, please contact your supervisor.
+
+
+ When you're ready, go ahead and start using your app.
+
+
+ There have been some changes to icons in your app. The next few screens will show you the difference.
+
+
+ Read each screen carefully and tap "Next" if you understand. If you need extra support, please contact your supervisor.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/data/skeleton/sample-forms/training-xlsx/new_actions_training.xlsx b/test/data/skeleton/sample-forms/training-xlsx/new_actions_training.xlsx
new file mode 100644
index 000000000..75e2b4817
Binary files /dev/null and b/test/data/skeleton/sample-forms/training-xlsx/new_actions_training.xlsx differ
diff --git a/test/data/skeleton/sample-forms/training-xml/new_actions_training.xml b/test/data/skeleton/sample-forms/training-xml/new_actions_training.xml
new file mode 100644
index 000000000..564fc7629
--- /dev/null
+++ b/test/data/skeleton/sample-forms/training-xml/new_actions_training.xml
@@ -0,0 +1,74 @@
+
+
+
+ new_actions_training
+
+
+
+
+ The "New Action" icon at the bottom of your app has changed to a big blue plus icon.
+
+
+ If you do not understand these changes, please contact your supervisor.
+
+
+ When you're ready, go ahead and start using your app.
+
+
+ There have been some changes to icons in your app. The next few screens will show you the difference.
+
+
+ Read each screen carefully and tap "Next" if you understand. If you need extra support, please contact your supervisor.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/fn/convert-training-forms.spec.js b/test/fn/convert-training-forms.spec.js
new file mode 100644
index 000000000..39a684cf3
--- /dev/null
+++ b/test/fn/convert-training-forms.spec.js
@@ -0,0 +1 @@
+require('./convert-forms.utils.js').testFor('convert-training-forms', 'training');
diff --git a/test/fn/watch-project.spec.js b/test/fn/watch-project.spec.js
index 2ba01fec8..4ff360810 100644
--- a/test/fn/watch-project.spec.js
+++ b/test/fn/watch-project.spec.js
@@ -13,11 +13,13 @@ const {
APP_FORMS_PATH,
CONTACT_FORMS_PATH,
COLLECT_FORMS_PATH,
+ TRAINING_FORMS_PATH,
RESOURCE_CONFIG_PATH,
APP_SETTINGS_DIR_PATH
} = require('../../src/lib/project-paths');
const testDir = path.join(__dirname, '../data/skeleton');
const appFormDir = path.join(testDir, APP_FORMS_PATH);
+const trainingFormDir = path.join(testDir, TRAINING_FORMS_PATH);
const collectFormsDir = path.join(testDir, COLLECT_FORMS_PATH);
const contactFormsDir = path.join(testDir, CONTACT_FORMS_PATH);
const snapshotsDir = path.join(testDir, '.snapshots');
@@ -71,8 +73,20 @@ function copySampleForms(sampleDir, destination = path.join('forms', 'app')) {
fse.copySync(absSampleDir, path.join(testDir, destination));
}
-function cleanFormDir(formDir, form) {
- fs.fs.readdirSync(formDir).filter(name => name.startsWith(form)).forEach(file => fse.removeSync(path.join(formDir, file)));
+function cleanFolders(folderPaths) {
+ (folderPaths || []).forEach(folder => {
+ if (!fs.exists(folder)) {
+ return;
+ }
+ fs.deleteFilesInFolder(folder);
+ });
+}
+
+function deleteFormFromFolder(folderPath, formFileName) {
+ fs.fs
+ .readdirSync(folderPath)
+ .filter(fileName => fileName.startsWith(formFileName))
+ .forEach(file => fse.removeSync(path.join(folderPath, file)));
}
function watchWrapper(action, file) {
@@ -97,11 +111,12 @@ describe('watch-project', function () {
});
afterEach(async () => {
+ cleanFolders([ appFormDir, collectFormsDir, trainingFormDir, contactFormsDir ]);
sinon.restore();
fs.writeJson(baseSettingsPath, baseSettings);
fs.writeJson(appSettingsPath, appSettings);
fs.write(sampleTranslationPath, messagesEn);
- if(fs.exists(snapshotsDir)) {
+ if (fs.exists(snapshotsDir)) {
fs.deleteFilesInFolder(snapshotsDir);
fs.fs.rmdirSync(snapshotsDir);
}
@@ -142,9 +157,7 @@ describe('watch-project', function () {
const docIds = docs.rows.map(row => row.id);
expect(docIds).to.include('resources');
})
- .then(() => {
- fs.writeJson(resourceJsonPath, {});
- });
+ .then(() => fs.writeJson(resourceJsonPath, {}));
});
it('watch-project: convert app forms', () => {
@@ -155,8 +168,7 @@ describe('watch-project', function () {
.then(() => {
const appForms = fs.fs.readdirSync(appFormDir);
expect(appForms).to.include(`${form}.xml`);
- })
- .then(() => cleanFormDir(appFormDir, form));
+ });
});
it('watch-project: convert collect forms', () => {
@@ -167,8 +179,7 @@ describe('watch-project', function () {
.then(() => {
const appForms = fs.fs.readdirSync(collectFormsDir);
expect(appForms).to.include(`${form}.xml`);
- })
- .then(() => cleanFormDir(collectFormsDir, form));
+ });
});
it('watch-project: upload app forms', () => {
@@ -184,24 +195,20 @@ describe('watch-project', function () {
.then(docs => {
const docIds = docs.rows.map(row => row.id);
expect(docIds).to.include(`form:${form}`);
- })
- .then(() => cleanFormDir(appFormDir, form));
+ });
});
it('watch-project: delete app forms', () => {
const form = 'death';
copySampleForms('upload-app-form');
- const deleteForm = () => {
- cleanFormDir(appFormDir, form);
- };
+ const deleteForm = () => deleteFormFromFolder(appFormDir, form);
return api.db.put({ _id: `form:${form}` })
.then(() => watchWrapper(deleteForm, `${form}.xml`))
.then(() => api.db.allDocs())
.then(docs => {
const doc = docs.rows.find(doc => doc.id === `form:${form}`);
expect(doc).to.be.undefined;
- })
- .then(() => cleanFormDir(appFormDir, form));
+ });
});
it('watch-project: do not delete app form when a form part exists', () => {
@@ -216,8 +223,7 @@ describe('watch-project', function () {
.then(docs => {
const doc = docs.rows.find(doc => doc.id === `form:${form}`);
expect(doc).to.be.not.undefined;
- })
- .then(() => cleanFormDir(appFormDir, form));
+ });
});
it('watch-project: upload convert forms', () => {
@@ -233,8 +239,7 @@ describe('watch-project', function () {
.then(docs => {
const docIds = docs.rows.map(row => row.id);
expect(docIds).to.include(`form:${form}`);
- })
- .then(() => cleanFormDir(collectFormsDir, form));
+ });
});
it('watch-project: upload app form on properties change', () => {
@@ -248,8 +253,7 @@ describe('watch-project', function () {
.then(docs => {
const docIds = docs.rows.map(row => row.id);
expect(docIds).to.include(`form:${form}`);
- })
- .then(() => cleanFormDir(appFormDir, form));
+ });
});
it('watch-project: upload app form on form-media change', () => {
@@ -268,9 +272,50 @@ describe('watch-project', function () {
.then(docs => {
const docIds = docs.rows.map(row => row.id);
expect(docIds).to.include(`form:${form}`);
- })
+ });
+ });
+
+ it('watch-project: convert training forms', () => {
+ const form = 'new_actions_training';
+ const copyForm = () => copySampleForms('training-xlsx', TRAINING_FORMS_PATH);
+
+ return watchWrapper(copyForm, `${form}.xlsx`)
.then(() => {
- cleanFormDir(appFormDir, form);
+ const forms = fs.fs.readdirSync(trainingFormDir);
+ expect(forms).to.include(`${form}.xml`);
+ });
+ });
+
+ it('watch-project: upload training forms', () => {
+ const form = 'new_actions_training';
+ const copyForm = () => copySampleForms('training-xml', TRAINING_FORMS_PATH);
+
+ api.giveResponses({ status: 200, body: { ok: true } }, { status: 200, body: { version: '1.0.0' } });
+
+ return watchWrapper(copyForm, `${form}.xml`)
+ .then(() => api.db.allDocs())
+ .then(docs => {
+ const docIds = docs.rows.map(row => row.id);
+ expect(docIds).to.include(`form:training:${form}`);
+ });
+ });
+
+ it('watch-project: upload training form on form-media change', () => {
+ const form = 'training';
+ copySampleForms('training-form-media', TRAINING_FORMS_PATH);
+ const dummyPng = 'test.png';
+ const formMediaDir = path.join(trainingFormDir, `${form}-media`);
+ const createFormMediaDir = () => {
+ fs.fs.writeFileSync(path.join(formMediaDir, dummyPng), '');
+ };
+
+ api.giveResponses({ status: 200, body: { ok: true } }, { status: 200, body: { version: '1.0.0' } });
+
+ return watchWrapper(createFormMediaDir, dummyPng)
+ .then(() => api.db.allDocs())
+ .then(docs => {
+ const docIds = docs.rows.map(row => row.id);
+ expect(docIds).to.include(`form:training:${form}`);
});
});
@@ -285,8 +330,7 @@ describe('watch-project', function () {
.then(() => {
const contactForms = fs.fs.readdirSync(contactFormsDir);
expect(contactForms).to.include(`${form}.xml`);
- })
- .then(() => cleanFormDir(contactFormsDir, form));
+ });
});
it('watch-project: upload contact forms', () => {
@@ -302,8 +346,7 @@ describe('watch-project', function () {
.then(docs => {
const docIds = docs.rows.map(row => row.id);
expect(docIds).to.include(`form:contact:${form.replace('-', ':')}`);
- })
- .then(() => cleanFormDir(contactFormsDir, form));
+ });
});
it('watch-project: upload app forms --skip-validate', () => {
@@ -320,8 +363,7 @@ describe('watch-project', function () {
expect(docIds).to.include(`form:${form}`);
// No requests should have been made to the api since the validations were not run
expect(api.requestLog()).to.be.empty;
- })
- .then(() => cleanFormDir(appFormDir, form));
+ });
});
});
diff --git a/test/lib/main.spec.js b/test/lib/main.spec.js
index 744cc510a..fda5938f4 100644
--- a/test/lib/main.spec.js
+++ b/test/lib/main.spec.js
@@ -156,24 +156,26 @@ describe('main', () => {
});
it('add validate forms actions for upload forms actions', async () => {
- await main([...normalArgv, '--local', 'upload-collect-forms', 'upload-contact-forms', 'upload-app-forms'], {});
+ await main([...normalArgv, '--local', 'upload-collect-forms', 'upload-contact-forms', 'upload-app-forms', 'upload-training-forms'], {});
expectExecuteActionBehavior(
[
'validate-collect-forms', 'upload-collect-forms',
'validate-contact-forms', 'upload-contact-forms',
- 'validate-app-forms', 'upload-app-forms'
+ 'validate-app-forms', 'upload-app-forms',
+ 'validate-training-forms', 'upload-training-forms',
], undefined
);
expect(mocks.environment.initialize.args[0][7]).to.be.undefined;
});
it('--skip-validate for upload forms actions', async () => {
- await main([...normalArgv, '--local', '--skip-validate', 'upload-collect-forms', 'upload-contact-forms', 'upload-app-forms'], {});
+ await main([...normalArgv, '--local', '--skip-validate', 'upload-collect-forms', 'upload-contact-forms', 'upload-app-forms', 'upload-training-forms'], {});
expectExecuteActionBehavior(
[
'upload-collect-forms',
'upload-contact-forms',
- 'upload-app-forms'
+ 'upload-app-forms',
+ 'upload-training-forms',
], undefined
);
expect(mocks.warn.callCount).to.equal(1);
@@ -184,12 +186,13 @@ describe('main', () => {
it('--skip-validate for validate forms actions', async () => {
await main([...normalArgv, '--local', '--skip-validate', 'validate-collect-forms', 'validate-contact-forms',
- 'validate-app-forms', 'upload-collect-forms', 'upload-contact-forms', 'upload-app-forms'], {});
+ 'validate-app-forms', 'upload-collect-forms', 'upload-contact-forms', 'upload-app-forms', 'upload-training-forms'], {});
expectExecuteActionBehavior(
[
'upload-collect-forms',
'upload-contact-forms',
- 'upload-app-forms'
+ 'upload-app-forms',
+ 'upload-training-forms',
], undefined
);
expect(mocks.warn.callCount).to.equal(1);