Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed buttons to mark oneself as idle or active #432

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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`);
manish591 marked this conversation as resolved.
Show resolved Hide resolved
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`);
heyrandhir marked this conversation as resolved.
Show resolved Hide resolved
});
});
Loading