Skip to content

Commit

Permalink
ui: fix tests for active tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
lgfa29 committed Aug 23, 2022
1 parent 1542604 commit 434ee99
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
22 changes: 12 additions & 10 deletions ui/tests/acceptance/exec-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,15 @@ module('Acceptance | exec', function (hooks) {
});

this.job.taskGroups.models.forEach((taskGroup) => {
server.create('allocation', {
const alloc = server.create('allocation', {
jobId: this.job.id,
taskGroup: taskGroup.name,
forceRunningClientStatus: true,
});
server.db.taskStates.update(
{ allocationId: alloc.id },
{ state: 'running' }
);
});
});

Expand Down Expand Up @@ -135,12 +139,11 @@ module('Acceptance | exec', function (hooks) {

let runningTaskGroup = this.job.taskGroups.models.sortBy('name')[1];
runningTaskGroup.tasks.models.forEach((task, index) => {
let state = 'running';
if (index > 0) {
this.server.db.taskStates.update(
{ name: task.name },
{ finishedAt: new Date() }
);
state = 'dead';
}
this.server.db.taskStates.update({ name: task.name }, { state });
});

await Exec.visitJob({ job: this.job.id });
Expand All @@ -159,12 +162,11 @@ module('Acceptance | exec', function (hooks) {
let runningTaskGroup = this.job.taskGroups.models.sortBy('name')[1];
let changingTaskStateName;
runningTaskGroup.tasks.models.sortBy('name').forEach((task, index) => {
let state = 'running';
if (index > 0) {
this.server.db.taskStates.update(
{ name: task.name },
{ finishedAt: new Date() }
);
state = 'dead';
}
this.server.db.taskStates.update({ name: task.name }, { state });

if (index === 1) {
changingTaskStateName = task.name;
Expand All @@ -187,7 +189,7 @@ module('Acceptance | exec', function (hooks) {
);

if (changingTaskState) {
changingTaskState.set('finishedAt', undefined);
changingTaskState.set('state', 'running');
}
});

Expand Down
4 changes: 4 additions & 0 deletions ui/tests/acceptance/task-detail-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ module('Acceptance | task detail', function (hooks) {
allocation = server.create('allocation', 'withTaskWithPorts', {
clientStatus: 'running',
});
server.db.taskStates.update(
{ allocationId: allocation.id },
{ state: 'running' }
);
task = server.db.taskStates.where({ allocationId: allocation.id })[0];

await Task.visit({ id: allocation.id, name: task.name });
Expand Down

0 comments on commit 434ee99

Please sign in to comment.