diff --git a/tests/e2e/default/admin/admin-access.wdio-spec.js b/tests/e2e/default/admin/admin-access.wdio-spec.js index ae994eff272..b84359f54d5 100644 --- a/tests/e2e/default/admin/admin-access.wdio-spec.js +++ b/tests/e2e/default/admin/admin-access.wdio-spec.js @@ -5,10 +5,10 @@ const adminPage = require('@page-objects/default/admin/admin.wdio.page'); const common = require('@page-objects/default/common/common.wdio.page'); const placeFactory = require('@factories/cht/contacts/place'); -const offlineUser = userFactory.build({ username: 'offline-user-admin', isOffline: true }); -const parent = placeFactory.place().build({ _id: 'dist1', type: 'district_hospital' }); - describe('Acessing the admin app', () => { + const offlineUser = userFactory.build({ username: 'offline-user-admin', isOffline: true }); + const parent = placeFactory.place().build({ _id: 'dist1', type: 'district_hospital' }); + afterEach(async () => { await browser.reloadSession(); await browser.url('/'); diff --git a/tests/e2e/default/analytics/analytics.wdio-spec.js b/tests/e2e/default/analytics/analytics.wdio-spec.js index 04199307b22..19542236fbc 100644 --- a/tests/e2e/default/analytics/analytics.wdio-spec.js +++ b/tests/e2e/default/analytics/analytics.wdio-spec.js @@ -12,19 +12,6 @@ const chtConfUtils = require('@utils/cht-conf'); const chtDbUtils = require('@utils/cht-db'); const { TARGET_MET_COLOR, TARGET_UNMET_COLOR } = analyticsPage; -const updateSettings = async (settings) => { - await utils.updateSettings(settings, 'api'); - await commonPage.sync(true); - await browser.refresh(); -}; - -const compileTargets = async (targetsFileName = 'targets-config.js') => { - await chtConfUtils.initializeConfigDir(); - const targetFilePath = path.join(__dirname, `config/${targetsFileName}`); - - return chtConfUtils.compileNoolsConfig({ targets: targetFilePath }); -}; - describe('Targets', () => { const places = placeFactory.generateHierarchy(); const healthCenter = places.get('health_center'); @@ -41,7 +28,14 @@ describe('Targets', () => { parent: { _id: clinic._id, parent: clinic.parent } }); - const chw = userFactory.build({ place: healthCenter._id, roles: ['chw'], contact }); + const chw = userFactory.build({ place: healthCenter._id, contact: contact }); + + const compileTargets = async (targetsFileName = 'targets-config.js') => { + await chtConfUtils.initializeConfigDir(); + const targetFilePath = path.join(__dirname, `config/${targetsFileName}`); + + return chtConfUtils.compileNoolsConfig({ targets: targetFilePath }); + }; before(async () => { await utils.saveDocs([...places.values(), owl]); @@ -75,7 +69,8 @@ describe('Targets', () => { it('should display correct message when no target found', async () => { const settings = await compileTargets(); - await updateSettings(settings); + await utils.updateSettings(settings, { ignoreReload: 'api', sync: true, refresh: true }); + await analyticsPage.goToTargets(); const emptySelection = await analyticsPage.noSelectedTarget(); @@ -89,7 +84,7 @@ describe('Targets', () => { const tasks = { targets: { enabled: false } }; - await updateSettings({ tasks }); + await utils.updateSettings({ tasks }, { ignoreReload: 'api', sync: true, refresh: true }); await analyticsPage.goToTargets(); const emptySelection = await analyticsPage.noSelectedTarget(); @@ -103,7 +98,7 @@ describe('Targets', () => { it('should show error message for bad config', async () => { const settings = await compileTargets('targets-error-config.js'); - await updateSettings(settings); + await utils.updateSettings(settings, { ignoreReload: 'api', sync: true, refresh: true }); await analyticsPage.goToTargets(); const { errorMessage, url, username, errorStack } = await commonPage.getErrorLog(); diff --git a/tests/e2e/default/contacts/add-custom-hierarchy.wdio-spec.js b/tests/e2e/default/contacts/add-custom-hierarchy.wdio-spec.js index 184f9faa5dd..f5bd0c1d618 100644 --- a/tests/e2e/default/contacts/add-custom-hierarchy.wdio-spec.js +++ b/tests/e2e/default/contacts/add-custom-hierarchy.wdio-spec.js @@ -61,7 +61,8 @@ describe('Creating custom places', () => { translations = customTypeFactory.translationKeys(contacts); forms = customTypeFactory.formsForTypes(contacts, ngoCreateXML); await utils.addTranslations('en', translations); - await utils.updateSettings({ contact_types: contacts }, true); + await utils.updateSettings({ contact_types: contacts }, { ignoreReload: true }); + await utils.saveDocs(forms); await login.cookieLogin(); }); @@ -82,7 +83,7 @@ describe('Creating custom places', () => { settings.contact_types.push(secondTopLevel); const forms = customTypeFactory.formsForTypes([secondTopLevel], ngoCreateXML); await utils.revertSettings(true); - await utils.updateSettings({ contact_types: settings.contact_types }, true); + await utils.updateSettings({ contact_types: settings.contact_types }, { ignoreReload: true }); await utils.saveDocs(forms); await login.cookieLogin(); await commonPage.goToPeople(); diff --git a/tests/e2e/default/contacts/contact-details.wdio-spec.js b/tests/e2e/default/contacts/contact-details.wdio-spec.js index 53aa223d884..3464f964e8e 100644 --- a/tests/e2e/default/contacts/contact-details.wdio-spec.js +++ b/tests/e2e/default/contacts/contact-details.wdio-spec.js @@ -21,11 +21,6 @@ describe('Contact details page.', () => { const user = userFactory.build({username: 'offlineuser', roles: [ROLE]}); const patient = personFactory.build({parent: {_id: user.place._id, parent: {_id: parent._id}}}); - const updateSettings = async (settings) => { - await utils.revertSettings(true); - await utils.updateSettings(settings, true); - }; - const waitForContactLoaded = async (expectTasks) => { await commonElements.waitForPageLoaded(); await contactPage.waitForContactLoaded(); @@ -81,7 +76,11 @@ describe('Contact details page.', () => { removePermissions.forEach(permission => { settings.permissions[permission] = settings.permissions[permission].filter(r => r !== roleValue); }); - await updateSettings({roles: settings.roles, permissions: settings.permissions}); + await utils.updateSettings( + { roles: settings.roles, permissions: settings.permissions }, + { revert: true, ignoreReload: true } + ); + }; before(async () => { diff --git a/tests/e2e/default/contacts/delete-assigned-place.wdio-spec.js b/tests/e2e/default/contacts/delete-assigned-place.wdio-spec.js index b2f9a65b50c..2f6fedb6c83 100644 --- a/tests/e2e/default/contacts/delete-assigned-place.wdio-spec.js +++ b/tests/e2e/default/contacts/delete-assigned-place.wdio-spec.js @@ -34,7 +34,7 @@ describe('User Test Cases -> Creating Users ->', () => { ...settings.permissions, can_have_multiple_places: [offlineUserRole], }; - await utils.updateSettings({ permissions }, true); + await utils.updateSettings({ permissions }, { ignoreReload: true }); await utils.saveDocs(docs); await loginPage.cookieLogin(); }); diff --git a/tests/e2e/default/contacts/muting-contact-using-form.wdio-spec.js b/tests/e2e/default/contacts/muting-contact-using-form.wdio-spec.js index 7e0c61b8998..327d59b7573 100644 --- a/tests/e2e/default/contacts/muting-contact-using-form.wdio-spec.js +++ b/tests/e2e/default/contacts/muting-contact-using-form.wdio-spec.js @@ -36,7 +36,7 @@ describe('Mute/Unmute contacts using a specific form - ', () => { before(async () => { await utils.saveDocs([...places.values(), person, mutePerson]); - await utils.updateSettings(settings_mute, true); + await utils.updateSettings(settings_mute, { ignoreReload: true }); await utils.createUsers([offlineUser]); await loginPage.login(offlineUser); }); diff --git a/tests/e2e/default/db/db-access-for-custom-roles.wdio-spec.js b/tests/e2e/default/db/db-access-for-custom-roles.wdio-spec.js index 21552128956..e62ad1d4fd5 100644 --- a/tests/e2e/default/db/db-access-for-custom-roles.wdio-spec.js +++ b/tests/e2e/default/db/db-access-for-custom-roles.wdio-spec.js @@ -31,7 +31,7 @@ describe('Database access for new roles', () => { roles.push(NEW_ROLE); } }); - await utils.updateSettings(settings, true); + await utils.updateSettings(settings, { ignoreReload: true }); }; before(async () => { diff --git a/tests/e2e/default/db/ongoing-replication.wdio-spec.js b/tests/e2e/default/db/ongoing-replication.wdio-spec.js index ecf3a63761f..cafcfa7a02b 100644 --- a/tests/e2e/default/db/ongoing-replication.wdio-spec.js +++ b/tests/e2e/default/db/ongoing-replication.wdio-spec.js @@ -170,7 +170,7 @@ describe('ongoing replication', function() { it('should download settings updates', async () => { await commonPage.sync(); - await utils.updateSettings({ test: true }, 'api'); + await utils.updateSettings({ test: true }, { ignoreReload: 'api' }); await commonPage.sync(true); const [settings] = await chtDbUtils.getDocs(['settings']); expect(settings.settings.test).to.equal(true); diff --git a/tests/e2e/default/enketo/unauthorized-form.wdio-spec.js b/tests/e2e/default/enketo/unauthorized-form.wdio-spec.js index 5543479021e..baca57b6330 100644 --- a/tests/e2e/default/enketo/unauthorized-form.wdio-spec.js +++ b/tests/e2e/default/enketo/unauthorized-form.wdio-spec.js @@ -8,14 +8,13 @@ const utils = require('@utils'); describe('Unauthorized form', () => { - const updateSettings = async (customPlaceType, permissions = {}) => { + const updateUnauthorizedFormSettings = async (customPlaceType, permissions = {}) => { const settings = await utils.getSettings(); const newSettings = { contact_types: [ ...settings.contact_types, customPlaceType ], permissions: { ...settings.permissions, ...permissions }, }; - await utils.updateSettings(newSettings, true); - await commonPage.sync(true); + await utils.updateSettings(newSettings, { ignoreReload: true, sync: true }); }; const EXPECTED_UNAUTHORIZED_MESSAGE = 'Error loading form. Your user is not authorized to access this form. ' + @@ -46,7 +45,7 @@ describe('Unauthorized form', () => { it('should display unauthorized error message in contacts tab when user does not have form permission', async () => { await commonPage.goToPeople(); - await updateSettings(customPlaceType); + await updateUnauthorizedFormSettings(customPlaceType); await commonPage.goToUrl(`#/contacts/add/${customPlaceType.id}`); await commonPage.waitForPageLoaded(); @@ -56,7 +55,7 @@ describe('Unauthorized form', () => { it('should not display unauthorized error message in contacts tab when user has the form permission', async () => { await commonPage.goToPeople(); - await updateSettings(customPlaceType, { can_create_clinic: [ 'chw' ] }); + await updateUnauthorizedFormSettings(customPlaceType, { can_create_clinic: ['chw'] }); await commonPage.goToUrl(`#/contacts/add/${customPlaceType.id}`); await commonPage.waitForPageLoaded(); diff --git a/tests/e2e/default/login/token-login.wdio-spec.js b/tests/e2e/default/login/token-login.wdio-spec.js index 9b71bc098f2..82f455854e4 100644 --- a/tests/e2e/default/login/token-login.wdio-spec.js +++ b/tests/e2e/default/login/token-login.wdio-spec.js @@ -29,7 +29,7 @@ describe('Token login', () => { }, app_url: utils.getOrigin() }; - return utils.updateSettings(settings, true); + return utils.updateSettings(settings, { ignoreReload: true }); }; const createUser = (user) => { diff --git a/tests/e2e/default/purge/purge.wdio-spec.js b/tests/e2e/default/purge/purge.wdio-spec.js index fa3fcd30f53..6c123668b59 100644 --- a/tests/e2e/default/purge/purge.wdio-spec.js +++ b/tests/e2e/default/purge/purge.wdio-spec.js @@ -53,12 +53,9 @@ describe('purge', function() { .catch(callback); }); - const updateSettings = async (purgeFn, revert) => { - if (revert) { - await utils.revertSettings(true); - } + const updatePurgeSettings = async (purgeFn, revert) => { const settings = { purge: { fn: purgeFn.toString(), text_expression: 'every 1 seconds', run_every_days: -1 } }; - await utils.updateSettings(settings, true); + await utils.updateSettings(settings, { revert: revert, ignoreReload: true }); }; const runPurging = async () => { @@ -79,7 +76,7 @@ describe('purge', function() { }); it('purging runs on sync', async () => { - await updateSettings(filterPurgeReports); // settings should be at the beginning of the changes feed + await updatePurgeSettings(filterPurgeReports); // settings should be at the beginning of the changes feed await utils.saveDocs([...places.values(), contact, patient]); await utils.createUsers([user]); @@ -96,7 +93,7 @@ describe('purge', function() { expect(allReports.length).to.equal(homeVisits.length + pregnancies.length); expect(allReports.map(r => r.form)).to.not.have.members(['purge']); - await updateSettings(filterHomeVisitReports, true); + await updatePurgeSettings(filterHomeVisitReports, true); await runPurging(); await commonElements.sync(true); @@ -109,7 +106,7 @@ describe('purge', function() { }); it('purging runs when using chtScriptApi', async () => { - await updateSettings(filterByCht); // settings should be at the beginning of the changes feed + await updatePurgeSettings(filterByCht); // settings should be at the beginning of the changes feed await utils.saveDocs([...places.values(), contact, patient]); await utils.createUsers([user]); diff --git a/tests/e2e/default/reports/date-filter.wdio-spec.js b/tests/e2e/default/reports/date-filter.wdio-spec.js index ffca63e6130..ce98934d806 100644 --- a/tests/e2e/default/reports/date-filter.wdio-spec.js +++ b/tests/e2e/default/reports/date-filter.wdio-spec.js @@ -52,7 +52,7 @@ describe('Report Filter', () => { ...settings.permissions, can_view_old_filter_and_search: [ 'chw' ] }; - await utils.updateSettings({ permissions }, true); + await utils.updateSettings({ permissions }, { ignoreReload: true }); const results = await utils.saveDocs([ parent, patient, ...reports ]); results.splice(0, 2); // Keeping only reports diff --git a/tests/e2e/default/reports/generate-short-codes.wdio-spec.js b/tests/e2e/default/reports/generate-short-codes.wdio-spec.js index 086032d3d18..3f40b153bf3 100644 --- a/tests/e2e/default/reports/generate-short-codes.wdio-spec.js +++ b/tests/e2e/default/reports/generate-short-codes.wdio-spec.js @@ -38,7 +38,7 @@ describe('generating short codes', () => { before(async () => { await utils.saveDocs(docs); - await utils.updateSettings({forms, registrations, transitions}, true); + await utils.updateSettings({ forms, registrations, transitions }, { ignoreReload: true }); await loginPage.cookieLogin(); }); diff --git a/tests/e2e/default/reports/reports-subject.wdio-spec.js b/tests/e2e/default/reports/reports-subject.wdio-spec.js index a84f45150ad..1bb3fdd9b44 100644 --- a/tests/e2e/default/reports/reports-subject.wdio-spec.js +++ b/tests/e2e/default/reports/reports-subject.wdio-spec.js @@ -59,7 +59,7 @@ describe('Reports Subject', () => { }; before(async () => { - await utils.updateSettings(appSettings.WITH_SMS_FORMS, true); + await utils.updateSettings(appSettings.WITH_SMS_FORMS, { ignoreReload: true }); await utils.saveDocs([...places.values(), person]); await utils.createUsers([user]); await loginPage.cookieLogin(); @@ -341,7 +341,7 @@ describe('Reports Subject', () => { }); }); - it('changes to a loaded or list report should be reflected in the UI ', async () => { + it('changes to a loaded or list report should be reflected in the UI ', async () => { const reportTest = { _id: 'REF_REF_V3', form: 'RR', diff --git a/tests/e2e/default/sms/link-to-patient.wdio-spec.js b/tests/e2e/default/sms/link-to-patient.wdio-spec.js index f1b691c6317..79b7a0fdda1 100644 --- a/tests/e2e/default/sms/link-to-patient.wdio-spec.js +++ b/tests/e2e/default/sms/link-to-patient.wdio-spec.js @@ -37,7 +37,7 @@ const docs = [...places.values(), user]; describe('Link SMS to patient without passing id', () => { before(async () => { await utils.saveDocs(docs); - await utils.updateSettings({ forms, registrations, transitions, self_report }, true); + await utils.updateSettings({ forms, registrations, transitions, self_report }, { ignoreReload: true }); await loginPage.cookieLogin(); }); diff --git a/tests/e2e/default/sms/rapidpro.wdio-spec.js b/tests/e2e/default/sms/rapidpro.wdio-spec.js index f4c2530dbb5..fec4c4b1552 100644 --- a/tests/e2e/default/sms/rapidpro.wdio-spec.js +++ b/tests/e2e/default/sms/rapidpro.wdio-spec.js @@ -65,7 +65,7 @@ describe('RapidPro SMS Gateway', () => { }; it('should fail with no incoming key configured', async () => { - await utils.updateSettings({ sms: smsSettings }, true); + await utils.updateSettings({ sms: smsSettings }, { ignoreReload: true }); try { await utils.request({ path: endpoint, @@ -81,7 +81,7 @@ describe('RapidPro SMS Gateway', () => { it('should fail with no authentication provided', async () => { await setIncomingKey(); - await utils.updateSettings({ sms: smsSettings }, true); + await utils.updateSettings({ sms: smsSettings }, { ignoreReload: true }); try { await utils.request({ @@ -97,7 +97,7 @@ describe('RapidPro SMS Gateway', () => { it('should fail with incorrect authentication', async () => { await setIncomingKey(); - await utils.updateSettings({ sms: smsSettings }, true); + await utils.updateSettings({ sms: smsSettings }, { ignoreReload: true }); try { await utils.request({ @@ -114,7 +114,7 @@ describe('RapidPro SMS Gateway', () => { it('should fail with malformed authentication', async () => { await setIncomingKey(); - await utils.updateSettings({ sms: smsSettings }, true); + await utils.updateSettings({ sms: smsSettings }, { ignoreReload: true }); try { await utils.request({ @@ -131,7 +131,7 @@ describe('RapidPro SMS Gateway', () => { it('should fail when message was not created', async () => { await setIncomingKey(); - await utils.updateSettings({ sms: smsSettings }, true); + await utils.updateSettings({ sms: smsSettings }, { ignoreReload: true }); try { await utils.request({ @@ -159,7 +159,7 @@ describe('RapidPro SMS Gateway', () => { }; await setIncomingKey(); - await utils.updateSettings({ sms: smsSettings }, true); + await utils.updateSettings({ sms: smsSettings }, { ignoreReload: true }); const messageResult = await utils.request({ path: endpoint, method: 'POST', @@ -215,7 +215,7 @@ describe('RapidPro SMS Gateway', () => { }; await setIncomingKey(); - await utils.updateSettings({ sms: smsSettings, forms }, true); + await utils.updateSettings({ sms: smsSettings, forms }, { ignoreReload: true }); const messageResult = await utils.request({ path: endpoint, @@ -297,7 +297,7 @@ describe('RapidPro SMS Gateway', () => { rapidpro: { url: utils.hostURL(server.address().port) }, } }; - await utils.updateSettings(settings, true); + await utils.updateSettings(settings, { ignoreReload: true }); }); afterEach(() => utils.revertDb([], true)); diff --git a/tests/e2e/default/targets/target-aggregates.wdio-spec.js b/tests/e2e/default/targets/target-aggregates.wdio-spec.js index 6138c0b017f..e7e95aa8a83 100644 --- a/tests/e2e/default/targets/target-aggregates.wdio-spec.js +++ b/tests/e2e/default/targets/target-aggregates.wdio-spec.js @@ -43,7 +43,7 @@ describe('Target aggregates', () => { const settings = await utils.getSettings(); const tasks = settings.tasks; tasks.targets.items[0].aggregate = true; - await utils.updateSettings({ tasks }, true); + await utils.updateSettings({ tasks }, { ignoreReload: true }); await commonPage.closeReloadModal(); await commonPage.goToAnalytics(); @@ -59,7 +59,7 @@ describe('Target aggregates', () => { const NAMES_DH2 = ['Viviana', 'Ximena', 'Esteban', 'Luis', 'Marta']; const TARGET_VALUES_BY_CONTACT = helperFunctions.generateTargetValuesByContact([...NAMES_DH1, ...NAMES_DH2]); - + const districtHospital1 = placeFactory.place().build({ type: 'district_hospital', name: 'District Hospital 1' }); const districtHospital2 = placeFactory.place().build({ type: 'district_hospital', name: 'District Hospital 2' }); @@ -68,7 +68,7 @@ describe('Target aggregates', () => { }); const onlineUser = userFactory.build({ place: districtHospital1._id, roles: ['program_officer'] }); - + const userWithManyPlaces = userSettingsFactory.build({ _id: 'org.couchdb.user:offline_many_facilities', name: 'offline_many_facilities', @@ -129,7 +129,7 @@ describe('Target aggregates', () => { }); it('should display no data when no targets are uploaded', async () => { - await helperFunctions.updateSettings( + await helperFunctions.updateAggregateTargetsSettings( targetAggregatesConfig.TARGETS_CONFIG_WITH_AND_WITHOUT_AGGREGATES, onlineUser ); @@ -158,7 +158,7 @@ describe('Target aggregates', () => { const expectedTargets = targetAggregatesConfig.EXPECTED_DEFAULTS_TARGETS; await utils.saveDocs(targetDocs); - await helperFunctions.updateSettings(targetAggregatesConfig.TARGETS_DEFAULT_CONFIG, onlineUser); + await helperFunctions.updateAggregateTargetsSettings(targetAggregatesConfig.TARGETS_DEFAULT_CONFIG, onlineUser); await commonPage.goToAnalytics(); await targetAggregatesPage.goToTargetAggregates(true); @@ -231,7 +231,7 @@ describe('Target aggregates', () => { ]; await utils.saveDocs(targetDocs); - await helperFunctions.updateSettings(targetsConfig, onlineUser, contactSummaryScript); + await helperFunctions.updateAggregateTargetsSettings(targetsConfig, onlineUser, contactSummaryScript); await commonPage.goToAnalytics(); await targetAggregatesPage.goToTargetAggregates(true); @@ -312,7 +312,10 @@ describe('Target aggregates', () => { const expectedTargets = targetAggregatesConfig.EXPECTED_TARGETS_NO_PROGRESS; await utils.saveDocs(targetDocs); - await helperFunctions.updateSettings(targetAggregatesConfig.TARGETS_DEFAULT_CONFIG, userWithManyPlaces); + await helperFunctions.updateAggregateTargetsSettings( + targetAggregatesConfig.TARGETS_DEFAULT_CONFIG, + userWithManyPlaces + ); await commonPage.sync(true); await browser.refresh(); diff --git a/tests/e2e/default/targets/utils/aggregates-helper-functions.js b/tests/e2e/default/targets/utils/aggregates-helper-functions.js index 717740c919a..84828f70c51 100644 --- a/tests/e2e/default/targets/utils/aggregates-helper-functions.js +++ b/tests/e2e/default/targets/utils/aggregates-helper-functions.js @@ -8,13 +8,14 @@ const targetAggregatesConfig = require('../config/target-aggregates'); const generateRandomNumber = (max) => Math.floor(Math.random() * max); -const updateSettings = async (targetsConfig, user, contactSummary) => { +const updateAggregateTargetsSettings = async (targetsConfig, user, contactSummary) => { const settings = await utils.getSettings(); - const tasks = settings.tasks; - tasks.targets.items = targetsConfig; - const permissions = settings.permissions; - permissions.can_aggregate_targets = user.roles; - await utils.updateSettings({ tasks, permissions, contact_summary: contactSummary }, true); + settings.tasks.targets.items = targetsConfig; + settings.permissions.can_aggregate_targets = user.roles; + await utils.updateSettings( + { tasks: settings.tasks, permissions: settings.permissions, contact_summary: contactSummary }, + { ignoreReload: true } + ); await commonPage.closeReloadModal(); await commonPage.goToBase(); }; @@ -181,7 +182,7 @@ const getDocsByPlace = (contactDocs, placeId) => { }; module.exports = { - updateSettings, + updateAggregateTargetsSettings, generateTargetValuesByContact, docTags, generateContactsAndTargets, diff --git a/tests/e2e/default/tasks/due-dates.wdio-spec.js b/tests/e2e/default/tasks/due-dates.wdio-spec.js index 6973d9d4576..55a95579588 100644 --- a/tests/e2e/default/tasks/due-dates.wdio-spec.js +++ b/tests/e2e/default/tasks/due-dates.wdio-spec.js @@ -41,15 +41,13 @@ const getTasksInfos = async (tasks) => { return infos; }; -const updateSettings = async (updates = {}) => { +const updateDueDatesSettings = async (updates = {}) => { await chtConfUtils.initializeConfigDir(); const tasksFilePath = path.join(__dirname, 'config/due-dates-config.js'); const { tasks } = await chtConfUtils.compileNoolsConfig({ tasks: tasksFilePath }); updates.tasks = tasks; - await utils.updateSettings(updates, 'api'); - await commonPage.sync(true); - await browser.refresh(); + await utils.updateSettings(updates, { ignoreReload: 'api', sync: true, refresh: true }); }; describe('Task list due dates', () => { @@ -67,7 +65,7 @@ describe('Task list due dates', () => { }); it('should display correct due dates with default settings', async () => { - await updateSettings(); + await updateDueDatesSettings(); await tasksPage.goToTasksTab(); const infos = await getTasksInfos(await tasksPage.getTasks()); @@ -103,7 +101,7 @@ describe('Task list due dates', () => { }); it('should display correct due dates with taskDaysOverdue setting', async () => { - await updateSettings({ task_days_overdue: true }); + await updateDueDatesSettings({ task_days_overdue: true }); await tasksPage.goToTasksTab(); const infos = await getTasksInfos(await tasksPage.getTasks()); @@ -140,7 +138,7 @@ describe('Task list due dates', () => { it('should display correct due dates with taskDaysOverdue setting and simple translation', async () => { await utils.addTranslations('en', { 'task.overdue.days': 'Late' }); - await updateSettings({ task_days_overdue: true }); + await updateDueDatesSettings({ task_days_overdue: true }); await tasksPage.goToTasksTab(); const infos = await getTasksInfos(await tasksPage.getTasks()); diff --git a/tests/e2e/default/tasks/tasks-breadcrumbs.wdio-spec.js b/tests/e2e/default/tasks/tasks-breadcrumbs.wdio-spec.js index b0722b0c33f..91b3e4fe06a 100644 --- a/tests/e2e/default/tasks/tasks-breadcrumbs.wdio-spec.js +++ b/tests/e2e/default/tasks/tasks-breadcrumbs.wdio-spec.js @@ -107,7 +107,7 @@ describe('Tasks tab breadcrumbs', () => { const tasksFilePath = path.join(__dirname, 'config/tasks-breadcrumbs-config.js'); const { tasks } = await chtConfUtils.compileNoolsConfig({ tasks: tasksFilePath }); - await utils.updateSettings({ tasks }, 'api'); + await utils.updateSettings({ tasks }, { ignoreReload: 'api' }); }); describe('for chw', () => { diff --git a/tests/e2e/default/tasks/tasks-group.wdio-spec.js b/tests/e2e/default/tasks/tasks-group.wdio-spec.js index f7a972f85d7..f5e39b5a513 100644 --- a/tests/e2e/default/tasks/tasks-group.wdio-spec.js +++ b/tests/e2e/default/tasks/tasks-group.wdio-spec.js @@ -185,7 +185,7 @@ describe('Tasks group landing page', () => { const tasksFilePath = path.join(__dirname, 'config/tasks-group-config.js'); const { tasks } = await chtConfUtils.compileNoolsConfig({ tasks: tasksFilePath }); - await utils.updateSettings({ tasks }, 'api'); + await utils.updateSettings({ tasks }, { ignoreReload: 'api' }); }); describe('for chw', () => { diff --git a/tests/e2e/default/tasks/tasks.wdio-spec.js b/tests/e2e/default/tasks/tasks.wdio-spec.js index e0a827b1b24..9ecf2cdcb35 100644 --- a/tests/e2e/default/tasks/tasks.wdio-spec.js +++ b/tests/e2e/default/tasks/tasks.wdio-spec.js @@ -8,11 +8,6 @@ const placeFactory = require('@factories/cht/contacts/place'); const personFactory = require('@factories/cht/contacts/person'); const chtDbUtils = require('@utils/cht-db'); -const updateSettings = async (settings) => { - await utils.updateSettings(settings, 'api'); - await commonPage.sync(true); -}; - const compileTasks = async (tasksFileName) => { await chtConfUtils.initializeConfigDir(); const tasksFilePath = path.join(__dirname, `config/${tasksFileName}`); @@ -62,7 +57,7 @@ describe('Tasks', () => { it('Should show error message for bad config', async () => { const settings = await compileTasks('tasks-error-config.js'); - await updateSettings(settings); + await utils.updateSettings(settings, { ignoreReload: 'api', sync: true }); await commonPage.goToTasks(); const { errorMessage, url, username, errorStack } = await commonPage.getErrorLog(); diff --git a/tests/e2e/default/transitions/client-side-muting.wdio-spec.js b/tests/e2e/default/transitions/client-side-muting.wdio-spec.js index 549802b04e3..d06821adea4 100644 --- a/tests/e2e/default/transitions/client-side-muting.wdio-spec.js +++ b/tests/e2e/default/transitions/client-side-muting.wdio-spec.js @@ -16,13 +16,13 @@ describe('Muting', () => { const district = places.get('district_hospital'); const healthCenter = places.get('health_center'); - const contact1 = personFactory.build({ + const contact1 = personFactory.build({ name: 'contact1', parent: { _id: healthCenter._id, parent: district._id } }); - const clinic1 = Object.assign({}, + const clinic1 = Object.assign({}, places.get('clinic'), { name: 'Clinic One', _id: 'clinic_1', contact: { _id: contact1._id }}); - const clinic2 = Object.assign({}, + const clinic2 = Object.assign({}, places.get('clinic'), { name: 'Clinic Two', _id: 'clinic_2', contact: { _id: contact1._id }}); @@ -61,7 +61,7 @@ describe('Muting', () => { parent: { _id: clinic1._id, parent: { _id: healthCenter._id, parent: { _id: district._id } } }, patient_id: 'patient_3', }); - + const contacts = [ contact1, clinic1, @@ -117,7 +117,7 @@ describe('Muting', () => { await commonPage.openFastActionReport(form); await genericForm.submitForm(); await commonPage.waitForLoaders(); - + if (sync) { const lastSubmittedReport = await getLastSubmittedReport(); await ensureSync(lastSubmittedReport); @@ -197,7 +197,7 @@ describe('Muting', () => { await loginPage.login({username: onlineUser.username, password: onlineUser.password}); await utils.stopSentinel(); await utils.updateSettings(settings); - + await muteClinic(clinic1); await commonPage.waitForLoaders(); expectUnmutedNoHistory(await utils.getDoc(clinic1._id)); @@ -212,7 +212,7 @@ describe('Muting', () => { }); describe('for an offline user', () => { - const updateSettings = async (settings) => { + const updateClientSideMutingSettings = async (settings) => { await setBrowserOffline(); await utils.updateSettings(settings); await setBrowserOnline(); @@ -275,7 +275,7 @@ describe('Muting', () => { settingsWithDisabled.transitions.muting = { client_side: false }; await utils.stopSentinel(); - await updateSettings(settingsWithDisabled); + await updateClientSideMutingSettings(settingsWithDisabled); await muteClinic(clinic2, true); await commonPage.waitForLoaders(); @@ -293,7 +293,7 @@ describe('Muting', () => { // for simplicity, offline means sentinel is stopped it( 'should mute and unmute a person while "offline", with processing in between', async () => { await utils.stopSentinel(); - await updateSettings(settings); + await updateClientSideMutingSettings(settings); await mutePerson(patient1, true); @@ -383,7 +383,7 @@ describe('Muting', () => { it( 'should mute and unmute a person while "offline", without processing in between', async () => { await utils.stopSentinel(); - await updateSettings(settings); + await updateClientSideMutingSettings(settings); await mutePerson(patient1, true); @@ -449,7 +449,7 @@ describe('Muting', () => { it( 'should mute and unmute a clinic while "offline", with processing in between', async () => { await utils.stopSentinel(); - await updateSettings(settings); + await updateClientSideMutingSettings(settings); await muteClinic(clinic1, true); @@ -595,7 +595,7 @@ describe('Muting', () => { it( 'should mute and unmute a clinic while "offline", without processing in between', async () => { await utils.stopSentinel(); - await updateSettings(settings); + await updateClientSideMutingSettings(settings); await muteClinic(clinic1, true); @@ -696,7 +696,7 @@ describe('Muting', () => { it( 'should mute a clinic and unmute a patient while "offline", without processing in between', async () => { await utils.stopSentinel(); - await updateSettings(settings); + await updateClientSideMutingSettings(settings); await muteClinic(clinic1, true); @@ -827,7 +827,7 @@ describe('Muting', () => { it( 'should handle offline multiple muting/unmuting events gracefully', async () => { // this test has value after it ran for at least 100 times await utils.stopSentinel(); - await updateSettings(settings); + await updateClientSideMutingSettings(settings); await commonPage.waitForLoaders(); await muteClinic(clinic1); await unmutePerson(patient1); // also unmutes clinic @@ -886,7 +886,7 @@ describe('Muting', () => { }; await utils.stopSentinel(); - await updateSettings(settingsWithValidations); + await updateClientSideMutingSettings(settingsWithValidations); await mutePerson(patient1); let updatedPatient1 = await utils.getDoc(patient1._id); @@ -915,7 +915,7 @@ describe('Muting', () => { it( 'should work with composite forms', async () => { await utils.stopSentinel(); - await updateSettings(settings); + await updateClientSideMutingSettings(settings); await commonPage.goToPeople(healthCenter._id); await commonPage.openFastActionReport('mute_new_clinic'); diff --git a/tests/e2e/default/transitions/create-user-for-contacts.create-user.wdio-spec.js b/tests/e2e/default/transitions/create-user-for-contacts.create-user.wdio-spec.js index f92221c148f..6348f574cf4 100644 --- a/tests/e2e/default/transitions/create-user-for-contacts.create-user.wdio-spec.js +++ b/tests/e2e/default/transitions/create-user-for-contacts.create-user.wdio-spec.js @@ -136,7 +136,7 @@ describe('Create user when adding contact', () => { await utils.createUsers([offlineUser]); newUsers.push(offlineUser.username); - await utils.updateSettings(settings, 'sentinel'); + await utils.updateSettings(settings, {ignoreReload: 'sentinel'}); await loginPage.login(offlineUser); await commonPage.waitForPageLoaded(); await browser.throttle('offline'); @@ -151,7 +151,7 @@ describe('Create user when adding contact', () => { }); it('creates a new user while online', async () => { - await utils.updateSettings(settings, 'sentinel'); + await utils.updateSettings(settings, {ignoreReload: 'sentinel'}); await cookieLogin(); await commonPage.goToPeople(district._id); @@ -161,7 +161,7 @@ describe('Create user when adding contact', () => { }); it('Creates a new user when adding a person while adding a place', async () => { - await utils.updateSettings(settings, 'sentinel'); + await utils.updateSettings(settings, {ignoreReload: 'sentinel'}); await cookieLogin(); await commonPage.goToPeople(district._id); @@ -188,7 +188,7 @@ describe('Create user when adding contact', () => { }); it('creates a new user when contact is added from app form', async () => { - await utils.updateSettings(settings, 'sentinel'); + await utils.updateSettings(settings, {ignoreReload: 'sentinel'}); await cookieLogin(); await commonPage.goToPeople(district._id); @@ -200,7 +200,7 @@ describe('Create user when adding contact', () => { }); it('Does not create a new user when the transition fails', async () => { - await utils.updateSettings(settings, 'sentinel'); + await utils.updateSettings(settings, {ignoreReload: 'sentinel'}); await cookieLogin(); await commonPage.goToPeople(district._id); @@ -213,7 +213,7 @@ describe('Create user when adding contact', () => { }); it('Does not create a new user when editing contact', async () => { - await utils.updateSettings(settings, 'sentinel'); + await utils.updateSettings(settings, {ignoreReload: 'sentinel'}); await cookieLogin(); await commonPage.goToPeople(district._id); await commonPage.openFastActionReport(addChwAppForm.internalId); @@ -233,7 +233,7 @@ describe('Create user when adding contact', () => { }); it('creates a new user when Sentinel recovers from outage', async () => { - await utils.updateSettings(settings, 'sentinel'); + await utils.updateSettings(settings, {ignoreReload: 'sentinel'}); await utils.stopSentinel(); await cookieLogin(); diff --git a/tests/e2e/default/transitions/create-user-for-contacts.replace-user.wdio-spec.js b/tests/e2e/default/transitions/create-user-for-contacts.replace-user.wdio-spec.js index 5a904cbef35..aa8e6517d02 100644 --- a/tests/e2e/default/transitions/create-user-for-contacts.replace-user.wdio-spec.js +++ b/tests/e2e/default/transitions/create-user-for-contacts.replace-user.wdio-spec.js @@ -204,7 +204,7 @@ describe('Create user for contacts', () => { describe('user replace', () => { describe('for an offline user', () => { it('creates a new user and re-parents reports when the replace_user form is submitted', async () => { - await utils.updateSettings(SETTINGS, 'sentinel'); + await utils.updateSettings(SETTINGS, {ignoreReload: 'sentinel'}); await loginAsOfflineUser(); const originalContactId = ORIGINAL_USER.contact._id; @@ -287,7 +287,7 @@ describe('Create user for contacts', () => { }); it('creates a new user when the replace_user form is submitted while online', async () => { - await utils.updateSettings(SETTINGS, 'sentinel'); + await utils.updateSettings(SETTINGS, {ignoreReload: 'sentinel'}); await loginAsOfflineUser(); const originalContactId = ORIGINAL_USER.contact._id; @@ -336,7 +336,7 @@ describe('Create user for contacts', () => { // eslint-disable-next-line max-len it('does not assign new person as primary contact of parent place if original person was not primary', async () => { - await utils.updateSettings(SETTINGS, 'sentinel'); + await utils.updateSettings(SETTINGS, {ignoreReload: 'sentinel'}); const district = await utils.getDoc(DISTRICT._id); district.contact = { _id: 'not-the-original-contact' }; await utils.saveDoc(district); @@ -387,7 +387,7 @@ describe('Create user for contacts', () => { }); it('creates new user from latest replace_user form data if multiple are submitted before syncing', async () => { - await utils.updateSettings(SETTINGS, 'sentinel'); + await utils.updateSettings(SETTINGS, {ignoreReload: 'sentinel'}); await loginAsOfflineUser(); const originalContactId = ORIGINAL_USER.contact._id; @@ -484,7 +484,7 @@ describe('Create user for contacts', () => { // eslint-disable-next-line max-len it('creates new user when replace_user form is submitted for contact associated with multiple users', async () => { - await utils.updateSettings(SETTINGS, 'sentinel'); + await utils.updateSettings(SETTINGS, {ignoreReload: 'sentinel'}); await loginAsOfflineUser(); const otherUser = { @@ -551,7 +551,7 @@ describe('Create user for contacts', () => { // eslint-disable-next-line max-len it('creates new user for the first version of a contact to sync and conflicting replacements ignored', async () => { - await utils.updateSettings(SETTINGS, 'sentinel'); + await utils.updateSettings(SETTINGS, {ignoreReload: 'sentinel'}); await loginAsOfflineUser(); const originalContactId = ORIGINAL_USER.contact._id; @@ -671,7 +671,7 @@ describe('Create user for contacts', () => { it('does not create a new user or re-parent reports when the transition is disabled', async () => { const settings = { ...SETTINGS, transitions: { create_user_for_contacts: false } }; - await utils.updateSettings(settings, 'sentinel'); + await utils.updateSettings(settings, {ignoreReload: 'sentinel'}); await loginAsOfflineUser(); const originalContactId = ORIGINAL_USER.contact._id; @@ -705,7 +705,7 @@ describe('Create user for contacts', () => { }); it('does not create any new user nor does it reparent new reports when the transition fails', async () => { - await utils.updateSettings(SETTINGS, 'sentinel'); + await utils.updateSettings(SETTINGS, {ignoreReload: 'sentinel'}); await loginAsOfflineUser(); const originalContactId = ORIGINAL_USER.contact._id; @@ -784,7 +784,7 @@ describe('Create user for contacts', () => { }); it('does not create a new user when the replace_user form is submitted for online user', async () => { - await utils.updateSettings(SETTINGS, 'sentinel'); + await utils.updateSettings(SETTINGS, {ignoreReload: 'sentinel'}); await loginAsOnlineUser(); const originalContactId = ONLINE_USER.contact._id; await commonPage.goToPeople(originalContactId); diff --git a/tests/e2e/default/translations/enabled-languages.wdio-spec.js b/tests/e2e/default/translations/enabled-languages.wdio-spec.js index 2d893f662d3..e64ac53261d 100644 --- a/tests/e2e/default/translations/enabled-languages.wdio-spec.js +++ b/tests/e2e/default/translations/enabled-languages.wdio-spec.js @@ -26,7 +26,7 @@ describe('Enabling/disabling languages', () => { }); it('should disable a language and enable another', async () => { - await utils.updateSettings(settings, true); + await utils.updateSettings(settings, { ignoreReload: true }); await browser.reloadSession(); await browser.url('/'); diff --git a/tests/e2e/default/translations/nepali-dates-and-numbers.wdio-spec.js b/tests/e2e/default/translations/nepali-dates-and-numbers.wdio-spec.js index 9732d810f06..31add4824ef 100644 --- a/tests/e2e/default/translations/nepali-dates-and-numbers.wdio-spec.js +++ b/tests/e2e/default/translations/nepali-dates-and-numbers.wdio-spec.js @@ -106,7 +106,10 @@ describe('Bikram Sambat date display', () => { const contactSummaryFile = path.join(__dirname, 'bikram-sambat-contact-template-config.js'); const { contactSummary } = await chtConfUtils.compileNoolsConfig({ contactSummary: contactSummaryFile }); - await utils.updateSettings({ contact_summary: contactSummary, forms, registrations, transitions }, true); + await utils.updateSettings( + { contact_summary: contactSummary, forms, registrations, transitions }, + { ignoreReload: true } + ); const formsPath = path.join(__dirname, 'forms'); await chtConfUtils.compileAndUploadAppForms(formsPath); @@ -263,7 +266,7 @@ describe('Bikram Sambat date display', () => { id: 'lmp-id-bs-parts', from: '+9779876543210', content: `${formIdBSParts} Shrestha ` + - `${lmpBSParts.year} ${lmpBSParts.month} ${lmpBSParts.day}` + `${lmpBSParts.year} ${lmpBSParts.month} ${lmpBSParts.day}` }); await commonPage.goToPeople(); diff --git a/tests/e2e/default/users/add-user.wdio-spec.js b/tests/e2e/default/users/add-user.wdio-spec.js index 07b96112524..fbc820bf18a 100644 --- a/tests/e2e/default/users/add-user.wdio-spec.js +++ b/tests/e2e/default/users/add-user.wdio-spec.js @@ -37,7 +37,7 @@ describe('User Test Cases ->', () => { ...settings.permissions, can_have_multiple_places: [offlineUserRole], }; - await utils.updateSettings({ permissions }, true); + await utils.updateSettings({ permissions }, { ignoreReload: true }); await utils.saveDocs(docs); await loginPage.cookieLogin(); }); diff --git a/tests/integration/api/controllers/all-docs.spec.js b/tests/integration/api/controllers/all-docs.spec.js index 062103a48fd..f67f88b71cd 100644 --- a/tests/integration/api/controllers/all-docs.spec.js +++ b/tests/integration/api/controllers/all-docs.spec.js @@ -581,7 +581,7 @@ describe('all_docs handler', () => { const settings = { replication_depth: [{ role: 'district_admin', depth: 2, report_depth: 1 }] }; return utils - .updateSettings(settings, true) + .updateSettings(settings, { ignoreReload: true }) .then(() => utils.saveDocsRevs(docs)) .then(() => Promise.all([ utils.requestOnMedicDb(Object.assign({ qs: { keys: keys } }, supervisorRequestOptions)), diff --git a/tests/integration/api/controllers/bulk-docs.spec.js b/tests/integration/api/controllers/bulk-docs.spec.js index 9b6a363faed..fa3b4376054 100644 --- a/tests/integration/api/controllers/bulk-docs.spec.js +++ b/tests/integration/api/controllers/bulk-docs.spec.js @@ -985,7 +985,7 @@ describe('bulk-docs handler', () => { const settings = { replication_depth: [{ role: 'district_admin', depth: 1 }] }; return utils - .updateSettings(settings, true) + .updateSettings(settings, { ignoreReload: true }) .then(() => utils.saveDocsRevs(existentDocs)) .then(() => { offlineRequestOptions.body = { docs: [...newDocs, ...existentDocs], new_edits: true }; @@ -1133,7 +1133,7 @@ describe('bulk-docs handler', () => { const settings = { replication_depth: [{ role: 'district_admin', depth: 1 }] }; return utils - .updateSettings(settings, true) + .updateSettings(settings, { ignoreReload: true }) .then(() => utils.saveDocsRevs(existentDocs)) .then(() => { offlineRequestOptions.body = { docs: [...newDocs, ...existentDocs], new_edits: true }; @@ -1280,7 +1280,7 @@ describe('bulk-docs handler', () => { const settings = { replication_depth: [{ role: 'district_admin', depth: 2, report_depth: 1 }] }; return utils - .updateSettings(settings, true) + .updateSettings(settings, { ignoreReload: true }) .then(() => utils.saveDocsRevs(existentDocs)) .then(() => { offlineRequestOptions.body = { docs: [...newDocs, ...existentDocs], new_edits: true }; diff --git a/tests/integration/api/controllers/bulk-get.spec.js b/tests/integration/api/controllers/bulk-get.spec.js index 01e93c10049..cc23e31f647 100644 --- a/tests/integration/api/controllers/bulk-get.spec.js +++ b/tests/integration/api/controllers/bulk-get.spec.js @@ -570,7 +570,7 @@ describe('bulk-get handler', () => { const settings = { replication_depth: [{ role: 'district_admin', depth: 1 }] }; return utils - .updateSettings(settings, true) + .updateSettings(settings, { ignoreReload: true }) .then(() => utils.saveDocsRevs(existentDocs)) .then(() => { const docs = existentDocs.map(doc => ({ id: doc._id, rev: doc._rev })); @@ -655,7 +655,7 @@ describe('bulk-get handler', () => { const settings = { replication_depth: [{ role: 'district_admin', depth: 1 }] }; return utils - .updateSettings(settings, true) + .updateSettings(settings, { ignoreReload: true }) .then(() => utils.saveDocsRevs(existentDocs)) .then(() => { const docs = existentDocs.map(doc => ({ id: doc._id, rev: doc._rev })); @@ -740,7 +740,7 @@ describe('bulk-get handler', () => { const settings = { replication_depth: [{ role: 'district_admin', depth: 2, report_depth: 1 }] }; return utils - .updateSettings(settings, true) + .updateSettings(settings, { ignoreReload: true }) .then(() => utils.saveDocsRevs(existentDocs)) .then(() => { const docs = existentDocs.map(doc => ({ id: doc._id, rev: doc._rev })); diff --git a/tests/integration/api/controllers/db-doc.spec.js b/tests/integration/api/controllers/db-doc.spec.js index 62a13ee0c8b..45b042fd03e 100644 --- a/tests/integration/api/controllers/db-doc.spec.js +++ b/tests/integration/api/controllers/db-doc.spec.js @@ -446,7 +446,7 @@ describe('db-doc handler', () => { ]; const docs = reportScenarios.map(scenario => scenario.doc); return utils - .updateSettings({replication_depth: [{ role: 'district_admin', depth: 1 }]}, true) + .updateSettings({replication_depth: [{ role: 'district_admin', depth: 1 }]}, { ignoreReload: true }) .then(() => utils.saveDocs(docs)) .then(() => Promise.all(reportScenarios.map(scenario => utils.requestOnTestDb( _.defaults({ path: `/${scenario.doc._id}` }, offlineRequestOptions) @@ -481,7 +481,10 @@ describe('db-doc handler', () => { const docs = reportScenarios.map(scenario => scenario.doc); return utils - .updateSettings({replication_depth: [{ role: 'district_admin', depth: 2, report_depth: 1 }]}, true) + .updateSettings( + {replication_depth: [{ role: 'district_admin', depth: 2, report_depth: 1 }]}, + { ignoreReload: true } + ) .then(() => utils.saveDocs(docs)) .then(() => Promise.all( reportScenarios.map(scenario => utils @@ -765,7 +768,7 @@ describe('db-doc handler', () => { const docs = reportScenarios.map(scenario => scenario.doc); return utils - .updateSettings({replication_depth: [{ role: 'district_admin', depth: 1 }]}, true) + .updateSettings({replication_depth: [{ role: 'district_admin', depth: 1 }]}, { ignoreReload: true }) .then(() => utils.saveDocs([...patientsToDelete, ...docs, ...submittersToDelete])) .then(() => Promise.all(patientsToDelete.map(patient => utils.requestOnTestDb( _.defaults({ path: `/${patient._id}` }, offlineRequestOptions) @@ -1063,7 +1066,7 @@ describe('db-doc handler', () => { }; return utils - .updateSettings({ replication_depth: [{ role: 'district_admin', depth: 2 }]}, true) + .updateSettings({ replication_depth: [{ role: 'district_admin', depth: 2 }]}, { ignoreReload: true }) .then(() => utils.saveDocs([ allowedTask, deniedTask, allowedTarget, deniedTarget ])) .then(() => Promise.all([ utils.requestOnTestDb(_.defaults({ path: '/task1' }, offlineRequestOptions)), @@ -1136,7 +1139,7 @@ describe('db-doc handler', () => { // user can't see the unallocated report without permissions chai.expect(result).to.deep.nested.include({ statusCode: 403, 'responseBody.error': 'forbidden'}); }) - .then(() => utils.updateSettings(settings, true)) + .then(() => utils.updateSettings(settings, { ignoreReload: true })) .then(() => utils.requestOnTestDb(_.defaults({ path: `/${doc._id}` }, offlineRequestOptions)).catch(err => err)) .then(result => { // user can see the unallocated report with permissions @@ -1407,7 +1410,7 @@ describe('db-doc handler', () => { { doc: reportForPatient('fixture:online:clinic:patient', 'online', ['patient_id'], true), allowed: false }, ]; return utils - .updateSettings({replication_depth: [{ role: 'district_admin', depth: 1 }]}, true) + .updateSettings({replication_depth: [{ role: 'district_admin', depth: 1 }]}, { ignoreReload: true }) .then(() => Promise.all(reportScenarios.map(scenario => utils.requestOnTestDb( _.defaults({ path: '/', body: scenario.doc }, offlineRequestOptions) ).catch(err => err)))) @@ -1707,7 +1710,7 @@ describe('db-doc handler', () => { { doc: reportForPatient('fixture:online:clinic:patient', 'online', ['patient_id'], true), allowed: false }, ]; return utils - .updateSettings({replication_depth: [{ role: 'district_admin', depth: 1 }]}, true) + .updateSettings({replication_depth: [{ role: 'district_admin', depth: 1 }]}, { ignoreReload: true }) .then(() => Promise.all(reportScenarios.map(scenario => utils.requestOnTestDb( _.defaults({ path: `/${scenario.doc._id}`, body: scenario.doc }, offlineRequestOptions) ).catch(err => err)))) diff --git a/tests/integration/api/controllers/login.spec.js b/tests/integration/api/controllers/login.spec.js index 02d8dbd8203..dc9be54a07e 100644 --- a/tests/integration/api/controllers/login.spec.js +++ b/tests/integration/api/controllers/login.spec.js @@ -68,7 +68,7 @@ const setupTokenLoginSettings = (configureAppUrl = false) => { settings.app_url = utils.getOrigin(); } return utils - .updateSettings(settings, true) + .updateSettings(settings, { ignoreReload: true }) .then(() => utils.addTranslations('en', { login_sms: 'Instructions sms' })); }; diff --git a/tests/integration/api/controllers/places.spec.js b/tests/integration/api/controllers/places.spec.js index a3dd0000f7c..3d0862b4ef6 100644 --- a/tests/integration/api/controllers/places.spec.js +++ b/tests/integration/api/controllers/places.spec.js @@ -31,7 +31,7 @@ describe('Places API', () => { ...settings.permissions, 'can_create_places': ['national_admin'], }; - await utils.updateSettings({ permissions }, true); + await utils.updateSettings({ permissions }, { ignoreReload: true }); await utils.createUsers(users); }); diff --git a/tests/integration/api/controllers/records.spec.js b/tests/integration/api/controllers/records.spec.js index ae1f02c2048..97c2434cee5 100644 --- a/tests/integration/api/controllers/records.spec.js +++ b/tests/integration/api/controllers/records.spec.js @@ -33,7 +33,7 @@ describe('Import Records', () => { } } } - }, true)); + }, { ignoreReload: true })); describe('JSON', () => { it('parses and stores the passed JSON', () => { diff --git a/tests/integration/api/controllers/replication.spec.js b/tests/integration/api/controllers/replication.spec.js index beb2d7ecb7b..4213d4cf6cd 100644 --- a/tests/integration/api/controllers/replication.spec.js +++ b/tests/integration/api/controllers/replication.spec.js @@ -294,7 +294,7 @@ describe('replication', () => { it('should be supplied if user has this perm and district_admins_access_unallocated_messages is enabled', async () => { - await utils.updateSettings({ district_admins_access_unallocated_messages: true }, true); + await utils.updateSettings({ district_admins_access_unallocated_messages: true }, { ignoreReload: true }); await utils.saveDoc({ _id: 'unallocated_report', type: 'data_record' }); const response = await requestDocs('bob'); assertDocIds(response, ...bobsIds, 'unallocated_report'); @@ -337,7 +337,10 @@ describe('replication', () => { }); it('should show contacts to a user only if they are within the configured depth', async () => { - await utils.updateSettings({ replication_depth: [{ role: 'district_admin', depth: 1 }] }, true); + await utils.updateSettings( + { replication_depth: [{ role: 'district_admin', depth: 1 }] }, + { ignoreReload: true } + ); const response = await requestDocs('chw'); assertDocIds(response, ...chwIds, 'depth_clinic'); @@ -353,7 +356,7 @@ describe('replication', () => { { role: 'analytics', depth: 2 }, ] }, - true + { ignoreReload: true } ); await utils.saveDocs(docs); const response = await requestDocs('chw'); @@ -423,7 +426,7 @@ describe('replication', () => { await utils.updateSettings( { replication_depth: [{ role: 'district_admin', depth: 2, report_depth: 1 }] }, - true + { ignoreReload: true } ); await utils.saveDocs(contacts); await utils.saveDocs(reports); @@ -498,7 +501,7 @@ describe('replication', () => { replication_depth: [{ role: 'district_admin', depth: 2, report_depth: 1 }], permissions, }, - true + { ignoreReload: true } ); await utils.saveDocs(contacts); await utils.saveDocs(reports); @@ -563,7 +566,7 @@ describe('replication', () => { await utils.updateSettings( { replication_depth: [{ role: 'district_admin', depth: 1, report_depth: 0 }] }, - true + { ignoreReload: true } ); await utils.saveDocs(docs); const response = await requestDocs('chw'); @@ -638,7 +641,7 @@ describe('replication', () => { } }; - await utils.updateSettings({replication_depth: [{ role: 'district_admin', depth: 1 }]}, true); + await utils.updateSettings({replication_depth: [{ role: 'district_admin', depth: 1 }]}, { ignoreReload: true }); await utils.saveDocs([ clinicReport, clinicReport2, healthCenterReport, bobReport ]); assertDocIds(await requestDocs('chw'), ...chwIds, 'clinic_patient', 'clinic_report', 'clinic_report_2'); @@ -697,7 +700,10 @@ describe('replication', () => { } }; - await utils.updateSettings({ replication_depth: [{ role: 'district_admin', depth: 1 }]}, true); + await utils.updateSettings( + { replication_depth: [{ role: 'district_admin', depth: 1 }]}, + { ignoreReload: true } + ); await utils.saveDocs([ clinicReport, clinicReport2, healthCenterReport, bobReport ]); assertDocIds(await requestDocs('chw'), ...chwIds, 'clinic_patient', 'clinic_report', 'clinic_report_2'); @@ -770,7 +776,10 @@ describe('replication', () => { } }; - await utils.updateSettings({replication_depth: [{ role: 'district_admin', depth: 1, report_depth: 0 }]}, true); + await utils.updateSettings( + {replication_depth: [{ role: 'district_admin', depth: 1, report_depth: 0 }]}, + { ignoreReload: true } + ); await utils.saveDocs([ clinicReport, clinicReport2, healthCenterReport, bobReport ]); assertDocIds(await requestDocs('chw'), ...chwIds, 'clinic_patient', 'clinic_report', 'clinic_report_2'); @@ -1076,7 +1085,10 @@ describe('replication', () => { await utils.saveDocs(reports); const seq = await sentinelUtils.getCurrentSeq(); - await utils.updateSettings({ purge: { fn: purgeFn.toString(), text_expression: 'every 1 seconds' } }, true); + await utils.updateSettings( + { purge: { fn: purgeFn.toString(), text_expression: 'every 1 seconds' } }, + { ignoreReload: true } + ); await utils.stopSentinel(); await utils.startSentinel(); await sentinelUtils.waitForPurgeCompletion(seq); @@ -1099,7 +1111,10 @@ describe('replication', () => { await utils.saveDocs(reports); const seq = await sentinelUtils.getCurrentSeq(); - await utils.updateSettings({ purge: { fn: purgeFn.toString(), text_expression: 'every 1 seconds' } }, true); + await utils.updateSettings( + { purge: { fn: purgeFn.toString(), text_expression: 'every 1 seconds' } }, + { ignoreReload: true } + ); await utils.stopSentinel(); await utils.startSentinel(); await sentinelUtils.waitForPurgeCompletion(seq); diff --git a/tests/integration/api/controllers/settings.spec.js b/tests/integration/api/controllers/settings.spec.js index ff6048de925..c4bda666dc9 100644 --- a/tests/integration/api/controllers/settings.spec.js +++ b/tests/integration/api/controllers/settings.spec.js @@ -8,7 +8,7 @@ const getDoc = () => { }; describe('Settings API', () => { - before(() => utils.updateSettings({}, true)); + before(() => utils.updateSettings({}, { ignoreReload: true })); after(() => utils.revertSettings(true)); describe('old api', () => { diff --git a/tests/integration/api/controllers/users.spec.js b/tests/integration/api/controllers/users.spec.js index 42f40668274..5def034326f 100644 --- a/tests/integration/api/controllers/users.spec.js +++ b/tests/integration/api/controllers/users.spec.js @@ -310,7 +310,10 @@ describe('Users API', () => { }; return utils .revertSettings(true) - .then(() => utils.updateSettings({ transitions: { generate_patient_id_on_people: true }}, true)) + .then(() => utils.updateSettings( + { transitions: { generate_patient_id_on_people: true }}, + { ignoreReload: true } + )) .then(() => utils.saveDoc(parentPlace)) .then(() => { const opts = { @@ -810,7 +813,7 @@ describe('Users API', () => { it('should create and update a user correctly w/o token_login', () => { const settings = { token_login: { translation_key: 'token_login_sms', enabled: true } }; return utils - .updateSettings(settings, true) + .updateSettings(settings, { ignoreReload: true }) .then(() => utils.addTranslations('en', { token_login_sms: 'Instructions sms' })) .then(() => utils.request({ path: '/api/v1/users', method: 'POST', body: user })) .then(response => { @@ -888,7 +891,7 @@ describe('Users API', () => { }, ]; const settings = { token_login: { translation_key: 'token_login_sms', enabled: true } }; - await utils.updateSettings(settings, true); + await utils.updateSettings(settings, { ignoreReload: true }); await utils.addTranslations('en', { token_login_sms: 'Instructions sms' }); const response = await utils.request({ path: '/api/v1/users', method: 'POST', body: users }); @@ -956,7 +959,7 @@ describe('Users API', () => { }, ]; const settings = { token_login: { translation_key: 'token_login_sms', enabled: true } }; - await utils.updateSettings(settings, true); + await utils.updateSettings(settings, { ignoreReload: true }); await utils.addTranslations('en', { token_login_sms: 'Instructions sms' }); const response = await utils.request({ path: '/api/v1/users', method: 'POST', body: users }); @@ -1028,7 +1031,7 @@ describe('Users API', () => { }, ]; const settings = { token_login: { translation_key: 'token_login_sms', enabled: true } }; - await utils.updateSettings(settings, true); + await utils.updateSettings(settings, { ignoreReload: true }); await utils.addTranslations('en', { token_login_sms: 'Instructions sms' }); const response = await utils.request({ path: '/api/v1/users', method: 'POST', body: users }); @@ -1141,7 +1144,7 @@ describe('Users API', () => { enabled: true, }, }; - await utils.updateSettings(settings, true); + await utils.updateSettings(settings, { ignoreReload: true }); await utils.addTranslations('en', { token_login_sms: 'Instructions sms' }); const response = await utils.request({ path: '/api/v1/users', method: 'POST', body: users }); response.forEach((responseUser, index) => { @@ -1227,7 +1230,7 @@ describe('Users API', () => { it('should throw an error when phone is missing when creating a user with token_login', () => { const settings = { token_login: { translation_key: 'token_login_sms', enabled: true } }; return utils - .updateSettings(settings, true) + .updateSettings(settings, { ignoreReload: true }) .then(() => utils.addTranslations('en', { token_login_sms: 'Instructions sms' })) .then(() => { user.token_login = true; @@ -1245,7 +1248,7 @@ describe('Users API', () => { it('should throw an error when phone is missing when updating a user with token_login', () => { const settings = { token_login: { translation_key: 'token_login_sms', enabled: true }, app_url: 'https://host/' }; return utils - .updateSettings(settings, true) + .updateSettings(settings, { ignoreReload: true }) .then(() => utils.addTranslations('en', { token_login_sms: 'Instructions sms' })) .then(() => utils.request({ path: '/api/v1/users', method: 'POST', body: user })) .then(() => { @@ -1284,7 +1287,7 @@ describe('Users API', () => { let tokenUrl; return utils - .updateSettings(settings, true) + .updateSettings(settings, { ignoreReload: true }) .then(() => utils.addTranslations('en', { token_login_sms: 'Instructions sms' })) .then(() => utils.request({ path: '/api/v1/users', method: 'POST', body: user })) .then(response => { @@ -1356,7 +1359,7 @@ describe('Users API', () => { const settings = { token_login: { translation_key: 'sms_text', enabled: true }, app_url: utils.getOrigin() }; let tokenUrl; return utils - .updateSettings(settings, true) + .updateSettings(settings, { ignoreReload: true }) .then(() => utils.addTranslations('en', { sms_text: 'Instructions sms' })) .then(() => utils.request({ path: '/api/v1/users', method: 'POST', body: user })) .then(() => { @@ -1436,7 +1439,7 @@ describe('Users API', () => { user.phone = '+40755232323'; let tokenLogin; return utils - .updateSettings(settings, true) + .updateSettings(settings, { ignoreReload: true }) .then(() => utils.addTranslations('en', { login_sms: 'Instructions sms' })) .then(() => utils.request({ path: '/api/v1/users', method: 'POST', body: user })) .then(() => getUser(user)) @@ -1469,7 +1472,7 @@ describe('Users API', () => { let firstTokenLogin; let secondTokenLogin; return utils - .updateSettings(settings, true) + .updateSettings(settings, { ignoreReload: true }) .then(() => utils.addTranslations('en', { login_sms: 'Instructions sms' })) .then(() => utils.request({ path: '/api/v1/users', method: 'POST', body: user })) .then(() => getUser(user)) @@ -1522,7 +1525,7 @@ describe('Users API', () => { user.phone = '+40755969696'; let firstTokenLogin; return utils - .updateSettings(settings, true) + .updateSettings(settings, { ignoreReload: true }) .then(() => utils.addTranslations('en', { login_sms: 'Instructions sms' })) .then(() => utils.request({ path: '/api/v1/users', method: 'POST', body: user })) .then(() => getUser(user)) @@ -1579,7 +1582,7 @@ describe('Users API', () => { let tokenLoginDocId; return utils - .updateSettings(settings, true) + .updateSettings(settings, { ignoreReload: true }) .then(() => utils.addTranslations('en', { login_sms: 'Instructions sms' })) .then(() => utils.request({ path: '/api/v1/users', method: 'POST', body: onlineUser })) .then(() => utils.request({ path: '/api/v1/users', method: 'POST', body: user })) diff --git a/tests/integration/api/controllers/well-known.spec.js b/tests/integration/api/controllers/well-known.spec.js index c1c5901f506..6d77886ce78 100644 --- a/tests/integration/api/controllers/well-known.spec.js +++ b/tests/integration/api/controllers/well-known.spec.js @@ -31,7 +31,7 @@ describe('well-known', () => { ['62:BF:C1:78:24:D8:4D:5C:B4:E1:8B:66:98:EA:14:16:57:6F:A4:E5:96:CD:93:81:B2:65:19:71:A7:80:EA:4D'] } }]; - await utils.updateSettings({ assetlinks }, true); + await utils.updateSettings({ assetlinks }, { ignoreReload: true }); const response = await utils.request(Object.assign( { path: '/.well-known/assetlinks.json' }, diff --git a/tests/integration/api/routing.spec.js b/tests/integration/api/routing.spec.js index 88c00ecad60..dcbbad60fc4 100644 --- a/tests/integration/api/routing.spec.js +++ b/tests/integration/api/routing.spec.js @@ -775,8 +775,8 @@ describe('routing', () => { it('should still route to deprecated apiV0 settings endpoints', () => { let settings; - return utils - .updateSettings({}, true) // this test will update settings that we want successfully reverted afterwards + return utils // this test will update settings that we want successfully reverted afterwards + .updateSettings({}, { ignoreReload: true }) .then(() => utils.getDoc('settings')) .then(result => settings = result.settings) .then(() => Promise.all([ diff --git a/tests/integration/infodocs/infodocs.spec.js b/tests/integration/infodocs/infodocs.spec.js index fc165b99bcb..bf2827a007b 100644 --- a/tests/integration/infodocs/infodocs.spec.js +++ b/tests/integration/infodocs/infodocs.spec.js @@ -216,7 +216,7 @@ describe('infodocs', () => { const settings = { transitions: { generate_shortcode_on_contacts: true } }; - await utils.updateSettings(settings, 'sentinel'); + await utils.updateSettings(settings, { ignoreReload: 'sentinel' }); const doc = { _id: uuid(), type: 'person' }; const { rev } = await utils.saveDoc(doc); diff --git a/tests/integration/logging/logging.spec.js b/tests/integration/logging/logging.spec.js index 598b54b78ee..2b3cfe3cd0c 100644 --- a/tests/integration/logging/logging.spec.js +++ b/tests/integration/logging/logging.spec.js @@ -16,7 +16,7 @@ describe('logging', () => { const collectSentinelLogs = await utils.collectApiLogs(/.*/); await utils.delayPromise(1000); // log debug message for checking messages await utils.request('/dbinfo'); - await utils.updateSettings({ test: true }, 'sentinel'); + await utils.updateSettings({ test: true }, { ignoreReload: 'sentinel' }); const apiLogs = (await collectApiLogs()).filter(log => log.length); const sentinelLogs = (await collectSentinelLogs()).filter(log => log.length); diff --git a/tests/integration/sentinel/queue.spec.js b/tests/integration/sentinel/queue.spec.js index ebc75622ccc..b2c6d5c1527 100644 --- a/tests/integration/sentinel/queue.spec.js +++ b/tests/integration/sentinel/queue.spec.js @@ -85,7 +85,7 @@ describe('Sentinel queue drain', () => { } return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs(docs)) .then(() => sentinelUtils.waitForSentinel(ids)) .then(() => utils.getDocs(ids)) @@ -111,7 +111,7 @@ describe('Sentinel queue drain', () => { await utils.listenForApi(); const settings = { transitions: { update_clinics: true } }; - await utils.updateSettings(settings, 'api'); + await utils.updateSettings(settings, { ignoreReload: 'api' }); const doc = { _id: uuid(), diff --git a/tests/integration/sentinel/schedules/due-tasks.spec.js b/tests/integration/sentinel/schedules/due-tasks.spec.js index 985a23f3737..22f57d54f36 100644 --- a/tests/integration/sentinel/schedules/due-tasks.spec.js +++ b/tests/integration/sentinel/schedules/due-tasks.spec.js @@ -364,7 +364,7 @@ describe('Due Tasks', () => { before(() => utils .saveDocs(contacts) .then(() => utils.addTranslations('test', translations)) - .then(() => utils.updateSettings(settings, 'sentinel'))); + .then(() => utils.updateSettings(settings, { ignoreReload: 'sentinel' }))); after(() => utils.revertDb([], true)); it('should process scheduled messages correctly', async () => { diff --git a/tests/integration/sentinel/schedules/outbound.spec.js b/tests/integration/sentinel/schedules/outbound.spec.js index 0f389908ab8..e3ea78b3176 100644 --- a/tests/integration/sentinel/schedules/outbound.spec.js +++ b/tests/integration/sentinel/schedules/outbound.spec.js @@ -112,7 +112,7 @@ describe('Outbound', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs(docs)) // pushes will fail if destination server is not up, so tasks will get created .then(() => waitForPushes(3)) diff --git a/tests/integration/sentinel/schedules/purging.spec.js b/tests/integration/sentinel/schedules/purging.spec.js index 483e3ffbb80..e2d7948ad86 100644 --- a/tests/integration/sentinel/schedules/purging.spec.js +++ b/tests/integration/sentinel/schedules/purging.spec.js @@ -421,7 +421,7 @@ describe('Server side purge', () => { it('should purge correct docs', async () => { const seq = await sentinelUtils.getCurrentSeq(); - await utils.updateSettings({ purge: purgeSettings }, true); + await utils.updateSettings({ purge: purgeSettings }, { ignoreReload: true }); await restartSentinel(); await sentinelUtils.waitForPurgeCompletion(seq); @@ -472,7 +472,7 @@ describe('Server side purge', () => { }); it('should clear purged cache when settings are updated', async () => { - await utils.updateSettings({ district_admins_access_unallocated_messages: true }, true); + await utils.updateSettings({ district_admins_access_unallocated_messages: true }, { ignoreReload: true }); const responseDocsUser1 = await requestDocs('user1'); const responseDocsUser2 = await requestDocs('user2'); @@ -502,7 +502,7 @@ describe('Server side purge', () => { .then(result => { seq = result; purgeSettings.fn = reversePurgeFn.toString(); - return utils.updateSettings({ purge: purgeSettings }, true); + return utils.updateSettings({ purge: purgeSettings }, { ignoreReload: true }); }) .then(() => restartSentinel()) .then(() => sentinelUtils.waitForPurgeCompletion(seq)) @@ -541,7 +541,7 @@ describe('Server side purge', () => { it('should clear purged cache when users are updated', async () => { const seq = await sentinelUtils.getCurrentSeq(); purgeSettings.fn = purgeFn.toString(); - await utils.updateSettings({ purge: purgeSettings }, true); + await utils.updateSettings({ purge: purgeSettings }, { ignoreReload: true }); await restartSentinel(); await sentinelUtils.waitForPurgeCompletion(seq); diff --git a/tests/integration/sentinel/schedules/reminders.spec.js b/tests/integration/sentinel/schedules/reminders.spec.js index 58fed0407b7..90491dc4d54 100644 --- a/tests/integration/sentinel/schedules/reminders.spec.js +++ b/tests/integration/sentinel/schedules/reminders.spec.js @@ -205,7 +205,10 @@ const restartSentinel = () => utils.stopSentinel().then(() => utils.startSentine describe('reminders', () => { before(() => { return utils - .updateSettings({ transitions, forms, 'contact_types': contactTypes, reminders: remindersConfig }, 'sentinel') + .updateSettings( + { transitions, forms, 'contact_types': contactTypes, reminders: remindersConfig }, + { ignoreReload: 'sentinel' } + ) .then(() => utils.saveDocs(contacts)); }); @@ -272,7 +275,7 @@ describe('reminders', () => { remindersConfig[1].text_expression = momentToTextExpression(start.clone().subtract(3, 'minute')); return utils.updateSettings( { transitions, forms, 'contact_types': contactTypes, reminders: remindersConfig }, - true + { ignoreReload: true } ); }) .then(() => restartSentinel()) @@ -375,7 +378,7 @@ describe('reminders', () => { remindersConfig[1].text_expression = momentToTextExpression(start.clone().subtract(1, 'minute')); return utils.updateSettings( { transitions, forms, 'contact_types': contactTypes, reminders: remindersConfig }, - true + { ignoreReload: true } ); }) .then(() => restartSentinel()) diff --git a/tests/integration/sentinel/schedules/schedules-start-from.spec.js b/tests/integration/sentinel/schedules/schedules-start-from.spec.js index 5bfde54c3d4..90a5718ca7d 100644 --- a/tests/integration/sentinel/schedules/schedules-start-from.spec.js +++ b/tests/integration/sentinel/schedules/schedules-start-from.spec.js @@ -247,7 +247,7 @@ describe('schedules alternative start_from', () => { const expectedDue5_1 = expectedDueDate(moment(), '9', 'days'); return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs([patient, clinic])) .then(() => sentinelUtils.waitForSentinel([patient._id, clinic._id])) .then(() => sentinelUtils.getInfoDocs([patient._id, clinic._id])) @@ -277,7 +277,7 @@ describe('schedules alternative start_from', () => { chai.expect(moment(sch3_2.due).format('YYYY-MM-DD')).to.equal(expectedDue3_2, 'schedule 2 of sch3'); // schedules from sch4; Not expected this to be created chai.expect(moment(sch5_1.due).format('YYYY-MM-DD')).to.equal(expectedDue5_1, 'schedule 1 of sch5'); - + chai.expect(updWithClinic.scheduled_tasks).to.be.ok; chai.expect(updWithClinic.scheduled_tasks).to.have.lengthOf(4); diff --git a/tests/integration/sentinel/transitions/accept-patient-reports.spec.js b/tests/integration/sentinel/transitions/accept-patient-reports.spec.js index b6171721fa7..b2f5719f8bb 100644 --- a/tests/integration/sentinel/transitions/accept-patient-reports.spec.js +++ b/tests/integration/sentinel/transitions/accept-patient-reports.spec.js @@ -78,7 +78,7 @@ describe('accept_patient_reports', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -107,7 +107,7 @@ describe('accept_patient_reports', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -234,7 +234,7 @@ describe('accept_patient_reports', () => { const ids = getIds(docs); return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs(docs)) .then(() => sentinelUtils.waitForSentinel(ids)) .then(() => sentinelUtils.getInfoDocs(ids)) @@ -357,7 +357,7 @@ describe('accept_patient_reports', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs([doc1, doc2])) .then(() => sentinelUtils.waitForSentinel([doc1._id, doc2._id])) .then(() => sentinelUtils.getInfoDocs([doc1._id, doc2._id])) @@ -501,7 +501,7 @@ describe('accept_patient_reports', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs(reports)) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) @@ -617,7 +617,7 @@ describe('accept_patient_reports', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs(reports)) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) @@ -732,7 +732,7 @@ describe('accept_patient_reports', () => { return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs(reports)) .then(() => utils.saveDoc(doc1)) .then(() => sentinelUtils.waitForSentinel(doc1._id)) @@ -981,7 +981,7 @@ describe('accept_patient_reports', () => { const registrationIds = getIds(registrations); return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs(registrations)) .then(() => utils.saveDoc(noSilence)) .then(() => sentinelUtils.waitForSentinel(noSilence._id)) diff --git a/tests/integration/sentinel/transitions/conditional-alerts.spec.js b/tests/integration/sentinel/transitions/conditional-alerts.spec.js index 3d2ac061336..d4c95895f53 100644 --- a/tests/integration/sentinel/transitions/conditional-alerts.spec.js +++ b/tests/integration/sentinel/transitions/conditional-alerts.spec.js @@ -70,7 +70,7 @@ describe('conditional_alerts', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -104,7 +104,7 @@ describe('conditional_alerts', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -142,7 +142,7 @@ describe('conditional_alerts', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -177,7 +177,7 @@ describe('conditional_alerts', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -238,7 +238,7 @@ describe('conditional_alerts', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(form1)) .then(() => sentinelUtils.waitForSentinel(form1._id)) .then(() => sentinelUtils.getInfoDoc(form1._id)) diff --git a/tests/integration/sentinel/transitions/create-user-for-contacts.spec.js b/tests/integration/sentinel/transitions/create-user-for-contacts.spec.js index e44fde3c782..d534d67137e 100644 --- a/tests/integration/sentinel/transitions/create-user-for-contacts.spec.js +++ b/tests/integration/sentinel/transitions/create-user-for-contacts.spec.js @@ -76,7 +76,7 @@ describe('create_user_for_contacts', () => { const transitionsDisabledPattern = /Transitions are disabled until the above configuration errors are fixed\./; const collectLogs = await utils.collectSentinelLogs(tokenLoginErrorPattern, transitionsDisabledPattern); - await utils.updateSettings(getSettings({ token_login: { enabled: false } }), 'sentinel'); + await utils.updateSettings(getSettings({ token_login: { enabled: false } }), { ignoreReload: 'sentinel' }); // Wait a bit before collecting logs. Cannot wait on directly on Sentinel because no docs are being processed await sentinelUtils.getCurrentSeq(); const logs = await collectLogs(); @@ -90,7 +90,7 @@ describe('create_user_for_contacts', () => { const transitionsDisabledPattern = /Transitions are disabled until the above configuration errors are fixed\./; const collectLogs = await utils.collectSentinelLogs(appUrlErrorPattern, transitionsDisabledPattern); - await utils.updateSettings(getSettings({ app_url: '' }), 'sentinel'); + await utils.updateSettings(getSettings({ app_url: '' }), { ignoreReload: 'sentinel' }); // Wait a bit before collecting logs. Cannot wait on directly on Sentinel because no docs are being processed await sentinelUtils.getCurrentSeq(); const logs = await collectLogs(); @@ -99,7 +99,7 @@ describe('create_user_for_contacts', () => { }); it('does nothing when no users should be created for the contact', async () => { - await utils.updateSettings(getSettings(), 'sentinel'); + await utils.updateSettings(getSettings(), { ignoreReload: 'sentinel' }); await utils.createUsers([ORIGINAL_USER]); newUsers.push(ORIGINAL_USER.username); await utils.saveDoc(NEW_PERSON); @@ -120,7 +120,7 @@ describe('create_user_for_contacts', () => { }); it('replaces user but does not create a new user for the same contact in the same transition', async () => { - await utils.updateSettings(getSettings(), 'sentinel'); + await utils.updateSettings(getSettings(), { ignoreReload: 'sentinel' }); await utils.createUsers([ORIGINAL_USER]); newUsers.push(ORIGINAL_USER.username); // Can log in as user @@ -213,7 +213,7 @@ describe('create_user_for_contacts', () => { }; it('replaces user for contact', async () => { - await utils.updateSettings(getSettings(), 'sentinel'); + await utils.updateSettings(getSettings(), { ignoreReload: 'sentinel' }); await utils.createUsers([ORIGINAL_USER]); newUsers.push(ORIGINAL_USER.username); // Can log in as user @@ -266,7 +266,7 @@ describe('create_user_for_contacts', () => { }); it('replaces user for a contact when the contact is associated with multiple users', async () => { - await utils.updateSettings(getSettings(), 'sentinel'); + await utils.updateSettings(getSettings(), { ignoreReload: 'sentinel' }); await utils.createUsers([ORIGINAL_USER]); newUsers.push(ORIGINAL_USER.username); const otherUser = { ...ORIGINAL_USER, username: 'other_user', contact: ORIGINAL_PERSON._id }; @@ -327,7 +327,7 @@ describe('create_user_for_contacts', () => { }); it('replaces multiple users for a contact', async () => { - await utils.updateSettings(getSettings(), 'sentinel'); + await utils.updateSettings(getSettings(), { ignoreReload: 'sentinel' }); await utils.createUsers([ORIGINAL_USER]); newUsers.push(ORIGINAL_USER.username); const otherUser = { ...ORIGINAL_USER, username: 'other_user', contact: ORIGINAL_PERSON._id }; @@ -398,7 +398,10 @@ describe('create_user_for_contacts', () => { }); it('does not replace user when transition is disabled', async () => { - await utils.updateSettings(getSettings({ transitions: { create_user_for_contacts: false } }), 'sentinel'); + await utils.updateSettings( + getSettings({ transitions: { create_user_for_contacts: false } }), + { ignoreReload: 'sentinel' } + ); await utils.createUsers([ORIGINAL_USER]); newUsers.push(ORIGINAL_USER.username); await utils.saveDoc(NEW_PERSON); @@ -423,7 +426,7 @@ describe('create_user_for_contacts', () => { it('does not replace user when the new contact does not exist', async () => { const missingPersonPattern = /Failed to find person/; const collectLogs = await utils.collectSentinelLogs(missingPersonPattern); - await utils.updateSettings(getSettings(), 'sentinel'); + await utils.updateSettings(getSettings(), { ignoreReload: 'sentinel' }); await utils.createUsers([ORIGINAL_USER]); newUsers.push(ORIGINAL_USER.username); const originalContact = await utils.getDoc(ORIGINAL_PERSON._id); @@ -447,7 +450,7 @@ describe('create_user_for_contacts', () => { it('does not replace user when the original user does not exist', async () => { const missingUserPattern = /Failed to find user with name \[original_person] in the \[(users|medic)] database\./; const collectLogs = await utils.collectSentinelLogs(missingUserPattern); - await utils.updateSettings(getSettings(), 'sentinel'); + await utils.updateSettings(getSettings(), { ignoreReload: 'sentinel' }); await utils.saveDocs([ORIGINAL_PERSON, NEW_PERSON]); const originalContact = await utils.getDoc(ORIGINAL_PERSON._id); originalContact.user_for_contact = { @@ -472,7 +475,7 @@ describe('create_user_for_contacts', () => { const newPerson = { ...NEW_PERSON, phone: undefined }; const collectLogs = await utils.collectSentinelLogs(missingPhonePattern); - await utils.updateSettings(getSettings(), 'sentinel'); + await utils.updateSettings(getSettings(), { ignoreReload: 'sentinel' }); await utils.createUsers([ORIGINAL_USER]); newUsers.push(ORIGINAL_USER.username); await utils.saveDoc(newPerson); @@ -499,7 +502,7 @@ describe('create_user_for_contacts', () => { const newPerson = { ...NEW_PERSON, phone: 12345 }; const collectLogs = await utils.collectSentinelLogs(invalidPhonePattern); - await utils.updateSettings(getSettings(), 'sentinel'); + await utils.updateSettings(getSettings(), { ignoreReload: 'sentinel' }); await utils.createUsers([ORIGINAL_USER]); newUsers.push(ORIGINAL_USER.username); await utils.saveDoc(newPerson); @@ -526,7 +529,7 @@ describe('create_user_for_contacts', () => { const newPerson = { ...NEW_PERSON, name: undefined }; const collectLogs = await utils.collectSentinelLogs(missingNamePattern); - await utils.updateSettings(getSettings(), 'sentinel'); + await utils.updateSettings(getSettings(), { ignoreReload: 'sentinel' }); await utils.createUsers([ORIGINAL_USER]); newUsers.push(ORIGINAL_USER.username); await utils.saveDoc(newPerson); @@ -552,7 +555,7 @@ describe('create_user_for_contacts', () => { const missingIdPattern = /No id was provided for the new replacement contact\./; const collectLogs = await utils.collectSentinelLogs(missingIdPattern); - await utils.updateSettings(getSettings(), 'sentinel'); + await utils.updateSettings(getSettings(), { ignoreReload: 'sentinel' }); await utils.createUsers([ORIGINAL_USER]); newUsers.push(ORIGINAL_USER.username); await utils.saveDoc(NEW_PERSON); @@ -574,7 +577,7 @@ describe('create_user_for_contacts', () => { }); it('does not replace user when the replace status is not READY', async () => { - await utils.updateSettings(getSettings(), 'sentinel'); + await utils.updateSettings(getSettings(), { ignoreReload: 'sentinel' }); await utils.createUsers([ORIGINAL_USER]); newUsers.push(ORIGINAL_USER.username); await utils.saveDoc(NEW_PERSON); @@ -602,7 +605,7 @@ describe('create_user_for_contacts', () => { }); it('does not replace user when the contact being replaced is not a person', async () => { - await utils.updateSettings(getSettings(), 'sentinel'); + await utils.updateSettings(getSettings(), { ignoreReload: 'sentinel' }); await utils.createUsers([ORIGINAL_USER]); newUsers.push(ORIGINAL_USER.username); await utils.saveDoc(NEW_PERSON); @@ -637,7 +640,7 @@ describe('create_user_for_contacts', () => { }; it('creates user for new contact with multiple roles', async () => { - await utils.updateSettings(getSettings(), 'sentinel'); + await utils.updateSettings(getSettings(), { ignoreReload: 'sentinel' }); const originalContact = { roles: ['chw', 'other-role'], @@ -679,7 +682,7 @@ describe('create_user_for_contacts', () => { }); it('creates user for new contact with single role', async () => { - await utils.updateSettings(getSettings(), 'sentinel'); + await utils.updateSettings(getSettings(), { ignoreReload: 'sentinel' }); const originalContact = { role: 'chw', @@ -721,7 +724,10 @@ describe('create_user_for_contacts', () => { }); it('does not create user when transition is disabled', async () => { - await utils.updateSettings(getSettings({ transitions: { create_user_for_contacts: false } }), 'sentinel'); + await utils.updateSettings( + getSettings({ transitions: { create_user_for_contacts: false } }), + { ignoreReload: 'sentinel' } + ); const originalContact = { roles: ['chw', 'other-role'], @@ -741,7 +747,7 @@ describe('create_user_for_contacts', () => { const missingRolePattern = /must have a "role" or "roles" property/; const collectLogs = await utils.collectSentinelLogs(missingRolePattern); - await utils.updateSettings(getSettings(), 'sentinel'); + await utils.updateSettings(getSettings(), { ignoreReload: 'sentinel' }); const originalContact = { ...NEW_PERSON, @@ -760,7 +766,7 @@ describe('create_user_for_contacts', () => { const missingPhonePattern = /Missing required fields: phone/; const collectLogs = await utils.collectSentinelLogs(missingPhonePattern); - await utils.updateSettings(getSettings(), 'sentinel'); + await utils.updateSettings(getSettings(), { ignoreReload: 'sentinel' }); const originalContact = { ...NEW_PERSON, @@ -781,7 +787,7 @@ describe('create_user_for_contacts', () => { const invalidPhonePattern = /A valid phone number is required for SMS login/; const collectLogs = await utils.collectSentinelLogs(invalidPhonePattern); - await utils.updateSettings(getSettings(), 'sentinel'); + await utils.updateSettings(getSettings(), { ignoreReload: 'sentinel' }); const originalContact = { ...NEW_PERSON, @@ -802,7 +808,7 @@ describe('create_user_for_contacts', () => { const missingNamePattern = /Contact \[new_person] must have a name\./; const collectLogs = await utils.collectSentinelLogs(missingNamePattern); - await utils.updateSettings(getSettings(), 'sentinel'); + await utils.updateSettings(getSettings(), { ignoreReload: 'sentinel' }); const originalContact = { ...NEW_PERSON, @@ -820,7 +826,7 @@ describe('create_user_for_contacts', () => { }); it(`does not create user when the create is not 'true'`, async () => { - await utils.updateSettings(getSettings(), 'sentinel'); + await utils.updateSettings(getSettings(), { ignoreReload: 'sentinel' }); const originalContact = { ...NEW_PERSON, roles: ['chw', 'other-role'], @@ -841,7 +847,7 @@ describe('create_user_for_contacts', () => { }); it('does not create user when the contact being added is not a person', async () => { - await utils.updateSettings(getSettings(), 'sentinel'); + await utils.updateSettings(getSettings(), { ignoreReload: 'sentinel' }); await utils.createUsers([ORIGINAL_USER]); newUsers.push(ORIGINAL_USER.username); await utils.saveDoc(NEW_PERSON); @@ -865,7 +871,7 @@ describe('create_user_for_contacts', () => { }); it('does not create user when editing contact', async () => { - await utils.updateSettings(getSettings(), 'sentinel'); + await utils.updateSettings(getSettings(), { ignoreReload: 'sentinel' }); await utils.saveDoc(NEW_PERSON); await sentinelUtils.waitForSentinel(NEW_PERSON._id); diff --git a/tests/integration/sentinel/transitions/death-reporting.spec.js b/tests/integration/sentinel/transitions/death-reporting.spec.js index 0ba30d99206..bd4489d4f7c 100644 --- a/tests/integration/sentinel/transitions/death-reporting.spec.js +++ b/tests/integration/sentinel/transitions/death-reporting.spec.js @@ -47,7 +47,7 @@ describe('death_reporting', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -83,7 +83,7 @@ describe('death_reporting', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -119,7 +119,7 @@ describe('death_reporting', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -156,7 +156,7 @@ describe('death_reporting', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -192,7 +192,7 @@ describe('death_reporting', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -256,7 +256,7 @@ describe('death_reporting', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) diff --git a/tests/integration/sentinel/transitions/default-responses.spec.js b/tests/integration/sentinel/transitions/default-responses.spec.js index 2005894e4ee..87ced251a95 100644 --- a/tests/integration/sentinel/transitions/default-responses.spec.js +++ b/tests/integration/sentinel/transitions/default-responses.spec.js @@ -23,7 +23,7 @@ describe('default_responses', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -51,7 +51,7 @@ describe('default_responses', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -86,7 +86,7 @@ describe('default_responses', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -121,7 +121,7 @@ describe('default_responses', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) diff --git a/tests/integration/sentinel/transitions/generate-patient-id-on-people.spec.js b/tests/integration/sentinel/transitions/generate-patient-id-on-people.spec.js index a2d49bc8bc8..8b7f946aee7 100644 --- a/tests/integration/sentinel/transitions/generate-patient-id-on-people.spec.js +++ b/tests/integration/sentinel/transitions/generate-patient-id-on-people.spec.js @@ -20,7 +20,7 @@ describe('generate_patient_id_on_people', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -46,7 +46,7 @@ describe('generate_patient_id_on_people', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -73,7 +73,7 @@ describe('generate_patient_id_on_people', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -98,7 +98,7 @@ describe('generate_patient_id_on_people', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -123,7 +123,7 @@ describe('generate_patient_id_on_people', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) diff --git a/tests/integration/sentinel/transitions/generate-shortcode-on-contacts.spec.js b/tests/integration/sentinel/transitions/generate-shortcode-on-contacts.spec.js index c2aad3a0f8c..31a6e478685 100644 --- a/tests/integration/sentinel/transitions/generate-shortcode-on-contacts.spec.js +++ b/tests/integration/sentinel/transitions/generate-shortcode-on-contacts.spec.js @@ -19,7 +19,7 @@ describe('generate_shortcode_on_contacts', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -53,7 +53,7 @@ describe('generate_shortcode_on_contacts', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs([contact, report])) .then(() => sentinelUtils.waitForSentinel([contact._id, report._id])) .then(() => sentinelUtils.getInfoDocs([contact._id, report._id])) @@ -83,7 +83,7 @@ describe('generate_shortcode_on_contacts', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -110,7 +110,7 @@ describe('generate_shortcode_on_contacts', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -136,7 +136,7 @@ describe('generate_shortcode_on_contacts', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -161,7 +161,7 @@ describe('generate_shortcode_on_contacts', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -186,7 +186,7 @@ describe('generate_shortcode_on_contacts', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) diff --git a/tests/integration/sentinel/transitions/mark-for-outbound.spec.js b/tests/integration/sentinel/transitions/mark-for-outbound.spec.js index 74c52a13af5..ea89b53108f 100644 --- a/tests/integration/sentinel/transitions/mark-for-outbound.spec.js +++ b/tests/integration/sentinel/transitions/mark-for-outbound.spec.js @@ -106,7 +106,7 @@ describe('mark_for_outbound', () => { }; return utils - .updateSettings(config, 'sentinel') + .updateSettings(config, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(report)) .then(() => sentinelUtils.waitForSentinel([report._id])) .then(getTasks) @@ -157,7 +157,7 @@ describe('mark_for_outbound', () => { }; return utils - .updateSettings(config, 'sentinel') + .updateSettings(config, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(report)) .then(() => sentinelUtils.waitForSentinel([report._id])) .then(getTasks) @@ -210,7 +210,7 @@ describe('mark_for_outbound', () => { }; return utils - .updateSettings(config, 'sentinel') + .updateSettings(config, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(report)) .then(() => sentinelUtils.waitForSentinel([report._id])) .then(getTasks) @@ -261,7 +261,7 @@ describe('mark_for_outbound', () => { // First round return utils - .updateSettings(config, 'sentinel') + .updateSettings(config, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(report)) .then(() => sentinelUtils.waitForSentinel([report._id])) .then(getTasks) @@ -326,7 +326,7 @@ describe('mark_for_outbound', () => { // First round return utils - .updateSettings(config, 'sentinel') + .updateSettings(config, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(report)) .then(() => sentinelUtils.waitForSentinel([report._id])) .then(getTasks) @@ -396,7 +396,7 @@ describe('mark_for_outbound', () => { }; return utils - .updateSettings(config, 'sentinel') + .updateSettings(config, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(report)) .then(() => sentinelUtils.waitForSentinel([report._id])) .then(getTasks) @@ -431,7 +431,7 @@ describe('mark_for_outbound', () => { }; return utils - .updateSettings(config, 'sentinel') + .updateSettings(config, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(report)) .then(() => sentinelUtils.waitForSentinel([report._id])) .then(getTasks) @@ -454,7 +454,7 @@ describe('mark_for_outbound', () => { }; return utils - .updateSettings(config, 'sentinel') + .updateSettings(config, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(report)) .then(() => sentinelUtils.waitForSentinel([report._id])) .then(getTasks) @@ -477,7 +477,7 @@ describe('mark_for_outbound', () => { }; return utils - .updateSettings(config, 'sentinel') + .updateSettings(config, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(report)) .then(() => sentinelUtils.waitForSentinel([report._id])) .then(getTasks) @@ -508,7 +508,7 @@ describe('mark_for_outbound', () => { }; return utils - .updateSettings(config, 'sentinel') + .updateSettings(config, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(report)) .then(() => sentinelUtils.waitForSentinel([report._id])) .then(getTasks) @@ -559,7 +559,7 @@ describe('mark_for_outbound', () => { let collect; return utils - .updateSettings(config, 'sentinel') + .updateSettings(config, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(report)) .then(() => utils.collectSentinelLogs(/Mapping error.+_idddddddddddddddd/)) .then((result) => collect = result) @@ -593,7 +593,7 @@ describe('mark_for_outbound', () => { let collect; return utils - .updateSettings(config, 'sentinel') + .updateSettings(config, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(report)) .then(() => utils.collectSentinelLogs(/Failed to push/, /Response body.+error response/)) .then((result) => collect = result) @@ -628,7 +628,7 @@ describe('mark_for_outbound', () => { let collect; return utils - .updateSettings(config, 'sentinel') + .updateSettings(config, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(report)) .then(() => utils.collectSentinelLogs(/Failed to push.+ECONNREFUSED/)) .then((result) => collect = result) diff --git a/tests/integration/sentinel/transitions/multi-report-alerts.spec.js b/tests/integration/sentinel/transitions/multi-report-alerts.spec.js index 9cc59354127..2e49eeb8e8d 100644 --- a/tests/integration/sentinel/transitions/multi-report-alerts.spec.js +++ b/tests/integration/sentinel/transitions/multi-report-alerts.spec.js @@ -39,7 +39,7 @@ describe('multi_report_alerts', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -72,7 +72,7 @@ describe('multi_report_alerts', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -106,7 +106,7 @@ describe('multi_report_alerts', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -168,7 +168,7 @@ describe('multi_report_alerts', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs(contacts)) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) @@ -237,7 +237,7 @@ describe('multi_report_alerts', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -302,7 +302,7 @@ describe('multi_report_alerts', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -397,7 +397,7 @@ describe('multi_report_alerts', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs(contacts)) .then(() => utils.saveDoc(doc_unknown)) .then(() => sentinelUtils.waitForSentinel(doc_unknown._id)) @@ -521,7 +521,7 @@ describe('multi_report_alerts', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs(contacts)) .then(() => utils.saveDoc(doc_unknown)) .then(() => sentinelUtils.waitForSentinel(doc_unknown._id)) diff --git a/tests/integration/sentinel/transitions/muting.spec.js b/tests/integration/sentinel/transitions/muting.spec.js index c929a0e7480..2c16ae1b6fd 100644 --- a/tests/integration/sentinel/transitions/muting.spec.js +++ b/tests/integration/sentinel/transitions/muting.spec.js @@ -130,7 +130,7 @@ describe('muting', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -164,7 +164,7 @@ describe('muting', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -236,7 +236,7 @@ describe('muting', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs([doc1, doc2])) .then(() => sentinelUtils.waitForSentinel([doc1._id, doc2._id])) .then(() => sentinelUtils.getInfoDocs([doc1._id, doc2._id])) @@ -372,7 +372,7 @@ describe('muting', () => { let unmuteTime; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs(extraContacts)) .then(() => utils.saveDoc(mute1)) .then(() => sentinelUtils.waitForSentinel(mute1._id)) @@ -515,7 +515,7 @@ describe('muting', () => { let muteTime; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs(extraContacts)) .then(() => utils.saveDoc(mute)) .then(() => sentinelUtils.waitForSentinel(mute._id)) @@ -633,7 +633,7 @@ describe('muting', () => { let clinicMuteTime; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs(extraContacts)) .then(() => utils.saveDoc(mutePerson)) .then(() => sentinelUtils.waitForSentinel(mutePerson._id)) @@ -751,7 +751,7 @@ describe('muting', () => { let muteHCTime; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(mute)) .then(() => sentinelUtils.waitForSentinel(mute._id)) .then(() => sentinelUtils.getInfoDocs([mute._id, 'person', 'clinic', 'health_center'])) @@ -896,7 +896,7 @@ describe('muting', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(mute)) .then(() => sentinelUtils.waitForSentinel(mute._id)) .then(() => utils.saveDocs([person, personWithContactType])) @@ -1164,7 +1164,7 @@ describe('muting', () => { const getReportById = (id) => reports.find(report => report._id === id); return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs(extraContacts)) .then(() => utils.saveDocs(reports)) .then(() => utils.saveDoc(mute)) @@ -1266,7 +1266,7 @@ describe('muting', () => { const reportIds = reports.map(r => r._id); return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs(reports)) .then(() => utils.saveDoc(contact)) .then(() => sentinelUtils.waitForSentinel(contact._id)) @@ -1354,7 +1354,7 @@ describe('muting', () => { const reportIds = reports.map(r => r._id); return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs(reports)) .then(() => utils.saveDoc(contact)) .then(() => sentinelUtils.waitForSentinel(contact._id)) @@ -1512,7 +1512,7 @@ describe('muting', () => { const docs = _.shuffle([clinic, person, newPerson, ...reports]); return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs(docs)) .then(() => sentinelUtils.waitForSentinel(reportIds)) .then(() => Promise.all([ @@ -1731,7 +1731,7 @@ describe('muting', () => { const docs = _.shuffle([clinic, person, newPerson, ...reports]); return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs(docs)) .then(() => sentinelUtils.waitForSentinel(reportIds)) .then(() => Promise.all([ @@ -1903,7 +1903,7 @@ describe('muting', () => { const docs = _.shuffle([clinic, person, ...reports]); return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs(docs)) .then(() => sentinelUtils.waitForSentinel(reportIds)) .then(() => utils.getDocs([clinic._id, person._id])) diff --git a/tests/integration/sentinel/transitions/registration.spec.js b/tests/integration/sentinel/transitions/registration.spec.js index c25e52c3385..772e32c08e0 100644 --- a/tests/integration/sentinel/transitions/registration.spec.js +++ b/tests/integration/sentinel/transitions/registration.spec.js @@ -121,7 +121,7 @@ describe('registration', () => { const docIds = getIds(docs); let newPatientId; return utils - .updateSettings(testForm.forms.NP, 'sentinel') + .updateSettings(testForm.forms.NP, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs(docs)) .then(() => sentinelUtils.waitForSentinel(docIds)) .then(() => sentinelUtils.getInfoDocs(docIds)) @@ -183,7 +183,7 @@ describe('registration', () => { const docIds = getIds(docs); return utils - .updateSettings(testForm.forms.NP, 'sentinel') + .updateSettings(testForm.forms.NP, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs(docs)) .then(() => sentinelUtils.waitForSentinel(docIds)) .then(() => sentinelUtils.getInfoDocs(docIds)) @@ -227,7 +227,7 @@ describe('registration', () => { const docIds = getIds(docs); return utils - .updateSettings(testForm.forms.NP, 'sentinel') + .updateSettings(testForm.forms.NP, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs(docs)) .then(() => sentinelUtils.waitForSentinel(docIds)) .then(() => sentinelUtils.getInfoDocs(docIds)) @@ -268,7 +268,7 @@ describe('registration', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -307,7 +307,7 @@ describe('registration', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -405,7 +405,7 @@ describe('registration', () => { const docIds = getIds(docs); return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs(docs)) .then(() => sentinelUtils.waitForSentinel(docIds)) .then(() => sentinelUtils.getInfoDocs(docIds)) @@ -563,7 +563,7 @@ describe('registration', () => { const allIds = getIds(allDocs); return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs(allDocs)) .then(() => sentinelUtils.waitForSentinel(allIds)) .then(() => sentinelUtils.getInfoDocs(allIds)) @@ -702,7 +702,7 @@ describe('registration', () => { let newPatientId; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs(docs)) .then(() => sentinelUtils.waitForSentinel(docIds)) .then(() => sentinelUtils.getInfoDocs(docIds)) @@ -923,7 +923,7 @@ describe('registration', () => { const docIds = getIds(docs); return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs(docs)) .then(() => sentinelUtils.waitForSentinel(docIds)) .then(() => sentinelUtils.getInfoDocs(docIds)) @@ -1103,7 +1103,7 @@ describe('registration', () => { let updatedDocs; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs(docs)) .then(() => sentinelUtils.waitForSentinel(ids)) .then(() => sentinelUtils.getInfoDocs(ids)) @@ -1240,7 +1240,7 @@ describe('registration', () => { const docIds = getIds(docs); return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs(docs)) .then(() => sentinelUtils.waitForSentinel(docIds)) .then(() => sentinelUtils.getInfoDocs(docIds)) @@ -1339,7 +1339,7 @@ describe('registration', () => { const docIds = getIds(docs); return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs(docs)) .then(() => sentinelUtils.waitForSentinel(docIds)) .then(() => sentinelUtils.getInfoDocs(docIds)) @@ -1387,7 +1387,7 @@ describe('registration', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(createPlace)) // Sentinel won't process these, so we can't wait for a metadata update, but let's give it 5 seconds just in case .then(() => utils.delayPromise(5000)) @@ -1592,7 +1592,7 @@ describe('registration', () => { const ids = reports.map(r => r._id); return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs(reports)) .then(() => sentinelUtils.waitForSentinel(ids)) .then(() => sentinelUtils.getInfoDocs(ids)) @@ -1841,7 +1841,7 @@ describe('registration', () => { let updatedDocs; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs(docs)) .then(() => sentinelUtils.waitForSentinel(ids)) .then(() => sentinelUtils.getInfoDocs(ids)) @@ -2008,7 +2008,7 @@ describe('registration', () => { let updatedDocs; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs(docs)) .then(() => sentinelUtils.waitForSentinel(ids)) .then(() => sentinelUtils.getInfoDocs(ids)) @@ -2213,7 +2213,7 @@ describe('registration', () => { }); return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs([withPatient1, withClinic1])) .then(() => sentinelUtils.waitForSentinel([withPatient1._id, withClinic1._id])) .then(() => sentinelUtils.getInfoDocs([withPatient1._id, withClinic1._id])) @@ -2390,7 +2390,7 @@ describe('registration', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) diff --git a/tests/integration/sentinel/transitions/resolve-pending.spec.js b/tests/integration/sentinel/transitions/resolve-pending.spec.js index 12bb1b92728..cf4fc640ab1 100644 --- a/tests/integration/sentinel/transitions/resolve-pending.spec.js +++ b/tests/integration/sentinel/transitions/resolve-pending.spec.js @@ -19,7 +19,7 @@ describe('resolve_pending', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -37,7 +37,7 @@ describe('resolve_pending', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -99,7 +99,7 @@ describe('resolve_pending', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) diff --git a/tests/integration/sentinel/transitions/self-report.spec.js b/tests/integration/sentinel/transitions/self-report.spec.js index c2a5268199b..ebf0e1c2d00 100644 --- a/tests/integration/sentinel/transitions/self-report.spec.js +++ b/tests/integration/sentinel/transitions/self-report.spec.js @@ -42,7 +42,7 @@ describe('self_report', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -66,7 +66,7 @@ describe('self_report', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -92,7 +92,7 @@ describe('self_report', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -116,7 +116,7 @@ describe('self_report', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -165,7 +165,7 @@ describe('self_report', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -204,7 +204,7 @@ describe('self_report', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -232,7 +232,7 @@ describe('self_report', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -272,7 +272,7 @@ describe('self_report', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -325,7 +325,7 @@ describe('self_report', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -388,7 +388,7 @@ describe('self_report', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) diff --git a/tests/integration/sentinel/transitions/sentinel-transition-error-log.spec.js b/tests/integration/sentinel/transitions/sentinel-transition-error-log.spec.js index f926c8a129c..aa90c76abd2 100644 --- a/tests/integration/sentinel/transitions/sentinel-transition-error-log.spec.js +++ b/tests/integration/sentinel/transitions/sentinel-transition-error-log.spec.js @@ -13,7 +13,7 @@ describe('Sentinel transition error log', function() { }; const waitForLogs = await utils.waitForSentinelLogs(true, unknownTransitionPattern); - await utils.updateSettings(settings, 'sentinel'); + await utils.updateSettings(settings, { ignoreReload: 'sentinel' }); await waitForLogs.promise; }); }); diff --git a/tests/integration/sentinel/transitions/update-clinics.spec.js b/tests/integration/sentinel/transitions/update-clinics.spec.js index b6330cf9e6c..00139b74987 100644 --- a/tests/integration/sentinel/transitions/update-clinics.spec.js +++ b/tests/integration/sentinel/transitions/update-clinics.spec.js @@ -25,7 +25,7 @@ describe('update_clinics', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(contact)) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) @@ -64,7 +64,7 @@ describe('update_clinics', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(contact)) .then(() => utils.saveDoc(doc1)) .then(() => sentinelUtils.waitForSentinel(doc1._id)) @@ -111,7 +111,7 @@ describe('update_clinics', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs([doc1, doc2])) .then(() => sentinelUtils.waitForSentinel([doc1._id, doc2._id])) .then(() => sentinelUtils.getInfoDocs([doc1._id, doc2._id])) @@ -168,7 +168,7 @@ describe('update_clinics', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs([doc1, doc2, doc3])) .then(() => sentinelUtils.waitForSentinel([doc1._id, doc2._id, doc3._id])) .then(() => sentinelUtils.getInfoDocs([doc1._id, doc2._id, doc3._id])) @@ -263,7 +263,7 @@ describe('update_clinics', () => { const docIds = docs.map(doc => doc._id); return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs(contacts)) .then(() => utils.saveDocs(docs)) .then(() => sentinelUtils.waitForSentinel(docIds)) diff --git a/tests/integration/sentinel/transitions/update-notifications.spec.js b/tests/integration/sentinel/transitions/update-notifications.spec.js index 0394ec93dee..5ebecba030e 100644 --- a/tests/integration/sentinel/transitions/update-notifications.spec.js +++ b/tests/integration/sentinel/transitions/update-notifications.spec.js @@ -66,7 +66,7 @@ describe('update_notifications', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -97,7 +97,7 @@ describe('update_notifications', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -161,7 +161,7 @@ describe('update_notifications', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs([doc1, doc2])) .then(() => sentinelUtils.waitForSentinel([doc1._id, doc2._id])) .then(() => sentinelUtils.getInfoDocs([doc1._id, doc2._id])) @@ -268,7 +268,7 @@ describe('update_notifications', () => { let unmuteTime; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(mute1)) .then(() => sentinelUtils.waitForSentinel(mute1._id)) .then(() => sentinelUtils.getInfoDocs([mute1._id, 'person', 'clinic'])) diff --git a/tests/integration/sentinel/transitions/update-scheduled-reports.spec.js b/tests/integration/sentinel/transitions/update-scheduled-reports.spec.js index 3460da44ebe..ff06b9ac2b4 100644 --- a/tests/integration/sentinel/transitions/update-scheduled-reports.spec.js +++ b/tests/integration/sentinel/transitions/update-scheduled-reports.spec.js @@ -99,7 +99,7 @@ describe('update_scheduled_reports', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -135,7 +135,7 @@ describe('update_scheduled_reports', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs([doc1, doc2])) .then(() => sentinelUtils.waitForSentinel([ doc1._id, doc2._id ])) .then(() => sentinelUtils.getInfoDocs([ doc1._id, doc2._id ])) @@ -199,7 +199,7 @@ describe('update_scheduled_reports', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs([doc1, doc2, doc3, doc4])) .then(() => sentinelUtils.waitForSentinel([ doc1._id, doc2._id, doc3._id, doc4._id ])) .then(() => sentinelUtils.getInfoDocs([ doc1._id, doc2._id, doc3._id, doc4._id ])) @@ -277,7 +277,7 @@ describe('update_scheduled_reports', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs([doc1, doc2, doc3, doc4, doc5])) .then(() => sentinelUtils.waitForSentinel([ doc1._id, doc2._id, doc3._id, doc4._id, doc5._id ])) .then(() => utils.getDocs([ doc1._id, doc2._id, doc3._id, doc4._id, doc5._id ])) diff --git a/tests/integration/sentinel/transitions/update-sent-by.spec.js b/tests/integration/sentinel/transitions/update-sent-by.spec.js index 22c6102e73d..acfc8b376ab 100644 --- a/tests/integration/sentinel/transitions/update-sent-by.spec.js +++ b/tests/integration/sentinel/transitions/update-sent-by.spec.js @@ -20,7 +20,7 @@ describe('update_sent_by', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(doc)) .then(() => sentinelUtils.waitForSentinel(doc._id)) .then(() => sentinelUtils.getInfoDoc(doc._id)) @@ -70,7 +70,7 @@ describe('update_sent_by', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDoc(contact)) .then(() => utils.saveDocs([report1, report2, report3, report4])) .then(() => sentinelUtils.waitForSentinel([report1._id, report2._id, report3._id, report4._id])) @@ -113,7 +113,7 @@ describe('update_sent_by', () => { ]; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs(contacts)) .then(() => utils.saveDoc(report)) .then(() => sentinelUtils.waitForSentinel(report._id)) diff --git a/tests/integration/transitions/message-duplicates.spec.js b/tests/integration/transitions/message-duplicates.spec.js index ce409c2dbf7..c17f7b926bd 100644 --- a/tests/integration/transitions/message-duplicates.spec.js +++ b/tests/integration/transitions/message-duplicates.spec.js @@ -83,7 +83,7 @@ describe('message duplicates', () => { ]; return utils - .updateSettings(settings, true) + .updateSettings(settings, { ignoreReload: true }) .then(() => postMessages(firstMessages)) .then(ids => utils.getDocs(ids)) .then(docs => { @@ -153,7 +153,7 @@ describe('message duplicates', () => { ]; return utils - .updateSettings(settings, true) + .updateSettings(settings, { ignoreReload: true }) .then(() => postMessages(firstMessages)) .then(ids => utils.getDocs(ids)) .then(docs => { diff --git a/tests/integration/transitions/public-form-transitions.spec.js b/tests/integration/transitions/public-form-transitions.spec.js index 007b40de669..8cbcf83ae5d 100644 --- a/tests/integration/transitions/public-form-transitions.spec.js +++ b/tests/integration/transitions/public-form-transitions.spec.js @@ -251,7 +251,7 @@ const expectTransitions = (infodoc, ...transitions) => { const processSMS = (settings) => { let ids; const watchChanges = apiUtils.getApiSmsChanges(messages); - return utils.updateSettings(settings, true) + return utils.updateSettings(settings, { ignoreReload: true }) .then(() => Promise.all([ watchChanges, utils.request(getPostOpts('/api/sms', { messages: messages })) diff --git a/tests/integration/transitions/sentinel-api-transitions.spec.js b/tests/integration/transitions/sentinel-api-transitions.spec.js index 3c2d6d5a4a0..c36089b44ec 100644 --- a/tests/integration/transitions/sentinel-api-transitions.spec.js +++ b/tests/integration/transitions/sentinel-api-transitions.spec.js @@ -361,7 +361,7 @@ describe('transitions', () => { let ids; return utils - .updateSettings(settings, true) + .updateSettings(settings, { ignoreReload: true }) .then(() => Promise.all([ apiUtils.getApiSmsChanges(messages), utils.request(getPostOpts('/api/sms', { messages })), @@ -692,7 +692,7 @@ describe('transitions', () => { let ids; return utils - .updateSettings(settings, true) + .updateSettings(settings, { ignoreReload: true }) .then(() => Promise.all([ apiUtils.getApiSmsChanges(messages), utils.request(getPostOpts('/api/sms', { messages: messages })), @@ -808,7 +808,7 @@ describe('transitions', () => { let ids; return utils - .updateSettings(settings, true) + .updateSettings(settings, { ignoreReload: true }) .then(() => Promise.all([ apiUtils.getApiSmsChanges(messages), utils.request(getPostOpts('/api/sms', { messages: messages })), @@ -906,7 +906,7 @@ describe('transitions', () => { let docId; return utils - .updateSettings(settings, true) + .updateSettings(settings, { ignoreReload: true }) .then(() => Promise.all([ apiUtils.getApiSmsChanges(messages), utils.request(getPostOpts('/api/sms', { messages: messages })), @@ -977,7 +977,7 @@ describe('transitions', () => { let docId; return utils - .updateSettings(settings, true) + .updateSettings(settings, { ignoreReload: true }) .then(() => Promise.all([ apiUtils.getApiSmsChanges(messages), utils.request(getPostOpts('/api/sms', { messages: messages })), @@ -1041,7 +1041,7 @@ describe('transitions', () => { }; return utils - .updateSettings(settings, 'sentinel') + .updateSettings(settings, { ignoreReload: 'sentinel' }) .then(() => utils.saveDocs([place, person])) .then(() => sentinelUtils.waitForSentinel([ place._id, person._id ])) .then(() => sentinelUtils.getInfoDocs([ place._id, person._id ])) @@ -1103,7 +1103,7 @@ describe('transitions', () => { const recordsBody = (person) => ({ _meta: { form: 'DR', from: 'phone1' }, patient_id: person.patient_id }); return utils - .updateSettings(settings, true) + .updateSettings(settings, { ignoreReload: true }) .then(() => utils.saveDocs([person1, person2])) .then(() => sentinelUtils.waitForSentinel()) .then(() => utils.request({ path: '/api/v2/records', method: 'POST', body: recordsBody(person1) })) diff --git a/tests/integration/transitions/sms-workflows.spec.js b/tests/integration/transitions/sms-workflows.spec.js index 51364516d89..0ce17fb3382 100644 --- a/tests/integration/transitions/sms-workflows.spec.js +++ b/tests/integration/transitions/sms-workflows.spec.js @@ -102,7 +102,7 @@ const expectTasks = (doc, expectations) => { const processReportsAndSettings = async (reports, settings) => { const ids = reports.map(report => report._id); - await utils.updateSettings(settings, 'sentinel'); + await utils.updateSettings(settings, { ignoreReload: 'sentinel' }); await utils.saveDocs(reports); await sentinelUtils.waitForSentinel(ids); return utils.getDocs(ids); diff --git a/tests/utils/index.js b/tests/utils/index.js index 38c103eddae..51e9e3a7954 100644 --- a/tests/utils/index.js +++ b/tests/utils/index.js @@ -521,20 +521,56 @@ const waitForSettingsUpdateLogs = (type) => { * * @param {Object} updates Object containing all updates you wish to * make - * @param {Boolean|String} ignoreReload if false, will wait for reload modal and reload. if truthy, will tail + * @param {Object} options | ignore reload: if false, will wait for reload modal and reload. if truthy, will tail * service logs and resolve when new settings are loaded. By default, watches * api logs, if value equals 'sentinel', will watch sentinel logs instead. * @return {Promise} completion promise */ -const updateSettings = async (updates, ignoreReload) => { - const watcher = ignoreReload && - Object.keys(updates).length && - await waitForSettingsUpdateLogs(ignoreReload); +/** + * Update settings and refresh if required. + * + * This function updates application settings based on the provided updates object and options. + * It handles optional settings for ignoring reloads, synchronizing, refreshing the page, + * and reverting settings to their previous state. + * + * @param {Object} updates - Object containing all updates you wish to make. + * The keys should correspond to the settings that need to be updated, + * and the values should be the new values for those settings. + * @param {Object} [options={}] - Options to control the behavior of the update. + * @param {boolean} [options.ignoreReload=false] - if `false`, will wait for reload modal and reload. if `truthy`, + * will tail service logs and resolve when new settings are loaded. + * By default, watches api logs, if value equals 'sentinel', will + * watch sentinel logs instead. + * @param {boolean} [options.sync=false] - If `true`, the function will perform a synchronization + * after updating the settings. Defaults to `false`. + * @param {boolean} [options.refresh=false] - If `true`, the function will refresh the browser after + * updating the settings. Defaults to `false`. + * @param {boolean} [options.revert=false] - If `true`, the function will revert the settings to their + * previous state before applying the new updates. Defaults to `false`. + * + * @return {Promise} - A promise that resolves when the settings update process is complete. + * The promise may resolve after waiting for logs, reloading, synchronizing, or refreshing, + * depending on the options provided. + */ +const updateSettings = async (updates, options = {}) => { + const {ignoreReload = false, sync = false, refresh = false, revert = false} = options; + if (revert) { + await revertSettings(true); + } + const watcher = ignoreReload && Object.keys(updates).length && await waitForSettingsUpdateLogs(ignoreReload); await updateCustomSettings(updates); if (!ignoreReload) { return await commonElements.closeReloadModal(true); } - return watcher && await watcher.promise; + if (watcher) { + await watcher.promise; + } + if (sync) { + await commonElements.sync(true); + } + if (refresh) { + await browser.refresh(); + } }; const revertCustomSettings = () => { @@ -1046,7 +1082,7 @@ const enableLanguages = async (languageCodes) => { }); } } - await updateSettings({ languages }, true); + await updateSettings({ languages }, { ignoreReload: true }); }; const getSettings = () => getDoc('settings').then(settings => settings.settings); @@ -1465,7 +1501,7 @@ const getUpdatedPermissions = async (roles, addPermissions, removePermissions) = const updatePermissions = async (roles, addPermissions, removePermissions, ignoreReload) => { const permissions = await getUpdatedPermissions(roles, addPermissions, removePermissions); - await updateSettings({ permissions }, ignoreReload); + await updateSettings({permissions}, { ignoreReload: ignoreReload }); }; const getSentinelDate = () => getContainerDate('sentinel');