Skip to content

Commit

Permalink
Update mirage to provide displayMessage instead of message
Browse files Browse the repository at this point in the history
  • Loading branch information
philrenaud committed Sep 27, 2023
1 parent 2337287 commit 432b765
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
26 changes: 14 additions & 12 deletions ui/app/models/task-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,18 @@ export default class TaskEvent extends Fragment {
}

function simplifyTimeMessage(message) {
return message.replace(/(\d+h)?(\d+m)?(\d+\.\d+)s/g, (_, h, m, s) => {
h = h ? parseInt(h) : 0;
m = m ? parseInt(m) : 0;
s = Math.round(parseFloat(s));

m += Math.floor(s / 60);
s %= 60;
h += Math.floor(m / 60);
m %= 60;

return `${h ? h + 'h' : ''}${h || m ? m + 'm' : ''}${s}s`;
});
return (
message?.replace(/(\d+h)?(\d+m)?(\d+\.\d+)s/g, (_, h, m, s) => {
h = h ? parseInt(h) : 0;
m = m ? parseInt(m) : 0;
s = Math.round(parseFloat(s));

m += Math.floor(s / 60);
s %= 60;
h += Math.floor(m / 60);
m %= 60;

return `${h ? h + 'h' : ''}${h || m ? m + 'm' : ''}${s}s`;
}) || ''
);
}
2 changes: 1 addition & 1 deletion ui/mirage/factories/task-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ export default Factory.extend({
exitCode: () => null,
time: () => faker.date.past(2 / 365, REF_TIME) * 1000000,

message: () => faker.lorem.sentence(),
displayMessage: () => faker.lorem.sentence(),
});
2 changes: 1 addition & 1 deletion ui/tests/acceptance/job-status-panel-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ module('Acceptance | job status panel', function (hooks) {

await fillIn(
'[data-test-history-search] input',
serverEvents.models[0].message
serverEvents.models[0].displayMessage
);
assert.equal(
findAll('.timeline-object').length,
Expand Down

0 comments on commit 432b765

Please sign in to comment.