@zohodesk/library-platform 1.1.0-exp.1 → 1.1.0-exp.2

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 (116) hide show
  1. package/es/bc/zclient-actions/Constants.js +11 -0
  2. package/es/bc/zclient-actions/EventHandlers.js +1 -0
  3. package/es/bc/zlist/Properties.js +3 -0
  4. package/es/bc/zrecord/Constants.js +3 -1
  5. package/es/cc/table-connected/Properties.js +3 -0
  6. package/es/cc/table-list/Properties.js +32 -8
  7. package/es/cc/table-list/data-types/Header.js +8 -7
  8. package/es/cc/table-list/data-types/RowActionsConfig.js +1 -0
  9. package/es/cc/table-list/data-types/RowCursor.js +8 -0
  10. package/es/cc/table-list/row/Properties.js +16 -3
  11. package/es/desk-frameworks/table-connected/frameworks/TableConnectedFactory.js +4 -1
  12. package/es/desk-frameworks/table-connected/frameworks/TableConnectedView.js +4 -2
  13. package/es/desk-frameworks/table-connected/frameworks/__tests__/TableConnectedFactory.spec.js +453 -0
  14. package/es/desk-frameworks/table-connected/frameworks/__tests__/mock/data-broker/http-template/getAvailableFields.js +86 -0
  15. package/es/desk-frameworks/table-connected/frameworks/__tests__/mock/data-broker/http-template/getRecords.js +81 -0
  16. package/es/desk-frameworks/table-connected/frameworks/__tests__/mock/data-broker/http-template/getSelectedFields.js +32 -0
  17. package/es/desk-frameworks/table-connected/frameworks/__tests__/mock/data-broker/index.js +11 -0
  18. package/es/library/behaviours/list-selection/domain/entities/ListItemSelection.js +29 -9
  19. package/es/library/custom-component/domain/entities/Component.js +8 -4
  20. package/es/library/dot/components/table-list/frameworks/ui/TableListView.js +16 -6
  21. package/es/library/dot/components/table-list/frameworks/ui/css/TableList.module.css +10 -0
  22. package/es/library/dot/components/table-list/frameworks/ui/sub-components/Header.js +7 -6
  23. package/es/library/dot/components/table-list/frameworks/ui/sub-components/Rows.js +9 -7
  24. package/es/library/dot/components/table-list/frameworks/ui/sub-components/header/ActionColumn.js +3 -2
  25. package/es/library/dot/components/table-list/frameworks/ui/sub-components/header/HeaderData.js +2 -4
  26. package/es/library/dot/components/table-list/frameworks/ui/sub-components/header/Headers.js +0 -4
  27. package/es/library/dot/components/table-list/frameworks/ui/sub-components/header/SelectAll.js +4 -4
  28. package/es/library/dot/components/table-list/frameworks/ui/sub-components/row/Columns.js +2 -6
  29. package/es/library/dot/components/table-list/frameworks/ui/sub-components/row/Row.js +13 -7
  30. package/es/library/dot/components/table-list/frameworks/ui/sub-components/row/RowActions.js +2 -1
  31. package/es/library/dot/components/table-list/frameworks/ui/sub-components/row/RowData.js +2 -4
  32. package/es/platform/data-broker/http-template/deleteRecord.js +1 -1
  33. package/es/platform/data-broker/http-template/deleteRecords.js +1 -1
  34. package/es/platform/data-broker/http-template/getAvailableFields.js +1 -1
  35. package/es/platform/data-broker/http-template/getClientActions.js +23 -0
  36. package/es/platform/data-broker/http-template/getRecords.js +1 -1
  37. package/es/platform/data-broker/http-template/getSelectedFields.js +1 -1
  38. package/es/platform/data-broker/http-template/updateRecord.js +1 -1
  39. package/es/platform/data-broker/index.js +3 -3
  40. package/es/platform/zclient-actions/Readme.md +38 -0
  41. package/es/platform/zclient-actions/adapters/controllers/AbstractController.js +8 -0
  42. package/es/platform/zclient-actions/adapters/controllers/ClientActionBehaviourExecutorController.js +27 -0
  43. package/es/platform/zclient-actions/adapters/controllers/FailureController.js +28 -0
  44. package/es/platform/zclient-actions/adapters/controllers/FetchStateStopController.js +21 -0
  45. package/es/platform/zclient-actions/adapters/controllers/MountController.js +25 -0
  46. package/es/platform/zclient-actions/adapters/controllers/NoContentController.js +23 -0
  47. package/es/platform/zclient-actions/adapters/controllers/SetClientActionsController.js +24 -0
  48. package/es/platform/zclient-actions/adapters/controllers/SuccessController.js +28 -0
  49. package/es/platform/zclient-actions/adapters/gateways/Repository.js +28 -0
  50. package/es/platform/zclient-actions/adapters/gateways/Service.js +35 -0
  51. package/es/platform/zclient-actions/adapters/presenters/Presenter.js +24 -0
  52. package/es/platform/zclient-actions/applications/entities-factory/ClientActionFactory.js +12 -0
  53. package/es/platform/zclient-actions/applications/entities-factory/ClientActionManagerFactory.js +10 -0
  54. package/es/platform/zclient-actions/applications/interfaces/InputDependencies.js +1 -0
  55. package/es/platform/zclient-actions/applications/interfaces/gateways/IRepository.js +1 -0
  56. package/es/platform/zclient-actions/applications/interfaces/gateways/IService.js +0 -0
  57. package/es/platform/zclient-actions/applications/interfaces/gateways/State.js +1 -0
  58. package/es/platform/zclient-actions/applications/interfaces/input/ExecuteActionBehaviourInputModel.js +1 -0
  59. package/es/platform/zclient-actions/applications/interfaces/input/FailureInputModel.js +1 -0
  60. package/es/platform/zclient-actions/applications/interfaces/input/FetchStateStopInputModel.js +1 -0
  61. package/es/platform/zclient-actions/applications/interfaces/input/InitializeInputModel.js +1 -0
  62. package/es/platform/zclient-actions/applications/interfaces/input/NoContentInputModel.js +1 -0
  63. package/es/platform/zclient-actions/applications/interfaces/input/SetClientActionsInputModel.js +1 -0
  64. package/es/platform/zclient-actions/applications/interfaces/input/SuccessInputModel.js +1 -0
  65. package/es/platform/zclient-actions/applications/interfaces/output/IPresenter.js +1 -0
  66. package/es/platform/zclient-actions/applications/usecases/AbstractUseCase.js +17 -0
  67. package/es/platform/zclient-actions/applications/usecases/ExecuteActionBehaviourUseCase.js +33 -0
  68. package/es/platform/zclient-actions/applications/usecases/FailureUseCase.js +22 -0
  69. package/es/platform/zclient-actions/applications/usecases/FetchStateStopUseCase.js +25 -0
  70. package/es/platform/zclient-actions/applications/usecases/InitializeUseCase.js +17 -0
  71. package/es/platform/zclient-actions/applications/usecases/NoContentUseCase.js +27 -0
  72. package/es/platform/zclient-actions/applications/usecases/SetClientActionsUseCase.js +21 -0
  73. package/es/platform/zclient-actions/applications/usecases/SuccessUseCase.js +22 -0
  74. package/es/platform/zclient-actions/domain/entities/ClientAction.js +57 -0
  75. package/es/platform/zclient-actions/domain/entities/ClientActionManager.js +141 -0
  76. package/es/platform/zclient-actions/domain/entities/ClientActions.js +54 -0
  77. package/es/platform/zclient-actions/domain/entities/EventMapping.js +32 -0
  78. package/es/platform/zclient-actions/domain/entities/EventMappings.js +15 -0
  79. package/es/platform/zclient-actions/domain/entities/GetClientActionsStrategy.js +44 -0
  80. package/es/platform/zclient-actions/domain/entities/UIComponentMapping.js +37 -0
  81. package/es/platform/zclient-actions/domain/entities/interfaces/BehaviourState.js +1 -0
  82. package/es/platform/zclient-actions/domain/entities/interfaces/ClientActionModel.js +1 -0
  83. package/es/platform/zclient-actions/domain/entities/interfaces/ClientActionsModel.js +1 -0
  84. package/es/platform/zclient-actions/domain/entities/interfaces/ComponentPropertiesModel.js +1 -0
  85. package/es/platform/zclient-actions/domain/entities/interfaces/EventMappingModel.js +1 -0
  86. package/es/platform/zclient-actions/domain/entities/interfaces/EventModel.js +1 -0
  87. package/es/platform/zclient-actions/domain/entities/interfaces/IAction.js +1 -0
  88. package/es/platform/zclient-actions/domain/entities/interfaces/IClientAction.js +0 -0
  89. package/es/platform/zclient-actions/domain/entities/interfaces/IClientActionExecuteStrategy.js +0 -0
  90. package/es/platform/zclient-actions/domain/entities/interfaces/IClientActionManager.js +0 -0
  91. package/es/platform/zclient-actions/domain/entities/interfaces/IClientActions.js +0 -0
  92. package/es/platform/zclient-actions/domain/entities/interfaces/IError.js +1 -0
  93. package/es/platform/zclient-actions/domain/entities/interfaces/IEvent.js +1 -0
  94. package/es/platform/zclient-actions/domain/entities/interfaces/IEventMapping.js +0 -0
  95. package/es/platform/zclient-actions/domain/entities/interfaces/IEventMappings.js +0 -0
  96. package/es/platform/zclient-actions/domain/entities/interfaces/IPayload.js +0 -0
  97. package/es/platform/zclient-actions/domain/entities/interfaces/IUIComponentMapping.js +0 -0
  98. package/es/platform/zclient-actions/domain/entities/interfaces/PayloadValueMappingModel.js +1 -0
  99. package/es/platform/zclient-actions/domain/entities/interfaces/PropsMeta.js +1 -0
  100. package/es/platform/zclient-actions/domain/entities/interfaces/StrategyMeta.js +1 -0
  101. package/es/platform/zclient-actions/domain/entities/interfaces/SubMeta.js +1 -0
  102. package/es/platform/zclient-actions/domain/entities/interfaces/UIComponentMappingModel.js +1 -0
  103. package/es/platform/zclient-actions/domain/entities/interfaces/UserDetailsModel.js +1 -0
  104. package/es/platform/zclient-actions/frameworks/ActionsHandlersFactory.js +47 -0
  105. package/es/platform/zclient-actions/frameworks/ClientActionBehaviourFactory.js +12 -0
  106. package/es/platform/zdata-broker/adapters/controllers/{ActionExecutorController.js → DataBrokerExecutorController.js} +1 -1
  107. package/es/platform/zdata-broker/frameworks/EventHandlersFactory.js +3 -3
  108. package/es/platform/zlist/adapters/gateways/Repository.js +3 -1
  109. package/es/platform/zlist/adapters/presenters/TableTranslator.js +31 -2
  110. package/es/platform/zlist/adapters/presenters/translators/ColumnAlignmentTranslator.js +11 -0
  111. package/es/platform/zlist/adapters/presenters/translators/ColumnSizeTranslator.js +23 -0
  112. package/es/platform/zlist/adapters/presenters/translators/Header.js +4 -3
  113. package/es/platform/zlist/applications/entities-factory/ListFactory.js +3 -2
  114. package/es/platform/zlist/domain/entities/List.js +12 -21
  115. package/package.json +21 -20
  116. package/es/platform/data-broker/http-template/getUIActions.js +0 -22
