@truedat/dd 8.10.2 → 8.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,40 +1,9 @@
1
1
  import { render, waitForLoad } from "@truedat/test/render";
2
- import { useAuthorized } from "@truedat/core/hooks/useAuthorized";
3
- import { GRAPHS, GRAPH, LINEAGE_EVENTS, SAMPLE } from "@truedat/core/routes";
2
+ import userEvent from "@testing-library/user-event";
3
+ import { GRAPHS } from "@truedat/core/routes";
4
+ import { LineageEventsPanel } from "../LineageEventsPanel";
4
5
  import { LineageRoutes } from "../LineageRoutes";
5
6
 
6
- // Mock the hooks module to use the mock implementation
7
- jest.mock("@truedat/core/hooks/useAuthorized");
8
-
9
- // Mock components used in LineageRoutes
10
- jest.mock(
11
- "../LineageEvents",
12
- () =>
13
- function LineageEvents() {
14
- return <div>LineageEvents</div>;
15
- },
16
- );
17
- jest.mock(
18
- "../LineageGraph",
19
- () =>
20
- function LineageGraph() {
21
- return <div>LineageGraph</div>;
22
- },
23
- );
24
- jest.mock(
25
- "../LineageSample",
26
- () =>
27
- function LineageSample() {
28
- return <div>LineageSample</div>;
29
- },
30
- );
31
- jest.mock(
32
- "../LineageForm",
33
- () =>
34
- function LineageForm() {
35
- return <div>LineageForm</div>;
36
- },
37
- );
38
7
  jest.mock(
39
8
  "../GraphLoader",
40
9
  () =>
@@ -42,19 +11,6 @@ jest.mock(
42
11
  return <div>GraphLoader</div>;
43
12
  },
44
13
  );
45
- jest.mock(
46
- "../GraphRedirector",
47
- () =>
48
- function GraphRedirector() {
49
- return <div>GraphRedirector</div>;
50
- },
51
- );
52
- jest.mock("@truedat/core/components", () => ({
53
- Unauthorized: function Unauthorized() {
54
- return <div>Unauthorized</div>;
55
- },
56
- ...jest.requireActual("@truedat/core/components"),
57
- }));
58
14
 
59
15
  describe("<LineageRoutes />", () => {
60
16
  it("renders correctly with default route", async () => {
@@ -63,7 +19,6 @@ describe("<LineageRoutes />", () => {
63
19
  expect(rendered.container).toMatchSnapshot();
64
20
  });
65
21
 
66
- // Test each specific route in the component
67
22
  it("renders correctly with GRAPHS route", async () => {
68
23
  const rendered = render(<LineageRoutes />, {
69
24
  routes: [GRAPHS],
@@ -71,37 +26,68 @@ describe("<LineageRoutes />", () => {
71
26
  await waitForLoad(rendered);
72
27
  expect(rendered.container).toMatchSnapshot();
73
28
  });
29
+ });
74
30
 
75
- it("renders correctly with GRAPH route", async () => {
76
- const rendered = render(<LineageRoutes />, {
77
- routes: [GRAPH],
78
- });
79
- await waitForLoad(rendered);
80
- expect(rendered.container).toMatchSnapshot();
81
- });
82
-
83
- it("renders correctly with LINEAGE_EVENTS route", async () => {
84
- const rendered = render(<LineageRoutes />, {
85
- routes: [LINEAGE_EVENTS],
86
- });
87
- await waitForLoad(rendered);
88
- expect(rendered.container).toMatchSnapshot();
89
- });
31
+ describe("<LineageEventsPanel />", () => {
32
+ const lineageEvents = [
33
+ {
34
+ id: "old-lineage",
35
+ graph_id: 100,
36
+ graph_data: JSON.stringify(["node-b", "node-a"]),
37
+ type: "lineage",
38
+ status: "COMPLETED",
39
+ domain_name: "Finance",
40
+ inserted_at: "2021-11-26T10:09:27.168999Z",
41
+ },
42
+ {
43
+ id: "new-lineage",
44
+ graph_id: 101,
45
+ graph_data: JSON.stringify(["node-a", "node-b"]),
46
+ type: "lineage",
47
+ status: "COMPLETED",
48
+ domain_name: "Finance",
49
+ inserted_at: "2021-11-27T10:09:27.168999Z",
50
+ },
51
+ {
52
+ id: "impact-failed",
53
+ graph_id: 102,
54
+ graph_data: JSON.stringify(["node-a", "node-b"]),
55
+ type: "impact",
56
+ status: "FAILED",
57
+ message: "Graph generation failed",
58
+ inserted_at: "2021-11-28T10:09:27.168999Z",
59
+ },
60
+ {
61
+ id: "without-graph-id",
62
+ graph_data: JSON.stringify(["node-c"]),
63
+ status: "COMPLETED",
64
+ inserted_at: "2021-11-25T10:09:27.168999Z",
65
+ },
66
+ ];
90
67
 
91
- it("renders correctly with SAMPLE route", async () => {
92
- const rendered = render(<LineageRoutes />, {
93
- routes: [SAMPLE],
94
- });
95
- await waitForLoad(rendered);
96
- expect(rendered.container).toMatchSnapshot();
97
- });
68
+ it("renders each event as its own card with type and status", async () => {
69
+ const rendered = render(
70
+ <LineageEventsPanel
71
+ lineageEvents={lineageEvents}
72
+ lineageEventsLoading={false}
73
+ />,
74
+ );
75
+ const user = userEvent.setup({ delay: null });
98
76
 
99
- it("renders unauthorized component when not authorized", async () => {
100
- // For this test only, mock the return value as false
101
- useAuthorized.mockReturnValueOnce(false);
77
+ expect(rendered.container.querySelectorAll("article")).toHaveLength(4);
78
+ expect(rendered.getByText("#101")).toBeInTheDocument();
79
+ expect(rendered.getByText("#100")).toBeInTheDocument();
80
+ expect(rendered.getByText("#102")).toBeInTheDocument();
81
+ expect(rendered.getByText("#without-graph-id")).toBeInTheDocument();
82
+ expect(rendered.getAllByText(/Finance/)).toHaveLength(2);
83
+ expect(rendered.getAllByText("OK")).toHaveLength(3);
84
+ expect(rendered.getByText("KO")).toBeInTheDocument();
85
+ expect(rendered.getAllByText("navigation.lineage.lineage")).toHaveLength(3);
86
+ expect(rendered.getByText("navigation.lineage.impact")).toBeInTheDocument();
102
87
 
103
- const rendered = render(<LineageRoutes />);
104
- await waitForLoad(rendered);
105
- expect(rendered.container).toMatchSnapshot();
88
+ await user.click(rendered.getByLabelText("lineage.events.panel.error"));
89
+ expect(
90
+ await rendered.findByText("Graph generation failed"),
91
+ ).toBeInTheDocument();
106
92
  });
107
93
  });