Skip to content
Snippets Groups Projects
Unverified Commit d237bb31 authored by Elton Okawa's avatar Elton Okawa Committed by GitHub
Browse files

refactor: Tests depend on exported default polling value (#45264)

parent 43e09e64
No related branches found
No related tags found
No related merge requests found
......@@ -19,7 +19,11 @@ interface LogsProps {
pollingDurationMs?: number;
}
export const Logs = ({ pollingDurationMs = 1000 }: LogsProps) => {
export const DEFAULT_POLLING_DURATION_MS = 1000;
export const Logs = ({
pollingDurationMs = DEFAULT_POLLING_DURATION_MS,
}: LogsProps) => {
const [selectedProcessUUID, setSelectedProcessUUID] = useState("ALL");
const { loaded, error, logs } = usePollingLogsQuery(pollingDurationMs);
const processUUIDs = useMemo(() => getAllProcessUUIDs(logs), [logs]);
......
......@@ -3,7 +3,7 @@ import fetchMock from "fetch-mock";
import { UtilApi } from "metabase/services";
import { Logs } from "./Logs";
import { Logs, DEFAULT_POLLING_DURATION_MS } from "./Logs";
import { maybeMergeLogs } from "./utils";
const log = {
......@@ -49,7 +49,7 @@ describe("Logs", () => {
expect(utilSpy).toHaveBeenCalledTimes(1),
]);
act(() => {
jest.advanceTimersByTime(1100); // wait longer than polling period
jest.advanceTimersByTime(DEFAULT_POLLING_DURATION_MS + 100);
});
expect(utilSpy).toHaveBeenCalledTimes(1); // should not have been called
act(() => {
......@@ -61,7 +61,7 @@ describe("Logs", () => {
).toBeInTheDocument();
});
act(() => {
jest.advanceTimersByTime(1100);
jest.advanceTimersByTime(DEFAULT_POLLING_DURATION_MS + 100);
});
expect(utilSpy).toHaveBeenCalledTimes(2); // should have issued new request
});
......@@ -107,7 +107,7 @@ describe("Logs", () => {
unmount();
act(() => {
jest.advanceTimersByTime(1100); // wait longer than polling period
jest.advanceTimersByTime(DEFAULT_POLLING_DURATION_MS + 100);
});
expect(utilSpy).toHaveBeenCalledTimes(1);
});
......@@ -118,10 +118,10 @@ describe("Logs", () => {
const originalLogs = [log];
const shouldNotBeMerged = maybeMergeLogs(originalLogs, [log]);
expect(shouldNotBeMerged).toBe(originalLogs);
const shoudlBeMerged = maybeMergeLogs(originalLogs, [
const shouldBeMerged = maybeMergeLogs(originalLogs, [
{ ...log, msg: "different" },
]);
expect(shoudlBeMerged).not.toBe(originalLogs);
expect(shouldBeMerged).not.toBe(originalLogs);
});
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment