All files / pages AdminJobLogPage.jsx

100% Statements 6/6
100% Branches 2/2
100% Functions 2/2
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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                  1x 5x 5x     5x           5x     1x                                
import React from "react";
import { useNavigate, useParams } from "react-router";
import { Button } from "react-bootstrap";
import BasicLayout from "main/layouts/BasicLayout/BasicLayout";
import { useBackend } from "main/utils/useBackend";
 
// Full log for one job. The jobs table only shows a preview of the most
// recent lines (lib-jobs v0.2.0+ stores logs one row per line in job_logs);
// GET /api/jobs/logs/{id} returns the whole thing as plain text.
const AdminJobLogPage = () => {
  const { id } = useParams();
  const navigate = useNavigate();
 
  // Stryker disable all : hard to test for query caching
  const { data: jobLog } = useBackend([`/api/jobs/logs/${id}`], {
    method: "GET",
    url: `/api/jobs/logs/${id}`,
  });
  // Stryker restore all
 
  return (
    <BasicLayout>
      <Button
        onClick={() => navigate("/admin/jobs")}
        data-testid="AdminJobLogPage-back-button"
      >
        Back to Job List
      </Button>
      <h2 className="p-3">Log for Job {id}</h2>
      {jobLog === undefined ? (
        <p data-testid="AdminJobLogPage-loading">Loading...</p>
      ) : (
        <pre data-testid="AdminJobLogPage-log">{jobLog}</pre>
      )}
    </BasicLayout>
  );
};
 
export default AdminJobLogPage;