generated from Real-Dev-Squad/website-template
-
Notifications
You must be signed in to change notification settings - Fork 77
/
tasks-test.js
184 lines (155 loc) · 5.71 KB
/
tasks-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
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';
import { tasks } from 'website-my/tests/fixtures/tasks';
import { TASK_KEYS } from 'website-my/constants/tasks';
module('Integration | Component | tasks', function (hooks) {
setupRenderingTest(hooks);
test('it renders', async function (assert) {
// Set any properties with this.set('myProperty', 'value');
// Handle any actions with this.set('myAction', function(val) { ... });
await render(hbs`<Tasks />`);
assert.ok(this.element.textContent.trim().includes('tasks'));
});
skip('there is a fetch task button if no in progress task are there', async function (assert) {
this.setProperties({
onTaskChange: () => {},
onTaskUpdate: () => {},
showFetchButton: true,
handleAssignment: () => {},
findingTask: false,
dev: true,
});
await render(hbs`
<Tasks
@onTaskChange={{this.onTaskChange}}
@onTaskUpdate={{this.handleUpdateTask}}
@noInProgressTask={{this.showFetchButton}}
@handleAssignment={{this.handleAssignment}}
@findingTask={{this.findingTask}}
@dev={{this.dev}}
/>
`);
assert.dom('[data-test-fetchSection]').exists();
});
test('Spinner should be visible only on the current updating card', async function (assert) {
tasks[0].status = 'IN_PROGRESS';
this.setProperties({
onTaskChange: () => {},
onTaskUpdate: () => {},
showFetchButton: false,
handleUpdateTask: async () => new Promise((res) => setTimeout(res, 1000)),
handleAssignment: () => {},
findingTask: false,
dev: true,
tasksToShow: tasks,
});
await render(hbs`
<Tasks
@tasksToShow={{this.tasksToShow}}
@onTaskChange={{this.onTaskChange}}
@onTaskUpdate={{this.handleUpdateTask}}
@noInProgressTask={{this.showFetchButton}}
@handleAssignment={{this.handleAssignment}}
@findingTask={{this.findingTask}}
@dev={{this.dev}}
/>
`);
assert.dom('[data-test-task-spinner]').doesNotExist();
await fillIn('[data-test-task-status-select]', TASK_KEYS.DONE);
assert.dom('[data-test-task-spinner]').exists({ count: 1 });
await waitUntil(
() => {
return !find('[data-test-task-spinner]');
},
{ timeout: 1000 }
);
assert.dom('[data-test-task-spinner]').doesNotExist();
});
test('changing the task status from any status other than BLOCKED to IN_PROGRESS inform proceeding further will make progress 0', async function (assert) {
tasks[0].status = 'SMOKE_TESTING';
this.set('dev', true);
const ctrl = this.owner.lookup('controller:tasks');
// before action
assert.equal(ctrl.showModal, false);
assert.equal(ctrl.message, '');
ctrl.allTasks = tasks;
ctrl.dev = true;
ctrl.taskFields = {
status: 'IN_PROGRESS',
};
//action
ctrl.send('handleUpdateTask', tasks[0].id, () => {});
//after action
assert.equal(ctrl.showModal, true);
assert.equal(
ctrl.message,
'The progress of current task is 25%. Proceeding further will make task progress 0%.'
);
assert.equal(ctrl.taskFields.percentCompleted, 0);
});
test('changing the task status from IN_PROGRESS to any status other than BLOCKED inform proceeding further will make progress 100', async function (assert) {
tasks[0].status = 'IN_PROGRESS';
this.set('dev', true);
const ctrl = this.owner.lookup('controller:tasks');
// before action
assert.equal(ctrl.showModal, false);
assert.equal(ctrl.message, '');
ctrl.allTasks = tasks;
ctrl.dev = true;
ctrl.taskFields = {
status: 'SMOKE_TESTING',
};
// action
ctrl.send('handleUpdateTask', tasks[0].id, () => {});
// after action
assert.equal(ctrl.showModal, true);
assert.equal(
ctrl.message,
'The progress of current task is 25%. Proceeding further will make task progress 100%.'
);
assert.equal(ctrl.taskFields.percentCompleted, 100);
});
test('changing the task status from BLOCKED to any status other than IN_PROGRESS when percentCompleted is less than 100, inform the user proceeding further will make progress 100', async function (assert) {
tasks[0].status = 'BLOCKED';
this.set('dev', true);
const ctrl = this.owner.lookup('controller:tasks');
// before action
assert.equal(ctrl.showModal, false);
assert.equal(ctrl.message, '');
ctrl.allTasks = tasks;
ctrl.dev = true;
ctrl.taskFields = {
status: 'SMOKE_TESTING',
};
// action
ctrl.send('handleUpdateTask', tasks[0].id, () => {});
// after action
assert.equal(ctrl.showModal, true);
assert.equal(
ctrl.message,
`The progress of current task is ${tasks[0].percentCompleted}%. Proceeding further will make task progress 100%.`
);
assert.equal(ctrl.taskFields.percentCompleted, 100);
});
test('changing the task status from any status other than blocked and in progress to other status does not result in showing modal', async function (assert) {
tasks[0].status = 'SMOKE_TESTING';
this.set('dev', true);
const ctrl = this.owner.lookup('controller:tasks');
// before action
assert.equal(ctrl.showModal, false);
assert.equal(ctrl.message, '');
ctrl.allTasks = tasks;
ctrl.dev = true;
ctrl.taskFields = {
status: 'NEEDS_REVIEW',
};
// action
ctrl.send('handleUpdateTask', tasks[0].id, () => {});
// after action
assert.equal(ctrl.showModal, false);
assert.equal(ctrl.message, '');
assert.equal(ctrl.taskFields.percentCompleted, undefined);
});
});