Skip to content

Commit 47b80f8

Browse files
authored
Merge pull request #3096 from andrewbaldwin44/task/baseurl-add-credentials
Webui: Add credentials to stop and reset requests
2 parents 5f71427 + bf37a05 commit 47b80f8

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

Diff for: locust/webui/src/components/StateButtons/ResetButton.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import { Button } from '@mui/material';
22

33
export default function ResetButton() {
44
const onResetStatsClick = () => {
5-
fetch((window.baseUrl ? `${window.baseUrl}/` : '') + 'stats/reset');
5+
fetch(
6+
(window.baseUrl ? `${window.baseUrl}/` : '') + 'stats/reset',
7+
window.baseUrl ? { credentials: 'include' } : undefined,
8+
);
69
};
710

811
return (

Diff for: locust/webui/src/components/StateButtons/StopButton.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ export default function StopButton() {
99
}, []);
1010

1111
const onStopButtonClick = () => {
12-
fetch((window.baseUrl ? `${window.baseUrl}/` : '') + 'stop');
12+
fetch(
13+
(window.baseUrl ? `${window.baseUrl}/` : '') + 'stop',
14+
window.baseUrl ? { credentials: 'include' } : undefined,
15+
);
1316
setIsLoading(true);
1417
};
1518

Diff for: locust/webui/src/components/StateButtons/tests/ResetButton.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ describe('ResetButton', () => {
2323
});
2424

2525
expect(resetStats).toHaveBeenCalled();
26-
expect(resetStats).toBeCalledWith('stats/reset');
26+
expect(resetStats).toBeCalledWith('stats/reset', undefined);
2727
});
2828
});

Diff for: locust/webui/src/components/StateButtons/tests/StopButton.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('StopButton', () => {
2525
expect(getByText('Loading')).toBeTruthy();
2626

2727
expect(resetStats).toHaveBeenCalled();
28-
expect(resetStats).toBeCalledWith('stop');
28+
expect(resetStats).toBeCalledWith('stop', undefined);
2929
rerender(<StopButton />);
3030
expect(queryByText('Loading')).toBeFalsy();
3131
});

0 commit comments

Comments
 (0)