diff --git a/app/components/profile-field.hbs b/app/components/profile-field.hbs index e1c00879..ca4060e5 100644 --- a/app/components/profile-field.hbs +++ b/app/components/profile-field.hbs @@ -10,6 +10,7 @@ placeholder={{@placeholder}} class="profile-field-input" required={{@required}} + disabled={{@isDeveloper}} {{on 'input' (fn this.inputFieldChanged)}} {{on 'blur' (fn this.checkInputValidation)}} /> diff --git a/app/components/progress-bar.hbs b/app/components/progress-bar.hbs index e9220e79..a60ef1db 100644 --- a/app/components/progress-bar.hbs +++ b/app/components/progress-bar.hbs @@ -12,40 +12,15 @@ step='10' {{on 'change' this.onChange}} {{on 'input' this.onInput}} - disabled={{not this.isEditable}} /> \ No newline at end of file diff --git a/app/components/progress-bar.js b/app/components/progress-bar.js index 6aea892e..356ec898 100644 --- a/app/components/progress-bar.js +++ b/app/components/progress-bar.js @@ -4,29 +4,9 @@ import { action } from '@ember/object'; import { debounce } from '@ember/runloop'; export default class ProgressBarComponent extends Component { - @tracked isEditable = false; @tracked value = this.args.value; - lastEditTime = null; - - @action turnEditModeOn() { - this.isEditable = true; - this.lastEditTime = Date.now(); - this.setEditableToFalse(); - } - - setEditableToFalse() { - setTimeout(() => { - const timeDelta = Date.now() - this.lastEditTime; - if (this.isEditable && timeDelta >= 5000) { - this.isEditable = false; - } else if (this.isEditable) { - this.setEditableToFalse(); - } - }, 5000); - } @action onInput(e) { - this.lastEditTime = Date.now(); this.value = e.target.value; if (this.args.onInput) { this.args.onInput(this.value); @@ -34,7 +14,6 @@ export default class ProgressBarComponent extends Component { } @action onChange(e) { - this.lastEditTime = Date.now(); if (this.args.onChange) { debounce(this, this.debouncedChange, e, 600); } diff --git a/app/components/task/extension-form.hbs b/app/components/task/extension-form.hbs deleted file mode 100644 index 0f32dce7..00000000 --- a/app/components/task/extension-form.hbs +++ /dev/null @@ -1,78 +0,0 @@ -
-
-
-

{{@title}}

- {{#if this.createExtensionRequest}} -
-

Create Extension Request!!!

-
- {{#if this.createExtensionRequestError}} -

Error: {{this.createExtensionRequestError}}

- {{/if}} - - - -

Old ETA - {{this.oldETA}}

- - - - -
-
- {{else}} -
- {{#if this.extensionData.value}} -
- {{#each this.extensionData.value as |extension|}} - - {{/each}} -
- {{else if this.extensionData.isLoading}} -
- -
- {{else if this.extensionData.error}} -

{{this.extensionData.error}}

- - {{/if}} -
- {{/if}} - -
-
\ No newline at end of file diff --git a/app/components/task/extension-form.js b/app/components/task/extension-form.js deleted file mode 100644 index c9867b83..00000000 --- a/app/components/task/extension-form.js +++ /dev/null @@ -1,160 +0,0 @@ -import Component from '@glimmer/component'; -import { tracked } from '@glimmer/tracking'; -import { resource, use } from 'ember-resources'; -import { TrackedMap } from 'tracked-maps-and-sets'; -import ENV from 'website-my/config/environment'; -import { action } from '@ember/object'; -import { WARNING_INVALID_NEW_ETA } from '../../constants/user-status'; -import { toastNotificationTimeoutOptions } from '../../constants/toast-notification'; -import { inject as service } from '@ember/service'; - -export default class ExtensionFormComponent extends Component { - @tracked createExtensionRequest = false; - @tracked createExtensionRequestError = null; - @tracked disableExtensionRequestClose = false; - @service toast; - @service userState; - - oldETA = new Date(this.args.task.endsOn * 1000).toLocaleString(); - - @use load = resource(({ on }) => { - const state = new TrackedMap(); - const controller = new AbortController(); - - on.cleanup(() => controller.abort()); - (async () => { - if (this.args.task) { - state.set('isLoading', true); - try { - const response = await fetch( - `${ENV.BASE_API_URL}/extension-requests/self/?taskId=${this.args.task.id}`, - { - credentials: 'include', - signal: controller.signal, - } - ); - if (response.status === 200) { - const data = await response.json(); - if (!data.allExtensionRequests.length) { - throw Error( - 'No extension request found for this task, want to create one?' - ); - } - state.set('value', data.allExtensionRequests); - state.set('isLoading', false); - return; - } - this.toast.error('Something went wrong!', '', { - ...toastNotificationTimeoutOptions, - timeOut: '3000', - }); - } catch (error) { - state.set('error', error.message); - state.set('isLoading', false); - console.error(error); - this.toast.error(error.message, '', { - ...toastNotificationTimeoutOptions, - timeOut: '3000', - }); - } - } - })(); - - return state; - }); - - get extensionData() { - const result = {}; - result['isLoading'] = this.load.get('isLoading'); - result['value'] = this.load.get('value'); - result['error'] = this.load.get('error'); - return result; - } - - @action - createExtensionRequestToggle(e) { - e.stopPropagation(); - this.createExtensionRequest = !this.createExtensionRequest; - } - - @action - async submitExtensionRequest(e) { - e.preventDefault(); - this.disableExtensionRequestClose = true; - this.createExtensionRequestError = null; - //submit button - e.submitter.disabled = true; - const formData = new FormData(e.target); - const extensionTime = new Date(formData.get('newEndsOn')).getTime() / 1000; - const json = {}; - formData.forEach(function (value, key) { - json[key] = value; - }); - - if (extensionTime < this.args.task.endsOn) { - this.toast.error(WARNING_INVALID_NEW_ETA, '', { - ...toastNotificationTimeoutOptions, - timeOut: '3000', - }); - e.submitter.disabled = false; - this.disableExtensionRequestClose = false; - this.createExtensionRequestError = - 'The newEndsOn value cannot be smaller than the oldEndsOn value'; - return; - } - json['newEndsOn'] = extensionTime; - //setting default values - json['taskId'] = this.args.task.id; - json['assignee'] = this.userState.get('id'); - json['oldEndsOn'] = this.args.task.endsOn; - json['status'] = 'PENDING'; - - try { - const response = await fetch(`${ENV.BASE_API_URL}/extension-requests`, { - credentials: 'include', - method: 'POST', - body: JSON.stringify(json), - headers: { - 'Content-Type': 'application/json', - }, - }); - const data = await response.json(); - if (data.message === 'Extension Request created successfully!') { - this.disableExtensionRequestClose = false; - this.toast.success(data.message, '', { - ...toastNotificationTimeoutOptions, - timeOut: '3000', - }); - setTimeout(this.args.closeModel, 2000); - return; - } - this.toast.error('Something went wrong!', '', { - ...toastNotificationTimeoutOptions, - timeOut: '3000', - }); - e.submitter.disabled = false; - } catch (error) { - this.toast.error(error.message, '', { - ...toastNotificationTimeoutOptions, - timeOut: '3000', - }); - setTimeout(this.args.closeModel, 2000); - } - } - - @action - changeExtensionRequestETA(e) { - const extensionTime = new Date(e.target.value).getTime() / 1000; - - if (extensionTime < this.args.task.endsOn) { - this.toast.error(WARNING_INVALID_NEW_ETA, '', { - ...toastNotificationTimeoutOptions, - timeOut: '3000', - }); - e.target.value = ''; - this.createExtensionRequestError = - 'The newEndsOn value cannot be smaller than the oldEndsOn value'; - return; - } else this.createExtensionRequestError = null; - } -} diff --git a/app/components/task/holder.hbs b/app/components/task/holder.hbs index f4cb4708..56adab52 100644 --- a/app/components/task/holder.hbs +++ b/app/components/task/holder.hbs @@ -15,21 +15,12 @@
{{#if this.extensionFormOpened}} - {{#if @dev}} - - {{else}} - - {{/if}} + {{/if}} {{#if (not-eq this.status this.TASK_KEYS.VERIFIED)}} diff --git a/app/components/task/modal.hbs b/app/components/task/modal.hbs index 63814ce2..b7a2ce67 100644 --- a/app/components/task/modal.hbs +++ b/app/components/task/modal.hbs @@ -1,24 +1,39 @@ {{#if @showModal}} -
- {{/if}} \ No newline at end of file diff --git a/app/components/tasks.hbs b/app/components/tasks.hbs index f7329a3b..43bd28e1 100644 --- a/app/components/tasks.hbs +++ b/app/components/tasks.hbs @@ -1,7 +1,7 @@
{{#if @dev}} {{#if @noInProgressTask}} -
+
+ {{#if (get @model 'isDeveloper')}} +

You can't update the profile data from UI. + You have to create a profile service(if not created yet). Find more + details about profile service + here.

+ {{/if}} {{#each this.fields as |field|}} - {{/each}}
- +
diff --git a/tests/integration/components/profile-field-test.js b/tests/integration/components/profile-field-test.js index 9fb35415..c1287b9a 100644 --- a/tests/integration/components/profile-field-test.js +++ b/tests/integration/components/profile-field-test.js @@ -44,4 +44,58 @@ module('Integration | Component | profile-field', function (hooks) { assert.dom('[data-test-profile-field]').hasClass('profile-field-error'); assert.dom('[data-test-profile-field-error]').hasText(this.errorMessage); }); + + test('disabled profile field renders when isDeveloper is true', async function (assert) { + this.setProperties({ + label: 'First Name*', + icon_url: 'icons/user.svg', + isDeveloper: true, + }); + + await render(hbs` + + `); + + assert.dom('[data-test-profile-field-label]').hasText(this.label); + assert + .dom('[data-test-profile-field-icon]') + .exists() + .hasAttribute('src', this.icon_url); + assert + .dom('[data-test-profile-field-input]') + .hasProperty('disabled', true) + .exists(); + assert.dom('[data-test-profile-field-error]').exists(); + }); + + test('profile field renders when isDeveloper is false', async function (assert) { + this.setProperties({ + label: 'First Name*', + icon_url: 'icons/user.svg', + isDeveloper: false, + }); + + await render(hbs` + + `); + + assert.dom('[data-test-profile-field-label]').hasText(this.label); + assert + .dom('[data-test-profile-field-icon]') + .exists() + .hasAttribute('src', this.icon_url); + assert + .dom('[data-test-profile-field-input]') + .hasProperty('disabled', false) + .exists(); + assert.dom('[data-test-profile-field-error]').exists(); + }); }); diff --git a/tests/integration/components/tasks-test.js b/tests/integration/components/tasks-test.js index 89922d1e..9a76cd46 100644 --- a/tests/integration/components/tasks-test.js +++ b/tests/integration/components/tasks-test.js @@ -1,4 +1,4 @@ -import { module, test } from 'qunit'; +import { module, skip, test } from 'qunit'; import { setupRenderingTest } from 'ember-qunit'; import { find, render, waitUntil, fillIn } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; @@ -17,7 +17,7 @@ module('Integration | Component | tasks', function (hooks) { assert.ok(this.element.textContent.trim().includes('tasks')); }); - test('there is a fetch task button if no in progress task are there', async function (assert) { + skip('there is a fetch task button if no in progress task are there', async function (assert) { this.setProperties({ onTaskChange: () => {}, onTaskUpdate: () => {}, diff --git a/tests/integration/components/tasks/extension-form-test.js b/tests/integration/components/tasks/extension-form-test.js deleted file mode 100644 index f63b8a31..00000000 --- a/tests/integration/components/tasks/extension-form-test.js +++ /dev/null @@ -1,267 +0,0 @@ -import { module, test } from 'qunit'; -import { setupRenderingTest } from 'ember-qunit'; -import { tasks } from 'website-my/tests/fixtures/tasks'; -import { extensionRequests } from 'website-my/tests/fixtures/extension-requests'; -import { render, click, fillIn, waitFor } from '@ember/test-helpers'; -import { hbs } from 'ember-cli-htmlbars'; -import makeServer from 'website-my/mirage/config'; - -module('Integration | Component | Extension Request Form', function (hooks) { - setupRenderingTest(hooks); - let tasksData, extensionFormOpened, server; - - hooks.after(function () { - server.shutdown(); - }); - - hooks.before(function () { - tasksData = tasks; - extensionFormOpened = true; - server = makeServer({ environment: 'test' }); - extensionRequests.forEach((obj) => { - server.create('extensionRequest', obj); - }); - }); - - const toggleExtensionForm = (setter, name) => { - extensionFormOpened = !extensionFormOpened; - if (setter) { - setter(name, extensionFormOpened); - } - }; - - const closeExtensionForm = (setter, name) => () => { - extensionFormOpened = false; - if (setter) { - setter(name, false); - } - }; - - const closeExtensionModel = (setter, name) => (e) => { - if (!e) { - toggleExtensionForm(setter, name); - return; - } - e.stopPropagation(); - if (e.target.classList.contains('extension-form__container-back')) { - toggleExtensionForm(setter, name); - } - }; - - test('When Clicked /"Close Form/" button or background task extension form should unmount', async function (assert) { - this.set('task', tasksData[0]); - this.set( - 'closeExtensionModel', - closeExtensionModel(this.set, 'extensionFormOpened') - ); - this.set( - 'closeExtensionForm', - closeExtensionForm(this.set, 'extensionFormOpened') - ); - this.set('extensionFormOpened', extensionFormOpened); - - await render( - hbs` - {{#if this.extensionFormOpened}} - - {{/if}}` - ); - assert - .dom(this.element.querySelector('[data-test-title]')) - .hasText('Form for extension Request'); - await click( - this.element.querySelector('[data-test-extension-form-container-close]') - ); - assert.dom(this.element.querySelector('[data-test-title]')).doesNotExist(); - - extensionFormOpened = true; - this.set('extensionFormOpened', extensionFormOpened); - assert - .dom(this.element.querySelector('[data-test-title]')) - .hasText('Form for extension Request'); - await click( - this.element.querySelector('[data-test-extension-form-container-back]') - ); - assert.dom(this.element.querySelector('[data-test-title]')).doesNotExist(); - }); - - test('When no extension requests found, the option to create extension request should show and then later open form', async function (assert) { - this.set('task', tasksData[3]); - this.set( - 'closeExtensionModel', - closeExtensionModel(this.set, 'extensionFormOpened') - ); - this.set( - 'closeExtensionForm', - closeExtensionForm(this.set, 'extensionFormOpened') - ); - - await render( - hbs`` - ); - await waitFor('[data-test-create-extension-button]'); - assert - .dom(this.element.querySelector('[data-test-create-extension-button]')) - .hasText('Create an extension request'); - - await click( - this.element.querySelector('[data-test-create-extension-button]') - ); - assert - .dom( - this.element - .querySelector('[data-test-extension-from-content]') - .querySelector('button[type=submit]') - ) - .exists(); - }); - - test('When creating extension request, if the newEndsOn is smaller than the oldEndsOn then should throw error', async function (assert) { - this.set('task', tasksData[3]); - this.set( - 'closeExtensionModel', - closeExtensionModel(this.set, 'extensionFormOpened') - ); - this.set( - 'closeExtensionForm', - closeExtensionForm(this.set, 'extensionFormOpened') - ); - - await render( - hbs`` - ); - await waitFor('[data-test-create-extension-button]'); - assert - .dom(this.element.querySelector('[data-test-create-extension-button]')) - .hasText('Create an extension request'); - - await click( - this.element.querySelector('[data-test-create-extension-button]') - ); - assert - .dom( - this.element - .querySelector('[data-test-extension-from-content]') - .querySelector('button[type=submit]') - ) - .exists(); - - await fillIn( - '[data-test-extension-form-newEndsOn-input]', - '2022-09-09T09:45' - ); - assert - .dom(this.element.querySelector('[data-test-extension-from-error]')) - .hasText( - 'Error: The newEndsOn value cannot be smaller than the oldEndsOn value' - ); - - // if filled valid time then remove the error - await fillIn( - '[data-test-extension-form-newEndsOn-input]', - '2023-09-09T09:45' - ); - assert - .dom(this.element.querySelector('[data-test-extension-from-error]')) - .doesNotExist(); - }); - - test('When no extension requests found, we should be able to create one', async function (assert) { - this.set('task', tasksData[3]); - this.set( - 'closeExtensionModel', - closeExtensionModel(this.set, 'extensionFormOpened') - ); - this.set( - 'closeExtensionForm', - closeExtensionForm(this.set, 'extensionFormOpened') - ); - - await render( - hbs`` - ); - await waitFor('[data-test-create-extension-button]'); - assert - .dom(this.element.querySelector('[data-test-create-extension-button]')) - .hasText('Create an extension request'); - - await click( - this.element.querySelector('[data-test-create-extension-button]') - ); - assert - .dom( - this.element - .querySelector('[data-test-extension-from-content]') - .querySelector('button[type=submit]') - ) - .exists(); - - //create extension request - await fillIn('[data-test-extension-form-reason-input]', 'Testing'); - await fillIn( - '[data-test-extension-form-newEndsOn-input]', - '2030-12-31T02:43' - ); - await fillIn('[data-test-extension-form-title-input]', 'TestingAgain'); - await click(this.element.querySelector('button[type=submit]')); - - // rendering the component again to check the new data - await render( - hbs`` - ); - await waitFor('[data-test-extension-info-content]'); - assert - .dom(this.element.querySelector('[data-test-extension-info-content]')) - .containsText('Testing') - .containsText('TestingAgain') - .containsText('PENDING'); - }); - - test('When extension requests found, it should display the data', async function (assert) { - let extensionRequestData = extensionRequests[0]; - this.set('task', tasksData[0]); - 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 - .dom(this.element.querySelector('[data-test-extension-info-content]')) - .containsText(extensionRequestData['title']) - .containsText(extensionRequestData['reason']) - .containsText(extensionRequestData['status']); - }); -}); diff --git a/tests/integration/components/tasks/modal-test.js b/tests/integration/components/tasks/modal-test.js index f4b62a6f..655eed7a 100644 --- a/tests/integration/components/tasks/modal-test.js +++ b/tests/integration/components/tasks/modal-test.js @@ -200,8 +200,7 @@ module('Integration | Component | tasks/modal', function (hooks) { showModal: true, buttonRequired: true, dev: false, - message: - 'This task will be marked as done and a new task will be assigned to you', + message: 'This task will be marked as Done', }); await render(hbs` @@ -219,11 +218,7 @@ module('Integration | Component | tasks/modal', function (hooks) { 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-title]').hasText('This task will be marked as Done'); assert.dom('[data-test-notAssignBtn]').hasText('Proceed'); }); }); diff --git a/tests/integration/components/tasks/multiple-extension-form-test.js b/tests/integration/components/tasks/multiple-extension-form-test.js index 9e101ae2..913d557d 100644 --- a/tests/integration/components/tasks/multiple-extension-form-test.js +++ b/tests/integration/components/tasks/multiple-extension-form-test.js @@ -134,17 +134,13 @@ module('Integration | Component | Multiple Extension Form', function (hooks) { ); await render( - hbs`` ); await waitFor('[data-test-create-extension-button]'); - assert - .dom(this.element.querySelector('[data-test-create-extension-button]')) - .hasText('Create an extension request'); - await click( this.element.querySelector('[data-test-create-extension-button]') ); @@ -162,9 +158,7 @@ module('Integration | Component | Multiple Extension Form', function (hooks) { ); assert .dom(this.element.querySelector('[data-test-extension-from-error]')) - .hasText( - 'Error: The newEndsOn value cannot be smaller than the oldEndsOn value' - ); + .hasText('New ETA must be greater than Old ETA'); await settled(); // if filled valid time then remove the error @@ -174,67 +168,7 @@ module('Integration | Component | Multiple Extension Form', function (hooks) { ); assert .dom(this.element.querySelector('[data-test-extension-from-error]')) - .doesNotExist(); - }); - - test('When no extension requests found, we should be able to create one', async function (assert) { - this.set('task', tasksData[3]); - this.set( - 'closeExtensionModel', - closeExtensionModel(this.set, 'extensionFormOpened') - ); - this.set( - 'closeExtensionForm', - closeExtensionForm(this.set, 'extensionFormOpened') - ); - - await render( - hbs`` - ); - await waitFor('[data-test-create-extension-button]'); - assert - .dom(this.element.querySelector('[data-test-create-extension-button]')) - .hasText('Create an extension request'); - - await click( - this.element.querySelector('[data-test-create-extension-button]') - ); - assert - .dom( - this.element - .querySelector('[data-test-extension-from-content]') - .querySelector('button[type=submit]') - ) - .exists(); - - //create extension request - await fillIn('[data-test-extension-form-reason-input]', 'Testing'); - await fillIn( - '[data-test-extension-form-newEndsOn-input]', - '2030-12-31T02:43' - ); - await fillIn('[data-test-extension-form-title-input]', 'TestingAgain'); - await click(this.element.querySelector('button[type=submit]')); - - // rendering the component again to check the new data - await render( - hbs`` - ); - await waitFor('[data-test-extension-info-content]'); - assert - .dom(this.element.querySelector('[data-test-extension-info-content]')) - .containsText('Testing') - .containsText('TestingAgain') - .containsText('PENDING') - .containsText('1'); + .doesNotContainText(); }); test('When previous extension request is approved, the button to create extension request should be there', async function (assert) {