Skip to content

Commit

Permalink
Extension request should show reviewer's log if the request has been …
Browse files Browse the repository at this point in the history
…either approved or denied (#503)

* Feat : Added reviewed by log in extension status modal

* Test : Added test cases to verify review log
  • Loading branch information
joyguptaa authored Oct 18, 2023
1 parent 9d2c982 commit 0d93af1
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 48 deletions.
116 changes: 68 additions & 48 deletions app/components/task/multiple-extension-form.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<div class='extension-form__container-parent'>
<div
role='button' id='create'
role='button'
id='create'
class='extension-form__container-back'
data-test-extension-form-container-back
{{on 'click' @closeModel}}
Expand Down Expand Up @@ -42,24 +43,27 @@
name='title'
data-test-extension-form-title-input
></textarea>
<div class="error-container" id='error'>
<span class='error-placeholder' data-test-extension-from-error></span>
<div class='error-container' id='error'>
<span
class='error-placeholder'
data-test-extension-from-error
></span>
</div>
<div class='buttons' id='form'>
<button
class='multiple-extension-form__container-close'
data-test-extension-form-container-close
type='button'
{{on 'click' @closeForm}}
>
Cancel
</button>
<button
class='multiple-extension-form__container-close'
data-test-extension-form-container-close
type='button'
{{on 'click' @closeForm}}
>
Cancel
</button>

<button
class='multiple-extension-form__create-button primary-button-style'
disabled={{this.isSubmitButtonDisabled}}
type='submit'
>Submit</button>
<button
class='multiple-extension-form__create-button primary-button-style'
disabled={{this.isSubmitButtonDisabled}}
type='submit'
>Submit</button>
</div>
</form>
</div>
Expand All @@ -69,28 +73,44 @@
<div class='extension-form__content-wrapper'>
{{#each this.extensionData.value as |extension|}}
<Task::LatestExtensionInfo @extension={{extension}} />
{{#if extension.reviewedBy}}
<p data-reviewed-log>Your request was
{{#if
(eq extension.status 'APPROVED')
}}approved{{else}}denied{{/if}}
by
{{extension.reviewedBy}}
{{convertDate (array extension.timestamp) end_date=0}}.
</p>
{{/if}}
{{/each}}
</div>

<div class='buttons' id='detail'>
<button
class='multiple-extension-form__container-close'
data-test-extension-form-container-close
type='button'
{{on 'click' @closeForm}}
>
Close
</button>

{{#if (or (eq this.previousExtensionStatus 'APPROVED') (eq this.previousExtensionStatus 'DENIED'))}}
<button
class='multiple-extension-form__open-button primary-button-style'
data-test-create-another-extension
class='multiple-extension-form__container-close'
data-test-extension-form-container-close
type='button'
{{on 'click' this.createNewExtensionRequest}}
{{on 'click' @closeForm}}
>
Request Extension
Close
</button>
{{/if}}

{{#if
(or
(eq this.previousExtensionStatus 'APPROVED')
(eq this.previousExtensionStatus 'DENIED')
)
}}
<button
class='multiple-extension-form__open-button primary-button-style'
data-test-create-another-extension
type='button'
{{on 'click' this.createNewExtensionRequest}}
>
Request Extension
</button>
{{/if}}
</div>
{{else if this.extensionData.isLoading}}
<div class='task-card__loader-container'>
Expand All @@ -99,25 +119,25 @@
{{else if this.extensionData.error}}
<h4>{{this.extensionData.error}}</h4>
<div class='buttons' id='create'>
<button
class='multiple-extension-form__container-close'
data-test-extension-form-container-close
type='button'
{{on 'click' @closeForm}}
>
Close
</button>
<button
class='multiple-extension-form__open-button primary-button-style'
data-test-create-extension-button
type='button'
{{on 'click' this.createNewExtensionRequest}}
>
Request Extension
</button>
<button
class='multiple-extension-form__container-close'
data-test-extension-form-container-close
type='button'
{{on 'click' @closeForm}}
>
Close
</button>
<button
class='multiple-extension-form__open-button primary-button-style'
data-test-create-extension-button
type='button'
{{on 'click' this.createNewExtensionRequest}}
>
Request Extension
</button>
</div>
{{/if}}
</div>
{{/if}}
</div>
</div>
</div>
1 change: 1 addition & 0 deletions tests/fixtures/extension-requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const extensionRequests = [
id: 'T0S56aa3zaNsNghEPLeS',
timestamp: 1673784012,
assignee: 'ivinayakg',
reviewedBy: 'Joy Gupta',
},
{
oldEndsOn: 57658796,
Expand Down
67 changes: 67 additions & 0 deletions tests/integration/components/tasks/multiple-extension-form-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`<Task::MultipleExtensionForm
@task={{this.task}}
@closeForm={{this.closeExtensionForm}}
@title='Form for extension Request'
@closeModel={{this.closeExtensionModel}}/>
}`
);
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`<Task::MultipleExtensionForm
@task={{this.task}}
@closeForm={{this.closeExtensionForm}}
@title='Form for extension Request'
@closeModel={{this.closeExtensionModel}}/>
}`
);
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];
Expand Down

0 comments on commit 0d93af1

Please sign in to comment.