Skip to content

Commit

Permalink
Merge pull request #448 from Real-Dev-Squad/develop
Browse files Browse the repository at this point in the history
Dev to Main Sync
  • Loading branch information
rohan09-raj authored Jul 17, 2023
2 parents 065c232 + 321264f commit 17c4bda
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 63 deletions.
3 changes: 0 additions & 3 deletions app/components/user-status-modal.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
<Input name='untilDate' type='date' min={{if this.fromDate this.fromDate this.disableDatesPrior}}
value={{this.untilDate}} {{on "change" this.updateValue}} data-test-date-picker-until />
<label class="modal__inputs--description" data-test-label-reason>Reason</label>
{{else if (eq @newStatus this.USER_STATES.IDLE)}}
<label class="modal__inputs--description" data-test-label-missing-skills>What skills are you willing to
learn</label>
{{/if}}

<textarea name='reason' class="modal__text-area" value={{this.reason}} {{on "input" this.handleInput}}
Expand Down
6 changes: 1 addition & 5 deletions app/components/user-status.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
and ask for doubts in the team chat on Discord.
</p>
<p data-test-details>If you are not a developer, please contact Ankush for next steps.</p>
<button class="buttons__active" type="button" {disabled={{@isStatusUpdating}} {{on "click" (fn
this.changeStatus "ACTIVE" )}} data-test-active-button>
<span>Change your status to Active</span>
</button>
</div>
{{else}}
<h2 data-test-status>{{currentStatus.message}}</h2>
Expand All @@ -31,7 +27,7 @@
{{#each this.currentUserStatus as |currentStatus|}}
{{#if (eq @status currentStatus.status)}}
{{#each currentStatus.otherAvailableStatus as |otherPossibleStatus|}}
<button class={{otherPossibleStatus.class}} type="button" disabled={{@isStatusUpdating}} {{on "click" (fn this.changeStatus otherPossibleStatus.status )}}>
<button data-test-update-status-OOO class={{otherPossibleStatus.class}} type="button" disabled={{@isStatusUpdating}} {{on "click" (fn this.changeStatus otherPossibleStatus.status )}}>
<span>{{otherPossibleStatus.message}}</span>
</button>
{{/each}}
Expand Down
21 changes: 4 additions & 17 deletions app/components/user-status.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,38 +24,25 @@ export default class UserStatusComponent extends Component {
{
status: USER_STATES.ACTIVE,
message: 'You are Active',
otherAvailableStatus: [
this.ALL_FEASIBLE_STATUS.IDLE,
this.ALL_FEASIBLE_STATUS.OOO,
],
otherAvailableStatus: [this.ALL_FEASIBLE_STATUS.OOO],
},
{
status: USER_STATES.IDLE,
message: 'You are Idle',
otherAvailableStatus: [
this.ALL_FEASIBLE_STATUS.ACTIVE,
this.ALL_FEASIBLE_STATUS.OOO,
],
otherAvailableStatus: [this.ALL_FEASIBLE_STATUS.OOO],
},
{
status: USER_STATES.OOO,
message: 'You are OOO',
otherAvailableStatus: [
this.ALL_FEASIBLE_STATUS.ACTIVE,
this.ALL_FEASIBLE_STATUS.IDLE,
],
otherAvailableStatus: [],
},
{
status: USER_STATES.ONBOARDING,
},
{
status: USER_STATES.DNE,
message: `Your Status doesn't exist`,
otherAvailableStatus: [
this.ALL_FEASIBLE_STATUS.ACTIVE,
this.ALL_FEASIBLE_STATUS.IDLE,
this.ALL_FEASIBLE_STATUS.OOO,
],
otherAvailableStatus: [this.ALL_FEASIBLE_STATUS.OOO],
},
];

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default class IndexController extends Controller {
this.toggleUserStateModal();
}
try {
await fetch(`${BASE_URL}/users/status/self`, {
await fetch(`${BASE_URL}/users/status/self?userStatusFlag=true`, {
method: 'PATCH',
body: JSON.stringify(newStatus),
headers: {
Expand Down
37 changes: 0 additions & 37 deletions tests/integration/components/user-status-modal-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,43 +88,6 @@ module('Integration | Component | user-status-modal', function (hooks) {
await click('.modal__submit');
});

test('payload contains relevant data when status is changed to IDLE', async function (assert) {
this.setProperties({
newStatus: 'IDLE',
showUserStateModal: true,
toggleUserStateModal: () => {
this.set('showUserStateModal', !this.showUserStateModal);
},
updateStatus: (statusPayLoad) => {
const {
currentStatus: { state, from, message, updatedAt },
} = statusPayLoad;
assert.equal(state, 'IDLE', 'new state present in the payload');
assert.equal(
message,
'Rust and GoLang',
'message present in the payload'
);
assert.ok(typeof from === 'number', 'from is a numeric timestamp');
assert.ok(
typeof updatedAt === 'number',
'updatedAt is a numeric timestamp'
);
},
});

await render(hbs`
<UserStatusModal
@showUserStateModal={{this.showUserStateModal}}
@newStatus={{this.newStatus}}
@toggleUserStateModal={{this.toggleUserStateModal}}
@updateStatus={{this.updateStatus}}
/>`);
await fillIn('[data-test-textarea-reason]', 'Rust and GoLang');
await click('.modal__submit');
});

test('modal is closed on click of close button', async function (assert) {
this.setProperties({
newStatus: 'ACTIVE',
Expand Down
72 changes: 72 additions & 0 deletions tests/integration/components/user-status-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';

module('Integration | Component | user-status', function (hooks) {
setupRenderingTest(hooks);

test('show relevant data when status is ONBOARDING', async function (assert) {
this.setProperties({
changeStatus: () => {},
updateStatus: () => {},
status: 'ONBOARDING',
isStatusUpdating: false,
});

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

assert.dom('[data-test-onboarding-details]').exists();
assert.dom('[data-test-status]').hasText('You are undergoing onboarding');
});

test('show relevant data when status is IDLE', async function (assert) {
this.setProperties({
changeStatus: () => {},
updateStatus: () => {},
status: 'IDLE',
isStatusUpdating: false,
});

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

assert.dom('[data-test-status]').hasText(`You are Idle`);
assert
.dom('[data-test-update-status-OOO]')
.hasText('Change your status to OOO');
});

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

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

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

0 comments on commit 17c4bda

Please sign in to comment.