From 625eed7abab378c1c2721b3a56e2ab6693861498 Mon Sep 17 00:00:00 2001 From: Ajeyakrishna Date: Wed, 5 Jul 2023 20:16:46 +0530 Subject: [PATCH 1/5] spinner and task update fix --- app/components/task/holder.hbs | 13 ++++++++----- app/components/task/holder.js | 12 ++++++++++++ app/components/tasks.hbs | 22 +++++++++++++--------- app/controllers/tasks.js | 13 +++++-------- 4 files changed, 38 insertions(+), 22 deletions(-) diff --git a/app/components/task/holder.hbs b/app/components/task/holder.hbs index cc1e35c5..8f721d1c 100644 --- a/app/components/task/holder.hbs +++ b/app/components/task/holder.hbs @@ -13,7 +13,7 @@ max='100' step='25' {{on 'change' this.onPercentageChange}} - {{on 'change' (fn @onTaskUpdate @task.id)}} + {{on 'change' (fn this.onUpdate @task.id)}} /> @@ -22,7 +22,7 @@ {{#if (eq @userSelectedTask.key this.TASK_KEYS.ALL)}}
Current task status: - {{@task.status}} + {{this.status}}
{{/if}} @@ -40,7 +40,7 @@ Change task status: {{#each this.availabletaskStatusList as |taskStatus|}} {{#if (not-eq taskStatus.key this.TASK_KEYS.ALL)}} - {{#if (eq taskStatus.key @task.status)}} + {{#if (eq taskStatus.key this.status)}} diff --git a/app/components/task/holder.js b/app/components/task/holder.js index c4392c12..1153550a 100644 --- a/app/components/task/holder.js +++ b/app/components/task/holder.js @@ -73,6 +73,7 @@ export default class TasksHolderComponent extends Component { @action onPercentageChange(e) { const { value } = e.target; + this.percentCompleted = value; this.args.onTaskChange('percentCompleted', value); if (value === TASK_PERCENTAGE.completedPercentage) { this.percentCompleted = this.args.task.percentCompleted; @@ -92,6 +93,7 @@ export default class TasksHolderComponent extends Component { @action onStatusChange(e) { const { value } = e.target; + this.status = value; this.args.onTaskChange('status', value); } From c16fb8eefb3728701e77bb4112e3c4e4f2424b41 Mon Sep 17 00:00:00 2001 From: Ajeyakrishna Date: Sun, 9 Jul 2023 14:15:43 +0530 Subject: [PATCH 4/5] fix failing test case --- app/components/task/holder.hbs | 15 ++-- app/controllers/tasks.js | 2 +- .../components/tasks/holder-test.js | 78 +++---------------- 3 files changed, 17 insertions(+), 78 deletions(-) diff --git a/app/components/task/holder.hbs b/app/components/task/holder.hbs index 3c708b7f..2b96de6f 100644 --- a/app/components/task/holder.hbs +++ b/app/components/task/holder.hbs @@ -31,15 +31,12 @@ > {{#each this.availabletaskStatusList as |taskStatus|}} {{#if (not-eq taskStatus.key this.TASK_KEYS.ALL)}} - {{#if (eq taskStatus.key this.status)}} - - {{else}} - - {{/if}} + {{/if}} {{/each}} diff --git a/app/controllers/tasks.js b/app/controllers/tasks.js index 917d448a..9f011b82 100644 --- a/app/controllers/tasks.js +++ b/app/controllers/tasks.js @@ -264,7 +264,7 @@ export default class TasksController extends Controller { this.buttonRequired = true; this.tempTaskId = taskId; } else { - return this.updateTask(taskId, error); + this.updateTask(taskId, error); } } } diff --git a/tests/integration/components/tasks/holder-test.js b/tests/integration/components/tasks/holder-test.js index 1d34167f..b86538e9 100644 --- a/tests/integration/components/tasks/holder-test.js +++ b/tests/integration/components/tasks/holder-test.js @@ -2,7 +2,7 @@ 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 { find, render, waitUntil, fillIn } from '@ember/test-helpers'; +import { find, render, waitUntil, fillIn, select } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; module('Integration | Component | Tasks Holder', function (hooks) { @@ -146,7 +146,7 @@ module('Integration | Component | Tasks Holder', function (hooks) { }); }); - test('verify values of input slider upon api failures', async function (assert) { + test('Verify values of input slider upon api failures', async function (assert) { const testTask = tasksData[3]; testTask.percentCompleted = '50'; testTask.status = TASK_KEYS.IN_PROGRESS; @@ -177,39 +177,8 @@ module('Integration | Component | Tasks Holder', function (hooks) { assert.dom('[data-test-task-progress-bar]').hasValue('50'); }); - test('verify values of task status upon api failures', async function (assert) { + test('Verify values of task status upon api failures', async function (assert) { const testTask = tasksData[3]; - testTask.status = TASK_KEYS.AVAILABLE; - - 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); - - await render(hbs``); - - assert.dom('[data-test-task-status-select]').hasValue(TASK_KEYS.AVAILABLE); - - await fillIn('[data-test-task-status-select]', TASK_KEYS.COMPLETED); - - assert.dom('[data-test-task-status-select]').hasValue(TASK_KEYS.AVAILABLE); - }); - - test('verify values of input slider upon api failures', async function (assert) { - const testTask = tasksData[3]; - testTask.percentCompleted = '50'; testTask.status = TASK_KEYS.IN_PROGRESS; this.set('task', testTask); @@ -221,50 +190,23 @@ module('Integration | Component | Tasks Holder', function (hooks) { this.set('disabled', false); this.set('defaultType', DEFAULT_TASK_TYPE); - await render(hbs``); - - assert.dom('[data-test-task-progress-bar]').hasValue('50'); - - await fillIn('[data-test-task-progress-bar]', '25'); - - assert.dom('[data-test-task-progress-bar]').hasValue('50'); - }); - - test('verify values of task status upon api failures', async function (assert) { - const testTask = tasksData[3]; - testTask.status = TASK_KEYS.AVAILABLE; - - 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); - await render(hbs``); - assert.dom('[data-test-task-status-select]').hasValue(TASK_KEYS.AVAILABLE); + assert + .dom('[data-test-task-status-select]') + .hasValue(TASK_KEYS.IN_PROGRESS); - await fillIn('[data-test-task-status-select]', TASK_KEYS.COMPLETED); + await select('[data-test-task-status-select]', TASK_KEYS.COMPLETED); - assert.dom('[data-test-task-status-select]').hasValue(TASK_KEYS.AVAILABLE); + assert + .dom('[data-test-task-status-select]') + .hasValue(TASK_KEYS.IN_PROGRESS); }); }); From 637b0b9f3a26a76217ef072034ad1a7116de428f Mon Sep 17 00:00:00 2001 From: Ajeyakrishna Date: Sun, 9 Jul 2023 15:54:50 +0530 Subject: [PATCH 5/5] add return promise --- app/controllers/tasks.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/tasks.js b/app/controllers/tasks.js index 9f011b82..917d448a 100644 --- a/app/controllers/tasks.js +++ b/app/controllers/tasks.js @@ -264,7 +264,7 @@ export default class TasksController extends Controller { this.buttonRequired = true; this.tempTaskId = taskId; } else { - this.updateTask(taskId, error); + return this.updateTask(taskId, error); } } }