datajunction-ui 0.0.1-rc.2 → 0.0.1-rc.20

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.
Files changed (135) hide show
  1. package/.env +1 -0
  2. package/.prettierignore +3 -1
  3. package/dj-logo.svg +10 -0
  4. package/package.json +43 -13
  5. package/public/favicon.ico +0 -0
  6. package/src/__tests__/reportWebVitals.test.jsx +44 -0
  7. package/src/app/__tests__/__snapshots__/index.test.tsx.snap +5 -39
  8. package/src/app/components/DeleteNode.jsx +79 -0
  9. package/src/app/components/ListGroupItem.jsx +8 -1
  10. package/src/app/components/NamespaceHeader.jsx +4 -13
  11. package/src/app/components/QueryInfo.jsx +77 -0
  12. package/src/app/components/Tab.jsx +3 -2
  13. package/src/app/components/ToggleSwitch.jsx +20 -0
  14. package/src/app/components/__tests__/QueryInfo.test.jsx +55 -0
  15. package/src/app/components/__tests__/Tab.test.jsx +27 -0
  16. package/src/app/components/__tests__/ToggleSwitch.test.jsx +43 -0
  17. package/src/app/components/__tests__/__snapshots__/ListGroupItem.test.tsx.snap +3 -0
  18. package/src/app/components/__tests__/__snapshots__/NamespaceHeader.test.jsx.snap +2 -18
  19. package/src/app/components/djgraph/Collapse.jsx +46 -0
  20. package/src/app/components/djgraph/DJNode.jsx +60 -82
  21. package/src/app/components/djgraph/DJNodeColumns.jsx +71 -0
  22. package/src/app/components/djgraph/DJNodeDimensions.jsx +75 -0
  23. package/src/app/components/djgraph/LayoutFlow.jsx +104 -0
  24. package/src/app/components/djgraph/__tests__/Collapse.test.jsx +51 -0
  25. package/src/app/components/djgraph/__tests__/DJNodeColumns.test.jsx +83 -0
  26. package/src/app/components/djgraph/__tests__/DJNodeDimensions.test.jsx +118 -0
  27. package/src/app/components/djgraph/__tests__/__snapshots__/DJNode.test.tsx.snap +84 -40
  28. package/src/app/constants.js +2 -0
  29. package/src/app/icons/AlertIcon.jsx +32 -0
  30. package/src/app/icons/CollapsedIcon.jsx +15 -0
  31. package/src/app/icons/DJLogo.jsx +36 -0
  32. package/src/app/icons/DeleteIcon.jsx +21 -0
  33. package/src/app/icons/EditIcon.jsx +18 -0
  34. package/src/app/icons/ExpandedIcon.jsx +15 -0
  35. package/src/app/icons/HorizontalHierarchyIcon.jsx +15 -0
  36. package/src/app/icons/InvalidIcon.jsx +14 -0
  37. package/src/app/icons/PythonIcon.jsx +52 -0
  38. package/src/app/icons/TableIcon.jsx +14 -0
  39. package/src/app/icons/ValidIcon.jsx +14 -0
  40. package/src/app/index.tsx +79 -26
  41. package/src/app/pages/AddEditNodePage/FormikSelect.jsx +46 -0
  42. package/src/app/pages/AddEditNodePage/FullNameField.jsx +37 -0
  43. package/src/app/pages/AddEditNodePage/Loadable.jsx +16 -0
  44. package/src/app/pages/AddEditNodePage/NodeQueryField.jsx +89 -0
  45. package/src/app/pages/AddEditNodePage/__tests__/AddEditNodePageFormFailed.test.jsx +77 -0
  46. package/src/app/pages/AddEditNodePage/__tests__/AddEditNodePageFormSuccess.test.jsx +93 -0
  47. package/src/app/pages/AddEditNodePage/__tests__/FormikSelect.test.jsx +75 -0
  48. package/src/app/pages/AddEditNodePage/__tests__/FullNameField.test.jsx +31 -0
  49. package/src/app/pages/AddEditNodePage/__tests__/NodeQueryField.test.jsx +30 -0
  50. package/src/app/pages/AddEditNodePage/__tests__/__snapshots__/AddEditNodePageFormFailed.test.jsx.snap +53 -0
  51. package/src/app/pages/AddEditNodePage/__tests__/__snapshots__/AddEditNodePageFormSuccess.test.jsx.snap +53 -0
  52. package/src/app/pages/AddEditNodePage/__tests__/__snapshots__/index.test.jsx.snap +3 -0
  53. package/src/app/pages/AddEditNodePage/__tests__/index.test.jsx +178 -0
  54. package/src/app/pages/AddEditNodePage/index.jsx +357 -0
  55. package/src/app/pages/LoginPage/__tests__/index.test.jsx +70 -0
  56. package/src/app/pages/LoginPage/assets/sign-in-with-github.png +0 -0
  57. package/src/app/pages/LoginPage/assets/sign-in-with-google.png +0 -0
  58. package/src/app/pages/LoginPage/index.jsx +90 -0
  59. package/src/app/pages/NamespacePage/Explorer.jsx +57 -0
  60. package/src/app/pages/NamespacePage/Loadable.jsx +9 -7
  61. package/src/app/pages/NamespacePage/__tests__/index.test.jsx +95 -0
  62. package/src/app/pages/NamespacePage/index.jsx +131 -31
  63. package/src/app/pages/NodePage/ClientCodePopover.jsx +32 -0
  64. package/src/app/pages/NodePage/EditColumnPopover.jsx +102 -0
  65. package/src/app/pages/NodePage/LinkDimensionPopover.jsx +135 -0
  66. package/src/app/pages/NodePage/Loadable.jsx +9 -7
  67. package/src/app/pages/NodePage/NodeColumnTab.jsx +106 -27
  68. package/src/app/pages/NodePage/NodeGraphTab.jsx +94 -148
  69. package/src/app/pages/NodePage/NodeHistory.jsx +212 -0
  70. package/src/app/pages/NodePage/NodeInfoTab.jsx +166 -51
  71. package/src/app/pages/NodePage/NodeLineageTab.jsx +84 -0
  72. package/src/app/pages/NodePage/NodeMaterializationTab.jsx +174 -0
  73. package/src/app/pages/NodePage/NodeSQLTab.jsx +82 -0
  74. package/src/app/pages/NodePage/NodeStatus.jsx +14 -20
  75. package/src/app/pages/NodePage/NodesWithDimension.jsx +42 -0
  76. package/src/app/pages/NodePage/__tests__/ClientCodePopover.test.jsx +49 -0
  77. package/src/app/pages/NodePage/__tests__/EditColumnPopover.test.jsx +148 -0
  78. package/src/app/pages/NodePage/__tests__/LinkDimensionPopover.test.jsx +165 -0
  79. package/src/app/pages/NodePage/__tests__/NodeGraphTab.test.jsx +591 -0
  80. package/src/app/pages/NodePage/__tests__/NodeLineageTab.test.jsx +57 -0
  81. package/src/app/pages/NodePage/__tests__/NodePage.test.jsx +725 -0
  82. package/src/app/pages/NodePage/__tests__/NodeWithDimension.test.jsx +175 -0
  83. package/src/app/pages/NodePage/__tests__/__snapshots__/NodePage.test.jsx.snap +402 -0
  84. package/src/app/pages/NodePage/index.jsx +151 -41
  85. package/src/app/pages/NotFoundPage/__tests__/index.test.jsx +16 -0
  86. package/src/app/pages/RegisterTablePage/Loadable.jsx +16 -0
  87. package/src/app/pages/RegisterTablePage/index.jsx +163 -0
  88. package/src/app/pages/Root/__tests__/index.test.jsx +77 -0
  89. package/src/app/pages/Root/index.tsx +32 -4
  90. package/src/app/pages/SQLBuilderPage/Loadable.jsx +16 -0
  91. package/src/app/pages/SQLBuilderPage/__tests__/index.test.jsx +173 -0
  92. package/src/app/pages/SQLBuilderPage/index.jsx +390 -0
  93. package/src/app/providers/djclient.jsx +5 -0
  94. package/src/app/services/DJService.js +388 -22
  95. package/src/app/services/__tests__/DJService.test.jsx +609 -0
  96. package/src/mocks/mockNodes.jsx +1397 -0
  97. package/src/setupTests.ts +31 -1
  98. package/src/styles/dag.css +111 -5
  99. package/src/styles/index.css +467 -31
  100. package/src/styles/login.css +67 -0
  101. package/src/styles/node-creation.scss +197 -0
  102. package/src/styles/styles.scss +44 -0
  103. package/src/styles/styles.scss.d.ts +9 -0
  104. package/src/utils/form.jsx +23 -0
  105. package/tsconfig.json +1 -5
  106. package/webpack.config.js +29 -6
  107. package/.babelrc +0 -4
  108. package/.env.local +0 -4
  109. package/.env.production +0 -1
  110. package/.github/pull_request_template.md +0 -11
  111. package/.github/workflows/ci.yml +0 -33
  112. package/.vscode/extensions.json +0 -7
  113. package/.vscode/launch.json +0 -15
  114. package/.vscode/settings.json +0 -25
  115. package/Dockerfile +0 -7
  116. package/dist/5fa71a03d45dc2e3d61447f3013a303d.png +0 -0
  117. package/dist/index.html +0 -1
  118. package/dist/main.js +0 -23303
  119. package/dist/static/main.05a86d446163fd5f17d3.js +0 -2
  120. package/dist/static/main.05a86d446163fd5f17d3.js.LICENSE.txt +0 -98
  121. package/dist/static/main.9e53bed734dae98e5b10.js +0 -2
  122. package/dist/static/main.9e53bed734dae98e5b10.js.LICENSE.txt +0 -98
  123. package/dist/static/main.js +0 -2
  124. package/dist/static/main.js.LICENSE.txt +0 -98
  125. package/dist/static/vendor.05a86d446163fd5f17d3.js +0 -2
  126. package/dist/static/vendor.05a86d446163fd5f17d3.js.LICENSE.txt +0 -29
  127. package/dist/static/vendor.9e53bed734dae98e5b10.js +0 -2
  128. package/dist/static/vendor.9e53bed734dae98e5b10.js.LICENSE.txt +0 -29
  129. package/dist/static/vendor.js +0 -2
  130. package/dist/static/vendor.js.LICENSE.txt +0 -29
  131. package/dist/vendor.js +0 -281
  132. package/src/app/pages/ListNamespacesPage/Loadable.jsx +0 -14
  133. package/src/app/pages/ListNamespacesPage/index.jsx +0 -52
  134. package/src/app/pages/NamespacePage/__tests__/__snapshots__/index.test.tsx.snap +0 -45
  135. package/src/app/pages/NamespacePage/__tests__/index.test.tsx +0 -14
