From 0d580ad2b8dfb493290dfc194361aba8d7a102a6 Mon Sep 17 00:00:00 2001 From: mk-simsoft Date: Fri, 10 Mar 2023 09:22:40 +0300 Subject: [PATCH] AB#777: Change sub tasks field component and control conditions --- client/src/components/previews/TaskPreview.js | 2 +- client/src/pages/tasks/Show.js | 7 ++-- .../customFieldsSpecs/showTask.spec.js | 40 +++++++++++++++++++ client/tests/webdriver/pages/showTask.page.js | 24 +++++++++++ 4 files changed, 68 insertions(+), 5 deletions(-) diff --git a/client/src/components/previews/TaskPreview.js b/client/src/components/previews/TaskPreview.js index 469286deba..ddcec8220b 100644 --- a/client/src/components/previews/TaskPreview.js +++ b/client/src/components/previews/TaskPreview.js @@ -176,7 +176,7 @@ const TaskPreview = ({ className, uuid }) => { /> )} - {task.childrenTasks.length > 0 && ( + {Settings.fields.task.childrenTasks && task.childrenTasks?.length > 0 && ( { const ShortNameField = DictionaryField(Field) const LongNameField = DictionaryField(Field) const TaskParentTask = DictionaryField(Field) - const TaskChildrenTasks = DictionaryField(Field) const PlannedCompletionField = DictionaryField(Field) const ProjectedCompletionField = DictionaryField(Field) @@ -320,9 +319,9 @@ const TaskShow = ({ pageDispatchers }) => { } /> )} - {Settings.fields.task.childrenTasks && task.childrenTasks.length > 0 && ( - 0 && ( + { expect(await question1AssessmentWeekly.isExisting()).to.be.true }) }) + + describe("When on the show page of a task", () => { + it("We should see a parent task if there is any related to the current task", async() => { + const parentTask = await (await ShowTask.getParentTask()) + const parentTaskField = await (await ShowTask.getParentTaskField()) + if (await parentTask.isExisting()) { + await (await ShowTask.getParentTaskField()).waitForDisplayed() + // eslint-disable-next-line no-unused-expressions + expect(await parentTaskField.isExisting()).to.be.true + } + }) + + it("We should not see a parent task if there is not any related to the current task", async() => { + const parentTask = await (await ShowTask.getParentTask()) + const parentTaskField = await (await ShowTask.getParentTaskField()) + if (await parentTask.isExisting() === false) { + // eslint-disable-next-line no-unused-expressions + expect(await parentTaskField.isExisting()).to.be.false + } + }) + + it("We should see list of children tasks if there are any related to the current task", async() => { + const childrenTasks = await (await ShowTask.getChildrenTasks()) + const childrenTasksField = await (await ShowTask.getChildrenTasksField()) + if (await childrenTasks.isExisting()) { + await (await ShowTask.getChildrenTasksField()).waitForDisplayed() + // eslint-disable-next-line no-unused-expressions + expect(await childrenTasksField.isExisting()).to.be.true + } + }) + + it("We should not see list of children tasks if there are not any related to the current task", async() => { + const childrenTasks = await (await ShowTask.getChildrenTasks()) + const childrenTasksField = await (await ShowTask.getChildrenTasksField()) + if (await childrenTasks.isExisting() === false) { + // eslint-disable-next-line no-unused-expressions + expect(await childrenTasksField.isExisting()).to.be.false + } + }) + }) }) diff --git a/client/tests/webdriver/pages/showTask.page.js b/client/tests/webdriver/pages/showTask.page.js index 7642f43b44..fee15a9262 100644 --- a/client/tests/webdriver/pages/showTask.page.js +++ b/client/tests/webdriver/pages/showTask.page.js @@ -1,6 +1,30 @@ import Page from "./page" class ShowTask extends Page { + async getShortName() { + return browser.$('div[id="shortName"') + } + + async getLongName() { + return browser.$('div[id="longName"') + } + + async getParentTask() { + return browser.$('div[id="parentTask"') + } + + async getParentTaskField() { + return browser.$("#fg-parentTask") + } + + async getChildrenTasks() { + return browser.$('div[id="subEfforts"') + } + + async getChildrenTasksField() { + return browser.$("#fg-subEfforts") + } + async getAssessmentResultsMonthly() { return browser.$("#entity-assessments-results-monthly") }