Skip to content

Commit

Permalink
Merge pull request #519 from Real-Dev-Squad/develop
Browse files Browse the repository at this point in the history
Dev to main sync
  • Loading branch information
iamitprakash authored Nov 7, 2023
2 parents 55898fe + ee53203 commit 228e84b
Show file tree
Hide file tree
Showing 11 changed files with 133 additions and 48 deletions.
17 changes: 8 additions & 9 deletions app/components/task/holder.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,14 @@
id='task-update'
{{on 'change' this.onStatusChange}}
>
{{#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}}
{{#each this.taskStatusList as |taskStatus|}}
<option
data-test-dropdown-option={{taskStatus.displayLabel}}
value={{taskStatus.key}}
selected={{eq taskStatus.key this.status}}
>
{{taskStatus.displayLabel}}
</option>
{{/each}}
</select>
</div>
Expand Down
15 changes: 14 additions & 1 deletion app/components/task/holder.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,22 @@ export default class TasksHolderComponent extends Component {
TASK_KEYS = TASK_KEYS;
availabletaskStatusList = TASK_STATUS_LIST;

get taskStatusList() {
const statusToDisplay = this.availabletaskStatusList.filter(
(taskStatus) => {
if (this.args.dev === true) {
return taskStatus.key !== 'ALL' && taskStatus.key !== 'COMPLETED';
} else {
return taskStatus.key !== 'ALL' && taskStatus.key !== 'DONE';
}
}
);
return statusToDisplay;
}

get taskStyleClass() {
const statusNotOverDueList = [
TASK_KEYS.COMPLETED,
this.args.dev === true ? TASK_KEYS.DONE : TASK_KEYS.COMPLETED,
TASK_KEYS.VERIFIED,
TASK_KEYS.AVAILABLE,
];
Expand Down
2 changes: 0 additions & 2 deletions app/components/user-status.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
{{#each this.currentUserStatus as |currentStatus|}}
{{#if (eq @status currentStatus.status)}}
{{#if (eq currentStatus.status "OOO")}}
{{#if @dev}}
<button
data-test-cancel-status-OOO
class='buttons__cancel--ooo'
Expand All @@ -37,7 +36,6 @@
>
<span>Cancel OOO</span>
</button>
{{/if}}
{{else}}
{{#each currentStatus.otherAvailableStatus as |otherPossibleStatus|}}
<button data-test-update-status-OOO class={{otherPossibleStatus.class}} type="button" disabled={{@isStatusUpdating}} {{on "click" (fn this.changeStatus otherPossibleStatus.status )}}>
Expand Down
8 changes: 7 additions & 1 deletion app/constants/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const TASK_KEYS = {
BLOCKED: 'BLOCKED',
SMOKE_TESTING: 'SMOKE_TESTING',
COMPLETED: 'COMPLETED',
DONE: 'DONE',
NEEDS_REVIEW: 'NEEDS_REVIEW',
IN_REVIEW: 'IN_REVIEW',
APPROVED: 'APPROVED',
Expand All @@ -24,6 +25,7 @@ const {
BLOCKED,
SMOKE_TESTING,
COMPLETED,
DONE,
NEEDS_REVIEW,
IN_REVIEW,
APPROVED,
Expand Down Expand Up @@ -63,6 +65,10 @@ const TASK_STATUS_LIST = [
displayLabel: 'Completed',
key: COMPLETED,
},
{
displayLabel: 'Done',
key: DONE,
},
{
displayLabel: 'Needs Review',
key: NEEDS_REVIEW,
Expand Down Expand Up @@ -133,7 +139,7 @@ const TABS_TASK_STATUS_LIST = [
];
export const TASK_MESSAGES = {
MARK_DONE:
'This task will be marked as complete and a new task will be assigned to you',
'This task will be marked as done and a new task will be assigned to you',
UPDATE_TASK: 'Updating task',
FIND_TASK: 'Finding new task for you!',
};
Expand Down
5 changes: 0 additions & 5 deletions app/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,11 @@ const BASE_URL = ENV.BASE_API_URL;

export default class IndexController extends Controller {
@service toast;
@service featureFlag;
@tracked status = this.model;
@tracked isStatusUpdating = false;
@tracked showUserStateModal = false;
@tracked newStatus;

get isDevMode() {
return this.featureFlag.isDevMode;
}

@action toggleUserStateModal() {
this.showUserStateModal = !this.showUserStateModal;
}
Expand Down
9 changes: 8 additions & 1 deletion app/controllers/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const API_BASE_URL = ENV.BASE_API_URL;
export default class TasksController extends Controller {
queryParams = ['dev'];
@service toast;
@service featureFlag;
TASK_KEYS = TASK_KEYS;
taskStatusList = TASK_STATUS_LIST;
tabsTaskStatusList = TABS_TASK_STATUS_LIST;
Expand All @@ -42,6 +43,10 @@ export default class TasksController extends Controller {
@tracked showFetchButton = this.isShowFetchButton() && !this.alreadyFetched;
alreadyFetched = localStorage.getItem('already-fetched');

get isDevMode() {
return this.featureFlag.isDevMode;
}

@action toggleDropDown() {
this.showDropDown = !this.showDropDown;
}
Expand Down Expand Up @@ -93,7 +98,9 @@ export default class TasksController extends Controller {
const taskCompletionPercentage = object.percentCompleted;
if (taskCompletionPercentage) {
if (taskCompletionPercentage === TASK_PERCENTAGE.completedPercentage) {
requestBody.status = 'COMPLETED';
this.isDevMode === true
? (requestBody.status = 'DONE')
: (requestBody.status = 'COMPLETED');
}
requestBody.percentCompleted = parseInt(taskCompletionPercentage);
}
Expand Down
1 change: 0 additions & 1 deletion app/templates/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<UserStatus
@status={{this.status}}
@changeStatus={{this.changeStatus}}
@dev={{this.isDevMode}}
@isStatusUpdating={{this.isStatusUpdating}}
@updateStatus={{this.updateStatus}}
/>
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/components/tasks-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ module('Integration | Component | tasks', function (hooks) {

assert.dom('[data-test-task-spinner]').doesNotExist();

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

assert.dom('[data-test-task-spinner]').exists({ count: 1 });

Expand Down
58 changes: 58 additions & 0 deletions tests/integration/components/tasks/holder-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,41 @@ module('Integration | Component | Tasks Holder', function (hooks) {
.hasValue(TASK_KEYS.IN_PROGRESS);
});

test('Verify values of task status upon api failures under feature flag', async function (assert) {
const testTask = tasksData[3];
testTask.status = TASK_KEYS.IN_PROGRESS;

this.set('task', testTask);
this.set('mock', () => {});
this.set('onTaskUpdate', (taskId, error) => {
error();
});
this.set('isLoading', false);
this.set('disabled', false);
this.set('defaultType', DEFAULT_TASK_TYPE);
this.set('dev', true);

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

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

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

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

test('Verify status change to VERIFIED', async function (assert) {
const testTask = tasksData[3];

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

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

test('Render Task holder and check whether it has select tag with option DONE under feature flag', 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);
this.set('dev', true);

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={{this.dev}}
/>`);

assert.dom('[data-test-task-status-select]').exists();
assert.dom('[data-test-dropdown-option=Done]').hasText('Done');
});
});
36 changes: 36 additions & 0 deletions tests/integration/components/tasks/modal-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,40 @@ module('Integration | Component | tasks/modal', function (hooks) {
this.set('isUpdating', false);
assert.dom('[data-test-spinner]').doesNotExist();
});

test('when the progress bar reaches 100%, a model ais displayed with a message and a "Proceed" button', async function (assert) {
this.setProperties({
goBack: () => {},
isUpdating: false,
markComplete: () => {},
markCompleteAndAssignTask: () => {},
showModal: true,
buttonRequired: true,
dev: false,
message:
'This task will be marked as done and a new task will be assigned to you',
});

await render(hbs`
<Task::Modal
@goBack={{this.goBack}}
@markComplete={{this.markComplete}}
@markCompleteAndAssignTask={{this.markCompleteAndAssignTask}}
@message={{this.message}}
@showModal={{this.showModal}}
@buttonRequired={{this.buttonRequired}}
@isUpdating={{this.isUpdating}}
@dev={{this.dev}}
/>
`);

assert.dom('[data-test-notAssignBtn]').exists();
assert.dom('[data-test-notAssignBtn]').hasProperty('button');
assert
.dom('[data-test-title]')
.hasText(
'This task will be marked as done and a new task will be assigned to you'
);
assert.dom('[data-test-notAssignBtn]').hasText('Proceed');
});
});
28 changes: 1 addition & 27 deletions tests/integration/components/user-status-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,42 +50,18 @@ module('Integration | Component | user-status', function (hooks) {
.hasText('Change your status to OOO');
});

test('show relevant data when status is OOO and not have feature flag', async function (assert) {
test('show relevant data when status is OOO', async function (assert) {
this.setProperties({
status: 'OOO',
isStatusUpdating: false,
changeStatus: () => {},
updateStatus: () => {},
dev: false,
});

await render(hbs`
<UserStatus
@status={{this.status}}
@changeStatus={{this.changeStatus}}
@dev={{this.dev}}
@isStatusUpdating={{this.isStatusUpdating}}
@updateStatus={{this.updateStatus}}
/>
`);

assert.dom('[data-test-status]').hasText(`You are OOO`);
});

test('show relevant data when status is OOO and have feature flag', async function (assert) {
this.setProperties({
status: 'OOO',
isStatusUpdating: false,
changeStatus: () => {},
updateStatus: () => {},
dev: true,
});

await render(hbs`
<UserStatus
@status={{this.status}}
@changeStatus={{this.changeStatus}}
@dev={{this.dev}}
@isStatusUpdating={{this.isStatusUpdating}}
@updateStatus={{this.updateStatus}}
/>
Expand All @@ -105,15 +81,13 @@ module('Integration | Component | user-status', function (hooks) {
const { cancelOoo } = cancelOOOPayload;
assert.equal(cancelOoo, true, 'cancel OOO status');
},
dev: true,
});

await render(hbs`
<UserStatus
@status={{this.status}}
@changeStatus={{this.changeStatus}}
@isStatusUpdating={{this.isStatusUpdating}}
@dev={{this.dev}}
@updateStatus={{this.updateStatus}}
/>
`);
Expand Down

0 comments on commit 228e84b

Please sign in to comment.