@@ -0,0 +1,591 @@
1
+ import React from 'react';
2
+ import { render, screen, waitFor } from '@testing-library/react';
3
+ import NodeLineage from '../NodeGraphTab';
4
+ import DJClientContext from '../../../providers/djclient';
5
+
6
+ describe('<NodeLineage />', () => {
7
+ const domTestingLib = require('@testing-library/dom');
8
+ const { queryHelpers } = domTestingLib;
9
+
10
+ const queryByAttribute = attribute =>
11
+ queryHelpers.queryAllByAttribute.bind(null, attribute);
12
+
13
+ const mockNodeDAG = [
14
+ {
15
+ namespace: 'default',
16
+ node_revision_id: 2,
17
+ node_id: 2,
18
+ type: 'source',
19
+ name: 'default.repair_order_details',
20
+ display_name: 'Default: Repair Order Details',
21
+ version: 'v1.0',
22
+ status: 'valid',
23
+ mode: 'published',
24
+ catalog: {
25
+ id: 1,
26
+ uuid: '0fc18295-e1a2-4c3c-b72a-894725c12488',
27
+ created_at: '2023-08-21T16:48:51.146121+00:00',
28
+ updated_at: '2023-08-21T16:48:51.146122+00:00',
29
+ extra_params: {},
30
+ name: 'warehouse',
31
+ },
32
+ schema_: 'roads',
33
+ table: 'repair_order_details',
34
+ description: 'Details on repair orders',
35
+ query: null,
36
+ availability: null,
37
+ columns: [
38
+ {
39
+ name: 'repair_order_id',
40
+ type: 'int',
41
+ attributes: [],
42
+ dimension: {
43
+ name: 'default.repair_order',
44
+ },
45
+ },
46
+ {
47
+ name: 'repair_type_id',
48
+ type: 'int',
49
+ attributes: [],
50
+ dimension: null,
51
+ },
52
+ {
53
+ name: 'price',
54
+ type: 'float',
55
+ attributes: [],
56
+ dimension: null,
57
+ },
58
+ {
59
+ name: 'quantity',
60
+ type: 'int',
61
+ attributes: [],
62
+ dimension: null,
63
+ },
64
+ {
65
+ name: 'discount',
66
+ type: 'float',
67
+ attributes: [],
68
+ dimension: null,
69
+ },
70
+ ],
71
+ updated_at: '2023-08-21T16:48:52.981201+00:00',
72
+ materializations: [],
73
+ parents: [],
74
+ created_at: '2023-08-21T16:48:52.970554+00:00',
75
+ tags: [],
76
+ },
77
+ {
78
+ namespace: 'default',
79
+ node_revision_id: 14,
80
+ node_id: 14,
81
+ type: 'dimension',
82
+ name: 'default.date_dim',
83
+ display_name: 'Default: Date Dim',
84
+ version: 'v1.0',
85
+ status: 'valid',
86
+ mode: 'published',
87
+ catalog: {
88
+ id: 1,
89
+ uuid: '0fc18295-e1a2-4c3c-b72a-894725c12488',
90
+ created_at: '2023-08-21T16:48:51.146121+00:00',
91
+ updated_at: '2023-08-21T16:48:51.146122+00:00',
92
+ extra_params: {},
93
+ name: 'warehouse',
94
+ },
95
+ schema_: null,
96
+ table: null,
97
+ description: 'Date dimension',
98
+ query:
99
+ '\n SELECT\n dateint,\n month,\n year,\n day\n FROM default.date\n ',
100
+ availability: null,
101
+ columns: [
102
+ {
103
+ name: 'dateint',
104
+ type: 'timestamp',
105
+ attributes: [
106
+ {
107
+ attribute_type: {
108
+ namespace: 'system',
109
+ name: 'primary_key',
110
+ },
111
+ },
112
+ ],
113
+ dimension: null,
114
+ },
115
+ {
116
+ name: 'month',
117
+ type: 'int',
118
+ attributes: [],
119
+ dimension: null,
120
+ },
121
+ {
122
+ name: 'year',
123
+ type: 'int',
124
+ attributes: [],
125
+ dimension: null,
126
+ },
127
+ {
128
+ name: 'day',
129
+ type: 'int',
130
+ attributes: [],
131
+ dimension: null,
132
+ },
133
+ ],
134
+ updated_at: '2023-08-21T16:48:54.726980+00:00',
135
+ materializations: [],
136
+ parents: [
137
+ {
138
+ name: 'default.date',
139
+ },
140
+ ],
141
+ created_at: '2023-08-21T16:48:54.726871+00:00',
142
+ tags: [],
143
+ },
144
+ {
145
+ namespace: 'default',
146
+ node_revision_id: 18,
147
+ node_id: 18,
148
+ type: 'dimension',
149
+ name: 'default.hard_hat',
150
+ display_name: 'Default: Hard Hat',
151
+ version: 'v1.0',
152
+ status: 'valid',
153
+ mode: 'published',
154
+ catalog: {
155
+ id: 1,
156
+ uuid: '0fc18295-e1a2-4c3c-b72a-894725c12488',
157
+ created_at: '2023-08-21T16:48:51.146121+00:00',
158
+ updated_at: '2023-08-21T16:48:51.146122+00:00',
159
+ extra_params: {},
160
+ name: 'warehouse',
161
+ },
162
+ schema_: null,
163
+ table: null,
164
+ description: 'Hard hat dimension',
165
+ query:
166
+ '\n SELECT\n hard_hat_id,\n last_name,\n first_name,\n title,\n birth_date,\n hire_date,\n address,\n city,\n state,\n postal_code,\n country,\n manager,\n contractor_id\n FROM default.hard_hats\n ',
167
+ availability: null,
168
+ columns: [
169
+ {
170
+ name: 'hard_hat_id',
171
+ type: 'int',
172
+ attributes: [
173
+ {
174
+ attribute_type: {
175
+ namespace: 'system',
176
+ name: 'primary_key',
177
+ },
178
+ },
179
+ ],
180
+ dimension: null,
181
+ },
182
+ {
183
+ name: 'last_name',
184
+ type: 'string',
185
+ attributes: [],
186
+ dimension: null,
187
+ },
188
+ {
189
+ name: 'first_name',
190
+ type: 'string',
191
+ attributes: [],
192
+ dimension: null,
193
+ },
194
+ {
195
+ name: 'title',
196
+ type: 'string',
197
+ attributes: [],
198
+ dimension: null,
199
+ },
200
+ {
201
+ name: 'birth_date',
202
+ type: 'date',
203
+ attributes: [],
204
+ dimension: {
205
+ name: 'default.date_dim',
206
+ },
207
+ },
208
+ {
209
+ name: 'hire_date',
210
+ type: 'date',
211
+ attributes: [],
212
+ dimension: {
213
+ name: 'default.date_dim',
214
+ },
215
+ },
216
+ {
217
+ name: 'address',
218
+ type: 'string',
219
+ attributes: [],
220
+ dimension: null,
221
+ },
222
+ {
223
+ name: 'city',
224
+ type: 'string',
225
+ attributes: [],
226
+ dimension: null,
227
+ },
228
+ {
229
+ name: 'state',
230
+ type: 'string',
231
+ attributes: [],
232
+ dimension: {
233
+ name: 'default.us_state',
234
+ },
235
+ },
236
+ {
237
+ name: 'postal_code',
238
+ type: 'string',
239
+ attributes: [],
240
+ dimension: null,
241
+ },
242
+ {
243
+ name: 'country',
244
+ type: 'string',
245
+ attributes: [],
246
+ dimension: null,
247
+ },
248
+ {
249
+ name: 'manager',
250
+ type: 'int',
251
+ attributes: [],
252
+ dimension: null,
253
+ },
254
+ {
255
+ name: 'contractor_id',
256
+ type: 'int',
257
+ attributes: [],
258
+ dimension: null,
259
+ },
260
+ ],
261
+ updated_at: '2023-08-21T16:48:55.594603+00:00',
262
+ materializations: [],
263
+ parents: [
264
+ {
265
+ name: 'default.hard_hats',
266
+ },
267
+ ],
268
+ created_at: '2023-08-21T16:48:55.594537+00:00',
269
+ tags: [],
270
+ },
271
+ {
272
+ namespace: 'default',
273
+ node_revision_id: 24,
274
+ node_id: 24,
275
+ type: 'metric',
276
+ name: 'default.avg_repair_price',
277
+ display_name: 'Default: Avg Repair Price',
278
+ version: 'v1.0',
279
+ status: 'valid',
280
+ mode: 'published',
281
+ catalog: {
282
+ id: 1,
283
+ uuid: '0fc18295-e1a2-4c3c-b72a-894725c12488',
284
+ created_at: '2023-08-21T16:48:51.146121+00:00',
285
+ updated_at: '2023-08-21T16:48:51.146122+00:00',
286
+ extra_params: {},
287
+ name: 'warehouse',
288
+ },
289
+ schema_: null,
290
+ table: null,
291
+ description: 'Average repair price',
292
+ query:
293
+ 'SELECT avg(price) default_DOT_avg_repair_price \n FROM default.repair_order_details\n\n',
294
+ availability: null,
295
+ columns: [
296
+ {
297
+ name: 'default_DOT_avg_repair_price',
298
+ type: 'double',
299
+ attributes: [],
300
+ dimension: null,
301
+ },
302
+ ],
303
+ updated_at: '2023-08-21T16:48:56.932231+00:00',
304
+ materializations: [],
305
+ parents: [
306
+ {
307
+ name: 'default.repair_order_details',
308
+ },
309
+ ],
310
+ created_at: '2023-08-21T16:48:56.932162+00:00',
311
+ tags: [],
312
+ },
313
+ ];
314
+
315
+ function getByAttribute(container, id, attribute, ...rest) {
316
+ const result = queryByAttribute(attribute)(container, id, ...rest);
317
+ return result[0];
318
+ }
319
+
320
+ const mockDJClient = () => {
321
+ return {
322
+ DataJunctionAPI: {
323
+ metric: jest.fn(),
324
+ node_dag: jest.fn(name => {
325
+ return mockNodeDAG;
326
+ }),
327
+ },
328
+ };
329
+ };
330
+
331
+ const defaultProps = {
332
+ djNode: {
333
+ namespace: 'default',
334
+ node_revision_id: 24,
335
+ node_id: 24,
336
+ type: 'metric',
337
+ name: 'default.avg_repair_price',
338
+ display_name: 'Default: Avg Repair Price',
339
+ version: 'v1.0',
340
+ status: 'valid',
341
+ mode: 'published',
342
+ catalog: {
343
+ id: 1,
344
+ uuid: '0fc18295-e1a2-4c3c-b72a-894725c12488',
345
+ created_at: '2023-08-21T16:48:51.146121+00:00',
346
+ updated_at: '2023-08-21T16:48:51.146122+00:00',
347
+ extra_params: {},
348
+ name: 'warehouse',
349
+ },
350
+ schema_: null,
351
+ table: null,
352
+ description: 'Average repair price',
353
+ query:
354
+ 'SELECT avg(price) default_DOT_avg_repair_price \n FROM default.repair_order_details\n\n',
355
+ availability: null,
356
+ columns: [
357
+ {
358
+ name: 'default_DOT_avg_repair_price',
359
+ type: 'double',
360
+ attributes: [],
361
+ dimension: null,
362
+ },
363
+ ],
364
+ updated_at: '2023-08-21T16:48:56.932231+00:00',
365
+ materializations: [],
366
+ parents: [
367
+ {
368
+ name: 'default.repair_order_details',
369
+ },
370
+ ],
371
+ created_at: '2023-08-21T16:48:56.932162+00:00',
372
+ tags: [],
373
+ primary_key: [],
374
+ createNodeClientCode:
375
+ 'dj = DJBuilder(DJ_URL)\n\navg_repair_price = dj.create_metric(\n description="Average repair price",\n display_name="Default: Avg Repair Price",\n name="default.avg_repair_price",\n primary_key=[],\n query="""SELECT avg(price) default_DOT_avg_repair_price \n FROM default.repair_order_details\n\n"""\n)',
376
+ dimensions: [
377
+ {
378
+ name: 'default.date_dim.dateint',
379
+ type: 'timestamp',
380
+ path: [
381
+ 'default.repair_order_details.repair_order_id',
382
+ 'default.repair_order.hard_hat_id',
383
+ 'default.hard_hat.birth_date',
384
+ ],
385
+ },
386
+ {
387
+ name: 'default.date_dim.dateint',
388
+ type: 'timestamp',
389
+ path: [
390
+ 'default.repair_order_details.repair_order_id',
391
+ 'default.repair_order.hard_hat_id',
392
+ 'default.hard_hat.hire_date',
393
+ ],
394
+ },
395
+ {
396
+ name: 'default.date_dim.day',
397
+ type: 'int',
398
+ path: [
399
+ 'default.repair_order_details.repair_order_id',
400
+ 'default.repair_order.hard_hat_id',
401
+ 'default.hard_hat.birth_date',
402
+ ],
403
+ },
404
+ {
405
+ name: 'default.date_dim.day',
406
+ type: 'int',
407
+ path: [
408
+ 'default.repair_order_details.repair_order_id',
409
+ 'default.repair_order.hard_hat_id',
410
+ 'default.hard_hat.hire_date',
411
+ ],
412
+ },
413
+ {
414
+ name: 'default.date_dim.month',
415
+ type: 'int',
416
+ path: [
417
+ 'default.repair_order_details.repair_order_id',
418
+ 'default.repair_order.hard_hat_id',
419
+ 'default.hard_hat.birth_date',
420
+ ],
421
+ },
422
+ {
423
+ name: 'default.date_dim.month',
424
+ type: 'int',
425
+ path: [
426
+ 'default.repair_order_details.repair_order_id',
427
+ 'default.repair_order.hard_hat_id',
428
+ 'default.hard_hat.hire_date',
429
+ ],
430
+ },
431
+ {
432
+ name: 'default.date_dim.year',
433
+ type: 'int',
434
+ path: [
435
+ 'default.repair_order_details.repair_order_id',
436
+ 'default.repair_order.hard_hat_id',
437
+ 'default.hard_hat.birth_date',
438
+ ],
439
+ },
440
+ {
441
+ name: 'default.date_dim.year',
442
+ type: 'int',
443
+ path: [
444
+ 'default.repair_order_details.repair_order_id',
445
+ 'default.repair_order.hard_hat_id',
446
+ 'default.hard_hat.hire_date',
447
+ ],
448
+ },
449
+ {
450
+ name: 'default.hard_hat.address',
451
+ type: 'string',
452
+ path: [
453
+ 'default.repair_order_details.repair_order_id',
454
+ 'default.repair_order.hard_hat_id',
455
+ ],
456
+ },
457
+ {
458
+ name: 'default.hard_hat.birth_date',
459
+ type: 'date',
460
+ path: [
461
+ 'default.repair_order_details.repair_order_id',
462
+ 'default.repair_order.hard_hat_id',
463
+ ],
464
+ },
465
+ {
466
+ name: 'default.hard_hat.city',
467
+ type: 'string',
468
+ path: [
469
+ 'default.repair_order_details.repair_order_id',
470
+ 'default.repair_order.hard_hat_id',
471
+ ],
472
+ },
473
+ {
474
+ name: 'default.hard_hat.contractor_id',
475
+ type: 'int',
476
+ path: [
477
+ 'default.repair_order_details.repair_order_id',
478
+ 'default.repair_order.hard_hat_id',
479
+ ],
480
+ },
481
+ {
482
+ name: 'default.hard_hat.country',
483
+ type: 'string',
484
+ path: [
485
+ 'default.repair_order_details.repair_order_id',
486
+ 'default.repair_order.hard_hat_id',
487
+ ],
488
+ },
489
+ {
490
+ name: 'default.hard_hat.first_name',
491
+ type: 'string',
492
+ path: [
493
+ 'default.repair_order_details.repair_order_id',
494
+ 'default.repair_order.hard_hat_id',
495
+ ],
496
+ },
497
+ {
498
+ name: 'default.hard_hat.hard_hat_id',
499
+ type: 'int',
500
+ path: [
501
+ 'default.repair_order_details.repair_order_id',
502
+ 'default.repair_order.hard_hat_id',
503
+ ],
504
+ },
505
+ {
506
+ name: 'default.hard_hat.hire_date',
507
+ type: 'date',
508
+ path: [
509
+ 'default.repair_order_details.repair_order_id',
510
+ 'default.repair_order.hard_hat_id',
511
+ ],
512
+ },
513
+ {
514
+ name: 'default.hard_hat.last_name',
515
+ type: 'string',
516
+ path: [
517
+ 'default.repair_order_details.repair_order_id',
518
+ 'default.repair_order.hard_hat_id',
519
+ ],
520
+ },
521
+ {
522
+ name: 'default.hard_hat.manager',
523
+ type: 'int',
524
+ path: [
525
+ 'default.repair_order_details.repair_order_id',
526
+ 'default.repair_order.hard_hat_id',
527
+ ],
528
+ },
529
+ {
530
+ name: 'default.hard_hat.postal_code',
531
+ type: 'string',
532
+ path: [
533
+ 'default.repair_order_details.repair_order_id',
534
+ 'default.repair_order.hard_hat_id',
535
+ ],
536
+ },
537
+ {
538
+ name: 'default.hard_hat.state',
539
+ type: 'string',
540
+ path: [
541
+ 'default.repair_order_details.repair_order_id',
542
+ 'default.repair_order.hard_hat_id',
543
+ ],
544
+ },
545
+ {
546
+ name: 'default.hard_hat.title',
547
+ type: 'string',
548
+ path: [
549
+ 'default.repair_order_details.repair_order_id',
550
+ 'default.repair_order.hard_hat_id',
551
+ ],
552
+ },
553
+ ],
554
+ },
555
+ };
556
+
557
+ it('renders and calls node_dag with the correct node name', async () => {
558
+ const djClient = mockDJClient();
559
+ djClient.DataJunctionAPI.metric = name => defaultProps.djNode;
560
+ // const layoutFlowMock = jest.spyOn(LayoutFlow);
561
+ const { container } = render(
562
+ <DJClientContext.Provider value={djClient}>
563
+ <NodeLineage {...defaultProps} />
564
+ </DJClientContext.Provider>,
565
+ );
566
+
567
+ await waitFor(() => {
568
+ expect(djClient.DataJunctionAPI.node_dag).toHaveBeenCalledWith(
569
+ defaultProps.djNode.name,
570
+ );
571
+
572
+ // The origin node should be displayed
573
+ expect(screen.getByText('Default: Avg Repair Price')).toBeInTheDocument();
574
+
575
+ // Every node in the DAG should be displayed on the screen
576
+ mockNodeDAG.forEach(node =>
577
+ expect(
578
+ getByAttribute(container, node.name, 'data-id'),
579
+ ).toBeInTheDocument(),
580
+ );
581
+
582
+ const metricNode = getByAttribute(
583
+ container,
584
+ 'default.avg_repair_price',
585
+ 'data-id',
586
+ );
587
+ expect(screen.getByText('▶ Show dimensions')).toBeInTheDocument();
588
+ expect(screen.getByText('▶ More columns')).toBeInTheDocument();
589
+ });
590
+ });
591
+ });
@@ -0,0 +1,57 @@
1
+ import React from 'react';
2
+ import { render, screen, waitFor } from '@testing-library/react';
3
+ import NodeColumnLineage from '../NodeLineageTab';
4
+ import DJClientContext from '../../../providers/djclient';
5
+ import { mocks } from '../../../../mocks/mockNodes';
6
+
7
+ describe('<NodeColumnLineage />', () => {
8
+ const domTestingLib = require('@testing-library/dom');
9
+ const { queryHelpers } = domTestingLib;
10
+
11
+ const queryByAttribute = attribute =>
12
+ queryHelpers.queryAllByAttribute.bind(null, attribute);
13
+
14
+ function getByAttribute(container, id, attribute, ...rest) {
15
+ const result = queryByAttribute(attribute)(container, id, ...rest);
16
+ return result[0];
17
+ }
18
+
19
+ const mockDJClient = () => {
20
+ return {
21
+ DataJunctionAPI: {
22
+ node: jest.fn(),
23
+ metric: jest.fn(),
24
+ node_lineage: jest.fn(name => {
25
+ return mocks.mockNodeLineage;
26
+ }),
27
+ },
28
+ };
29
+ };
30
+
31
+ const defaultProps = {
32
+ djNode: mocks.mockMetricNodeJson,
33
+ };
34
+
35
+ it('renders and calls node_lineage with the correct node name', async () => {
36
+ const djClient = mockDJClient();
37
+ djClient.DataJunctionAPI.metric = name => defaultProps.djNode;
38
+ const { container } = render(
39
+ <DJClientContext.Provider value={djClient}>
40
+ <NodeColumnLineage {...defaultProps} />
41
+ </DJClientContext.Provider>,
42
+ );
43
+
44
+ await waitFor(() => {
45
+ expect(djClient.DataJunctionAPI.node_lineage).toHaveBeenCalledWith(
46
+ defaultProps.djNode.name,
47
+ );
48
+
49
+ // The origin node should be displayed
50
+ expect(screen.getByText('Default: Avg Repair Price')).toBeInTheDocument();
51
+
52
+ expect(
53
+ getByAttribute(container, 'default.avg_repair_price', 'data-id'),
54
+ ).toBeInTheDocument();
55
+ });
56
+ });
57
+ });