diff --git a/changes/43310-policy-report-details-flash b/changes/43310-policy-report-details-flash new file mode 100644 index 0000000000..3c687ed9c1 --- /dev/null +++ b/changes/43310-policy-report-details-flash @@ -0,0 +1 @@ +- Fixed the policy and report details pages briefly showing the previously-viewed policy/report's content when navigating between them. diff --git a/frontend/pages/policies/details/PolicyDetailsPage/PolicyDetailsPage.tests.tsx b/frontend/pages/policies/details/PolicyDetailsPage/PolicyDetailsPage.tests.tsx index 514d1a62e7..ef51a3deb9 100644 --- a/frontend/pages/policies/details/PolicyDetailsPage/PolicyDetailsPage.tests.tsx +++ b/frontend/pages/policies/details/PolicyDetailsPage/PolicyDetailsPage.tests.tsx @@ -1,13 +1,51 @@ +import React from "react"; +import { screen } from "@testing-library/react"; +import { http, HttpResponse } from "msw"; + import { IPolicy } from "interfaces/policy"; import { ILabelPolicy } from "interfaces/label"; +import { + createCustomRenderer, + baseUrl, + createMockRouter, +} from "test/test-utils"; +import mockServer from "test/mock-server"; +import createMockUser from "__mocks__/userMock"; +import createMockConfig from "__mocks__/configMock"; -import { getLabelModalData } from "./PolicyDetailsPage"; +import PolicyDetailsPage, { getLabelModalData } from "./PolicyDetailsPage"; // Stub SoftwareIcon to avoid asset resolution when importing the page module. jest.mock("pages/SoftwarePage/components/icons/SoftwareIcon", () => { return () => null; }); +// Avoid depending on react-router's browserHistory inside BackButton. +jest.mock("components/BackButton", () => ({ + __esModule: true, + default: ({ text }: { text: string }) => ( + + ), +})); + +// Surface the modal's `query` prop as plain text (the real modal renders it in +// an Ace editor that isn't reliably assertable in jsdom). +jest.mock("components/modals/ShowQueryModal", () => ({ + __esModule: true, + default: ({ query }: { query?: string }) => ( +