@genesislcap/pbc-reporting-ui 15.19.0 → 15.19.1
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.
- package/dist/custom-elements.json +4247 -5382
- package/dist/dts/react.d.ts +44 -44
- package/dist/react.cjs +65 -65
- package/dist/react.mjs +57 -57
- package/package.json +22 -23
- package/.env +0 -3
- package/api-extractor.json +0 -4
- package/dist/dts/new/main/edit-config/col-filters/col-filters-grid.helpers.test.d.ts +0 -2
- package/dist/dts/new/main/edit-config/col-filters/col-filters-grid.helpers.test.d.ts.map +0 -1
- package/dist/dts/new/main/edit-config/col-rename-alias/col-rename-alias-grid.helpers.test.d.ts +0 -2
- package/dist/dts/new/main/edit-config/col-rename-alias/col-rename-alias-grid.helpers.test.d.ts.map +0 -1
- package/dist/dts/new/main/edit-config/data-transforms-derived-fields/data-transforms.helpers.test.d.ts +0 -2
- package/dist/dts/new/main/edit-config/data-transforms-derived-fields/data-transforms.helpers.test.d.ts.map +0 -1
- package/dist/dts/new/main/edit-config/datasource-config/datasources-config-container.helpers.test.d.ts +0 -2
- package/dist/dts/new/main/edit-config/datasource-config/datasources-config-container.helpers.test.d.ts.map +0 -1
- package/dist/dts/new/main/edit-config/row-filters/row-filters.helpers.test.d.ts +0 -2
- package/dist/dts/new/main/edit-config/row-filters/row-filters.helpers.test.d.ts.map +0 -1
- package/dist/dts/new/main/edit-config/shared/datasource-data-base-component.test.d.ts +0 -5
- package/dist/dts/new/main/edit-config/shared/datasource-data-base-component.test.d.ts.map +0 -1
- package/dist/dts/new/utils/alias-generator.test.d.ts +0 -2
- package/dist/dts/new/utils/alias-generator.test.d.ts.map +0 -1
- package/dist/dts/new/utils/endpoint.test.d.ts +0 -2
- package/dist/dts/new/utils/endpoint.test.d.ts.map +0 -1
- package/dist/dts/new/utils/transformers.test.d.ts +0 -2
- package/dist/dts/new/utils/transformers.test.d.ts.map +0 -1
- package/dist/dts/new/utils/validators.test.d.ts +0 -2
- package/dist/dts/new/utils/validators.test.d.ts.map +0 -1
- package/dist/dts/old/main/main.test.d.ts +0 -2
- package/dist/dts/old/main/main.test.d.ts.map +0 -1
- package/dist/dts/old/utils/filterObjectArray.test.d.ts +0 -2
- package/dist/dts/old/utils/filterObjectArray.test.d.ts.map +0 -1
- package/dist/esm/new/main/edit-config/col-filters/col-filters-grid.helpers.test.js +0 -200
- package/dist/esm/new/main/edit-config/col-rename-alias/col-rename-alias-grid.helpers.test.js +0 -152
- package/dist/esm/new/main/edit-config/data-transforms-derived-fields/data-transforms.helpers.test.js +0 -629
- package/dist/esm/new/main/edit-config/datasource-config/datasources-config-container.helpers.test.js +0 -268
- package/dist/esm/new/main/edit-config/row-filters/row-filters.helpers.test.js +0 -1
- package/dist/esm/new/main/edit-config/shared/datasource-data-base-component.test.js +0 -426
- package/dist/esm/new/utils/alias-generator.test.js +0 -36
- package/dist/esm/new/utils/endpoint.test.js +0 -162
- package/dist/esm/new/utils/transformers.test.js +0 -469
- package/dist/esm/new/utils/validators.test.js +0 -139
- package/dist/esm/old/main/main.test.js +0 -5
- package/dist/esm/old/utils/filterObjectArray.test.js +0 -46
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/src/globals.d.ts +0 -7
- package/src/index.federated.ts +0 -1
- package/src/index.ts +0 -8
- package/src/new/components/clone-report-config-modal/clone-report-config-modal.styles.ts +0 -47
- package/src/new/components/clone-report-config-modal/clone-report-config-modal.template.ts +0 -55
- package/src/new/components/clone-report-config-modal/clone-report-config-modal.ts +0 -173
- package/src/new/components/components.ts +0 -118
- package/src/new/components/renderers/data-transform-renderer.ts +0 -111
- package/src/new/components/reporting-configurations/reporting-configurations.styles.ts +0 -42
- package/src/new/components/reporting-configurations/reporting-configurations.template.ts +0 -59
- package/src/new/components/reporting-configurations/reporting-configurations.ts +0 -366
- package/src/new/components/shared/file-template-picker.template.ts +0 -45
- package/src/new/lib/redux-store/README.md +0 -55
- package/src/new/lib/redux-store/index.ts +0 -2
- package/src/new/lib/redux-store/state-utils.ts +0 -1
- package/src/new/lib/redux-store/store.ts +0 -135
- package/src/new/main/edit-config/base-config/base-config.styles.ts +0 -26
- package/src/new/main/edit-config/base-config/base-config.template.ts +0 -71
- package/src/new/main/edit-config/base-config/base-config.ts +0 -116
- package/src/new/main/edit-config/col-filters/col-filters-grid.helpers.test.ts +0 -232
- package/src/new/main/edit-config/col-filters/col-filters-grid.helpers.ts +0 -35
- package/src/new/main/edit-config/col-filters/col-filters-grid.styles.ts +0 -22
- package/src/new/main/edit-config/col-filters/col-filters-grid.ts +0 -150
- package/src/new/main/edit-config/col-filters/col-filters-grid.types.ts +0 -7
- package/src/new/main/edit-config/col-filters/col-filters-tutorial.ts +0 -25
- package/src/new/main/edit-config/col-filters/col-fitlers-grid.template.ts +0 -15
- package/src/new/main/edit-config/col-rename-alias/col-rename-alias-grid.helpers.test.ts +0 -187
- package/src/new/main/edit-config/col-rename-alias/col-rename-alias-grid.helpers.ts +0 -89
- package/src/new/main/edit-config/col-rename-alias/col-rename-alias-grid.styles.ts +0 -22
- package/src/new/main/edit-config/col-rename-alias/col-rename-alias-grid.template.ts +0 -14
- package/src/new/main/edit-config/col-rename-alias/col-rename-alias-grid.ts +0 -119
- package/src/new/main/edit-config/col-rename-alias/col-rename-alias-grid.types.ts +0 -10
- package/src/new/main/edit-config/col-rename-alias/col-rename-alias-tutorial.ts +0 -33
- package/src/new/main/edit-config/config-journey-orchestrator.styles.ts +0 -120
- package/src/new/main/edit-config/config-journey-orchestrator.template.ts +0 -149
- package/src/new/main/edit-config/config-journey-orchestrator.ts +0 -92
- package/src/new/main/edit-config/data-transforms-derived-fields/data-transforms-tutorial.ts +0 -127
- package/src/new/main/edit-config/data-transforms-derived-fields/data-transforms.helpers.test.ts +0 -799
- package/src/new/main/edit-config/data-transforms-derived-fields/data-transforms.helpers.ts +0 -371
- package/src/new/main/edit-config/data-transforms-derived-fields/data-transforms.styles.ts +0 -22
- package/src/new/main/edit-config/data-transforms-derived-fields/data-transforms.template.ts +0 -21
- package/src/new/main/edit-config/data-transforms-derived-fields/data-transforms.ts +0 -162
- package/src/new/main/edit-config/data-transforms-derived-fields/data-transforms.types.ts +0 -211
- package/src/new/main/edit-config/data-transforms-derived-fields/date-format-modal/date-format-modal.styles.ts +0 -79
- package/src/new/main/edit-config/data-transforms-derived-fields/date-format-modal/date-format-modal.template.ts +0 -217
- package/src/new/main/edit-config/data-transforms-derived-fields/date-format-modal/date-format-modal.ts +0 -280
- package/src/new/main/edit-config/data-transforms-derived-fields/date-format-modal/index.ts +0 -1
- package/src/new/main/edit-config/data-transforms-derived-fields/format-warning.ts +0 -43
- package/src/new/main/edit-config/data-transforms-derived-fields/number-format-modal/index.ts +0 -1
- package/src/new/main/edit-config/data-transforms-derived-fields/number-format-modal/number-format-modal.styles.ts +0 -68
- package/src/new/main/edit-config/data-transforms-derived-fields/number-format-modal/number-format-modal.template.ts +0 -93
- package/src/new/main/edit-config/data-transforms-derived-fields/number-format-modal/number-format-modal.ts +0 -152
- package/src/new/main/edit-config/datasource-config/datasource-config-container.styles.ts +0 -22
- package/src/new/main/edit-config/datasource-config/datasource-config-item.styles.ts +0 -76
- package/src/new/main/edit-config/datasource-config/datasource-config-item.template.ts +0 -141
- package/src/new/main/edit-config/datasource-config/datasource-config-item.ts +0 -212
- package/src/new/main/edit-config/datasource-config/datasources-config-container.helpers.test.ts +0 -341
- package/src/new/main/edit-config/datasource-config/datasources-config-container.helpers.ts +0 -99
- package/src/new/main/edit-config/datasource-config/datasources-config-container.template.ts +0 -68
- package/src/new/main/edit-config/datasource-config/datasources-config-container.ts +0 -55
- package/src/new/main/edit-config/datasource-config/types.ts +0 -6
- package/src/new/main/edit-config/outputs-config/outputs-config.style.ts +0 -11
- package/src/new/main/edit-config/outputs-config/outputs-config.template.ts +0 -66
- package/src/new/main/edit-config/outputs-config/outputs-config.ts +0 -66
- package/src/new/main/edit-config/row-filters/row-filters-tutorial.styles.ts +0 -16
- package/src/new/main/edit-config/row-filters/row-filters-tutorial.template.ts +0 -229
- package/src/new/main/edit-config/row-filters/row-filters-tutorial.ts +0 -15
- package/src/new/main/edit-config/row-filters/row-filters.helpers.test.ts +0 -2
- package/src/new/main/edit-config/row-filters/row-filters.helpers.ts +0 -53
- package/src/new/main/edit-config/row-filters/row-filters.styles.ts +0 -23
- package/src/new/main/edit-config/row-filters/row-filters.template.ts +0 -15
- package/src/new/main/edit-config/row-filters/row-filters.ts +0 -58
- package/src/new/main/edit-config/row-filters/row-filters.types.ts +0 -14
- package/src/new/main/edit-config/scheduling/scheduling.styles.ts +0 -59
- package/src/new/main/edit-config/scheduling/scheduling.template.ts +0 -80
- package/src/new/main/edit-config/scheduling/scheduling.ts +0 -101
- package/src/new/main/edit-config/shared/datasource-data-base-component.helpers.ts.ts +0 -250
- package/src/new/main/edit-config/shared/datasource-data-base-component.test.ts +0 -568
- package/src/new/main/edit-config/shared/datasource-data-base-component.ts +0 -65
- package/src/new/main/edit-config/shared/datasource-data-base-component.types.ts +0 -55
- package/src/new/main/edit-config/shared/index.ts +0 -3
- package/src/new/main/edit-config/tabbed-datasource-container/index.ts +0 -2
- package/src/new/main/edit-config/tabbed-datasource-container/tabbed-datasource-container.styles.ts +0 -12
- package/src/new/main/edit-config/tabbed-datasource-container/tabbed-datasource-container.template.ts +0 -29
- package/src/new/main/edit-config/tabbed-datasource-container/tabbed-datasource-container.ts +0 -69
- package/src/new/main/edit-config/tabbed-datasource-container/tabbed-datasource-container.types.ts +0 -7
- package/src/new/main/generated-reports/generated-reports.styles.ts +0 -15
- package/src/new/main/generated-reports/generated-reports.template.ts +0 -29
- package/src/new/main/generated-reports/generated-reports.ts +0 -270
- package/src/new/main/index.ts +0 -3
- package/src/new/main/main.styles.ts +0 -31
- package/src/new/main/main.template.ts +0 -92
- package/src/new/main/main.ts +0 -117
- package/src/new/main/report-destinations/report-destinations.template.ts +0 -39
- package/src/new/main/report-destinations/report-destinations.ts +0 -63
- package/src/new/store/index.ts +0 -3
- package/src/new/store/slices/base-config.ts +0 -50
- package/src/new/store/slices/datasources-config.ts +0 -297
- package/src/new/store/slices/index.ts +0 -3
- package/src/new/store/slices/types.ts +0 -90
- package/src/new/store/store.ts +0 -36
- package/src/new/store/types.ts +0 -10
- package/src/new/styles/constraints.styles.ts +0 -32
- package/src/new/styles/forms.styles.ts +0 -38
- package/src/new/styles/index.ts +0 -3
- package/src/new/styles/misc.styles.ts +0 -25
- package/src/new/types/display.ts +0 -4
- package/src/new/types/index.ts +0 -4
- package/src/new/types/misc.ts +0 -73
- package/src/new/types/redux.ts +0 -73
- package/src/new/types/rights.ts +0 -28
- package/src/new/utils/alias-generator.test.ts +0 -44
- package/src/new/utils/alias-generator.ts +0 -18
- package/src/new/utils/date-filter-params.ts +0 -28
- package/src/new/utils/endpoint.test.ts +0 -193
- package/src/new/utils/endpoint.ts +0 -62
- package/src/new/utils/event-map.ts +0 -11
- package/src/new/utils/format-utils.ts +0 -22
- package/src/new/utils/formatters.ts +0 -36
- package/src/new/utils/index.ts +0 -10
- package/src/new/utils/notifications.ts +0 -9
- package/src/new/utils/renderer.ts +0 -38
- package/src/new/utils/rights.ts +0 -66
- package/src/new/utils/sorter.ts +0 -19
- package/src/new/utils/tooltip.ts +0 -94
- package/src/new/utils/transformers.test.ts +0 -549
- package/src/new/utils/transformers.ts +0 -174
- package/src/new/utils/validators.test.ts +0 -165
- package/src/new/utils/validators.ts +0 -81
- package/src/old/assets/images/index.ts +0 -69
- package/src/old/components/create-edit/create-edit.styles.ts +0 -16
- package/src/old/components/create-edit/create-edit.template.ts +0 -15
- package/src/old/components/create-edit/create-edit.ts +0 -70
- package/src/old/components/create-edit/index.ts +0 -3
- package/src/old/components/list/columns.ts +0 -175
- package/src/old/components/list/index.ts +0 -3
- package/src/old/components/list/list.styles.ts +0 -9
- package/src/old/components/list/list.template.ts +0 -40
- package/src/old/components/list/list.ts +0 -109
- package/src/old/components/preview/columns.ts +0 -58
- package/src/old/components/preview/index.ts +0 -3
- package/src/old/components/preview/preview.styles.ts +0 -22
- package/src/old/components/preview/preview.template.ts +0 -33
- package/src/old/components/preview/preview.ts +0 -143
- package/src/old/components/rapid-components.ts +0 -64
- package/src/old/components/renderers/custom-header-component.ts +0 -92
- package/src/old/components/renderers/filter-value-renderer.ts +0 -237
- package/src/old/components/renderers/row-select.renderer.ts +0 -148
- package/src/old/components/select-fields/columns.ts +0 -83
- package/src/old/components/select-fields/data.ts +0 -218
- package/src/old/components/select-fields/index.ts +0 -3
- package/src/old/components/select-fields/select-fields.styles.ts +0 -22
- package/src/old/components/select-fields/select-fields.template.ts +0 -58
- package/src/old/components/select-fields/select-fields.ts +0 -218
- package/src/old/components/select-filters/columns.ts +0 -78
- package/src/old/components/select-filters/index.ts +0 -3
- package/src/old/components/select-filters/select-filters.styles.ts +0 -21
- package/src/old/components/select-filters/select-filters.template.ts +0 -58
- package/src/old/components/select-filters/select-filters.ts +0 -255
- package/src/old/components/wizard/debug.ts +0 -35
- package/src/old/components/wizard/index.ts +0 -2
- package/src/old/components/wizard/steps/filters.ts +0 -13
- package/src/old/components/wizard/steps/index.ts +0 -4
- package/src/old/components/wizard/steps/name.ts +0 -72
- package/src/old/components/wizard/steps/run.ts +0 -14
- package/src/old/components/wizard/steps/select.ts +0 -14
- package/src/old/components/wizard/wizard.styles.ts +0 -198
- package/src/old/components/wizard/wizard.template.ts +0 -147
- package/src/old/components/wizard/wizard.ts +0 -398
- package/src/old/components/wizard/wizard.types.ts +0 -43
- package/src/old/components/zero-components.ts +0 -61
- package/src/old/config/config.ts +0 -59
- package/src/old/config/configure.ts +0 -66
- package/src/old/config/index.ts +0 -2
- package/src/old/config/templates.ts +0 -59
- package/src/old/constants/grid-config.ts +0 -19
- package/src/old/layouts/default.ts +0 -30
- package/src/old/layouts/index.ts +0 -2
- package/src/old/layouts/two-pane-horizontal.ts +0 -81
- package/src/old/main/index.ts +0 -3
- package/src/old/main/main.styles.ts +0 -69
- package/src/old/main/main.template.ts +0 -127
- package/src/old/main/main.test.ts +0 -7
- package/src/old/main/main.ts +0 -250
- package/src/old/main/types.ts +0 -29
- package/src/old/styles/colors.ts +0 -16
- package/src/old/styles/helpers.ts +0 -181
- package/src/old/styles/index.ts +0 -4
- package/src/old/styles/normalize.ts +0 -14
- package/src/old/styles/styles.ts +0 -24
- package/src/old/tags/index.ts +0 -1
- package/src/old/tags/tags.ts +0 -79
- package/src/old/tsconfig.json +0 -10
- package/src/old/utils/filterObjectArray.test.ts +0 -110
- package/src/old/utils/filterObjectArray.ts +0 -23
- package/src/old/utils/getFiltersByType.ts +0 -92
- package/src/old/utils/getSelectedFields.ts +0 -16
- package/src/old/utils/index.ts +0 -4
- package/src/old/utils/logger.ts +0 -3
- package/src/sandbox.ts +0 -51
- package/src/tsconfig.base.json +0 -24
- package/src/typings.d.ts +0 -1
- package/tsconfig.json +0 -9
|
@@ -1,426 +0,0 @@
|
|
|
1
|
-
import { assert, sinon, suite } from '@genesislcap/foundation-testing';
|
|
2
|
-
import { actions, selectors } from '../../../store';
|
|
3
|
-
import { convertToPathFormat, datasourceNameForDisplay, datasourceNameFromDisplay, lookupColumnIsIncluded, mapTypeToRenderer, pathParameters, shouldDisableColumn, configureDisabledColumns, } from './datasource-data-base-component.helpers.ts';
|
|
4
|
-
import { GridColumnNames } from './datasource-data-base-component.types';
|
|
5
|
-
// Helper function to create consistent test data
|
|
6
|
-
function createTestRowData(overrides = {}) {
|
|
7
|
-
const result = {
|
|
8
|
-
[GridColumnNames.ColumnName]: 'testColumn',
|
|
9
|
-
[GridColumnNames.DisplayName]: 'Test Column',
|
|
10
|
-
[GridColumnNames.Type]: 'STRING',
|
|
11
|
-
[GridColumnNames.Datasource]: 'Test (Snapshot)',
|
|
12
|
-
};
|
|
13
|
-
// Apply overrides properly
|
|
14
|
-
return Object.assign(Object.assign({}, result), overrides);
|
|
15
|
-
}
|
|
16
|
-
// Type for SelectRendererParams
|
|
17
|
-
const FIRST_PARAM = 0;
|
|
18
|
-
// DatasourceNameFromDisplay tests
|
|
19
|
-
const DatasourceNameFromDisplayTests = suite('datasourceNameFromDisplay()');
|
|
20
|
-
DatasourceNameFromDisplayTests.before.each(() => {
|
|
21
|
-
sinon.restore();
|
|
22
|
-
});
|
|
23
|
-
DatasourceNameFromDisplayTests('Correctly builds datasource key from Snapshot (REQ_REP) input', () => {
|
|
24
|
-
const input = 'myService (Snapshot)';
|
|
25
|
-
const expected = 'REQ_REP_myService_myService';
|
|
26
|
-
assert.equal(datasourceNameFromDisplay(input), expected);
|
|
27
|
-
});
|
|
28
|
-
DatasourceNameFromDisplayTests('Correctly builds datasource key from Data Pipeline (DATA_PIPELINE) input', () => {
|
|
29
|
-
const input = 'dataFlow (Data Pipeline)';
|
|
30
|
-
const expected = 'DATA_PIPELINE_dataFlow_dataFlow';
|
|
31
|
-
assert.equal(datasourceNameFromDisplay(input), expected);
|
|
32
|
-
});
|
|
33
|
-
DatasourceNameFromDisplayTests.run();
|
|
34
|
-
// datasourceNameForDisplay tests
|
|
35
|
-
const DatasourceNameForDisplayTests = suite('datasourceNameForDisplay()');
|
|
36
|
-
DatasourceNameForDisplayTests('Correctly formats REQ_REP datasource for display', () => {
|
|
37
|
-
const datasource = 'myService';
|
|
38
|
-
const type = 'REQ_REP';
|
|
39
|
-
const expected = 'myService (Snapshot)';
|
|
40
|
-
assert.equal(datasourceNameForDisplay(datasource, type), expected);
|
|
41
|
-
});
|
|
42
|
-
DatasourceNameForDisplayTests('Correctly formats DATA_PIPELINE datasource for display', () => {
|
|
43
|
-
const datasource = 'dataFlow';
|
|
44
|
-
const type = 'DATA_PIPELINE';
|
|
45
|
-
const expected = 'dataFlow (Data Pipeline)';
|
|
46
|
-
assert.equal(datasourceNameForDisplay(datasource, type), expected);
|
|
47
|
-
});
|
|
48
|
-
DatasourceNameForDisplayTests.run();
|
|
49
|
-
// LookupColumnIsFiltered tests
|
|
50
|
-
const LookupColumnIsIncluded = suite('lookupColumnIsIncluded');
|
|
51
|
-
LookupColumnIsIncluded.before.each(() => {
|
|
52
|
-
sinon.restore();
|
|
53
|
-
});
|
|
54
|
-
LookupColumnIsIncluded('returns true when column is in included', () => {
|
|
55
|
-
const mockData = {
|
|
56
|
-
[GridColumnNames.Datasource]: 'testSource (Snapshot)',
|
|
57
|
-
[GridColumnNames.ColumnName]: 'testColumn',
|
|
58
|
-
[GridColumnNames.DisplayName]: 'testColumn',
|
|
59
|
-
[GridColumnNames.Type]: 'STRING',
|
|
60
|
-
};
|
|
61
|
-
const mockDatasource = {
|
|
62
|
-
KEY: 'test',
|
|
63
|
-
NAME: 'Test Datasource',
|
|
64
|
-
INPUT_TYPE: 'REQ_REP',
|
|
65
|
-
OUTPUT_TYPE: 'TABLE',
|
|
66
|
-
GROUPING_STRATEGY: 'NONE',
|
|
67
|
-
GROUP_KEY: null,
|
|
68
|
-
TRANSFORMER_CONFIGURATION: { INCLUDE_COLUMNS: ['testColumn', 'otherColumn'] },
|
|
69
|
-
};
|
|
70
|
-
sinon.stub(selectors.datasourceConfig, 'getDatasource').returns(mockDatasource);
|
|
71
|
-
const result = lookupColumnIsIncluded(mockData);
|
|
72
|
-
assert.equal(result, true);
|
|
73
|
-
});
|
|
74
|
-
LookupColumnIsIncluded('returns false when column is not in filters', () => {
|
|
75
|
-
const mockData = {
|
|
76
|
-
[GridColumnNames.Datasource]: 'testSource (Snapshot)',
|
|
77
|
-
[GridColumnNames.ColumnName]: 'nonFilteredColumn',
|
|
78
|
-
[GridColumnNames.DisplayName]: 'nonFilteredColumn',
|
|
79
|
-
[GridColumnNames.Type]: 'STRING',
|
|
80
|
-
};
|
|
81
|
-
const mockDatasource = {
|
|
82
|
-
KEY: 'test',
|
|
83
|
-
NAME: 'Test Datasource',
|
|
84
|
-
INPUT_TYPE: 'REQ_REP',
|
|
85
|
-
OUTPUT_TYPE: 'TABLE',
|
|
86
|
-
GROUPING_STRATEGY: 'NONE',
|
|
87
|
-
GROUP_KEY: null,
|
|
88
|
-
TRANSFORMER_CONFIGURATION: { INCLUDE_COLUMNS: ['testColumn', 'otherColumn'] },
|
|
89
|
-
};
|
|
90
|
-
sinon.stub(selectors.datasourceConfig, 'getDatasource').returns(mockDatasource);
|
|
91
|
-
const result = lookupColumnIsIncluded(mockData);
|
|
92
|
-
assert.equal(result, false);
|
|
93
|
-
});
|
|
94
|
-
LookupColumnIsIncluded('returns false when INCLUDE_COLUMNS is undefined', () => {
|
|
95
|
-
const mockData = {
|
|
96
|
-
[GridColumnNames.Datasource]: 'testSource (Snapshot)',
|
|
97
|
-
[GridColumnNames.ColumnName]: 'testColumn',
|
|
98
|
-
[GridColumnNames.DisplayName]: 'testColumn',
|
|
99
|
-
[GridColumnNames.Type]: 'STRING',
|
|
100
|
-
};
|
|
101
|
-
const mockDatasource = {
|
|
102
|
-
KEY: 'test',
|
|
103
|
-
NAME: 'Test Datasource',
|
|
104
|
-
INPUT_TYPE: 'REQ_REP',
|
|
105
|
-
OUTPUT_TYPE: 'TABLE',
|
|
106
|
-
GROUPING_STRATEGY: 'NONE',
|
|
107
|
-
GROUP_KEY: null,
|
|
108
|
-
TRANSFORMER_CONFIGURATION: { INCLUDE_COLUMNS: undefined },
|
|
109
|
-
};
|
|
110
|
-
sinon.stub(selectors.datasourceConfig, 'getDatasource').returns(mockDatasource);
|
|
111
|
-
const result = lookupColumnIsIncluded(mockData);
|
|
112
|
-
assert.equal(result, false);
|
|
113
|
-
});
|
|
114
|
-
LookupColumnIsIncluded('returns false when INCLUDE_COLUMNS is empty array', () => {
|
|
115
|
-
const mockData = {
|
|
116
|
-
[GridColumnNames.Datasource]: 'testSource (Snapshot)',
|
|
117
|
-
[GridColumnNames.ColumnName]: 'testColumn',
|
|
118
|
-
[GridColumnNames.DisplayName]: 'testColumn',
|
|
119
|
-
[GridColumnNames.Type]: 'STRING',
|
|
120
|
-
};
|
|
121
|
-
const mockDatasource = {
|
|
122
|
-
KEY: 'test',
|
|
123
|
-
NAME: 'Test Datasource',
|
|
124
|
-
INPUT_TYPE: 'REQ_REP',
|
|
125
|
-
OUTPUT_TYPE: 'TABLE',
|
|
126
|
-
GROUPING_STRATEGY: 'NONE',
|
|
127
|
-
GROUP_KEY: null,
|
|
128
|
-
TRANSFORMER_CONFIGURATION: { INCLUDE_COLUMNS: [] },
|
|
129
|
-
};
|
|
130
|
-
sinon.stub(selectors.datasourceConfig, 'getDatasource').returns(mockDatasource);
|
|
131
|
-
const result = lookupColumnIsIncluded(mockData);
|
|
132
|
-
assert.equal(result, false);
|
|
133
|
-
});
|
|
134
|
-
LookupColumnIsIncluded.run();
|
|
135
|
-
// PathParametersTests tests
|
|
136
|
-
const PathParametersTests = suite('pathParameters()');
|
|
137
|
-
// Helper function to build JSON schema for testing
|
|
138
|
-
function buildJsonSchema(properties) {
|
|
139
|
-
return {
|
|
140
|
-
type: 'object',
|
|
141
|
-
properties: properties,
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
PathParametersTests('Should convert simple schema properties to grid row data', () => {
|
|
145
|
-
const datasource = {
|
|
146
|
-
name: 'TestDatasource',
|
|
147
|
-
spec: {
|
|
148
|
-
properties: {
|
|
149
|
-
field1: {
|
|
150
|
-
genesisType: 'STRING',
|
|
151
|
-
},
|
|
152
|
-
field2: {
|
|
153
|
-
genesisType: 'INT',
|
|
154
|
-
},
|
|
155
|
-
field3: {
|
|
156
|
-
genesisType: 'BOOLEAN',
|
|
157
|
-
},
|
|
158
|
-
},
|
|
159
|
-
},
|
|
160
|
-
};
|
|
161
|
-
const result = pathParameters(datasource);
|
|
162
|
-
assert.equal(result.length, 3);
|
|
163
|
-
assert.equal(result[0][GridColumnNames.ColumnName], 'field1');
|
|
164
|
-
assert.equal(result[0][GridColumnNames.DisplayName], 'field1');
|
|
165
|
-
assert.equal(result[0][GridColumnNames.Type], 'STRING');
|
|
166
|
-
assert.equal(result[0][GridColumnNames.Datasource], 'TestDatasource');
|
|
167
|
-
assert.equal(result[1][GridColumnNames.ColumnName], 'field2');
|
|
168
|
-
assert.equal(result[1][GridColumnNames.Type], 'INT');
|
|
169
|
-
assert.equal(result[2][GridColumnNames.ColumnName], 'field3');
|
|
170
|
-
assert.equal(result[2][GridColumnNames.Type], 'BOOLEAN');
|
|
171
|
-
});
|
|
172
|
-
PathParametersTests('Should handle nullable enum types and extract enum values correctly', () => {
|
|
173
|
-
// Schema with nullable enum field to test the handling of enum values
|
|
174
|
-
const datasource = {
|
|
175
|
-
name: 'TradesData',
|
|
176
|
-
spec: {
|
|
177
|
-
properties: {
|
|
178
|
-
TRADE_ID: {
|
|
179
|
-
type: 'integer',
|
|
180
|
-
description: '',
|
|
181
|
-
genesisType: 'LONG',
|
|
182
|
-
},
|
|
183
|
-
DIRECTION: {
|
|
184
|
-
oneOf: [
|
|
185
|
-
{
|
|
186
|
-
type: 'null',
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
type: 'string',
|
|
190
|
-
enum: ['SELL', 'SHORT_SELL', 'BUY'],
|
|
191
|
-
},
|
|
192
|
-
],
|
|
193
|
-
description: '',
|
|
194
|
-
genesisType: 'ENUM',
|
|
195
|
-
// No top-level enum property - matches server payload
|
|
196
|
-
},
|
|
197
|
-
INSTRUMENT_ID: {
|
|
198
|
-
oneOf: [
|
|
199
|
-
{
|
|
200
|
-
type: 'null',
|
|
201
|
-
},
|
|
202
|
-
{
|
|
203
|
-
type: 'integer',
|
|
204
|
-
},
|
|
205
|
-
],
|
|
206
|
-
description: '',
|
|
207
|
-
genesisType: 'LONG',
|
|
208
|
-
},
|
|
209
|
-
},
|
|
210
|
-
additionalProperties: false,
|
|
211
|
-
required: [],
|
|
212
|
-
},
|
|
213
|
-
};
|
|
214
|
-
const result = pathParameters(datasource);
|
|
215
|
-
// Find the DIRECTION field result
|
|
216
|
-
const directionField = result.find((row) => row[GridColumnNames.ColumnName] === 'DIRECTION');
|
|
217
|
-
assert.ok(directionField, 'DIRECTION field should be in the results');
|
|
218
|
-
assert.equal(directionField[GridColumnNames.Type], 'ENUM', 'Type should be ENUM');
|
|
219
|
-
// Check that EnumValues array exists and contains the expected values
|
|
220
|
-
assert.ok(Array.isArray(directionField[GridColumnNames.EnumValues]), 'EnumValues should be an array');
|
|
221
|
-
assert.equal(directionField[GridColumnNames.EnumValues].length, 3, 'EnumValues should have 3 items');
|
|
222
|
-
assert.equal(directionField[GridColumnNames.EnumValues][0], 'SELL');
|
|
223
|
-
assert.equal(directionField[GridColumnNames.EnumValues][1], 'SHORT_SELL');
|
|
224
|
-
assert.equal(directionField[GridColumnNames.EnumValues][2], 'BUY');
|
|
225
|
-
});
|
|
226
|
-
PathParametersTests('Should handle non-nullable enum types with top-level enum property', () => {
|
|
227
|
-
// Schema with non-nullable enum field (direct enum property)
|
|
228
|
-
const datasource = {
|
|
229
|
-
name: 'StatusData',
|
|
230
|
-
spec: {
|
|
231
|
-
properties: {
|
|
232
|
-
STATUS: {
|
|
233
|
-
type: 'string',
|
|
234
|
-
enum: ['ACTIVE', 'PENDING', 'COMPLETED', 'CANCELLED'],
|
|
235
|
-
description: 'Status field',
|
|
236
|
-
genesisType: 'ENUM',
|
|
237
|
-
},
|
|
238
|
-
},
|
|
239
|
-
additionalProperties: false,
|
|
240
|
-
required: [],
|
|
241
|
-
},
|
|
242
|
-
};
|
|
243
|
-
const result = pathParameters(datasource);
|
|
244
|
-
// Find the STATUS field result
|
|
245
|
-
const statusField = result.find((row) => row[GridColumnNames.ColumnName] === 'STATUS');
|
|
246
|
-
assert.ok(statusField, 'STATUS field should be in the results');
|
|
247
|
-
assert.equal(statusField[GridColumnNames.Type], 'ENUM', 'Type should be ENUM');
|
|
248
|
-
// Check that EnumValues array exists and contains the expected values
|
|
249
|
-
assert.ok(Array.isArray(statusField[GridColumnNames.EnumValues]), 'EnumValues should be an array');
|
|
250
|
-
assert.equal(statusField[GridColumnNames.EnumValues].length, 4, 'EnumValues should have 4 items');
|
|
251
|
-
assert.equal(statusField[GridColumnNames.EnumValues][0], 'ACTIVE');
|
|
252
|
-
assert.equal(statusField[GridColumnNames.EnumValues][1], 'PENDING');
|
|
253
|
-
assert.equal(statusField[GridColumnNames.EnumValues][2], 'COMPLETED');
|
|
254
|
-
assert.equal(statusField[GridColumnNames.EnumValues][3], 'CANCELLED');
|
|
255
|
-
});
|
|
256
|
-
PathParametersTests('Should throw error for malformed enum schema without enum values', () => {
|
|
257
|
-
// Schema with malformed enum field (no enum values available)
|
|
258
|
-
const datasource = {
|
|
259
|
-
name: 'MalformedData',
|
|
260
|
-
spec: {
|
|
261
|
-
properties: {
|
|
262
|
-
BROKEN_ENUM: {
|
|
263
|
-
description: 'Malformed enum without values',
|
|
264
|
-
genesisType: 'ENUM',
|
|
265
|
-
// Missing enum and oneOf - should cause an error
|
|
266
|
-
},
|
|
267
|
-
},
|
|
268
|
-
additionalProperties: false,
|
|
269
|
-
required: [],
|
|
270
|
-
},
|
|
271
|
-
};
|
|
272
|
-
// Should throw an error with specific message
|
|
273
|
-
assert.throws(() => pathParameters(datasource), Error, "Could not extract enum values for field 'BROKEN_ENUM'");
|
|
274
|
-
});
|
|
275
|
-
PathParametersTests('Should throw error when no properties exist', () => {
|
|
276
|
-
const datasource = {
|
|
277
|
-
name: 'TestDatasource',
|
|
278
|
-
spec: { type: 'object' }, // Schema without properties
|
|
279
|
-
};
|
|
280
|
-
assert.throws(() => pathParameters(datasource), Error, 'No properties on schema for datasource TestDatasource');
|
|
281
|
-
});
|
|
282
|
-
PathParametersTests('Should handle empty properties object', () => {
|
|
283
|
-
const datasource = {
|
|
284
|
-
name: 'TestDatasource',
|
|
285
|
-
spec: buildJsonSchema({}),
|
|
286
|
-
};
|
|
287
|
-
assert.equal(pathParameters(datasource), []);
|
|
288
|
-
});
|
|
289
|
-
PathParametersTests.run();
|
|
290
|
-
// ConvertToPathFormat tests
|
|
291
|
-
const ConvertToPathFormat = suite('convertToPathFormat()');
|
|
292
|
-
ConvertToPathFormat('Converts basic string to path format', () => {
|
|
293
|
-
assert.equal(convertToPathFormat('hello'), '/req-hello');
|
|
294
|
-
});
|
|
295
|
-
ConvertToPathFormat('Converts uppercase string to lowercase path format', () => {
|
|
296
|
-
assert.equal(convertToPathFormat('HELLO'), '/req-hello');
|
|
297
|
-
});
|
|
298
|
-
ConvertToPathFormat('Converts string with underscores to dashes', () => {
|
|
299
|
-
assert.equal(convertToPathFormat('hello_world'), '/req-hello-world');
|
|
300
|
-
});
|
|
301
|
-
ConvertToPathFormat('Converts mixed case string with multiple underscores', () => {
|
|
302
|
-
assert.equal(convertToPathFormat('HELLO_World_TEST'), '/req-hello-world-test');
|
|
303
|
-
});
|
|
304
|
-
ConvertToPathFormat('Handles empty string', () => {
|
|
305
|
-
assert.equal(convertToPathFormat(''), '/req-');
|
|
306
|
-
});
|
|
307
|
-
ConvertToPathFormat.run();
|
|
308
|
-
// MapTypeToRenderer tests
|
|
309
|
-
const MapTypeToRendererTests = suite('mapTypeToRenderer');
|
|
310
|
-
MapTypeToRendererTests('returns "boolean" for boolean type', () => {
|
|
311
|
-
const result = mapTypeToRenderer('BOOLEAN');
|
|
312
|
-
assert.equal(result, 'boolean');
|
|
313
|
-
});
|
|
314
|
-
MapTypeToRendererTests('returns "string" for string type', () => {
|
|
315
|
-
const result = mapTypeToRenderer('STRING');
|
|
316
|
-
assert.equal(result, 'string');
|
|
317
|
-
});
|
|
318
|
-
MapTypeToRendererTests('returns "string" for enum type', () => {
|
|
319
|
-
const result = mapTypeToRenderer('ENUM');
|
|
320
|
-
assert.equal(result, 'string');
|
|
321
|
-
});
|
|
322
|
-
MapTypeToRendererTests('returns "number" for number type', () => {
|
|
323
|
-
const result = mapTypeToRenderer('LONG');
|
|
324
|
-
assert.equal(result, 'number');
|
|
325
|
-
});
|
|
326
|
-
MapTypeToRendererTests('returns "number" for integer type', () => {
|
|
327
|
-
const result = mapTypeToRenderer('INT');
|
|
328
|
-
assert.equal(result, 'number');
|
|
329
|
-
});
|
|
330
|
-
MapTypeToRendererTests('returns "number" for DOUBLE type', () => {
|
|
331
|
-
const result = mapTypeToRenderer('DOUBLE');
|
|
332
|
-
assert.equal(result, 'number');
|
|
333
|
-
});
|
|
334
|
-
MapTypeToRendererTests('returns "number" for SHORT type', () => {
|
|
335
|
-
const result = mapTypeToRenderer('SHORT');
|
|
336
|
-
assert.equal(result, 'number');
|
|
337
|
-
});
|
|
338
|
-
MapTypeToRendererTests('returns "number" for BIGDECIMAL type', () => {
|
|
339
|
-
const result = mapTypeToRenderer('BIGDECIMAL');
|
|
340
|
-
assert.equal(result, 'number');
|
|
341
|
-
});
|
|
342
|
-
MapTypeToRendererTests('returns null for unsupported type', () => {
|
|
343
|
-
const result = mapTypeToRenderer('UNSUPPORTED_TYPE');
|
|
344
|
-
assert.equal(result, null);
|
|
345
|
-
});
|
|
346
|
-
MapTypeToRendererTests.run();
|
|
347
|
-
// ShouldDisableColumn tests
|
|
348
|
-
const ShouldDisableColumnTests = suite('shouldDisableColumn()');
|
|
349
|
-
ShouldDisableColumnTests.before.each(() => {
|
|
350
|
-
sinon.restore();
|
|
351
|
-
});
|
|
352
|
-
ShouldDisableColumnTests('should return true when Type is undefined', () => {
|
|
353
|
-
const mockData = {
|
|
354
|
-
[GridColumnNames.Type]: undefined,
|
|
355
|
-
};
|
|
356
|
-
const result = shouldDisableColumn(mockData);
|
|
357
|
-
assert.equal(result, true);
|
|
358
|
-
});
|
|
359
|
-
ShouldDisableColumnTests('should return true when Type is RAW', () => {
|
|
360
|
-
const mockData = {
|
|
361
|
-
[GridColumnNames.Type]: 'RAW',
|
|
362
|
-
};
|
|
363
|
-
const result = shouldDisableColumn(mockData);
|
|
364
|
-
assert.equal(result, true);
|
|
365
|
-
});
|
|
366
|
-
ShouldDisableColumnTests('should return false when Type is valid', () => {
|
|
367
|
-
const mockData = {
|
|
368
|
-
[GridColumnNames.Type]: 'STRING',
|
|
369
|
-
};
|
|
370
|
-
const result = shouldDisableColumn(mockData);
|
|
371
|
-
assert.equal(result, false);
|
|
372
|
-
});
|
|
373
|
-
ShouldDisableColumnTests.run();
|
|
374
|
-
// ConfigureDisabledColumns tests
|
|
375
|
-
const ConfigureDisabledColumnsTests = suite('configureDisabledColumns()');
|
|
376
|
-
ConfigureDisabledColumnsTests.before.each(() => {
|
|
377
|
-
sinon.restore();
|
|
378
|
-
});
|
|
379
|
-
ConfigureDisabledColumnsTests('should not set column filter when column type is valid', () => {
|
|
380
|
-
// Using enum keys now that imports are fixed
|
|
381
|
-
const mockData = {
|
|
382
|
-
[GridColumnNames.ColumnName]: 'testColumn',
|
|
383
|
-
[GridColumnNames.DisplayName]: 'Test Column',
|
|
384
|
-
[GridColumnNames.Type]: 'STRING',
|
|
385
|
-
[GridColumnNames.Datasource]: 'Test (Snapshot)',
|
|
386
|
-
};
|
|
387
|
-
const setColumnIncludedStub = sinon.stub(actions.datasourceConfig, 'setColumnIncluded');
|
|
388
|
-
const result = configureDisabledColumns(mockData);
|
|
389
|
-
assert.equal(result, mockData);
|
|
390
|
-
assert.ok(setColumnIncludedStub.notCalled);
|
|
391
|
-
});
|
|
392
|
-
ConfigureDisabledColumnsTests('should set column filter when column type is RAW', () => {
|
|
393
|
-
const mockData = {
|
|
394
|
-
[GridColumnNames.ColumnName]: 'testColumn',
|
|
395
|
-
[GridColumnNames.DisplayName]: 'Test Column',
|
|
396
|
-
[GridColumnNames.Type]: 'RAW',
|
|
397
|
-
[GridColumnNames.Datasource]: 'Test (Snapshot)',
|
|
398
|
-
};
|
|
399
|
-
const setColumnIncludedStub = sinon.stub(actions.datasourceConfig, 'setColumnIncluded');
|
|
400
|
-
const result = configureDisabledColumns(mockData);
|
|
401
|
-
assert.equal(result, mockData);
|
|
402
|
-
assert.ok(setColumnIncludedStub.calledOnce);
|
|
403
|
-
assert.ok(setColumnIncludedStub.calledWith({
|
|
404
|
-
key: datasourceNameFromDisplay(mockData[GridColumnNames.Datasource]),
|
|
405
|
-
column: mockData[GridColumnNames.ColumnName],
|
|
406
|
-
included: false,
|
|
407
|
-
}));
|
|
408
|
-
});
|
|
409
|
-
ConfigureDisabledColumnsTests('should set column filter when column type is undefined', () => {
|
|
410
|
-
const mockData = {
|
|
411
|
-
[GridColumnNames.ColumnName]: 'testColumn',
|
|
412
|
-
[GridColumnNames.DisplayName]: 'Test Column',
|
|
413
|
-
[GridColumnNames.Type]: undefined,
|
|
414
|
-
[GridColumnNames.Datasource]: 'Test (Snapshot)',
|
|
415
|
-
};
|
|
416
|
-
const setColumnIncludedStub = sinon.stub(actions.datasourceConfig, 'setColumnIncluded');
|
|
417
|
-
const result = configureDisabledColumns(mockData);
|
|
418
|
-
assert.equal(result, mockData);
|
|
419
|
-
assert.ok(setColumnIncludedStub.calledOnce);
|
|
420
|
-
assert.ok(setColumnIncludedStub.calledWith({
|
|
421
|
-
key: datasourceNameFromDisplay(mockData[GridColumnNames.Datasource]),
|
|
422
|
-
column: mockData[GridColumnNames.ColumnName],
|
|
423
|
-
included: false,
|
|
424
|
-
}));
|
|
425
|
-
});
|
|
426
|
-
ConfigureDisabledColumnsTests.run();
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { assert, suite } from '@genesislcap/foundation-testing';
|
|
2
|
-
import { generateUniqueAlias } from './alias-generator';
|
|
3
|
-
const GenerateUniqueAlias = suite('generateUniqueAlias');
|
|
4
|
-
GenerateUniqueAlias('returns the base alias if it does not exist', () => {
|
|
5
|
-
const existingAliases = new Set(['other']);
|
|
6
|
-
const alias = generateUniqueAlias('test', existingAliases);
|
|
7
|
-
assert.equal(alias, 'test');
|
|
8
|
-
});
|
|
9
|
-
GenerateUniqueAlias('increments the alias if it already exists', () => {
|
|
10
|
-
const existingAliases = new Set(['test']);
|
|
11
|
-
const alias = generateUniqueAlias('test', existingAliases);
|
|
12
|
-
assert.equal(alias, 'test_1');
|
|
13
|
-
});
|
|
14
|
-
GenerateUniqueAlias('increments the alias until it is unique', () => {
|
|
15
|
-
const existingAliases = new Set(['test', 'test_1']);
|
|
16
|
-
const alias = generateUniqueAlias('test', existingAliases);
|
|
17
|
-
assert.equal(alias, 'test_2');
|
|
18
|
-
});
|
|
19
|
-
GenerateUniqueAlias('handles case-insensitivity when checking for existing aliases', () => {
|
|
20
|
-
const existingAliases = new Set(['Test']);
|
|
21
|
-
const alias = generateUniqueAlias('test', existingAliases);
|
|
22
|
-
assert.equal(alias, 'test_1');
|
|
23
|
-
});
|
|
24
|
-
GenerateUniqueAlias('handles case-insensitivity for new alias generation', () => {
|
|
25
|
-
const existingAliases = new Set(['test']);
|
|
26
|
-
const alias = generateUniqueAlias('Test', existingAliases);
|
|
27
|
-
// Since input baseAlias is 'Test', it tries 'Test'. 'Test' matches 'test' case-insensitively.
|
|
28
|
-
// Next attempt 'Test_1'.
|
|
29
|
-
assert.equal(alias, 'Test_1');
|
|
30
|
-
});
|
|
31
|
-
GenerateUniqueAlias('handles mixed case existing aliases', () => {
|
|
32
|
-
const existingAliases = new Set(['TeSt', 'tEsT_1']);
|
|
33
|
-
const alias = generateUniqueAlias('test', existingAliases);
|
|
34
|
-
assert.equal(alias, 'test_2');
|
|
35
|
-
});
|
|
36
|
-
GenerateUniqueAlias.run();
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import { __awaiter } from "tslib";
|
|
2
|
-
import { assert, sinon, suite } from '@genesislcap/foundation-testing';
|
|
3
|
-
import { getDatasourceSchema, getEndpointUrl } from './endpoint';
|
|
4
|
-
const GetDatasourceSchema = suite('getDatasourceSchema');
|
|
5
|
-
GetDatasourceSchema.before.each(() => {
|
|
6
|
-
sinon.restore();
|
|
7
|
-
});
|
|
8
|
-
GetDatasourceSchema('returns schema items when response is valid', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
9
|
-
const mockConnect = {
|
|
10
|
-
getJSONSchema: sinon.stub(),
|
|
11
|
-
};
|
|
12
|
-
const mockResponse = {
|
|
13
|
-
OUTBOUND: {
|
|
14
|
-
properties: {
|
|
15
|
-
REPLY: {
|
|
16
|
-
items: {
|
|
17
|
-
type: 'object',
|
|
18
|
-
properties: {},
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
mockConnect.getJSONSchema.resolves(mockResponse);
|
|
25
|
-
const getSchema = getDatasourceSchema(mockConnect);
|
|
26
|
-
const result = yield getSchema('TEST_RESOURCE');
|
|
27
|
-
assert.equal(result, mockResponse.OUTBOUND.properties.REPLY.items);
|
|
28
|
-
}));
|
|
29
|
-
GetDatasourceSchema('surfaces server error response instead of a shape error', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
-
const mockConnect = {
|
|
31
|
-
getJSONSchema: sinon.stub(),
|
|
32
|
-
};
|
|
33
|
-
const mockResponse = {
|
|
34
|
-
MESSAGE_TYPE: 'JSON_SCHEMA_NACK',
|
|
35
|
-
ERROR: [
|
|
36
|
-
{
|
|
37
|
-
'@type': 'StandardError',
|
|
38
|
-
CODE: 'FEATURE_NOT_FOUND',
|
|
39
|
-
STATUS_CODE: '404 Not Found',
|
|
40
|
-
TEXT: 'Feature not found',
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
};
|
|
44
|
-
mockConnect.getJSONSchema.resolves(mockResponse);
|
|
45
|
-
const getSchema = getDatasourceSchema(mockConnect);
|
|
46
|
-
try {
|
|
47
|
-
yield getSchema('Allocations');
|
|
48
|
-
assert.unreachable('Expected function to throw');
|
|
49
|
-
}
|
|
50
|
-
catch (error) {
|
|
51
|
-
assert.equal(error.message, 'Failed to fetch JSON schema for Allocations: 404 Not Found - FEATURE_NOT_FOUND - Feature not found');
|
|
52
|
-
}
|
|
53
|
-
}));
|
|
54
|
-
GetDatasourceSchema('throws error when items is missing', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
55
|
-
const mockConnect = {
|
|
56
|
-
getJSONSchema: sinon.stub(),
|
|
57
|
-
};
|
|
58
|
-
const mockResponse = {
|
|
59
|
-
OUTBOUND: {
|
|
60
|
-
properties: {
|
|
61
|
-
REPLY: {
|
|
62
|
-
type: 'object',
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
mockConnect.getJSONSchema.resolves(mockResponse);
|
|
68
|
-
const getSchema = getDatasourceSchema(mockConnect);
|
|
69
|
-
try {
|
|
70
|
-
yield getSchema('TEST_RESOURCE');
|
|
71
|
-
assert.unreachable('Expected function to throw');
|
|
72
|
-
}
|
|
73
|
-
catch (error) {
|
|
74
|
-
assert.equal(error.message, 'Invalid response shape for TEST_RESOURCE');
|
|
75
|
-
}
|
|
76
|
-
}));
|
|
77
|
-
GetDatasourceSchema('throws error when REPLY is not an object', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
78
|
-
const mockConnect = {
|
|
79
|
-
getJSONSchema: sinon.stub(),
|
|
80
|
-
};
|
|
81
|
-
const mockResponse = {
|
|
82
|
-
OUTBOUND: {
|
|
83
|
-
properties: {
|
|
84
|
-
REPLY: 'not an object',
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
};
|
|
88
|
-
mockConnect.getJSONSchema.resolves(mockResponse);
|
|
89
|
-
const getSchema = getDatasourceSchema(mockConnect);
|
|
90
|
-
try {
|
|
91
|
-
yield getSchema('TEST_RESOURCE');
|
|
92
|
-
assert.unreachable('Expected function to throw');
|
|
93
|
-
}
|
|
94
|
-
catch (error) {
|
|
95
|
-
assert.equal(error.message, 'Invalid response shape for TEST_RESOURCE');
|
|
96
|
-
}
|
|
97
|
-
}));
|
|
98
|
-
GetDatasourceSchema('throws error when items is an array', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
99
|
-
const mockConnect = {
|
|
100
|
-
getJSONSchema: sinon.stub(),
|
|
101
|
-
};
|
|
102
|
-
const mockResponse = {
|
|
103
|
-
OUTBOUND: {
|
|
104
|
-
properties: {
|
|
105
|
-
REPLY: {
|
|
106
|
-
items: [],
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
};
|
|
111
|
-
mockConnect.getJSONSchema.resolves(mockResponse);
|
|
112
|
-
const getSchema = getDatasourceSchema(mockConnect);
|
|
113
|
-
try {
|
|
114
|
-
yield getSchema('TEST_RESOURCE');
|
|
115
|
-
assert.unreachable('Expected function to throw');
|
|
116
|
-
}
|
|
117
|
-
catch (error) {
|
|
118
|
-
assert.equal(error.message, 'Items is an array');
|
|
119
|
-
}
|
|
120
|
-
}));
|
|
121
|
-
GetDatasourceSchema.run();
|
|
122
|
-
const GetEndpointUrl = suite('getEndpointUrl');
|
|
123
|
-
GetEndpointUrl.before.each(() => {
|
|
124
|
-
sinon.restore();
|
|
125
|
-
// Clear sessionStorage before each test
|
|
126
|
-
sessionStorage.clear();
|
|
127
|
-
});
|
|
128
|
-
GetEndpointUrl('returns correct http URL for localhost', () => {
|
|
129
|
-
const endpoint = 'api/data';
|
|
130
|
-
const urlRoot = 'http://localhost:3000';
|
|
131
|
-
const result = getEndpointUrl(endpoint, urlRoot);
|
|
132
|
-
assert.equal(result, 'http://localhost:3000/api/data');
|
|
133
|
-
});
|
|
134
|
-
GetEndpointUrl('returns correct https URL for non-localhost', () => {
|
|
135
|
-
const endpoint = 'api/data';
|
|
136
|
-
const urlRoot = 'https://example.com';
|
|
137
|
-
const result = getEndpointUrl(endpoint, urlRoot);
|
|
138
|
-
assert.equal(result, 'https://example.com/api/data');
|
|
139
|
-
});
|
|
140
|
-
GetEndpointUrl('handles urlRoot with trailing slash correctly', () => {
|
|
141
|
-
const endpoint = 'api/data';
|
|
142
|
-
const urlRoot = 'https://example.com/';
|
|
143
|
-
const result = getEndpointUrl(endpoint, urlRoot);
|
|
144
|
-
assert.equal(result, 'https://example.com/api/data');
|
|
145
|
-
});
|
|
146
|
-
GetEndpointUrl('handles urlRoot with path correctly', () => {
|
|
147
|
-
const endpoint = 'api/data';
|
|
148
|
-
const urlRoot = 'https://example.com/base/path';
|
|
149
|
-
const result = getEndpointUrl(endpoint, urlRoot);
|
|
150
|
-
assert.equal(result, 'https://example.com/base/path/api/data');
|
|
151
|
-
});
|
|
152
|
-
GetEndpointUrl('uses sessionStorage hostUrl when urlRoot is not provided', () => {
|
|
153
|
-
sessionStorage.setItem('hostUrl', 'https://example.com/base');
|
|
154
|
-
const endpoint = 'api/data';
|
|
155
|
-
const result = getEndpointUrl(endpoint);
|
|
156
|
-
assert.equal(result, 'https://example.com/base/api/data');
|
|
157
|
-
});
|
|
158
|
-
GetEndpointUrl('throws error when no valid URL is provided', () => {
|
|
159
|
-
const endpoint = 'api/data';
|
|
160
|
-
assert.throws(() => getEndpointUrl(endpoint), 'Invalid URL');
|
|
161
|
-
});
|
|
162
|
-
GetEndpointUrl.run();
|