@fgv/ts-res-ui-components 5.0.0-23 → 5.0.0-25
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/package.json +12 -12
- package/config/api-extractor.json +0 -89
- package/config/jest.setup.js +0 -77
- package/config/rig.json +0 -16
- package/lib/test/helpers/testDataLoader.d.ts +0 -37
- package/lib/test/helpers/testDataLoader.js +0 -171
- package/lib/test/integration/observability.integration.test.d.ts +0 -2
- package/lib/test/unit/ResourcePicker.test.d.ts +0 -9
- package/lib/test/unit/components/ResolutionView.unified.test.d.ts +0 -2
- package/lib/test/unit/hooks/useResolutionState.context.test.d.ts +0 -2
- package/lib/test/unit/hooks/useResourceData.test.d.ts +0 -2
- package/lib/test/unit/utils/configurationUtils.test.d.ts +0 -2
- package/lib/test/unit/utils/downloadHelper.test.d.ts +0 -2
- package/lib/test/unit/utils/fileProcessing.test.d.ts +0 -2
- package/lib/test/unit/utils/filterResources.test.d.ts +0 -2
- package/lib/test/unit/utils/resolutionEditing.test.d.ts +0 -2
- package/lib/test/unit/utils/resolutionUtils.test.d.ts +0 -2
- package/lib/test/unit/utils/tsResIntegration.test.d.ts +0 -2
- package/lib/test/unit/workflows/resolutionWorkflows.test.d.ts +0 -2
- package/lib/test/unit/workflows/resourceCreation.test.d.ts +0 -2
- package/lib/test/unit/workflows/resultPatternExtensions.test.d.ts +0 -2
- package/lib/test/unit/workflows/validation.test.d.ts +0 -2
- package/lib-commonjs/components/common/QualifierContextControl.js +0 -236
- package/lib-commonjs/components/common/ResolutionContextOptionsControl.js +0 -195
- package/lib-commonjs/components/common/ResolutionResults/index.js +0 -298
- package/lib-commonjs/components/common/ResourceListView.js +0 -119
- package/lib-commonjs/components/common/ResourcePickerOptionsControl.js +0 -147
- package/lib-commonjs/components/common/ResourceTreeView.js +0 -301
- package/lib-commonjs/components/common/SourceResourceDetail/index.js +0 -344
- package/lib-commonjs/components/forms/GenericQualifierTypeEditForm.js +0 -171
- package/lib-commonjs/components/forms/HierarchyEditor.js +0 -183
- package/lib-commonjs/components/forms/QualifierEditForm.js +0 -298
- package/lib-commonjs/components/forms/QualifierTypeEditForm.js +0 -279
- package/lib-commonjs/components/forms/ResourceTypeEditForm.js +0 -290
- package/lib-commonjs/components/forms/index.js +0 -14
- package/lib-commonjs/components/orchestrator/ResourceOrchestrator.js +0 -407
- package/lib-commonjs/components/pickers/ResourcePicker/ResourceItem.js +0 -60
- package/lib-commonjs/components/pickers/ResourcePicker/ResourcePickerList.js +0 -76
- package/lib-commonjs/components/pickers/ResourcePicker/ResourcePickerTree.js +0 -328
- package/lib-commonjs/components/pickers/ResourcePicker/index.js +0 -140
- package/lib-commonjs/components/pickers/ResourcePicker/types.js +0 -3
- package/lib-commonjs/components/pickers/ResourcePicker/utils/treeNavigation.js +0 -156
- package/lib-commonjs/components/views/CompiledView/index.js +0 -910
- package/lib-commonjs/components/views/ConfigurationView/index.js +0 -475
- package/lib-commonjs/components/views/FilterView/index.js +0 -428
- package/lib-commonjs/components/views/GridView/EditableGridCell.js +0 -232
- package/lib-commonjs/components/views/GridView/GridSelector.js +0 -94
- package/lib-commonjs/components/views/GridView/MultiGridView.js +0 -201
- package/lib-commonjs/components/views/GridView/ResourceGrid.js +0 -237
- package/lib-commonjs/components/views/GridView/SharedContextControls.js +0 -100
- package/lib-commonjs/components/views/GridView/cells/BooleanCell.js +0 -54
- package/lib-commonjs/components/views/GridView/cells/DropdownCell.js +0 -187
- package/lib-commonjs/components/views/GridView/cells/StringCell.js +0 -111
- package/lib-commonjs/components/views/GridView/cells/TriStateCell.js +0 -117
- package/lib-commonjs/components/views/GridView/cells/index.js +0 -18
- package/lib-commonjs/components/views/GridView/index.js +0 -217
- package/lib-commonjs/components/views/ImportView/index.js +0 -586
- package/lib-commonjs/components/views/MessagesWindow/index.js +0 -197
- package/lib-commonjs/components/views/ResolutionView/EditableJsonView.js +0 -281
- package/lib-commonjs/components/views/ResolutionView/NewResourceModal.js +0 -65
- package/lib-commonjs/components/views/ResolutionView/UnifiedChangeControls.js +0 -76
- package/lib-commonjs/components/views/ResolutionView/index.js +0 -444
- package/lib-commonjs/components/views/SourceView/index.js +0 -178
- package/lib-commonjs/contexts/ObservabilityContext.js +0 -104
- package/lib-commonjs/contexts/index.js +0 -30
- package/lib-commonjs/hooks/useConfigurationState.js +0 -306
- package/lib-commonjs/hooks/useFilterState.js +0 -129
- package/lib-commonjs/hooks/useResolutionState.js +0 -1324
- package/lib-commonjs/hooks/useResourceData.js +0 -434
- package/lib-commonjs/hooks/useViewState.js +0 -75
- package/lib-commonjs/index.js +0 -82
- package/lib-commonjs/namespaces/ConfigurationTools.js +0 -61
- package/lib-commonjs/namespaces/FilterTools.js +0 -45
- package/lib-commonjs/namespaces/GridTools.js +0 -161
- package/lib-commonjs/namespaces/ImportTools.js +0 -41
- package/lib-commonjs/namespaces/ObservabilityTools.js +0 -33
- package/lib-commonjs/namespaces/PickerTools.js +0 -95
- package/lib-commonjs/namespaces/ResolutionTools.js +0 -64
- package/lib-commonjs/namespaces/ResourceTools.js +0 -99
- package/lib-commonjs/namespaces/TsResTools.js +0 -49
- package/lib-commonjs/namespaces/ViewStateTools.js +0 -89
- package/lib-commonjs/namespaces/ZipTools.js +0 -51
- package/lib-commonjs/namespaces/index.js +0 -55
- package/lib-commonjs/test/helpers/testDataLoader.js +0 -180
- package/lib-commonjs/types/index.js +0 -13
- package/lib-commonjs/utils/cellValidation.js +0 -253
- package/lib-commonjs/utils/configurationUtils.js +0 -286
- package/lib-commonjs/utils/downloadHelper.js +0 -198
- package/lib-commonjs/utils/fileProcessing.js +0 -152
- package/lib-commonjs/utils/filterResources.js +0 -317
- package/lib-commonjs/utils/observability/factories.js +0 -63
- package/lib-commonjs/utils/observability/implementations.js +0 -109
- package/lib-commonjs/utils/observability/index.js +0 -36
- package/lib-commonjs/utils/observability/interfaces.js +0 -24
- package/lib-commonjs/utils/resolutionEditing.js +0 -274
- package/lib-commonjs/utils/resolutionUtils.js +0 -631
- package/lib-commonjs/utils/resourceSelector.js +0 -200
- package/lib-commonjs/utils/resourceSelectors.js +0 -242
- package/lib-commonjs/utils/tsResIntegration.js +0 -316
- package/lib-commonjs/utils/zipLoader/index.js +0 -11
- package/lib-commonjs/utils/zipLoader/zipProcessingHelpers.js +0 -37
- package/lib-commonjs/utils/zipLoader/zipUtils.js +0 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fgv/ts-res-ui-components",
|
|
3
|
-
"version": "5.0.0-
|
|
3
|
+
"version": "5.0.0-25",
|
|
4
4
|
"description": "Reusable React components for ts-res resource visualization and management",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
"@heroicons/react": "~2.2.0",
|
|
24
24
|
"tslib": "^2.8.1",
|
|
25
25
|
"json-edit-react": "~1.28.2",
|
|
26
|
-
"@fgv/ts-res": "5.0.0-
|
|
27
|
-
"@fgv/ts-
|
|
28
|
-
"@fgv/ts-json-base": "5.0.0-
|
|
29
|
-
"@fgv/ts-
|
|
30
|
-
"@fgv/ts-
|
|
26
|
+
"@fgv/ts-res": "5.0.0-25",
|
|
27
|
+
"@fgv/ts-json": "5.0.0-25",
|
|
28
|
+
"@fgv/ts-json-base": "5.0.0-25",
|
|
29
|
+
"@fgv/ts-utils": "5.0.0-25",
|
|
30
|
+
"@fgv/ts-extras": "5.0.0-25"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"react": ">=18.0.0",
|
|
@@ -54,15 +54,15 @@
|
|
|
54
54
|
"react-dom": "~19.1.1",
|
|
55
55
|
"rimraf": "^5.0.7",
|
|
56
56
|
"ts-jest": "^29.4.1",
|
|
57
|
-
"typescript": "
|
|
58
|
-
"@rushstack/heft": "
|
|
59
|
-
"@rushstack/heft-web-rig": "0.29.
|
|
60
|
-
"@rushstack/eslint-config": "
|
|
61
|
-
"@rushstack/heft-jest-plugin": "
|
|
57
|
+
"typescript": "5.8.3",
|
|
58
|
+
"@rushstack/heft": "0.74.3",
|
|
59
|
+
"@rushstack/heft-web-rig": "0.29.8",
|
|
60
|
+
"@rushstack/eslint-config": "4.4.0",
|
|
61
|
+
"@rushstack/heft-jest-plugin": "0.16.12",
|
|
62
62
|
"@microsoft/api-documenter": "^7.26.31",
|
|
63
63
|
"@microsoft/api-extractor": "^7.52.10",
|
|
64
64
|
"@testing-library/dom": "^10.4.0",
|
|
65
|
-
"@fgv/ts-utils-jest": "5.0.0-
|
|
65
|
+
"@fgv/ts-utils-jest": "5.0.0-25"
|
|
66
66
|
},
|
|
67
67
|
"scripts": {
|
|
68
68
|
"build": "heft build --clean",
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Config file for API Extractor. For more info, please visit: https://api-extractor.com
|
|
3
|
-
*/
|
|
4
|
-
{
|
|
5
|
-
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* The path to the project folder, relative to the config file location
|
|
9
|
-
*/
|
|
10
|
-
"projectFolder": "..",
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* The entry point for the API extraction (must be a .d.ts file)
|
|
14
|
-
*/
|
|
15
|
-
"mainEntryPointFilePath": "<projectFolder>/lib/index.d.ts",
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* NPM packages to be treated as part of this package
|
|
19
|
-
*/
|
|
20
|
-
"bundledPackages": [],
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Compiler configuration
|
|
24
|
-
*/
|
|
25
|
-
"compiler": {
|
|
26
|
-
// Use the default tsconfig.json location
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* API report file generation
|
|
31
|
-
*/
|
|
32
|
-
"apiReport": {
|
|
33
|
-
"enabled": true,
|
|
34
|
-
"reportFolder": "<projectFolder>/etc/",
|
|
35
|
-
"reportTempFolder": "<projectFolder>/temp/"
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Doc model file generation (for API Documenter)
|
|
40
|
-
*/
|
|
41
|
-
"docModel": {
|
|
42
|
-
"enabled": true,
|
|
43
|
-
"apiJsonFilePath": "<projectFolder>/temp/<unscopedPackageName>.api.json"
|
|
44
|
-
},
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* .d.ts rollup file generation
|
|
48
|
-
*/
|
|
49
|
-
"dtsRollup": {
|
|
50
|
-
"enabled": true,
|
|
51
|
-
"untrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>.d.ts"
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* TSDoc metadata file generation
|
|
56
|
-
*/
|
|
57
|
-
"tsdocMetadata": {
|
|
58
|
-
"enabled": true
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Message reporting configuration
|
|
63
|
-
*/
|
|
64
|
-
"messages": {
|
|
65
|
-
"compilerMessageReporting": {
|
|
66
|
-
"default": {
|
|
67
|
-
"logLevel": "warning"
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
"extractorMessageReporting": {
|
|
71
|
-
"default": {
|
|
72
|
-
"logLevel": "warning"
|
|
73
|
-
},
|
|
74
|
-
"ae-unresolved-link": {
|
|
75
|
-
"logLevel": "none",
|
|
76
|
-
"addToApiReportFile": true
|
|
77
|
-
},
|
|
78
|
-
"ae-forgotten-export": {
|
|
79
|
-
"logLevel": "warning",
|
|
80
|
-
"addToApiReportFile": true
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
"tsdocMessageReporting": {
|
|
84
|
-
"default": {
|
|
85
|
-
"logLevel": "warning"
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
package/config/jest.setup.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
// Setup file for Jest tests
|
|
2
|
-
// Required for ts-utils which uses TextEncoder/TextDecoder
|
|
3
|
-
|
|
4
|
-
// Polyfill TextEncoder and TextDecoder for Node.js environment
|
|
5
|
-
if (typeof TextEncoder === 'undefined') {
|
|
6
|
-
const { TextEncoder, TextDecoder } = require('util');
|
|
7
|
-
global.TextEncoder = TextEncoder;
|
|
8
|
-
global.TextDecoder = TextDecoder;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// Mock File constructor for browser file operations
|
|
12
|
-
global.File = class MockFile {
|
|
13
|
-
constructor(bits, name, options = {}) {
|
|
14
|
-
this.bits = bits;
|
|
15
|
-
this.name = name;
|
|
16
|
-
this.type = options.type || '';
|
|
17
|
-
this.webkitRelativePath = options.webkitRelativePath || '';
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
// Mock FileReader for file reading operations
|
|
22
|
-
global.FileReader = class MockFileReader {
|
|
23
|
-
constructor() {
|
|
24
|
-
this.onload = null;
|
|
25
|
-
this.onerror = null;
|
|
26
|
-
this.result = null;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
readAsText(file) {
|
|
30
|
-
setTimeout(() => {
|
|
31
|
-
if (this.onload) {
|
|
32
|
-
this.result = file.bits ? file.bits[0] : '';
|
|
33
|
-
this.onload({ target: { result: this.result } });
|
|
34
|
-
}
|
|
35
|
-
}, 0);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
// Mock Blob for export operations
|
|
40
|
-
global.Blob = class MockBlob {
|
|
41
|
-
constructor(bits, options = {}) {
|
|
42
|
-
this.bits = bits;
|
|
43
|
-
this.type = options.type || '';
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
// Mock URL for createObjectURL/revokeObjectURL
|
|
48
|
-
global.URL = {
|
|
49
|
-
createObjectURL: jest.fn(() => 'mock-blob-url'),
|
|
50
|
-
revokeObjectURL: jest.fn()
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
// Extend jest matchers (toBeInTheDocument, etc.)
|
|
54
|
-
require('@testing-library/jest-dom');
|
|
55
|
-
|
|
56
|
-
// Suppress console output in tests by providing a no-op logger
|
|
57
|
-
// This affects both direct console calls and components that use logger dependency injection
|
|
58
|
-
global.testLogger = () => {}; // No-op logger for tests
|
|
59
|
-
global.console = {
|
|
60
|
-
...console,
|
|
61
|
-
log: global.testLogger,
|
|
62
|
-
warn: global.testLogger,
|
|
63
|
-
error: console.error // Keep error for actual test failures
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
// Mock document methods for file export
|
|
67
|
-
global.document = {
|
|
68
|
-
createElement: jest.fn(() => ({
|
|
69
|
-
href: '',
|
|
70
|
-
download: '',
|
|
71
|
-
click: jest.fn()
|
|
72
|
-
})),
|
|
73
|
-
body: {
|
|
74
|
-
appendChild: jest.fn(),
|
|
75
|
-
removeChild: jest.fn()
|
|
76
|
-
}
|
|
77
|
-
};
|
package/config/rig.json
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// The "rig.json" file directs tools to look for their config files in an external package.
|
|
2
|
-
// Documentation for this system: https://www.npmjs.com/package/@rushstack/rig-package
|
|
3
|
-
{
|
|
4
|
-
"$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json",
|
|
5
|
-
/**
|
|
6
|
-
* (Required) The name of the rig package to inherit from.
|
|
7
|
-
* It should be an NPM package name with the "-rig" suffix.
|
|
8
|
-
*/
|
|
9
|
-
"rigPackageName": "@rushstack/heft-web-rig",
|
|
10
|
-
/**
|
|
11
|
-
* (Optional) Selects a config profile from the rig package. The name must consist of
|
|
12
|
-
* lowercase alphanumeric words separated by hyphens, for example "sample-profile".
|
|
13
|
-
* If omitted, then the "default" profile will be used."
|
|
14
|
-
*/
|
|
15
|
-
"rigProfile": "library"
|
|
16
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Result } from '@fgv/ts-utils';
|
|
2
|
-
import { Config } from '@fgv/ts-res';
|
|
3
|
-
/**
|
|
4
|
-
* Generate a unique temp folder name with timestamp and random suffix
|
|
5
|
-
*/
|
|
6
|
-
export declare function createUniqueTempPath(prefix?: string): string;
|
|
7
|
-
/**
|
|
8
|
-
* Load a test configuration file from the existing test data
|
|
9
|
-
*/
|
|
10
|
-
export declare function loadTestConfiguration(testSet: 'default' | 'custom-config' | 'extended-example', filename?: string): Result<Config.Model.ISystemConfiguration>;
|
|
11
|
-
/**
|
|
12
|
-
* Load test resource files from a test set
|
|
13
|
-
*/
|
|
14
|
-
export declare function loadTestResources(testSet: 'default' | 'custom-config' | 'extended-example'): Result<Array<{
|
|
15
|
-
path: string;
|
|
16
|
-
content: string;
|
|
17
|
-
}>>;
|
|
18
|
-
/**
|
|
19
|
-
* Write test data to a temp file
|
|
20
|
-
*/
|
|
21
|
-
export declare function writeTempFile(tempDir: string, filename: string, content: string): Result<string>;
|
|
22
|
-
/**
|
|
23
|
-
* Write test data structure to temp directory
|
|
24
|
-
*/
|
|
25
|
-
export declare function writeTempResourceFiles(tempDir: string, files: Array<{
|
|
26
|
-
path: string;
|
|
27
|
-
content: string;
|
|
28
|
-
}>): Result<string[]>;
|
|
29
|
-
/**
|
|
30
|
-
* Load a test bundle file as buffer or text
|
|
31
|
-
*/
|
|
32
|
-
export declare function loadTestBundleFile(filename?: string, asBuffer?: boolean): Result<Buffer | string>;
|
|
33
|
-
/**
|
|
34
|
-
* Clean up temp directory (optional - temp folder is git-ignored)
|
|
35
|
-
*/
|
|
36
|
-
export declare function cleanupTempPath(tempPath: string): void;
|
|
37
|
-
//# sourceMappingURL=testDataLoader.d.ts.map
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2025 Erik Fortune
|
|
3
|
-
*
|
|
4
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
* in the Software without restriction, including without limitation the rights
|
|
7
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
* furnished to do so, subject to the following conditions:
|
|
10
|
-
*
|
|
11
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
-
* copies or substantial portions of the Software.
|
|
13
|
-
*
|
|
14
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
-
* SOFTWARE.
|
|
21
|
-
*/
|
|
22
|
-
import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'fs';
|
|
23
|
-
import { join, dirname } from 'path';
|
|
24
|
-
import { succeed, fail } from '@fgv/ts-utils';
|
|
25
|
-
/**
|
|
26
|
-
* Base path for test fixtures - using existing test data in monorepo
|
|
27
|
-
*/
|
|
28
|
-
const PROJECT_ROOT = dirname(dirname(dirname(__dirname)));
|
|
29
|
-
const FIXTURES_PATH = join(PROJECT_ROOT, '../../data/test/ts-res');
|
|
30
|
-
const TEMP_PATH = join(PROJECT_ROOT, 'temp');
|
|
31
|
-
/**
|
|
32
|
-
* Generate a unique temp folder name with timestamp and random suffix
|
|
33
|
-
*/
|
|
34
|
-
export function createUniqueTempPath(prefix = 'test') {
|
|
35
|
-
const timestamp = Date.now();
|
|
36
|
-
const random = Math.random().toString(36).substring(2, 8);
|
|
37
|
-
const uniqueName = `${prefix}-${timestamp}-${random}`;
|
|
38
|
-
const tempPath = join(TEMP_PATH, uniqueName);
|
|
39
|
-
// Create the temp directory
|
|
40
|
-
mkdirSync(tempPath, { recursive: true });
|
|
41
|
-
return tempPath;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Load a test configuration file from the existing test data
|
|
45
|
-
*/
|
|
46
|
-
export function loadTestConfiguration(testSet, filename) {
|
|
47
|
-
try {
|
|
48
|
-
let configPath;
|
|
49
|
-
if (testSet === 'default') {
|
|
50
|
-
configPath = join(FIXTURES_PATH, 'default', filename || 'default-config.json');
|
|
51
|
-
}
|
|
52
|
-
else if (testSet === 'custom-config') {
|
|
53
|
-
configPath = join(FIXTURES_PATH, 'custom-config', filename || 'resources-config.json');
|
|
54
|
-
}
|
|
55
|
-
else if (testSet === 'extended-example') {
|
|
56
|
-
configPath = join(FIXTURES_PATH, 'extended-example', filename || 'configuration.json');
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
return fail(`Unknown test set: ${testSet}`);
|
|
60
|
-
}
|
|
61
|
-
const configData = readFileSync(configPath, 'utf8');
|
|
62
|
-
const config = JSON.parse(configData);
|
|
63
|
-
return succeed(config);
|
|
64
|
-
}
|
|
65
|
-
catch (error) {
|
|
66
|
-
return fail(`Failed to load test configuration from ${testSet}/${filename}: ${error}`);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Load test resource files from a test set
|
|
71
|
-
*/
|
|
72
|
-
export function loadTestResources(testSet) {
|
|
73
|
-
try {
|
|
74
|
-
const resourcesPath = join(FIXTURES_PATH, testSet, 'resources');
|
|
75
|
-
const fs = require('fs');
|
|
76
|
-
if (!existsSync(resourcesPath)) {
|
|
77
|
-
return fail(`Test resource directory for ${testSet} does not exist`);
|
|
78
|
-
}
|
|
79
|
-
const files = [];
|
|
80
|
-
function readDirectory(dir, basePath = '') {
|
|
81
|
-
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
82
|
-
for (const entry of entries) {
|
|
83
|
-
const fullPath = join(dir, entry.name);
|
|
84
|
-
const relativePath = join(basePath, entry.name);
|
|
85
|
-
if (entry.isDirectory()) {
|
|
86
|
-
readDirectory(fullPath, relativePath);
|
|
87
|
-
}
|
|
88
|
-
else if (entry.isFile() && entry.name.endsWith('.json')) {
|
|
89
|
-
const content = readFileSync(fullPath, 'utf8');
|
|
90
|
-
files.push({ path: relativePath, content });
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
readDirectory(resourcesPath);
|
|
95
|
-
return succeed(files);
|
|
96
|
-
}
|
|
97
|
-
catch (error) {
|
|
98
|
-
return fail(`Failed to load test resources from ${testSet}: ${error}`);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Write test data to a temp file
|
|
103
|
-
*/
|
|
104
|
-
export function writeTempFile(tempDir, filename, content) {
|
|
105
|
-
try {
|
|
106
|
-
const filePath = join(tempDir, filename);
|
|
107
|
-
const fileDir = dirname(filePath);
|
|
108
|
-
// Ensure directory exists
|
|
109
|
-
if (!existsSync(fileDir)) {
|
|
110
|
-
mkdirSync(fileDir, { recursive: true });
|
|
111
|
-
}
|
|
112
|
-
writeFileSync(filePath, content, 'utf8');
|
|
113
|
-
return succeed(filePath);
|
|
114
|
-
}
|
|
115
|
-
catch (error) {
|
|
116
|
-
return fail(`Failed to write temp file ${filename}: ${error}`);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Write test data structure to temp directory
|
|
121
|
-
*/
|
|
122
|
-
export function writeTempResourceFiles(tempDir, files) {
|
|
123
|
-
try {
|
|
124
|
-
const writtenPaths = [];
|
|
125
|
-
for (const file of files) {
|
|
126
|
-
const result = writeTempFile(tempDir, file.path, file.content);
|
|
127
|
-
if (result.isFailure()) {
|
|
128
|
-
return fail(`Failed to write resource file ${file.path}: ${result.message}`);
|
|
129
|
-
}
|
|
130
|
-
writtenPaths.push(result.value);
|
|
131
|
-
}
|
|
132
|
-
return succeed(writtenPaths);
|
|
133
|
-
}
|
|
134
|
-
catch (error) {
|
|
135
|
-
return fail(`Failed to write temp resource files: ${error}`);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Load a test bundle file as buffer or text
|
|
140
|
-
*/
|
|
141
|
-
export function loadTestBundleFile(filename = 'extended.resource-bundle.json', asBuffer = false) {
|
|
142
|
-
try {
|
|
143
|
-
const bundlePath = join(FIXTURES_PATH, filename);
|
|
144
|
-
if (asBuffer) {
|
|
145
|
-
const buffer = readFileSync(bundlePath);
|
|
146
|
-
return succeed(buffer);
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
const text = readFileSync(bundlePath, 'utf8');
|
|
150
|
-
return succeed(text);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
catch (error) {
|
|
154
|
-
return fail(`Failed to load test bundle file ${filename}: ${error}`);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Clean up temp directory (optional - temp folder is git-ignored)
|
|
159
|
-
*/
|
|
160
|
-
export function cleanupTempPath(tempPath) {
|
|
161
|
-
try {
|
|
162
|
-
const fs = require('fs');
|
|
163
|
-
if (existsSync(tempPath)) {
|
|
164
|
-
fs.rmSync(tempPath, { recursive: true, force: true });
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
catch (error) {
|
|
168
|
-
console.warn(`Warning: Failed to cleanup temp path ${tempPath}:`, error);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
//# sourceMappingURL=testDataLoader.js.map
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Basic unit tests for ResourcePicker component
|
|
3
|
-
*
|
|
4
|
-
* Note: These are simplified tests that focus on the core functionality
|
|
5
|
-
* without requiring full testing library setup. For comprehensive testing,
|
|
6
|
-
* the component should be tested in the actual application context.
|
|
7
|
-
*/
|
|
8
|
-
export {};
|
|
9
|
-
//# sourceMappingURL=ResourcePicker.test.d.ts.map
|