From 0d93af1bb02287e555e4ff706e671538f244e306 Mon Sep 17 00:00:00 2001 From: Joy <56365512+ardourApeX@users.noreply.github.com> Date: Wed, 18 Oct 2023 23:55:55 +0530 Subject: [PATCH] Extension request should show reviewer's log if the request has been either approved or denied (#503) * Feat : Added reviewed by log in extension status modal * Test : Added test cases to verify review log --- .../task/multiple-extension-form.hbs | 116 ++++++++++-------- tests/fixtures/extension-requests.js | 1 + .../tasks/multiple-extension-form-test.js | 67 ++++++++++ 3 files changed, 136 insertions(+), 48 deletions(-) diff --git a/app/components/task/multiple-extension-form.hbs b/app/components/task/multiple-extension-form.hbs index c13d76ec..ac0ba8ed 100644 --- a/app/components/task/multiple-extension-form.hbs +++ b/app/components/task/multiple-extension-form.hbs @@ -1,6 +1,7 @@
-
- +
+
- + - +
@@ -69,28 +73,44 @@
{{#each this.extensionData.value as |extension|}} + {{#if extension.reviewedBy}} +

Your request was + {{#if + (eq extension.status 'APPROVED') + }}approved{{else}}denied{{/if}} + by + {{extension.reviewedBy}} + {{convertDate (array extension.timestamp) end_date=0}}. +

+ {{/if}} {{/each}}
+
- - - {{#if (or (eq this.previousExtensionStatus 'APPROVED') (eq this.previousExtensionStatus 'DENIED'))}} - {{/if}} + + {{#if + (or + (eq this.previousExtensionStatus 'APPROVED') + (eq this.previousExtensionStatus 'DENIED') + ) + }} + + {{/if}}
{{else if this.extensionData.isLoading}}
@@ -99,25 +119,25 @@ {{else if this.extensionData.error}}

{{this.extensionData.error}}

- - + +
{{/if}}
{{/if}}
-
+ \ No newline at end of file diff --git a/tests/fixtures/extension-requests.js b/tests/fixtures/extension-requests.js index 57daf0c3..241dfe34 100644 --- a/tests/fixtures/extension-requests.js +++ b/tests/fixtures/extension-requests.js @@ -9,6 +9,7 @@ const extensionRequests = [ id: 'T0S56aa3zaNsNghEPLeS', timestamp: 1673784012, assignee: 'ivinayakg', + reviewedBy: 'Joy Gupta', }, { oldEndsOn: 57658796, diff --git a/tests/integration/components/tasks/multiple-extension-form-test.js b/tests/integration/components/tasks/multiple-extension-form-test.js index 64e6e08d..9e101ae2 100644 --- a/tests/integration/components/tasks/multiple-extension-form-test.js +++ b/tests/integration/components/tasks/multiple-extension-form-test.js @@ -283,6 +283,73 @@ module('Integration | Component | Multiple Extension Form', function (hooks) { } }); + test('Review log should present if extension status is either approved or denied and reviewedBy field is present', async function (assert) { + const extensionRequestData = extensionRequests[0]; + this.set('task', tasksData[0]); + this.set('value', [extensionRequestData]); + this.set('previousExtensionStatus', extensionRequestData.status); + this.set( + 'closeExtensionModel', + closeExtensionModel(this.set, 'extensionFormOpened') + ); + this.set( + 'closeExtensionForm', + closeExtensionForm(this.set, 'extensionFormOpened') + ); + + await render( + hbs` + }` + ); + await waitFor('[data-test-extension-info-content]'); + + // Assert the initial state + if (['APPROVED', 'DENIED'].includes(this.previousExtensionStatus)) { + assert + .dom(this.element.querySelector('[data-reviewed-log]')) + .containsText(extensionRequestData['reviewedBy']) + .exists(); + } else { + assert + .dom(this.element.querySelector('[data-reviewed-log]')) + .doesNotExist(); + } + }); + + test('Review log should not be present as extensionRequestData does not contains reviewedBy field', async function (assert) { + const extensionRequestData = extensionRequests[2]; + this.set('task', tasksData[2]); + this.set('value', [extensionRequestData]); + this.set('previousExtensionStatus', extensionRequestData.status); + this.set( + 'closeExtensionModel', + closeExtensionModel(this.set, 'extensionFormOpened') + ); + this.set( + 'closeExtensionForm', + closeExtensionForm(this.set, 'extensionFormOpened') + ); + + await render( + hbs` + }` + ); + await waitFor('[data-test-extension-info-content]'); + + // Assert the initial state + assert + .dom(this.element.querySelector('[data-reviewed-log]')) + .doesNotExist(); + }); + test('When previous extension request is pending, the option to create extension request should show and then later open form', async function (assert) { // Set up test data and conditions, such as setting this.previousExtensionStatus let extensionRequestData = extensionRequests[1];