Skip to content

Commit aaa16fa

Browse files
link to specific logs page
1 parent 149dbca commit aaa16fa

2 files changed

Lines changed: 22 additions & 5 deletions

File tree

frontend/src/__tests__/ErrorSnackbar.test.jsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,25 @@ describe("ErrorSnackbar", () => {
118118
);
119119
});
120120

121+
test("links system log alerts to the unit-specific system logs page", () => {
122+
renderErrorSnackbar();
123+
const handler = mockSubscribeToTopic.mock.calls[0][1];
124+
125+
publishLog(handler, {
126+
unit: "xr1",
127+
experiment: "$experiment",
128+
message: "stirring is already running (job_id=2062). Skipping.",
129+
});
130+
131+
const firstCallOptions = mockEnqueueSnackbar.mock.calls[0][1];
132+
render(<MemoryRouter>{firstCallOptions.content("snackbar-1")}</MemoryRouter>);
133+
134+
expect(screen.getByRole("link", { name: "View System Logs" })).toHaveAttribute(
135+
"href",
136+
"/system-logs/xr1",
137+
);
138+
});
139+
121140
test("updates repeated alerts from the same unit without replacing the snackbar", () => {
122141
const { unmount } = renderErrorSnackbar();
123142
const handler = mockSubscribeToTopic.mock.calls[0][1];

frontend/src/components/ErrorSnackbar.jsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,13 @@ function getDedupeKey({ unit, experiment, task, level, message }) {
8787
}
8888

8989
function getLogsRoute(unit, experiment) {
90-
if (experiment === "$experiment") {
91-
return "/system-logs";
92-
}
90+
const logsRoute = experiment === "$experiment" ? "/system-logs" : "/logs";
9391

9492
if (unit === "$broadcast") {
95-
return "/logs";
93+
return logsRoute;
9694
}
9795

98-
return `/logs/${encodeURIComponent(unit)}`;
96+
return `${logsRoute}/${encodeURIComponent(unit)}`;
9997
}
10098

10199
const LogAlertContent = React.forwardRef(function LogAlertContent({

0 commit comments

Comments
 (0)