Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow assessments to be in the future #4503

Merged
merged 7 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions anet-dictionary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ fields:
subTaskMonthly:
label: Monthly assessment of effort
recurrence: monthly
allowFutureAssessments: true
questions:
requiredButFilteredOutQuestion:
test: $.subject[?(@property === "noSuchProperty" && @.match(/^willNeverMatch/i))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,7 @@ const InstantAssessmentResultsTable = ({
return null
}
const { recurrence, numberOfPeriods } = periodsDetails
const periodsConfig = getPeriodsConfig(
recurrence,
numberOfPeriods,
offset,
true
)
const periodsConfig = getPeriodsConfig(recurrence, numberOfPeriods, offset)
gjvoosten marked this conversation as resolved.
Show resolved Hide resolved
if (_isEmpty(periodsConfig?.periods)) {
return null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,19 @@ const PeriodicAssessmentResultsTable = ({
if (!entity) {
return null
}
const entityPeriodicAssessmentConfig =
entity.getInstantAssessmentConfig(assessmentKey)
const { recurrence, numberOfPeriods } = periodsDetails
const periodsConfig = getPeriodsConfig(
recurrence,
numberOfPeriods,
offset,
true
true,
entityPeriodicAssessmentConfig?.allowFutureAssessments
)
if (_isEmpty(periodsConfig?.periods)) {
return null
}
const entityPeriodicAssessmentConfig =
entity.getInstantAssessmentConfig(assessmentKey)
const subEntitiesPeriodicAssessmentConfig = subEntities
?.map(s => s.getInstantAssessmentConfig(assessmentKey))
.filter(mc => !_isEmpty(mc))
Expand Down
12 changes: 8 additions & 4 deletions client/src/periodUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,20 @@ export const getPeriodsConfig = (
recurrence,
numberOfPeriods,
offset,
forAssessments = false
forPeriodicAssessments = false,
allowFutureAssessments = false
) => {
const now = moment()
const periods = []
for (let i = numberOfPeriods - 1; i >= 0; i--) {
const periodDetails = PERIOD_FACTORIES[recurrence](now, offset + i)
if (forAssessments) {
// only allow assessments for past periods
periodDetails.allowNewAssessments = offset + i > 0

if (forPeriodicAssessments) {
// allow new assessments
periodDetails.allowNewAssessments =
allowFutureAssessments || offset + i > 0
}

periods.push(periodDetails)
}
return {
Expand Down
31 changes: 31 additions & 0 deletions client/tests/webdriver/baseSpecs/assessmentsForTasks.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,37 @@ describe("For the periodic task assessments", () => {
"monthly",
ADVISOR_1_TASK_EDIT_DETAILS
)
})

it("Should see an add button for subTaskMonthly assessments in the future", async() => {
await (
await ShowTask.getNextPeriodButton("subTaskMonthly", "monthly")
).waitForExist()

await (
await ShowTask.getNextPeriodButton("subTaskMonthly", "monthly")
).click()

await (
await ShowTask.getFutureAddAssessmentButton("subTaskMonthly", "monthly")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are testing this against subTaskMonthly, yet you have not set allowFutureAssessments: true for that assessment definition.

).waitForExist()
})

it("Should not see an add button for subTaskWeekly assessments in the future", async() => {
await (
await ShowTask.getNextPeriodButton("subTaskWeekly", "weekly")
).waitForExist()

await (
await ShowTask.getNextPeriodButton("subTaskWeekly", "weekly")
).click()

expect(
await (
await ShowTask.getFutureAddAssessmentButton("subTaskWeekly", "weekly")
).isExisting()
).to.equal(false)

await ShowTask.logout()
})
})
Expand Down
14 changes: 13 additions & 1 deletion client/tests/webdriver/pages/showTask.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ class ShowTask extends Page {
)
}

async getNextPeriodButton(assessmentKey, recurrence) {
return (await this.getAssessmentResults(assessmentKey, recurrence)).$(
"button:last-child"
)
}

async getFutureAddAssessmentButton(assessmentKey, recurrence) {
return (await this.getAssessmentsTable(assessmentKey, recurrence)).$(
"tbody tr:last-child td:last-child button"
)
}

async getEditAssessmentButton(assessmentKey, recurrence) {
return (await this.getAssessmentsTable(assessmentKey, recurrence)).$(
'div.card button[title="Edit assessment"]'
Expand All @@ -76,7 +88,7 @@ class ShowTask extends Page {

async getShownAssessmentPanel(assessmentKey, recurrence) {
return (await this.getAssessmentsTable(assessmentKey, recurrence)).$(
"tbody tr:last-child td:first-child .card"
"tbody tr:nth-child(2) td:first-child .card"
)
}

Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/anet-schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@ $defs:
type: string
enum: [once, daily, weekly, biweekly, semimonthly, monthly, quarterly, semiannually, annually, ondemand]
default: once
allowFutureAssessments:
type: boolean
default: false
title: Allow assessments to be in the future
description: Allow assessment dates to be in the future for planning purposes.
relatedObjectType:
title: object type context in which the assessment will be made
type: string
Expand Down
1 change: 1 addition & 0 deletions testDictionaries/no-custom-fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ fields:
subTaskMonthly:
label: Monthly assessment of effort
recurrence: monthly
allowFutureAssessments: true
questions:
requiredButFilteredOutQuestion:
test: $.subject[?(@property === "noSuchProperty" && @.match(/^willNeverMatch/i))]
Expand Down