diff --git a/tests/e2e/default/contacts/fab-actionbar.wdio-spec.js b/tests/e2e/default/contacts/fab-actionbar.wdio-spec.js new file mode 100644 index 00000000000..c44ceb984fb --- /dev/null +++ b/tests/e2e/default/contacts/fab-actionbar.wdio-spec.js @@ -0,0 +1,86 @@ +const placeFactory = require('@factories/cht/contacts/place'); +const userFactory = require('@factories/cht/users/users'); +const personFactory = require('@factories/cht/contacts/person'); +const utils = require('@utils'); +const loginPage = require('@page-objects/default/login/login.wdio.page'); +const commonElements = require('@page-objects/default/common/common.wdio.page'); +const { genericForm } = require('@page-objects/default/contacts/contacts.wdio.page'); + +const places = placeFactory.generateHierarchy(); +const healthCenter = places.get('health_center'); +const onlineUser = userFactory.build({ place: healthCenter._id, roles: [ 'program_officer' ] }); +const patient = personFactory.build({ parent: { _id: healthCenter._id, parent: healthCenter.parent } }); +describe('FAB + Actionbar', () => { + before(async () => { + await utils.saveDocs([ ...places.values(), patient ]); + await utils.createUsers([ onlineUser ]); + await loginPage.login(onlineUser); + }); + + afterEach(async () => { + await utils.revertSettings(false); + }); + + describe('FAB', () => { + it('should show new household and new person create option', async () => { + await commonElements.goToPeople(healthCenter._id); + const fabLabels = await commonElements.getFastActionItemsLabels(); + + expect(fabLabels).to.have.members(['New household', 'New person']); + }); + + it('should show fab when user only has can_create_places permission', async () => { + await utils.updatePermissions(onlineUser.roles, [], ['can_create_people']); + await commonElements.goToPeople(healthCenter._id); + + await commonElements.clickFastActionFAB({ waitForList: false }); + const formTitle = await genericForm.getFormTitle(); + expect(formTitle).to.equal('New household'); + }); + + it('should show fab when user only has can_create_people permission', async () => { + await utils.updatePermissions(onlineUser.roles, [], ['can_create_places']); + await commonElements.goToPeople(healthCenter._id); + + await commonElements.clickFastActionFAB({ waitForList: false }); + const formTitle = await genericForm.getFormTitle(); + expect(formTitle).to.equal('New person'); + }); + }); + + describe('Action bar', () => { + it('should show new household and new person create option', async () => { + await utils.updatePermissions(onlineUser.roles, ['can_view_old_action_bar']); + await commonElements.goToPeople(healthCenter._id); + const actionBarLabels = await commonElements.getActionBarLabels(); + + expect(actionBarLabels).to.have.members([ + 'New household', + 'New person', + 'New action', + ]); + }); + + it('should not show new person when missing permission', async () => { + await utils.updatePermissions(onlineUser.roles, ['can_view_old_action_bar'], ['can_create_people']); + await commonElements.goToPeople(healthCenter._id); + const actionBarLabels = await commonElements.getActionBarLabels(); + + expect(actionBarLabels).to.have.members([ + 'New household', + 'New action', + ]); + }); + + it('should not show new place when missing permission', async () => { + await utils.updatePermissions(onlineUser.roles, ['can_view_old_action_bar'], ['can_create_places']); + await commonElements.goToPeople(healthCenter._id); + const actionBarLabels = await commonElements.getActionBarLabels(); + + expect(actionBarLabels).to.have.members([ + 'New person', + 'New action', + ]); + }); + }); +}); diff --git a/tests/e2e/default/sms/messages-breadcrumbs.wdio-spec.js b/tests/e2e/default/sms/messages-sender-data.wdio-spec.js similarity index 79% rename from tests/e2e/default/sms/messages-breadcrumbs.wdio-spec.js rename to tests/e2e/default/sms/messages-sender-data.wdio-spec.js index 988d9561960..7182669c193 100644 --- a/tests/e2e/default/sms/messages-breadcrumbs.wdio-spec.js +++ b/tests/e2e/default/sms/messages-sender-data.wdio-spec.js @@ -5,8 +5,9 @@ const userFactory = require('@factories/cht/users/users'); const placeFactory = require('@factories/cht/contacts/place'); const personFactory = require('@factories/cht/contacts/person'); const messagesPage = require('@page-objects/default/sms/messages.wdio.page'); +const contactsPage = require('@page-objects/default/contacts/contacts.wdio.page'); -describe('Message tab breadcrumbs', () => { +describe('Message Tab - Sender Data', () => { const places = placeFactory.generateHierarchy(); const clinic = places.get('clinic'); const health_center = places.get('health_center'); @@ -84,4 +85,19 @@ describe('Message tab breadcrumbs', () => { expect(lineage).to.equal(expectedLineage); }); + it('should display conversation with link and navigate to contact', async () => { + await loginPage.login(offlineUser); + await commonElements.waitForPageLoaded(); + await commonElements.goToMessages(); + + await messagesPage.openMessage(patient._id); + const header = await messagesPage.getMessageHeader(); + expect(header.name).to.equal(patient.name); + expect(header.phone).to.equal(patient.phone); + + await messagesPage.navigateFromConversationToContact(); + const title = await contactsPage.getContactInfoName(); + expect(title).to.equal(patient.name); + }); + }); diff --git a/tests/e2e/default/tasks/forms/home-visit.properties.json b/tests/e2e/default/tasks/forms/home-visit.properties.json index 7d629e5a219..be17f733fd1 100644 --- a/tests/e2e/default/tasks/forms/home-visit.properties.json +++ b/tests/e2e/default/tasks/forms/home-visit.properties.json @@ -1,6 +1,6 @@ { "context": { - "expression": "!contact || contact.type === 'person'", + "expression": "false", "person": true, "place": false }, diff --git a/tests/e2e/default/tasks/tasks-breadcrumbs.wdio-spec.js b/tests/e2e/default/tasks/tasks-breadcrumbs.wdio-spec.js index 138c9074685..6343411d1cb 100644 --- a/tests/e2e/default/tasks/tasks-breadcrumbs.wdio-spec.js +++ b/tests/e2e/default/tasks/tasks-breadcrumbs.wdio-spec.js @@ -110,6 +110,13 @@ describe('Tasks tab breadcrumbs', () => { }, ]); }); + + it('should open task with expression', async () => { + await tasksPage.goToTasksTab(); + const task = await tasksPage.getTaskByContactAndForm('patient1', 'person_create'); + await task.click(); + await tasksPage.waitForTaskContentLoaded('Home Visit'); + }); }); describe('for supervisor', () => { diff --git a/tests/e2e/default/tasks/tasks.wdio-spec.js b/tests/e2e/default/tasks/tasks.wdio-spec.js index 7e3d10e93bf..36f319cc828 100644 --- a/tests/e2e/default/tasks/tasks.wdio-spec.js +++ b/tests/e2e/default/tasks/tasks.wdio-spec.js @@ -20,7 +20,7 @@ const compileTasks = async (tasksFileName) => { return await chtConfUtils.compileNoolsConfig({ tasks: tasksFilePath }); }; -describe('Task list', () => { +describe('Tasks', () => { const places = placeFactory.generateHierarchy(); const clinic = places.get('clinic'); const healthCenter = places.get('health_center'); diff --git a/tests/page-objects/default/common/common.wdio.page.js b/tests/page-objects/default/common/common.wdio.page.js index 86646477066..d48f0aa6fda 100644 --- a/tests/page-objects/default/common/common.wdio.page.js +++ b/tests/page-objects/default/common/common.wdio.page.js @@ -12,6 +12,7 @@ const FAST_ACTION_LIST_CONTAINER = '.fast-action-content-wrapper'; const fastActionListContainer = () => $(FAST_ACTION_LIST_CONTAINER); const fastActionListCloseButton = () => $(`${FAST_ACTION_LIST_CONTAINER} .panel-header .panel-header-close`); const fastActionById = (id) => $(`${FAST_ACTION_LIST_CONTAINER} .fast-action-item[test-id="${id}"]`); +const fastActionItems = () => $$(`${FAST_ACTION_LIST_CONTAINER} .fast-action-item`); const moreOptionsMenu = () => $('.more-options-menu-container>.mat-mdc-menu-trigger'); const hamburgerMenuItemSelector = '#header-dropdown li'; const logoutButton = () => $(`${hamburgerMenuItemSelector} .fa-power-off`); @@ -28,6 +29,9 @@ const syncSuccess = () => $(`${hamburgerMenuItemSelector}.sync-status .success`) const syncRequired = () => $(`${hamburgerMenuItemSelector}.sync-status .required`); const jsonError = async () => (await $('pre')).getText(); +const actionBar = () => $('.detail-actions.right-pane'); +const actionBarActions = () => $$('.detail-actions.right-pane span'); + //languages const activeSnackbar = () => $('#snackbar.active'); const inactiveSnackbar = () => $('#snackbar:not(.active)'); @@ -82,6 +86,20 @@ const clickFastActionFAB = async ({ actionId, waitForList }) => { } }; +const getFastActionItemsLabels = async () => { + await closeHamburgerMenu(); + await (await fastActionFAB()).waitForDisplayed(); + await (await fastActionFAB()).waitForClickable(); + await (await fastActionFAB()).click(); + + await browser.pause(500); + await (await fastActionListContainer()).waitForDisplayed(); + + const items = await fastActionItems(); + const fastActionItemLabels = await Promise.all(items.map(item => item.getText())); + return fastActionItemLabels; +}; + const clickFastActionFlat = async ({ actionId, waitForList }) => { await (await fastActionFlat()).waitForDisplayed(); await (await fastActionFlat()).waitForClickable(); @@ -406,6 +424,14 @@ const loadNextInfiniteScrollPage = async () => { await waitForLoaderToDisappear(await $('.left-pane')); }; +const getActionBarLabels = async () => { + await (await actionBar()).waitForDisplayed(); + await (await actionBarActions())[0].waitForDisplayed(); + const items = await actionBarActions(); + const labels = await Promise.all(items.map(item => item.getText())); + return labels.filter(label => !!label); +}; + module.exports = { openMoreOptionsMenu, closeFastActionList, @@ -466,4 +492,6 @@ module.exports = { getAllButtonLabelsNames, loadNextInfiniteScrollPage, goToUrl, + getFastActionItemsLabels, + getActionBarLabels, }; diff --git a/tests/page-objects/default/sms/messages.wdio.page.js b/tests/page-objects/default/sms/messages.wdio.page.js index 83457876598..bf0f0fbda1b 100644 --- a/tests/page-objects/default/sms/messages.wdio.page.js +++ b/tests/page-objects/default/sms/messages.wdio.page.js @@ -45,6 +45,12 @@ const getMessageHeader = async () => { }; }; +const navigateFromConversationToContact = async () => { + await $(`${MESSAGE_HEADER} a.name`).waitForClickable(); + await $(`${MESSAGE_HEADER} a.name`).click(); + await commonPage.waitForPageLoaded(); +}; + const getMessageContent = async (index = 1) => { const sms = await $(`${MESSAGE_CONTENT} li:nth-child(${index})`); await sms.waitForDisplayed(); @@ -140,5 +146,6 @@ module.exports = { sendReply, replyAddRecipients, getAmountOfMessagesByPhone, + navigateFromConversationToContact, getMessagesModalDetails, }; diff --git a/webapp/src/ts/components/actionbar/actionbar.component.html b/webapp/src/ts/components/actionbar/actionbar.component.html index 9a5659ee81f..dc7c5723b3e 100644 --- a/webapp/src/ts/components/actionbar/actionbar.component.html +++ b/webapp/src/ts/components/actionbar/actionbar.component.html @@ -38,10 +38,10 @@
-
+
@@ -51,7 +51,7 @@