Skip to content

Commit

Permalink
AB#777: Change sub tasks field component and control conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
mk-simsoft committed Mar 20, 2023
1 parent 2a14f13 commit 0d580ad
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 5 deletions.
2 changes: 1 addition & 1 deletion client/src/components/previews/TaskPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ const TaskPreview = ({ className, uuid }) => {
/>
)}

{task.childrenTasks.length > 0 && (
{Settings.fields.task.childrenTasks && task.childrenTasks?.length > 0 && (
<PreviewField
label={Settings.fields.task.childrenTasks}
name="subEfforts"
Expand Down
7 changes: 3 additions & 4 deletions client/src/pages/tasks/Show.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ const TaskShow = ({ pageDispatchers }) => {
const ShortNameField = DictionaryField(Field)
const LongNameField = DictionaryField(Field)
const TaskParentTask = DictionaryField(Field)
const TaskChildrenTasks = DictionaryField(Field)
const PlannedCompletionField = DictionaryField(Field)
const ProjectedCompletionField = DictionaryField(Field)

Expand Down Expand Up @@ -320,9 +319,9 @@ const TaskShow = ({ pageDispatchers }) => {
}
/>
)}
{Settings.fields.task.childrenTasks && task.childrenTasks.length > 0 && (
<TaskChildrenTasks
dictProps={Settings.fields.task.childrenTasks}
{Settings.fields.task.childrenTasks && task.childrenTasks?.length > 0 && (
<Field
label={Settings.fields.task.childrenTasks}
name="subEfforts"
component={FieldHelper.ReadonlyField}
humanValue={
Expand Down
40 changes: 40 additions & 0 deletions client/tests/webdriver/customFieldsSpecs/showTask.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,44 @@ describe("Show task page", () => {
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
}
})
})
})
24 changes: 24 additions & 0 deletions client/tests/webdriver/pages/showTask.page.js
Original file line number Diff line number Diff line change
@@ -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")
}
Expand Down

0 comments on commit 0d580ad

Please sign in to comment.