@@ -0,0 +1,11 @@
1
+ export const SET_CLIENTACTIONS = 'CLIENTACTION#SET_CLIENTACTIONS';
2
+ export const CLIENTACTION_BEHAVIOUR_EXECUTE = 'CLIENTACTION_BEHAVIOUR#EXECUTE';
3
+ export const CLIENTACTION_EXECUTE_SUCCEEDED = 'CLIENTACTION#EXECUTE_SUCCEEDED';
4
+ export const CLIENTACTION_EXECUTE_FAILED = 'CLIENTACTION#EXECUTE_FAILED';
5
+ export const CLIENTACTION_EXECUTE_SUCCEEDED_NO_CONTENT = 'CLIENTACTION#EXECUTE_SUCCEEDED_NO_CONTENT';
6
+ export const CLIENTACTION_EXECUTE_SUCCESS_CALLBACK = 'CLIENTACTION#EXECUTE_SUCCESS_CALLBACK';
7
+ export const CLIENTACTION_EXECUTE_SUCCESS_NO_CONTENT_CALLBACK = 'CLIENTACTION#EXECUTE_SUCCESS_NO_CONTENT_CALLBACK';
8
+ export const CLIENTACTION_EXECUTE_FAIL_CALLBACK = 'CLIENTACTION#EXECUTE_FAIL_CALLBACK';
9
+ export const ClientActionApiActionName = {
10
+ GET_CLIENTACTIONS: "getClientActions"
11
+ };
@@ -0,0 +1 @@
1
+ import { CLIENTACTION_BEHAVIOUR_EXECUTE, CLIENTACTION_EXECUTE_FAIL_CALLBACK, CLIENTACTION_EXECUTE_FAILED, CLIENTACTION_EXECUTE_SUCCEEDED, CLIENTACTION_EXECUTE_SUCCEEDED_NO_CONTENT, CLIENTACTION_EXECUTE_SUCCESS_CALLBACK, CLIENTACTION_EXECUTE_SUCCESS_NO_CONTENT_CALLBACK } from "./Constants";
@@ -38,6 +38,9 @@ export default {
38
38
  orgName: {
39
39
  type: 'string'
40
40
  },
41
+ servicePrefix: {
42
+ type: 'string'
43
+ },
41
44
  departmentName: {
42
45
  type: 'string'
43
46
  },
@@ -22,4 +22,6 @@ _defineProperty(RecordApiActionName, "DELETE_RECORDS", 'deleteRecords');
22
22
 
23
23
  _defineProperty(RecordApiActionName, "DELETE_RECORD", 'deleteRecord');
24
24
 
25
- _defineProperty(RecordApiActionName, "UPDATE_RECORD", 'updateRecord');
25
+ _defineProperty(RecordApiActionName, "UPDATE_RECORD", 'updateRecord');
26
+
27
+ _defineProperty(RecordApiActionName, "GET_CLIENTACTIONS", 'getClientActions');
@@ -23,6 +23,9 @@ export default {
23
23
  fields: {
24
24
  type: 'object'
25
25
  },
26
+ rowActionsComponentName: {
27
+ type: 'string'
28
+ },
26
29
  emptyState: {
27
30
  type: 'string'
28
31
  }
@@ -1,3 +1,5 @@
1
+ import { Alignment, SortedBy, Width } from "./data-types/Header";
2
+ import RowCursor from "./data-types/RowCursor";
1
3
  import ResizerConfigSchema from "../../bc/table-column-resizer/Properties";
2
4
  import { actionsSchema } from "../action-location/Properties";
3
5
  import PropertiesConverter from "../component/properties/PropertiesConverter";
@@ -34,12 +36,24 @@ const TableListProperties = {
34
36
  },
35
37
  defaultValue: ''
36
38
  },
37
- hasRowActions: {
39
+ rowActionsConfig: {
38
40
  required: false,
39
- defaultValue: false,
41
+ defaultValue: {
42
+ hasActions: false,
43
+ columnWidth: Width.XSmall
44
+ },
40
45
  typeMetadata: {
41
46
  schema: {
42
- type: 'boolean'
47
+ type: 'object',
48
+ properties: {
49
+ hasActions: {
50
+ type: 'boolean'
51
+ },
52
+ columnWidth: {
53
+ type: 'number',
54
+ enum: Object.values(Width)
55
+ }
56
+ }
43
57
  }
44
58
  }
45
59
  },
@@ -52,6 +66,16 @@ const TableListProperties = {
52
66
  }
53
67
  }
54
68
  },
