Skip to content

Commit

Permalink
Adding UNASSIGNED and DONE to task status options
Browse files Browse the repository at this point in the history
  • Loading branch information
chandrareddy7 committed Oct 8, 2023
1 parent 2aa9b9a commit 56bda08
Show file tree
Hide file tree
Showing 3 changed files with 175 additions and 7 deletions.
25 changes: 19 additions & 6 deletions app/components/task/holder.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,25 @@
>
{{#each this.availabletaskStatusList as |taskStatus|}}
{{#if (not-eq taskStatus.key this.TASK_KEYS.ALL)}}
<option
value={{taskStatus.key}}
selected={{eq taskStatus.key this.status}}
>
{{taskStatus.displayLabel}}
</option>
{{#if @dev}}
{{#if (not (or (eq taskStatus.key this.TASK_KEYS.AVAILABLE) (eq taskStatus.key this.TASK_KEYS.COMPLETED)))}}
<option
value={{taskStatus.key}}
selected={{eq taskStatus.key this.status}}
>
{{taskStatus.displayLabel}}
</option>
{{/if}}
{{else}}
{{#if (not (or (eq taskStatus.key this.TASK_KEYS.UNASSIGNED) (eq taskStatus.key this.TASK_KEYS.DONE)))}}
<option
value={{taskStatus.key}}
selected={{eq taskStatus.key this.status}}
>
{{taskStatus.displayLabel}}
</option>
{{/if}}
{{/if}}
{{/if}}
{{/each}}
</select>
Expand Down
15 changes: 15 additions & 0 deletions app/constants/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const TASK_KEYS = {
ALL: 'ALL',
AVAILABLE: 'AVAILABLE',
ASSIGNED: 'ASSIGNED',
UNASSIGNED: 'UNASSIGNED',
IN_PROGRESS: 'IN_PROGRESS',
BLOCKED: 'BLOCKED',
SMOKE_TESTING: 'SMOKE_TESTING',
Expand All @@ -14,16 +15,19 @@ const TASK_KEYS = {
REGRESSION_CHECK: 'REGRESSION_CHECK',
RELEASED: 'RELEASED',
VERIFIED: 'VERIFIED',
DONE: 'DONE',
};

const {
ALL,
AVAILABLE,
ASSIGNED,
UNASSIGNED,
IN_PROGRESS,
BLOCKED,
SMOKE_TESTING,
COMPLETED,
DONE,
NEEDS_REVIEW,
IN_REVIEW,
APPROVED,
Expand All @@ -47,6 +51,10 @@ const TASK_STATUS_LIST = [
displayLabel: 'Assigned',
key: ASSIGNED,
},
{
displayLabel: 'Unassigned',
key: UNASSIGNED,
},
{
displayLabel: 'In Progress',
key: IN_PROGRESS,
Expand All @@ -63,6 +71,10 @@ const TASK_STATUS_LIST = [
displayLabel: 'Completed',
key: COMPLETED,
},
{
displayLabel: 'Done',
key: DONE,
},
{
displayLabel: 'Needs Review',
key: NEEDS_REVIEW,
Expand Down Expand Up @@ -143,3 +155,6 @@ export const TASK_PERCENTAGE = {
};

export { TASK_KEYS, TASK_STATUS_LIST, TABS_TASK_STATUS_LIST };

export const oldTaskStatus = { AVAILABLE: 'AVAILABLE', COMPLETED: 'COMPLETED' };
export const newTaskStatus = { UNASSIGNED: 'UNASSIGNED', DONE: 'DONE' };
142 changes: 141 additions & 1 deletion tests/integration/components/tasks/holder-test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { tasks, overDueTask } from 'website-my/tests/fixtures/tasks';
import { TASK_KEYS, TASK_STATUS_LIST } from 'website-my/constants/tasks';
import {
TASK_KEYS,
TASK_STATUS_LIST,
oldTaskStatus,
newTaskStatus,
} from 'website-my/constants/tasks';
import { find, render, waitUntil, fillIn, select } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';

Expand Down Expand Up @@ -242,4 +247,139 @@ module('Integration | Component | Tasks Holder', function (hooks) {

assert.equal(onTaskUpdateCalled, 1, 'onTaskUpdate should be called once');
});

test('Check if UNASSIGNED and DONE is not in task status options when dev is false', async function (assert) {
this.set('task', tasksData[3]);
this.set('mock', () => {});
this.set('isLoading', false);
this.set('disabled', false);
this.set('defaultType', DEFAULT_TASK_TYPE);

await render(hbs`<Task::Holder
@task={{this.task}}
@onTaskChange={{this.mock}}
@onStausChange={{this.mock}}
@onTaskUpdate={{this.mock}}
@isLoading={{this.isLoading}}
@userSelectedTask={{this.defaultType}}
@disabled={{this.disabled}}
/>`);

await waitUntil(() => find('[data-test-task-status-select]'));

const taskStatusList = this.element.querySelector(
'[data-test-task-status-select]'
);

const updatedTaskKeys = Object.keys(TASK_KEYS).filter(
(key) => !(key in newTaskStatus)
);

for (let i = 0; i < taskStatusList.options.length; i++) {
const optionValue = taskStatusList.options[i].value;
assert.ok(updatedTaskKeys.includes(optionValue));
}
});

test('Check if UNASSIGNED and DONE is in task status options when dev is true', async function (assert) {
this.set('task', tasksData[3]);
this.set('mock', () => {});
this.set('isLoading', false);
this.set('disabled', false);
this.set('defaultType', DEFAULT_TASK_TYPE);

await render(hbs`<Task::Holder
@task={{this.task}}
@onTaskChange={{this.mock}}
@onStausChange={{this.mock}}
@onTaskUpdate={{this.mock}}
@isLoading={{this.isLoading}}
@userSelectedTask={{this.defaultType}}
@disabled={{this.disabled}}
@dev={{true}}
/>`);

await waitUntil(() => find('[data-test-task-status-select]'));

const taskStatusList = this.element.querySelector(
'[data-test-task-status-select]'
);

const updatedTaskKeys = Object.keys(TASK_KEYS).filter(
(key) => !(key in oldTaskStatus)
);

for (let i = 0; i < taskStatusList.options.length; i++) {
const optionValue = taskStatusList.options[i].value;
assert.ok(updatedTaskKeys.includes(optionValue));
}
});

test('Verify task status update to UNASSIGNED when dev is true', async function (assert) {
const testTask = tasksData[3];

testTask.status = TASK_KEYS.IN_PROGRESS;

let onTaskUpdateCalled = 0;

this.set('task', testTask);
this.set('onTaskUpdate', () => {
onTaskUpdateCalled++;
});
this.set('mock', () => {});
this.set('isLoading', false);
this.set('disabled', false);
this.set('defaultType', DEFAULT_TASK_TYPE);

await render(hbs`<Task::Holder
@task={{this.task}}
@onTaskUpdate={{onTaskUpdate}}
@onTaskChange={{this.mock}}
@userSelectedTask={{this.defaultType}}
@disabled={{this.disabled}}
@dev={{true}}
/>`);

assert
.dom('[data-test-task-status-select]')
.hasValue(TASK_KEYS.IN_PROGRESS);

await select('[data-test-task-status-select]', TASK_KEYS.UNASSIGNED);

assert.equal(onTaskUpdateCalled, 1, 'onTaskUpdate should be called once');
});

test('Verify task status update to DONE when dev is true', async function (assert) {
const testTask = tasksData[3];

testTask.status = TASK_KEYS.IN_PROGRESS;

let onTaskUpdateCalled = 0;

this.set('task', testTask);
this.set('onTaskUpdate', () => {
onTaskUpdateCalled++;
});
this.set('mock', () => {});
this.set('isLoading', false);
this.set('disabled', false);
this.set('defaultType', DEFAULT_TASK_TYPE);

await render(hbs`<Task::Holder
@task={{this.task}}
@onTaskUpdate={{onTaskUpdate}}
@onTaskChange={{this.mock}}
@userSelectedTask={{this.defaultType}}
@disabled={{this.disabled}}
@dev={{true}}
/>`);

assert
.dom('[data-test-task-status-select]')
.hasValue(TASK_KEYS.IN_PROGRESS);

await select('[data-test-task-status-select]', TASK_KEYS.DONE);

assert.equal(onTaskUpdateCalled, 1, 'onTaskUpdate should be called once');
});
});

0 comments on commit 56bda08

Please sign in to comment.