Skip to content

Commit

Permalink
Update HTML report tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewbaldwin44 authored and mquinnfd committed May 26, 2024
1 parent 267a1a6 commit 709b9a2
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion locust/webui/src/pages/tests/HtmlReport.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { describe, expect, test } from 'vitest';

import HtmlReport from 'pages/HtmlReport';
import { swarmReportMock } from 'test/mocks/swarmState.mock';
import { formatLocalDate } from 'utils/date';

describe('HtmlReport', () => {
test('renders a report', () => {
Expand All @@ -15,10 +16,21 @@ describe('HtmlReport', () => {
expect(getByRole('heading', { name: 'Final ratio' })).toBeTruthy();
expect(getByRole('link', { name: 'Download the Report' }));
expect(getByText(swarmReportMock.locustfile)).toBeTruthy();
expect(getByText(`${swarmReportMock.startTime} - ${swarmReportMock.endTime}`)).toBeTruthy();
expect(getByText(swarmReportMock.host)).toBeTruthy();
});

test('formats the start and end time as expected', () => {
const { getByText } = render(<HtmlReport {...swarmReportMock} />);

expect(
getByText(
`${formatLocalDate(swarmReportMock.startTime)} - ${formatLocalDate(
swarmReportMock.endTime,
)}`,
),
).toBeTruthy();
});

test('does not render the download link when showDownloadLink is false', () => {
const { queryByRole } = render(<HtmlReport {...swarmReportMock} showDownloadLink={false} />);

Expand Down

0 comments on commit 709b9a2

Please sign in to comment.