69
+ rowCursor: {
70
+ required: false,
71
+ defaultValue: 'pointer',
72
+ typeMetadata: {
73
+ schema: {
74
+ type: 'string',
75
+ enum: Object.values(RowCursor)
76
+ }
77
+ }
78
+ },
55
79
  resizerConfig: {
56
80
  required: false,
57
81
  defaultValue: {
@@ -86,20 +110,20 @@ const TableListProperties = {
86
110
  text: {
87
111
  type: 'string'
88
112
  },
89
- size: {
90
- type: 'string',
91
- enum: ['xsmall', 'small', 'medium', 'large', 'xlarge']
113
+ width: {
114
+ type: 'number',
115
+ enum: Object.values(Width)
92
116
  },
93
117
  alignment: {
94
118
  type: 'string',
95
- enum: ['left', 'center', 'right']
119
+ enum: Object.values(Alignment)
96
120
  },
97
121
  sortable: {
98
122
  type: 'boolean'
99
123
  },
100
124
  sortOrder: {
101
125
  type: 'string',
102
- enum: ['none', 'ascending', 'descending']
126
+ enum: Object.values(SortedBy)
103
127
  },
104
128
  sortTooltip: {
105
129
  type: 'string'
@@ -4,13 +4,14 @@ export let SortedBy = /*#__PURE__*/function (SortedBy) {
4
4
  SortedBy["Descending"] = "descending";
5
5
  return SortedBy;
6
6
  }({});
7
- export let Size = /*#__PURE__*/function (Size) {
8
- Size["XSmall"] = "xsmall";
9
- Size["Small"] = "small";
10
- Size["Medium"] = "medium";
11
- Size["Large"] = "large";
12
- Size["XLarge"] = "xlarge";
13
- return Size;
7
+ export let Width = /*#__PURE__*/function (Width) {
8
+ Width[Width["XSmall"] = 120] = "XSmall";
9
+ Width[Width["Small"] = 160] = "Small";
10
+ Width[Width["Medium"] = 200] = "Medium";
11
+ Width[Width["Large"] = 240] = "Large";
12
+ Width[Width["XLarge"] = 280] = "XLarge";
13
+ Width[Width["XXLarge"] = 320] = "XXLarge";
14
+ return Width;
14
15
  }({});
15
16
  export let Alignment = /*#__PURE__*/function (Alignment) {
16
17
  Alignment["Left"] = "left";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ var RowCursor = /*#__PURE__*/function (RowCursor) {
2
+ RowCursor["Default"] = "default";
3
+ RowCursor["Pointer"] = "pointer";
4
+ RowCursor["NotAllowed"] = "not-allowed";
5
+ return RowCursor;
6
+ }(RowCursor || {});
7
+
8
+ export default RowCursor;
@@ -1,3 +1,5 @@
1
+ import { Width } from "../data-types/Header";
2
+ import RowCursor from "../data-types/RowCursor";
1
3
  const TableRowProperties = {
2
4
  isSelectionEnabled: {
3
5
  required: false,
@@ -53,6 +55,16 @@ const TableRowProperties = {
53
55
  }
54
56
  }
55
57
  },
58
+ cursor: {
59
+ required: false,
60
+ defaultValue: 'pointer',
61
+ typeMetadata: {
62
+ schema: {
63
+ type: 'string',
64
+ enum: Object.values(RowCursor)
65
+ }
66
+ }
67
+ },
56
68
  rowActionLocation: {
57
69
  required: false,
58
70
  defaultValue: {},
@@ -71,12 +83,13 @@ const TableRowProperties = {
71
83
  }
72
84
  }
73
85
  },
74
- resizedColumnsWidth: {
86
+ rowActionsColumnWidth: {
75
87
  required: false,
76
- defaultValue: false,
88
+ defaultValue: Width.XSmall,
77
89
  typeMetadata: {
78
90
  schema: {
79
- type: 'object'
91
+ type: 'number',
92
+ enum: Object.values(Width)
80
93
  }
81
94
  }
82
95
  },
@@ -9,6 +9,7 @@ import EventHandlersFactory from "./EventHandlersFactory";
9
9
  import TableConnectedView from "./TableConnectedView";
10
10
  import defaultDataBroker from "../../../platform/data-broker";
11
11
  import DataBrokerBehaviourFactory from "../../../platform/zdata-broker/frameworks/DataBrokerBehaviourFactory";
12
+ import ClientActionBehaviourFactory from "../../../platform/zclient-actions/frameworks/ClientActionBehaviourFactory";
12
13
  export default class TableConnectedFactory {
13
14
  static create(_ref) {
14
15
  let {
@@ -23,7 +24,9 @@ export default class TableConnectedFactory {
23
24
  properties: Properties,
24
25
  eventHandlers: EventHandlersFactory.create(eventHandlers),
25
26
  transformState: TableTranslator.transformState,
26
- behaviours: [ZHttpBehaviourFactory.create(), DataBrokerBehaviourFactory.create(), RecordBehaviourFactory.create(dataBroker.httpTemplates), ZFieldBehaviourFactory.create({
27
+ behaviours: [ZHttpBehaviourFactory.create(), DataBrokerBehaviourFactory.create(), RecordBehaviourFactory.create(dataBroker.httpTemplates), ClientActionBehaviourFactory.create({
28
+ getClientActions: dataBroker.httpTemplates.getClientActions
29
+ }), ZFieldBehaviourFactory.create({
27
30
  availableFields: dataBroker.httpTemplates.getAvailableFields,
28
31
  selectedFields: dataBroker.httpTemplates.getSelectedFields
29
32
  }), ZListBehaviourFactory.create()]
@@ -9,7 +9,8 @@ function View(_ref, ref) {
9
9
  const {
10
10
  isLoading,
11
11
  data = [],
12
- hasRowActions,
12
+ rowActionsConfig,
13
+ rowCursor,
13
14
  properties,
14
15
  emptyStateUiType
15
16
  } = state;
@@ -19,9 +20,10 @@ function View(_ref, ref) {
19
20
  } = properties;
20
21
  return /*#__PURE__*/React.createElement(TableList, {
21
22
  data: data,
23
+ rowCursor: rowCursor,
22
24
  getRef: ref,
23
25
  isFlexibleColumns: isFlexibleColumns,
24
- hasRowActions: hasRowActions,
26
+ rowActionsConfig: rowActionsConfig,
25
27
  isLoading: isLoading,
26
28
  emptyStateUiType: emptyStateUiType,
27
29
  selectionConfig: selectionConfig
@@ -0,0 +1,453 @@
1
+ import fetchMock from 'jest-fetch-mock';
2
+ import React from 'react';
3
+ import { render, screen, waitFor } from '@testing-library/react';
4
+ import '@testing-library/jest-dom';
5
+ import TableConnectedFactory from "../TableConnectedFactory";
6
+ import dataBroker from "./mock/data-broker";
7
+ describe('Table Connected Factory', () => {
8
+ fetchMock.enableMocks();
9
+ it('should mount the component and check the rendering', () => {
10
+ const TableConnected = TableConnectedFactory.create({
11
+ name: 'TableConnected'
12
+ });
13
+ let {
14
+ container
15
+ } = render( /*#__PURE__*/React.createElement(TableConnected, null));
16
+ expect(container).toBeInTheDocument();
17
+ });
18
+ });
19
+ describe('Table header', () => {
20
+ fetchMock.enableMocks();
21
+ it('Number of Columns', async () => {
22
+ const TableConnected = TableConnectedFactory.create({
23
+ name: 'TableConnected',
24
+ dataBroker
25
+ });
26
+ const filter = {
27
+ viewId: '',
28
+ orgId: '',
29
+ departmentId: ''
30
+ };
31
+ let {
32
+ container
33
+ } = render( /*#__PURE__*/React.createElement(TableConnected, {
34
+ filter: filter,
35
+ limit: 25
36
+ }));
37
+ await waitFor(() => {
38
+ const rows = container.querySelectorAll('th');
39
+ expect(rows.length).toBe(8);
40
+ });
41
+ });
42
+ it('Field names', async () => {
43
+ const TableConnected = TableConnectedFactory.create({
44
+ name: 'TableConnected',
45
+ dataBroker
46
+ });
47
+ const filter = {
48
+ viewId: '',
49
+ orgId: '',
50
+ departmentId: ''
51
+ };
52
+ let {
53
+ container
54
+ } = render( /*#__PURE__*/React.createElement(TableConnected, {
55
+ filter: filter,
56
+ limit: 25
57
+ }));
58
+ await waitFor(() => {
59
+ const rows = container.querySelectorAll('th');
60
+ const columnName = rows[3];
61
+ expect(columnName.textContent).toBe("Is Admin");
62
+ });
63
+ });
64
+ it('Field order', async () => {
65
+ const TableConnected = TableConnectedFactory.create({
66
+ name: 'TableConnected',
67
+ dataBroker
68
+ });
69
+ const filter = {
70
+ viewId: '',
71
+ orgId: '',
72
+ departmentId: ''
73
+ };
74
+ let {
75
+ container
76
+ } = render( /*#__PURE__*/React.createElement(TableConnected, {
77
+ filter: filter,
78
+ limit: 25
79
+ }));
80
+ await waitFor(() => {
81
+ const rows = container.querySelectorAll('th');
82
+ const rowsText = [];
83
+ rows.forEach(row => {
84
+ rowsText.push(row.textContent);
85
+ });
86
+ const columnOrder = ['ID', 'Name', 'Email', 'Is Admin', 'Created Time', 'Created By', 'Owner', 'URL'];
87
+ expect(rowsText).toStrictEqual(columnOrder);
88
+ });
89
+ });
90
+ });
91
+ describe('Table body', () => {
92
+ fetchMock.enableMocks();
93
+ it('The Table should have 5 records after fetch', async () => {
94
+ const TableConnected = TableConnectedFactory.create({
95
+ name: 'TableConnected',
96
+ dataBroker
97
+ });
98
+ const filter = {
99
+ viewId: '',
100
+ orgId: '',
101
+ departmentId: ''
102
+ };
103
+ let {
104
+ container
105
+ } = render( /*#__PURE__*/React.createElement(TableConnected, {
106
+ filter: filter,
107
+ limit: 5
108
+ }));
109
+ await waitFor(() => {
110
+ var _container$querySelec;
111
+
112
+ const rows = (_container$querySelec = container.querySelector('tbody')) === null || _container$querySelec === void 0 ? void 0 : _container$querySelec.childNodes;
113
+ expect(rows.length).toBe(5);
114
+ });
115
+ }); // fit('The Table should render 5 records on scroll to the end', async () => {
116
+ // const TableConnected = TableConnectedFactory.create({ name: 'TableConnected', dataBroker });
117
+ // const filter = { viewId: '', orgId: '', departmentId: '' };
118
+ // let { container } = render(
119
+ // <div id="tableContainer" style={{ height: '300px', width: '100%' }}>
120
+ // <TableConnected filter={filter} limit={15} />
121
+ // </div>
122
+ // );
123
+ // await waitFor(() => {
124
+ // const rows = container.querySelector('tbody')?.childNodes;
125
+ // expect(rows?.length).toBe(15);
126
+ // });
127
+ // const scrollableElement = container.querySelector('table');
128
+ // if (scrollableElement) {
129
+ // Object.defineProperty(scrollableElement, 'scrollHeight', { value: 2000, writable: true });
130
+ // Object.defineProperty(scrollableElement, 'clientHeight', { value: 300, writable: true });
131
+ // // fireEvent.scroll(scrollableElement, { target: { scrollTop: 2000 } });
132
+ // // fireEvent.scroll(scrollableElement, new Event('scroll'));
133
+ // scrollableElement.scrollTop = 2000;
134
+ // scrollableElement.dispatchEvent(new Event('scroll'));
135
+ // }
136
+ // });
137
+ // });
138
+ });
139
+ describe('Field cases', () => {
140
+ fetchMock.enableMocks();
141
+ it('Field type order', async () => {
142
+ const TableConnected = TableConnectedFactory.create({
143
+ name: 'TableConnected',
144
+ dataBroker
145
+ });
146
+ const uiMapping = {
147
+ fields: {
148
+ "cf_isAdmin": "Switch"
149
+ }
150
+ };
151
+ const filter = {
152
+ viewId: '',
153
+ orgId: '',
154
+ departmentId: ''
155
+ };
156
+ let {
157
+ container
158
+ } = render( /*#__PURE__*/React.createElement(TableConnected, {
159
+ uiMapping: uiMapping,
160
+ filter: filter,
161
+ limit: 1
162
+ }));
163
+ await waitFor(() => {
164
+ const rows = container.querySelectorAll('td');
165
+ const rowsText = [];
166
+ rows.forEach(row => {
167
+ rowsText.push(row.textContent);
168
+ });
169
+ const columnOrder = ['1', 'Record 1', 'odin@asgard@thundermail.com', "", '2025-01-13T07:01:50.686Z', 'ODOdin ', 'GodSpecies', 'https://en.wikipedia.org/wiki/Asgard'];
170
+ expect(rowsText).toStrictEqual(columnOrder);
171
+ });
172
+ });
173
+ it('Text rendered', async () => {
174
+ const TableConnected = TableConnectedFactory.create({
175
+ name: 'TableConnected',
176
+ dataBroker: dataBroker
177
+ });
178
+ const uiMapping = {
179
+ fields: {
180
+ "cf_isAdmin": "Switch"
181
+ }
182
+ };
183
+ const filter = {
184
+ viewId: '',
185
+ orgId: '',
186
+ departmentId: ''
187
+ };
188
+ let {
189
+ container
190
+ } = render( /*#__PURE__*/React.createElement(TableConnected, {
191
+ uiMapping: uiMapping,
192
+ filter: filter,
193
+ limit: 1
194
+ }));
195
+ await waitFor(() => {
196
+ const rows = container.querySelectorAll('td');
197
+ const rowsText = [];
198
+ rows.forEach(row => {
199
+ rowsText.push(row.textContent);
200
+ });
201
+ const textEle = "ODOdin ";
202
+ expect(rowsText[5]).toStrictEqual(textEle);
203
+ });
204
+ });
205
+ it('Switch rendered', async () => {
206
+ const TableConnected = TableConnectedFactory.create({
207
+ name: 'TableConnected',
208
+ dataBroker: dataBroker
209
+ });
210
+ const uiMapping = {
211
+ fields: {
212
+ "cf_isAdmin": "Switch"
213
+ }
214
+ };
215
+ const filter = {
216
+ viewId: '',
217
+ orgId: '',
218
+ departmentId: ''
219
+ };
220
+ let {
221
+ container
222
+ } = render( /*#__PURE__*/React.createElement(TableConnected, {
223
+ uiMapping: uiMapping,
224
+ filter: filter,
225
+ limit: 25
226
+ }));
227
+ await waitFor(() => {
228
+ expect(screen.getByText('Is Admin')).toBeInTheDocument();
229
+ const switchField = screen.getAllByRole('switch');
230
+ const firstSwitch = switchField[0];
231
+ expect(firstSwitch).toBeInTheDocument();
232
+ });
233
+ });
234
+ it('Switch checked', async () => {
235
+ const TableConnected = TableConnectedFactory.create({
236
+ name: 'TableConnected',
237
+ dataBroker: dataBroker
238
+ });
239
+ const uiMapping = {
240
+ fields: {
241
+ "cf_isAdmin": "Switch"
242
+ }
243
+ };
244
+ const filter = {
245
+ viewId: '',
246
+ orgId: '',
247
+ departmentId: ''
248
+ };
249
+ let {
250
+ container
251
+ } = render( /*#__PURE__*/React.createElement(TableConnected, {
252
+ uiMapping: uiMapping,
253
+ filter: filter,
254
+ limit: 25
255
+ }));
256
+ await waitFor(() => {
257
+ expect(screen.getByText('Is Admin')).toBeInTheDocument();
258
+ const switchField = screen.getAllByRole('switch');
259
+ const firstSwitch = switchField[1];
260
+ const isChecked = firstSwitch.getAttribute('aria-checked');
261
+ expect(isChecked).toBe('true');
262
+ });
263
+ });
264
+ it('Switch unchecked', async () => {
265
+ const TableConnected = TableConnectedFactory.create({
266
+ name: 'TableConnected',
267
+ dataBroker: dataBroker
268
+ });
269
+ const uiMapping = {
270
+ fields: {
271
+ "cf_isAdmin": "Switch"
272
+ }
273
+ };
274
+ const filter = {
275
+ viewId: '',
276
+ orgId: '',
277
+ departmentId: ''
278
+ };
279
+ let {
280
+ container
281
+ } = render( /*#__PURE__*/React.createElement(TableConnected, {
282
+ uiMapping: uiMapping,
283
+ filter: filter,
284
+ limit: 25
285
+ }));
286
+ await waitFor(() => {
287
+ expect(screen.getByText('Is Admin')).toBeInTheDocument();
288
+ const switchField = screen.getAllByRole('switch');
289
+ const firstSwitch = switchField[0];
290
+ const isChecked = firstSwitch.getAttribute('aria-checked');
291
+ expect(isChecked).toBe('false');
292
+ });
293
+ });
294
+ it('Checkbox rendered', async () => {
295
+ const TableConnected = TableConnectedFactory.create({
296
+ name: 'TableConnected',
297
+ dataBroker: dataBroker
298
+ });
299
+ const filter = {
300
+ viewId: '',
301
+ orgId: '',
302
+ departmentId: ''
303
+ };
304
+ let {
305
+ container
306
+ } = render( /*#__PURE__*/React.createElement(TableConnected, {
307
+ filter: filter,
308
+ limit: 25
309
+ }));
310
+ await waitFor(() => {
311
+ expect(screen.getByText('Is Admin')).toBeInTheDocument();
312
+ const checkboxField = screen.getAllByRole('checkbox');
313
+ const firstCheckbox = checkboxField[0];
314
+ expect(firstCheckbox).toBeInTheDocument();
315
+ });
316
+ });
317
+ it('Checkbox checked', async () => {
318
+ const TableConnected = TableConnectedFactory.create({
319
+ name: 'TableConnected',
320
+ dataBroker: dataBroker
321
+ });
322
+ const filter = {
323
+ viewId: '',
324
+ orgId: '',
325
+ departmentId: ''
326
+ };
327
+ let {
328
+ container
329
+ } = render( /*#__PURE__*/React.createElement(TableConnected, {
330
+ filter: filter,
331
+ limit: 25
332
+ }));
333
+ await waitFor(() => {
334
+ expect(screen.getByText('Is Admin')).toBeInTheDocument();
335
+ const checkboxField = screen.getAllByRole('checkbox');
336
+ const firstCheckbox = checkboxField[1];
337
+ const isChecked = firstCheckbox.checked;
338
+ expect(isChecked).toBe(true);
339
+ });
340
+ });
341
+ it('Checkbox unchecked', async () => {
342
+ const TableConnected = TableConnectedFactory.create({
343
+ name: 'TableConnected',
344
+ dataBroker: dataBroker
345
+ });
346
+ const filter = {
347
+ viewId: '',
348
+ orgId: '',
349
+ departmentId: ''
350
+ };
351
+ let {
352
+ container
353
+ } = render( /*#__PURE__*/React.createElement(TableConnected, {
354
+ filter: filter,
355
+ limit: 25
356
+ }));
357
+ await waitFor(() => {
358
+ expect(screen.getByText('Is Admin')).toBeInTheDocument();
359
+ const checkboxField = screen.getAllByRole('checkbox');
360
+ const firstCheckbox = checkboxField[0];
361
+ const isChecked = firstCheckbox.checked;
362
+ expect(isChecked).toBe(false);
363
+ });
364
+ });
365
+ it('Tags rendered', async () => {
366
+ const TableConnected = TableConnectedFactory.create({
367
+ name: 'TableConnected',
368
+ dataBroker: dataBroker
369
+ });
370
+ const filter = {
371
+ viewId: '',
372
+ orgId: '',
373
+ departmentId: ''
374
+ };
375
+ let {
376
+ container
377
+ } = render( /*#__PURE__*/React.createElement(TableConnected, {
378
+ filter: filter,
379
+ limit: 25
380
+ }));
381
+ await waitFor(() => {
382
+ expect(screen.getByText('Owner')).toBeInTheDocument();
383
+ const rows = container.querySelectorAll('[data-title="God"]');
384
+ expect(rows[0]).toBeInTheDocument();
385
+ });
386
+ });
387
+ it('Avatar rendered', async () => {
388
+ const TableConnected = TableConnectedFactory.create({
389
+ name: 'TableConnected',
390
+ dataBroker: dataBroker
391
+ });
392
+ const filter = {
393
+ viewId: '',
394
+ orgId: '',
395
+ departmentId: ''
396
+ };
397
+ let {
398
+ container
399
+ } = render( /*#__PURE__*/React.createElement(TableConnected, {
400
+ filter: filter,
401
+ limit: 25
402
+ }));
403
+ await waitFor(() => {
404
+ expect(screen.getByText('Created By')).toBeInTheDocument();
405
+ const rows = container.querySelectorAll('[data-title="Odin "]');
406
+ expect(rows[0]).toBeInTheDocument();
407
+ });
408
+ });
409
+ it('Email rendered', async () => {
410
+ const TableConnected = TableConnectedFactory.create({
411
+ name: 'TableConnected',
412
+ dataBroker: dataBroker
413
+ });
414
+ const filter = {
415
+ viewId: '',
416
+ orgId: '',
417
+ departmentId: ''
418
+ };
419
+ let {
420
+ container
421
+ } = render( /*#__PURE__*/React.createElement(TableConnected, {
422
+ filter: filter,
423
+ limit: 25
424
+ }));
425
+ await waitFor(() => {
426
+ expect(screen.getByText('Email')).toBeInTheDocument();
427
+ const rows = container.querySelectorAll('[data-title="odin@asgard@thundermail.com"]');
428
+ expect(rows[0]).toBeInTheDocument();
429
+ });
430
+ });
431
+ it('URL rendered', async () => {
432
+ const TableConnected = TableConnectedFactory.create({
433
+ name: 'TableConnected',
434
+ dataBroker: dataBroker
435
+ });
436
+ const filter = {
437
+ viewId: '',
438
+ orgId: '',
439
+ departmentId: ''
440
+ };
441
+ let {
442
+ container
443
+ } = render( /*#__PURE__*/React.createElement(TableConnected, {
444
+ filter: filter,
445
+ limit: 25
446
+ }));
447
+ await waitFor(() => {
448
+ expect(screen.getByText('URL')).toBeInTheDocument();
449
+ const rows = container.querySelectorAll('[data-title="https://en.wikipedia.org/wiki/Asgard"]');
450
+ expect(rows[0]).toBeInTheDocument();
451
+ });
452
+ });
453
+ });