Skip to content

Commit fd8b5af

Browse files
committed
Removed highlighting for jobs that completed successfully
1 parent 225b8e3 commit fd8b5af

File tree

4 files changed

+34
-11
lines changed

4 files changed

+34
-11
lines changed

__tests__/JobLogsModal.test.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,18 @@ global.window.bootstrap = {
1313
import JobLogsModal from '../src/lib/components/jobs/JobLogsModal.svelte';
1414

1515
describe('JobLogsModal', async () => {
16-
it('display log without highlighting', async () => {
16+
it('display error log fully highlighted', async () => {
1717
const result = render(JobLogsModal);
1818
const error = `TASK ERROR:Task id: 20 (Create OME-Zarr structure), e.workflow_task_order=0
1919
TRACEBACK:
2020
Command "/tmp/FRACTAL_TASKS_DIR/.fractal/fractal-tasks-core0.14.1/venv/bin/python" is not valid. Hint: make sure that it is executable.`;
21-
await result.component.show(error);
22-
expect(result.container.querySelector('pre').innerHTML).eq(error);
21+
await result.component.show({ status: 'failed', log: error });
22+
const pre = result.container.querySelector('pre');
23+
expect(pre.classList.contains('highlight')).eq(true);
24+
expect(pre.innerHTML).eq(error);
2325
});
2426

25-
it('display log with highlighting', async () => {
27+
it('display log with highlighting and hidden details', async () => {
2628
const result = render(JobLogsModal);
2729
const error = `TASK ERROR:Task id: 15 (Create OME-Zarr structure), e.workflow_task_order=0
2830
TRACEBACK:
@@ -37,13 +39,15 @@ Traceback (most recent call last):
3739
pydantic.error_wrappers.ValidationError: 1 validation error for CreateOmeZarr
3840
allowed_channels
3941
field required (type=value_error.missing)`;
40-
await result.component.show(error);
42+
await result.component.show({ status: 'failed', log: error });
4143
const pre = result.container.querySelector('pre');
4244
let divs = pre.querySelectorAll('div');
4345
expect(divs.length).eq(2);
46+
expect(divs[0].classList.contains('highlight')).eq(true);
4447
expect(divs[0].innerHTML).eq(
4548
'TASK ERROR:Task id: 15 (Create OME-Zarr structure), e.workflow_task_order=0\n'
4649
);
50+
expect(divs[1].classList.contains('highlight')).eq(true);
4751
expect(divs[1].innerHTML)
4852
.eq(`pydantic.error_wrappers.ValidationError: 1 validation error for CreateOmeZarr
4953
allowed_channels
@@ -52,7 +56,19 @@ allowed_channels
5256
await fireEvent.click(result.getByRole('button', { name: /details hidden/ }));
5357
divs = pre.querySelectorAll('div');
5458
expect(divs.length).eq(3);
59+
expect(divs[0].classList.contains('highlight')).eq(true);
60+
expect(divs[1].classList.contains('highlight')).eq(false);
61+
expect(divs[2].classList.contains('highlight')).eq(true);
5562
expect(divs[1].innerHTML.startsWith('TRACEBACK')).eq(true);
5663
expect(pre.querySelectorAll('button').length).eq(0);
5764
});
65+
66+
it('display successful log', async () => {
67+
const result = render(JobLogsModal);
68+
const log = 'Successful log...';
69+
await result.component.show({ status: 'done', log });
70+
const pre = result.container.querySelector('pre');
71+
expect(pre.classList.contains('highlight')).eq(false);
72+
expect(pre.innerHTML).eq(log);
73+
});
5874
});

src/lib/components/jobs/JobLogsModal.svelte

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,23 @@
99
let modal;
1010
/** Show/hide complete stack trace */
1111
let showDetails = false;
12+
/** @type {import('$lib/types').JobStatus} */
13+
let jobStatus;
1214
1315
/**
14-
* @param logs {string|null}
16+
* @param {import('$lib/types').ApplyWorkflow} job
1517
*/
16-
export async function show(logs) {
18+
export async function show(job) {
1719
// remove previous error
1820
if (errorAlert) {
1921
errorAlert.hide();
2022
}
21-
logParts = extractJobErrorParts(logs, true);
23+
jobStatus = job.status;
24+
if (job.status === 'failed') {
25+
logParts = extractJobErrorParts(job.log, true);
26+
} else {
27+
logParts = [{ text: job.log || '', highlight: false }];
28+
}
2229
modal.show();
2330
}
2431
@@ -56,7 +63,7 @@
5663
on:click={expandDetails}>... (details hidden, click here to expand)</button
5764
>{/if}{/each}</pre>
5865
{:else}
59-
<pre class="highlight">{logParts.map((p) => p.text).join('\n')}</pre>
66+
<pre class:highlight={jobStatus === 'failed'}>{logParts.map((p) => p.text).join('\n')}</pre>
6067
{/if}
6168
</div>
6269
</svelte:fragment>

src/lib/components/jobs/JobsList.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@
305305
{#if row.status === 'failed' || row.status === 'done'}
306306
<button
307307
class="btn btn-light"
308-
on:click|preventDefault={() => jobLogsModal.show(row.log)}
308+
on:click|preventDefault={() => jobLogsModal.show(row)}
309309
>
310310
<i class="bi-list-columns-reverse" />
311311
Logs

src/routes/projects/[projectId]/workflows/experimental/[workflowId]/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@
583583
if (!failedJob) {
584584
return;
585585
}
586-
jobLogsModal.show(failedJob.log);
586+
jobLogsModal.show(failedJob);
587587
}
588588
589589
/**

0 commit comments

Comments
 (0)