From 27c104ed3b645640ec0b27b9f38e71b83f393189 Mon Sep 17 00:00:00 2001 From: Orcun Gurer Date: Fri, 29 Sep 2023 14:33:00 +0300 Subject: [PATCH 1/7] AB#888: Allow to assess future dates --- .../instant/InstantAssessmentResultsTable.js | 7 +------ .../periodic/PeriodicAssessmentResultsTable.js | 7 +------ client/src/periodUtils.js | 15 +++++---------- 3 files changed, 7 insertions(+), 22 deletions(-) diff --git a/client/src/components/assessments/instant/InstantAssessmentResultsTable.js b/client/src/components/assessments/instant/InstantAssessmentResultsTable.js index d27741bf8a..cf2683629a 100644 --- a/client/src/components/assessments/instant/InstantAssessmentResultsTable.js +++ b/client/src/components/assessments/instant/InstantAssessmentResultsTable.js @@ -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) if (_isEmpty(periodsConfig?.periods)) { return null } diff --git a/client/src/components/assessments/periodic/PeriodicAssessmentResultsTable.js b/client/src/components/assessments/periodic/PeriodicAssessmentResultsTable.js index 834df8e467..f851c245a4 100644 --- a/client/src/components/assessments/periodic/PeriodicAssessmentResultsTable.js +++ b/client/src/components/assessments/periodic/PeriodicAssessmentResultsTable.js @@ -85,12 +85,7 @@ const PeriodicAssessmentResultsTable = ({ return null } const { recurrence, numberOfPeriods } = periodsDetails - const periodsConfig = getPeriodsConfig( - recurrence, - numberOfPeriods, - offset, - true - ) + const periodsConfig = getPeriodsConfig(recurrence, numberOfPeriods, offset) if (_isEmpty(periodsConfig?.periods)) { return null } diff --git a/client/src/periodUtils.js b/client/src/periodUtils.js index 17aef2acf2..649a6c4fbb 100644 --- a/client/src/periodUtils.js +++ b/client/src/periodUtils.js @@ -153,20 +153,15 @@ export const PERIOD_FACTORIES = { }) } -export const getPeriodsConfig = ( - recurrence, - numberOfPeriods, - offset, - forAssessments = false -) => { +export const getPeriodsConfig = (recurrence, numberOfPeriods, offset) => { 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 - } + + // always allow assessments for all periods + periodDetails.allowNewAssessments = true + periods.push(periodDetails) } return { From 2853bc9ac755a09d1c756900dd5c871afa7629ba Mon Sep 17 00:00:00 2001 From: Orcun Gurer Date: Tue, 3 Oct 2023 16:16:43 +0300 Subject: [PATCH 2/7] AB#888: Improve code & update test --- .../instant/InstantAssessmentResultsTable.js | 7 ++++++- .../periodic/PeriodicAssessmentResultsTable.js | 7 ++++++- client/src/periodUtils.js | 13 ++++++++++--- client/tests/webdriver/pages/showTask.page.js | 2 +- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/client/src/components/assessments/instant/InstantAssessmentResultsTable.js b/client/src/components/assessments/instant/InstantAssessmentResultsTable.js index cf2683629a..d27741bf8a 100644 --- a/client/src/components/assessments/instant/InstantAssessmentResultsTable.js +++ b/client/src/components/assessments/instant/InstantAssessmentResultsTable.js @@ -107,7 +107,12 @@ const InstantAssessmentResultsTable = ({ return null } const { recurrence, numberOfPeriods } = periodsDetails - const periodsConfig = getPeriodsConfig(recurrence, numberOfPeriods, offset) + const periodsConfig = getPeriodsConfig( + recurrence, + numberOfPeriods, + offset, + true + ) if (_isEmpty(periodsConfig?.periods)) { return null } diff --git a/client/src/components/assessments/periodic/PeriodicAssessmentResultsTable.js b/client/src/components/assessments/periodic/PeriodicAssessmentResultsTable.js index f851c245a4..834df8e467 100644 --- a/client/src/components/assessments/periodic/PeriodicAssessmentResultsTable.js +++ b/client/src/components/assessments/periodic/PeriodicAssessmentResultsTable.js @@ -85,7 +85,12 @@ const PeriodicAssessmentResultsTable = ({ return null } const { recurrence, numberOfPeriods } = periodsDetails - const periodsConfig = getPeriodsConfig(recurrence, numberOfPeriods, offset) + const periodsConfig = getPeriodsConfig( + recurrence, + numberOfPeriods, + offset, + true + ) if (_isEmpty(periodsConfig?.periods)) { return null } diff --git a/client/src/periodUtils.js b/client/src/periodUtils.js index 649a6c4fbb..454a7972d9 100644 --- a/client/src/periodUtils.js +++ b/client/src/periodUtils.js @@ -153,14 +153,21 @@ export const PERIOD_FACTORIES = { }) } -export const getPeriodsConfig = (recurrence, numberOfPeriods, offset) => { +export const getPeriodsConfig = ( + recurrence, + numberOfPeriods, + offset, + forAssessments = false +) => { const now = moment() const periods = [] for (let i = numberOfPeriods - 1; i >= 0; i--) { const periodDetails = PERIOD_FACTORIES[recurrence](now, offset + i) - // always allow assessments for all periods - periodDetails.allowNewAssessments = true + if (forAssessments) { + // allow new assessments + periodDetails.allowNewAssessments = true + } periods.push(periodDetails) } diff --git a/client/tests/webdriver/pages/showTask.page.js b/client/tests/webdriver/pages/showTask.page.js index 4b86aa4283..26181dd1c0 100644 --- a/client/tests/webdriver/pages/showTask.page.js +++ b/client/tests/webdriver/pages/showTask.page.js @@ -76,7 +76,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" ) } From 4482547c8c46d68a2c1683e65256966330dd4b72 Mon Sep 17 00:00:00 2001 From: Orcun Gurer Date: Fri, 6 Oct 2023 09:50:16 +0300 Subject: [PATCH 3/7] AB#888: Add new test for future button --- .../baseSpecs/assessmentsForTasks.spec.js | 15 +++++++++++++++ client/tests/webdriver/pages/showTask.page.js | 12 ++++++++++++ 2 files changed, 27 insertions(+) diff --git a/client/tests/webdriver/baseSpecs/assessmentsForTasks.spec.js b/client/tests/webdriver/baseSpecs/assessmentsForTasks.spec.js index 1f4f50d086..298c7a2eea 100644 --- a/client/tests/webdriver/baseSpecs/assessmentsForTasks.spec.js +++ b/client/tests/webdriver/baseSpecs/assessmentsForTasks.spec.js @@ -87,6 +87,21 @@ describe("For the periodic task assessments", () => { "monthly", ADVISOR_1_TASK_EDIT_DETAILS ) + }) + + it("Should allow seeing add button for the 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") + ).waitForExist() + await ShowTask.logout() }) }) diff --git a/client/tests/webdriver/pages/showTask.page.js b/client/tests/webdriver/pages/showTask.page.js index 26181dd1c0..f829f866a9 100644 --- a/client/tests/webdriver/pages/showTask.page.js +++ b/client/tests/webdriver/pages/showTask.page.js @@ -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" + ) + } + async getEditAssessmentButton(assessmentKey, recurrence) { return (await this.getAssessmentsTable(assessmentKey, recurrence)).$( 'div.card button[title="Edit assessment"]' From f9293594ce36fc3f3061226ac5386c084a4dcb24 Mon Sep 17 00:00:00 2001 From: Orcun Gurer Date: Mon, 9 Oct 2023 11:05:01 +0300 Subject: [PATCH 4/7] AB#888: Add future assessments to dictionary and schema --- anet-dictionary.yml | 1 + src/main/resources/anet-schema.yml | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/anet-dictionary.yml b/anet-dictionary.yml index 03f0d466c7..f26b2803c2 100644 --- a/anet-dictionary.yml +++ b/anet-dictionary.yml @@ -61,6 +61,7 @@ fields: topTaskOnceReport: label: Engagement assessment of objective recurrence: once + allowFutureAssesments: true relatedObjectType: report authorizationGroupUuids: read: ['c21e7321-7ec5-4837-8805-a302f9575754'] diff --git a/src/main/resources/anet-schema.yml b/src/main/resources/anet-schema.yml index 92bb259bc3..6d80ad486b 100644 --- a/src/main/resources/anet-schema.yml +++ b/src/main/resources/anet-schema.yml @@ -238,6 +238,11 @@ $defs: type: string enum: [once, daily, weekly, biweekly, semimonthly, monthly, quarterly, semiannually, annually, ondemand] default: once + allowFutureAssesments: + type: boolean + default: false + title: allow assesments to be in the future + description: allow assesment dates to be in the future in order to be able to plan future. relatedObjectType: title: object type context in which the assessment will be made type: string From 3c19186cc620b0956ba49487517fb62c4e1c38e0 Mon Sep 17 00:00:00 2001 From: Gertjan van Oosten Date: Wed, 11 Oct 2023 09:59:11 +0200 Subject: [PATCH 5/7] AB#888 Fix allowFutureAssessments Move the new prop to the correct assessment definition (it only applies to periodic assessments, and the test checks subTaskMonthly). Correct typo in new dictionary property allowFutureAssessments. Change the title/description a bit Add the new prop also to the test dictionary. --- anet-dictionary.yml | 2 +- src/main/resources/anet-schema.yml | 6 +++--- testDictionaries/no-custom-fields.yml | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/anet-dictionary.yml b/anet-dictionary.yml index f26b2803c2..ddce2c9c7c 100644 --- a/anet-dictionary.yml +++ b/anet-dictionary.yml @@ -61,7 +61,6 @@ fields: topTaskOnceReport: label: Engagement assessment of objective recurrence: once - allowFutureAssesments: true relatedObjectType: report authorizationGroupUuids: read: ['c21e7321-7ec5-4837-8805-a302f9575754'] @@ -143,6 +142,7 @@ fields: subTaskMonthly: label: Monthly assessment of effort recurrence: monthly + allowFutureAssessments: true questions: requiredButFilteredOutQuestion: test: $.subject[?(@property === "noSuchProperty" && @.match(/^willNeverMatch/i))] diff --git a/src/main/resources/anet-schema.yml b/src/main/resources/anet-schema.yml index 6d80ad486b..6e72884d05 100644 --- a/src/main/resources/anet-schema.yml +++ b/src/main/resources/anet-schema.yml @@ -238,11 +238,11 @@ $defs: type: string enum: [once, daily, weekly, biweekly, semimonthly, monthly, quarterly, semiannually, annually, ondemand] default: once - allowFutureAssesments: + allowFutureAssessments: type: boolean default: false - title: allow assesments to be in the future - description: allow assesment dates to be in the future in order to be able to plan future. + 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 diff --git a/testDictionaries/no-custom-fields.yml b/testDictionaries/no-custom-fields.yml index 2e3dcbba42..a2e30159fb 100644 --- a/testDictionaries/no-custom-fields.yml +++ b/testDictionaries/no-custom-fields.yml @@ -141,6 +141,7 @@ fields: subTaskMonthly: label: Monthly assessment of effort recurrence: monthly + allowFutureAssessments: true questions: requiredButFilteredOutQuestion: test: $.subject[?(@property === "noSuchProperty" && @.match(/^willNeverMatch/i))] From 11e162d3a84160233aabba6f0b95c421ed883bc0 Mon Sep 17 00:00:00 2001 From: Gertjan van Oosten Date: Wed, 11 Oct 2023 10:44:26 +0200 Subject: [PATCH 6/7] AB#888 Properly check allowFutureAssessments It only applies to periodic assessments; reflect this in getPeriodsConfig. --- .../assessments/instant/InstantAssessmentResultsTable.js | 7 +------ .../periodic/PeriodicAssessmentResultsTable.js | 7 ++++--- client/src/periodUtils.js | 8 +++++--- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/client/src/components/assessments/instant/InstantAssessmentResultsTable.js b/client/src/components/assessments/instant/InstantAssessmentResultsTable.js index d27741bf8a..cf2683629a 100644 --- a/client/src/components/assessments/instant/InstantAssessmentResultsTable.js +++ b/client/src/components/assessments/instant/InstantAssessmentResultsTable.js @@ -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) if (_isEmpty(periodsConfig?.periods)) { return null } diff --git a/client/src/components/assessments/periodic/PeriodicAssessmentResultsTable.js b/client/src/components/assessments/periodic/PeriodicAssessmentResultsTable.js index 834df8e467..b1e52d23f1 100644 --- a/client/src/components/assessments/periodic/PeriodicAssessmentResultsTable.js +++ b/client/src/components/assessments/periodic/PeriodicAssessmentResultsTable.js @@ -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)) diff --git a/client/src/periodUtils.js b/client/src/periodUtils.js index 454a7972d9..bce249b201 100644 --- a/client/src/periodUtils.js +++ b/client/src/periodUtils.js @@ -157,16 +157,18 @@ 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) { + if (forPeriodicAssessments) { // allow new assessments - periodDetails.allowNewAssessments = true + periodDetails.allowNewAssessments = + allowFutureAssessments || offset + i > 0 } periods.push(periodDetails) From 73ceeae483d5eb50de73fac0905d310b29d8fdd1 Mon Sep 17 00:00:00 2001 From: Gertjan van Oosten Date: Wed, 11 Oct 2023 11:29:50 +0200 Subject: [PATCH 7/7] AB#888 Fix future assessment test And add a test to verify that you can't add future assessments if this has not been configured in the dictionary. --- .../baseSpecs/assessmentsForTasks.spec.js | 18 +++++++++++++++++- client/tests/webdriver/pages/showTask.page.js | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/client/tests/webdriver/baseSpecs/assessmentsForTasks.spec.js b/client/tests/webdriver/baseSpecs/assessmentsForTasks.spec.js index 298c7a2eea..0f669d43ad 100644 --- a/client/tests/webdriver/baseSpecs/assessmentsForTasks.spec.js +++ b/client/tests/webdriver/baseSpecs/assessmentsForTasks.spec.js @@ -89,7 +89,7 @@ describe("For the periodic task assessments", () => { ) }) - it("Should allow seeing add button for the assessments in the future", async() => { + it("Should see an add button for subTaskMonthly assessments in the future", async() => { await ( await ShowTask.getNextPeriodButton("subTaskMonthly", "monthly") ).waitForExist() @@ -101,6 +101,22 @@ describe("For the periodic task assessments", () => { await ( await ShowTask.getFutureAddAssessmentButton("subTaskMonthly", "monthly") ).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() }) diff --git a/client/tests/webdriver/pages/showTask.page.js b/client/tests/webdriver/pages/showTask.page.js index f829f866a9..265a19d491 100644 --- a/client/tests/webdriver/pages/showTask.page.js +++ b/client/tests/webdriver/pages/showTask.page.js @@ -60,7 +60,7 @@ class ShowTask extends Page { async getFutureAddAssessmentButton(assessmentKey, recurrence) { return (await this.getAssessmentsTable(assessmentKey, recurrence)).$( - "tbody tr:last-child td:last-child" + "tbody tr:last-child td:last-child button" ) }