@uxland/primary-shell 7.38.5 → 7.40.0
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/component-t8PFluu3.js +52 -0
- package/dist/component-t8PFluu3.js.map +1 -0
- package/dist/{index-iNJRh1Zz.js → index-RXjJQygZ.js} +70 -45
- package/dist/index-RXjJQygZ.js.map +1 -0
- package/dist/index.js +3 -3
- package/dist/index.umd.cjs +53 -45
- package/dist/index.umd.cjs.map +1 -1
- package/dist/primary/shell/src/api/import-data-manager/component/component.d.ts +2 -5
- package/dist/primary/shell/src/api/import-data-manager/import-data-manager-impl.d.ts +4 -2
- package/dist/primary/shell/src/api/import-data-manager/import-data-manager.d.ts +17 -1
- package/dist/primary/shell/src/api/region-manager/regions.d.ts +1 -0
- package/dist/primary/shell/src/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/api/import-data-manager/component/component.ts +2 -10
- package/src/api/import-data-manager/component/styles.css +47 -12
- package/src/api/import-data-manager/component/template.ts +23 -14
- package/src/api/import-data-manager/import-data-manager-impl.test.ts +107 -103
- package/src/api/import-data-manager/import-data-manager-impl.ts +29 -18
- package/src/api/import-data-manager/import-data-manager.ts +28 -6
- package/src/api/import-data-manager/index.ts +2 -2
- package/src/api/region-manager/regions.ts +1 -0
- package/src/index.ts +5 -1
- package/dist/component-BVxZwqoc.js +0 -47
- package/dist/component-BVxZwqoc.js.map +0 -1
- package/dist/index-iNJRh1Zz.js.map +0 -1
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
2
|
import { ConfirmationContentProps } from '../../interaction-service';
|
|
3
|
-
declare
|
|
4
|
-
export declare class ImportDataManagerModal extends ImportDataManagerModal_base implements ConfirmationContentProps<undefined, undefined> {
|
|
3
|
+
export declare class ImportDataManagerModal extends LitElement implements ConfirmationContentProps<undefined, undefined> {
|
|
5
4
|
data: undefined;
|
|
6
5
|
setResult: (result: undefined) => void;
|
|
7
6
|
setIsValid: (isValid: boolean) => void;
|
|
8
7
|
confirm: () => void;
|
|
9
8
|
cancel: () => void;
|
|
10
|
-
importDataRegion: IRegion | undefined;
|
|
11
9
|
render(): import('lit').TemplateResult<1>;
|
|
12
10
|
static styles: import('lit').CSSResult;
|
|
13
11
|
_accept: () => void;
|
|
14
12
|
}
|
|
15
|
-
export {};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { PrimariaImportDataManager } from './import-data-manager';
|
|
1
|
+
import { ImportParams, PrimariaImportDataManager } from './import-data-manager';
|
|
2
2
|
import { PrimariaInteractionService } from '../interaction-service/interaction-service';
|
|
3
3
|
export declare class ImportDataManagerImpl implements PrimariaImportDataManager {
|
|
4
4
|
private interactionService;
|
|
5
5
|
private selectedItems;
|
|
6
6
|
private currentImporterId;
|
|
7
|
+
private currentImportParams;
|
|
7
8
|
private pluginTexts;
|
|
8
9
|
constructor(interactionService: PrimariaInteractionService);
|
|
9
|
-
import(importerId: string): Promise<{
|
|
10
|
+
import(importerId: string, params?: ImportParams): Promise<{
|
|
10
11
|
accepted: boolean;
|
|
11
12
|
data: Record<string, any[]>;
|
|
12
13
|
text: {
|
|
@@ -23,5 +24,6 @@ export declare class ImportDataManagerImpl implements PrimariaImportDataManager
|
|
|
23
24
|
};
|
|
24
25
|
}): void;
|
|
25
26
|
getCurrentImporterId(): string;
|
|
27
|
+
getCurrentImportParams(): ImportParams | undefined;
|
|
26
28
|
private getConcatenatedText;
|
|
27
29
|
}
|
|
@@ -1,5 +1,18 @@
|
|
|
1
|
+
export interface ImportParamsDiagnostic {
|
|
2
|
+
code: string;
|
|
3
|
+
catalog: string;
|
|
4
|
+
description: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ImportParams {
|
|
7
|
+
/** Optional list of diagnostics the consumer wants the activity-history
|
|
8
|
+
* importer to filter by. If absent, the diagnostics filter is hidden.
|
|
9
|
+
* Plugins must map their own diagnostic shape to this common model. */
|
|
10
|
+
diagnostics?: ImportParamsDiagnostic[];
|
|
11
|
+
/** Open extension point for future per-importer parameters. */
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
}
|
|
1
14
|
export interface PrimariaImportDataManager {
|
|
2
|
-
import(importerId: string): Promise<{
|
|
15
|
+
import(importerId: string, params?: ImportParams): Promise<{
|
|
3
16
|
accepted: boolean;
|
|
4
17
|
data: Record<string, any[]>;
|
|
5
18
|
text: {
|
|
@@ -16,4 +29,7 @@ export interface PrimariaImportDataManager {
|
|
|
16
29
|
};
|
|
17
30
|
}): void;
|
|
18
31
|
getCurrentImporterId(): string;
|
|
32
|
+
/** Returns the params the current importer was opened with (or undefined
|
|
33
|
+
* if no import is in progress). */
|
|
34
|
+
getCurrentImportParams(): ImportParams | undefined;
|
|
19
35
|
}
|
|
@@ -16,7 +16,7 @@ export * from './api/interaction-service';
|
|
|
16
16
|
export { ExitShell } from './features/exit/request';
|
|
17
17
|
export type { ExitShellPayload } from './features/exit/request';
|
|
18
18
|
export type { IUserInfo } from './features/get-user-info/model';
|
|
19
|
-
export type { IActivityHistoryItem } from '../../../plugins/activity-history/src/activity-history-item/domain/model';
|
|
19
|
+
export type { IActivityHistoryItem, IHistoryDataImporterContext, IHistoryDataImporterRules, } from '../../../plugins/activity-history/src/activity-history-item/domain/model';
|
|
20
20
|
export type { InjectAsyncHistoryItemsPayload } from '../../../plugins/activity-history/src/activity-history-item/add/add-async-history-items/request';
|
|
21
21
|
export type { AddHistoryItemPayload } from '../../../plugins/activity-history/src/activity-history-item/add/add-history-item/request';
|
|
22
22
|
export type { AddHistoryItemsPayload } from '../../../plugins/activity-history/src/activity-history-item/add/add-history-items/request';
|
package/package.json
CHANGED
|
@@ -1,25 +1,17 @@
|
|
|
1
|
-
import { IRegion, region } from "@uxland/regions";
|
|
2
1
|
import { LitElement, css, html, unsafeCSS } from "lit";
|
|
3
2
|
import { customElement } from "lit/decorators.js";
|
|
3
|
+
import { ConfirmationContentProps } from "../../interaction-service";
|
|
4
4
|
import styles from "./styles.css?inline";
|
|
5
5
|
import { template } from "./template";
|
|
6
|
-
import { ConfirmationContentProps } from "../../interaction-service";
|
|
7
|
-
import { PrimariaRegionHost, shellApi } from "../../api";
|
|
8
6
|
|
|
9
7
|
@customElement("import-data-manager-modal")
|
|
10
|
-
export class ImportDataManagerModal
|
|
11
|
-
extends PrimariaRegionHost(LitElement)
|
|
12
|
-
implements ConfirmationContentProps<undefined, undefined>
|
|
13
|
-
{
|
|
8
|
+
export class ImportDataManagerModal extends LitElement implements ConfirmationContentProps<undefined, undefined> {
|
|
14
9
|
data: undefined;
|
|
15
10
|
setResult: (result: undefined) => void;
|
|
16
11
|
setIsValid: (isValid: boolean) => void;
|
|
17
12
|
confirm: () => void;
|
|
18
13
|
cancel: () => void;
|
|
19
14
|
|
|
20
|
-
@region({ targetId: "import-data-region", name: shellApi.regionManager.regions.shell.importData })
|
|
21
|
-
importDataRegion: IRegion | undefined;
|
|
22
|
-
|
|
23
15
|
render() {
|
|
24
16
|
return html`${template(this)}`;
|
|
25
17
|
}
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
display: flex;
|
|
4
4
|
flex-direction: column;
|
|
5
5
|
min-width: 500px;
|
|
6
|
-
width:
|
|
7
|
-
height:
|
|
6
|
+
width: 95vw;
|
|
7
|
+
height: 95vh;
|
|
8
8
|
border-radius: var(--dss-radius-sm);
|
|
9
9
|
overflow: hidden;
|
|
10
10
|
}
|
|
@@ -27,23 +27,58 @@
|
|
|
27
27
|
|
|
28
28
|
.content{
|
|
29
29
|
display: grid;
|
|
30
|
-
|
|
31
|
-
min-height:
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
flex: 1;
|
|
31
|
+
min-height: 0;
|
|
32
|
+
/* TEMPORAL: amaguem la columna esquerra (importDataActivityHistory) fins
|
|
33
|
+
que el client validi la nova UX. Per reactivar, tornar a
|
|
34
|
+
`grid-template-columns: 1fr 1fr;` i treure el `display: none` de sota. */
|
|
35
|
+
grid-template-columns: 1fr;
|
|
34
36
|
gap: 16px;
|
|
35
37
|
padding: 16px;
|
|
36
|
-
overflow-y: auto;
|
|
37
|
-
max-height: calc(90vh - 120px);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
.content >
|
|
40
|
+
.content > primaria-region[name="import-data-activity-history-region"] {
|
|
41
|
+
display: none;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.content > primaria-region {
|
|
45
|
+
width: 100%;
|
|
46
|
+
height: 100%;
|
|
47
|
+
min-height: 0;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.content primaria-region > div {
|
|
51
|
+
width: 100%;
|
|
52
|
+
height: 100%;
|
|
41
53
|
border: 1px solid var(--color-neutral-200);
|
|
42
54
|
border-radius: 8px;
|
|
43
55
|
padding: 16px;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
56
|
+
box-sizing: border-box;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* Right column: stacks plugin cards and scrolls as a whole. */
|
|
60
|
+
.content > primaria-region[name="import-data-region"] > div {
|
|
61
|
+
overflow-y: auto;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/* Left column: vertical stack of multiple views with a gap. The last view
|
|
65
|
+
takes the remaining space and handles its own scroll; preceding views
|
|
66
|
+
keep their natural height. */
|
|
67
|
+
.content > primaria-region[name="import-data-activity-history-region"] > div {
|
|
68
|
+
display: flex;
|
|
69
|
+
flex-direction: column;
|
|
70
|
+
gap: 16px;
|
|
71
|
+
overflow: hidden;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.content > primaria-region[name="import-data-activity-history-region"] > div > * {
|
|
75
|
+
flex-shrink: 0;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.content > primaria-region[name="import-data-activity-history-region"] > div > *:last-child {
|
|
79
|
+
flex: 1;
|
|
80
|
+
min-height: 0;
|
|
81
|
+
}
|
|
47
82
|
|
|
48
83
|
.footer {
|
|
49
84
|
display: flex;
|
|
@@ -1,24 +1,33 @@
|
|
|
1
1
|
import { html } from "lit";
|
|
2
2
|
import { translate } from "../../../locales";
|
|
3
|
+
import { shellApi } from "../../api";
|
|
3
4
|
import { ImportDataManagerModal } from "./component";
|
|
4
5
|
|
|
5
6
|
export const template = (props: ImportDataManagerModal) => {
|
|
6
7
|
return html`
|
|
7
8
|
<div class="container">
|
|
8
|
-
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
<
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
9
|
+
<div class="content">
|
|
10
|
+
<primaria-region name="${shellApi.regionManager.regions.shell.importDataActivityHistory}"></primaria-region>
|
|
11
|
+
<primaria-region name="${shellApi.regionManager.regions.shell.importData}"></primaria-region>
|
|
12
|
+
</div>
|
|
13
|
+
<div class="footer">
|
|
14
|
+
<dss-button
|
|
15
|
+
label="${translate("importDataManager.actions.cancel")}"
|
|
16
|
+
@click="${() => {
|
|
17
|
+
props.cancel();
|
|
18
|
+
}}"
|
|
19
|
+
size="md"
|
|
20
|
+
variant="secondary"
|
|
21
|
+
></dss-button>
|
|
22
|
+
<dss-button
|
|
23
|
+
label="${translate("importDataManager.actions.import")}"
|
|
24
|
+
@click="${() => {
|
|
25
|
+
props._accept();
|
|
26
|
+
}}"
|
|
27
|
+
size="md"
|
|
28
|
+
variant="primary"
|
|
29
|
+
></dss-button>
|
|
30
|
+
</div>
|
|
22
31
|
</div>
|
|
23
32
|
`;
|
|
24
33
|
};
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
-
import { ImportDataManagerImpl } from
|
|
3
|
-
import {
|
|
2
|
+
import { ImportDataManagerImpl } from "./import-data-manager-impl";
|
|
3
|
+
import {
|
|
4
|
+
PrimariaInteractionService,
|
|
5
|
+
ConfirmationOptions,
|
|
6
|
+
ConfirmComponentUI,
|
|
7
|
+
ConfirmationResult,
|
|
8
|
+
} from "../interaction-service/interaction-service";
|
|
4
9
|
|
|
5
10
|
// Mock del PrimariaInteractionService
|
|
6
11
|
class MockInteractionService extends PrimariaInteractionService {
|
|
@@ -19,15 +24,12 @@ class MockInteractionService extends PrimariaInteractionService {
|
|
|
19
24
|
return Promise.resolve(this.mockConfirmResult as ConfirmationResult<TResult | undefined>);
|
|
20
25
|
}
|
|
21
26
|
|
|
22
|
-
async confirmMessage(
|
|
23
|
-
_message: string,
|
|
24
|
-
_options?: ConfirmationOptions | undefined,
|
|
25
|
-
): Promise<ConfirmationResult> {
|
|
27
|
+
async confirmMessage(_message: string, _options?: ConfirmationOptions | undefined): Promise<ConfirmationResult> {
|
|
26
28
|
return Promise.resolve({ confirmed: this.mockConfirmResult.confirmed, result: undefined });
|
|
27
29
|
}
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
describe(
|
|
32
|
+
describe("ImportDataManagerImpl implements PrimariaImportDataManager", () => {
|
|
31
33
|
let importDataManager: ImportDataManagerImpl;
|
|
32
34
|
let mockInteractionService: MockInteractionService;
|
|
33
35
|
|
|
@@ -36,28 +38,28 @@ describe('ImportDataManagerImpl implements PrimariaImportDataManager', () => {
|
|
|
36
38
|
importDataManager = new ImportDataManagerImpl(mockInteractionService);
|
|
37
39
|
});
|
|
38
40
|
|
|
39
|
-
describe(
|
|
40
|
-
it(
|
|
41
|
-
expect(importDataManager.getCurrentImporterId()).toBe(
|
|
41
|
+
describe("getCurrentImporterId", () => {
|
|
42
|
+
it("should return empty string initially", () => {
|
|
43
|
+
expect(importDataManager.getCurrentImporterId()).toBe("");
|
|
42
44
|
});
|
|
43
45
|
|
|
44
|
-
it(
|
|
46
|
+
it("should return the current importer ID after calling import", async () => {
|
|
45
47
|
mockInteractionService.setMockConfirmResult({ confirmed: true });
|
|
46
48
|
|
|
47
|
-
const promise = importDataManager.import(
|
|
48
|
-
expect(importDataManager.getCurrentImporterId()).toBe(
|
|
49
|
+
const promise = importDataManager.import("test-importer-123");
|
|
50
|
+
expect(importDataManager.getCurrentImporterId()).toBe("test-importer-123");
|
|
49
51
|
|
|
50
52
|
await promise;
|
|
51
|
-
expect(importDataManager.getCurrentImporterId()).toBe(
|
|
53
|
+
expect(importDataManager.getCurrentImporterId()).toBe("");
|
|
52
54
|
});
|
|
53
55
|
});
|
|
54
56
|
|
|
55
|
-
describe(
|
|
56
|
-
it(
|
|
57
|
+
describe("selectItems", () => {
|
|
58
|
+
it("should store selected items correctly", () => {
|
|
57
59
|
const payload = {
|
|
58
|
-
pluginId:
|
|
59
|
-
data: [{ id:
|
|
60
|
-
text: { raw:
|
|
60
|
+
pluginId: "test-plugin",
|
|
61
|
+
data: [{ id: "1", name: "Test Item" }],
|
|
62
|
+
text: { raw: "Test Item", html: "<p>Test Item</p>" },
|
|
61
63
|
};
|
|
62
64
|
|
|
63
65
|
importDataManager.selectItems(payload);
|
|
@@ -66,17 +68,17 @@ describe('ImportDataManagerImpl implements PrimariaImportDataManager', () => {
|
|
|
66
68
|
expect(() => importDataManager.selectItems(payload)).not.toThrow();
|
|
67
69
|
});
|
|
68
70
|
|
|
69
|
-
it(
|
|
71
|
+
it("should handle multiple plugin selections", () => {
|
|
70
72
|
const payload1 = {
|
|
71
|
-
pluginId:
|
|
72
|
-
data: [{ id:
|
|
73
|
-
text: { raw:
|
|
73
|
+
pluginId: "plugin-1",
|
|
74
|
+
data: [{ id: "1", name: "Item 1" }],
|
|
75
|
+
text: { raw: "Item 1", html: "<p>Item 1</p>" },
|
|
74
76
|
};
|
|
75
77
|
|
|
76
78
|
const payload2 = {
|
|
77
|
-
pluginId:
|
|
78
|
-
data: [{ id:
|
|
79
|
-
text: { raw:
|
|
79
|
+
pluginId: "plugin-2",
|
|
80
|
+
data: [{ id: "2", name: "Item 2" }],
|
|
81
|
+
text: { raw: "Item 2", html: "<p>Item 2</p>" },
|
|
80
82
|
};
|
|
81
83
|
|
|
82
84
|
expect(() => {
|
|
@@ -85,17 +87,17 @@ describe('ImportDataManagerImpl implements PrimariaImportDataManager', () => {
|
|
|
85
87
|
}).not.toThrow();
|
|
86
88
|
});
|
|
87
89
|
|
|
88
|
-
it(
|
|
90
|
+
it("should overwrite previous selections from same plugin", () => {
|
|
89
91
|
const payload1 = {
|
|
90
|
-
pluginId:
|
|
91
|
-
data: [{ id:
|
|
92
|
-
text: { raw:
|
|
92
|
+
pluginId: "test-plugin",
|
|
93
|
+
data: [{ id: "1", name: "First Item" }],
|
|
94
|
+
text: { raw: "First Item", html: "<p>First Item</p>" },
|
|
93
95
|
};
|
|
94
96
|
|
|
95
97
|
const payload2 = {
|
|
96
|
-
pluginId:
|
|
97
|
-
data: [{ id:
|
|
98
|
-
text: { raw:
|
|
98
|
+
pluginId: "test-plugin",
|
|
99
|
+
data: [{ id: "2", name: "Second Item" }],
|
|
100
|
+
text: { raw: "Second Item", html: "<p>Second Item</p>" },
|
|
99
101
|
};
|
|
100
102
|
|
|
101
103
|
expect(() => {
|
|
@@ -105,178 +107,180 @@ describe('ImportDataManagerImpl implements PrimariaImportDataManager', () => {
|
|
|
105
107
|
});
|
|
106
108
|
});
|
|
107
109
|
|
|
108
|
-
describe(
|
|
109
|
-
it(
|
|
110
|
+
describe("import", () => {
|
|
111
|
+
it("should return accepted result with concatenated text when confirmed", async () => {
|
|
110
112
|
mockInteractionService.setMockConfirmResult({ confirmed: true });
|
|
111
113
|
|
|
112
114
|
// Mock the import to allow setting up items during the import process
|
|
113
115
|
const originalConfirm = mockInteractionService.confirm.bind(mockInteractionService);
|
|
114
|
-
vi.spyOn(mockInteractionService,
|
|
116
|
+
vi.spyOn(mockInteractionService, "confirm").mockImplementation(async (...args) => {
|
|
115
117
|
// Setup some selected items during the import process (simulating user interaction)
|
|
116
118
|
importDataManager.selectItems({
|
|
117
|
-
pluginId:
|
|
118
|
-
data: [{ id:
|
|
119
|
-
text: { raw:
|
|
119
|
+
pluginId: "plugin-1",
|
|
120
|
+
data: [{ id: "1", name: "Item 1" }],
|
|
121
|
+
text: { raw: "Item 1", html: "<p>Item 1</p>" },
|
|
120
122
|
});
|
|
121
123
|
|
|
122
124
|
importDataManager.selectItems({
|
|
123
|
-
pluginId:
|
|
124
|
-
data: [{ id:
|
|
125
|
-
text: { raw:
|
|
125
|
+
pluginId: "plugin-2",
|
|
126
|
+
data: [{ id: "2", name: "Item 2" }],
|
|
127
|
+
text: { raw: "Item 2", html: "<p>Item 2</p>" },
|
|
126
128
|
});
|
|
127
129
|
|
|
128
130
|
return originalConfirm(...args);
|
|
129
131
|
});
|
|
130
132
|
|
|
131
|
-
const result = await importDataManager.import(
|
|
133
|
+
const result = await importDataManager.import("test-importer");
|
|
132
134
|
|
|
133
135
|
expect(result.accepted).toBe(true);
|
|
134
136
|
expect(result.data).toEqual({
|
|
135
|
-
|
|
136
|
-
|
|
137
|
+
"plugin-1": [{ id: "1", name: "Item 1" }],
|
|
138
|
+
"plugin-2": [{ id: "2", name: "Item 2" }],
|
|
137
139
|
});
|
|
138
|
-
expect(result.text.raw).toBe(
|
|
139
|
-
expect(result.text.html).toBe(
|
|
140
|
+
expect(result.text.raw).toBe("Item 1\n\nItem 2");
|
|
141
|
+
expect(result.text.html).toBe("<p>Item 1</p><br><br><p>Item 2</p>");
|
|
140
142
|
});
|
|
141
143
|
|
|
142
|
-
it(
|
|
144
|
+
it("should return cancelled result with empty data when not confirmed", async () => {
|
|
143
145
|
mockInteractionService.setMockConfirmResult({ confirmed: false });
|
|
144
146
|
|
|
145
147
|
// Setup some selected items
|
|
146
148
|
importDataManager.selectItems({
|
|
147
|
-
pluginId:
|
|
148
|
-
data: [{ id:
|
|
149
|
-
text: { raw:
|
|
149
|
+
pluginId: "plugin-1",
|
|
150
|
+
data: [{ id: "1", name: "Item 1" }],
|
|
151
|
+
text: { raw: "Item 1", html: "<p>Item 1</p>" },
|
|
150
152
|
});
|
|
151
153
|
|
|
152
|
-
const result = await importDataManager.import(
|
|
154
|
+
const result = await importDataManager.import("test-importer");
|
|
153
155
|
|
|
154
156
|
expect(result.accepted).toBe(false);
|
|
155
157
|
expect(result.data).toEqual({});
|
|
156
|
-
expect(result.text.raw).toBe(
|
|
157
|
-
expect(result.text.html).toBe(
|
|
158
|
+
expect(result.text.raw).toBe("");
|
|
159
|
+
expect(result.text.html).toBe("");
|
|
158
160
|
});
|
|
159
161
|
|
|
160
|
-
it(
|
|
162
|
+
it("should clear state after successful import", async () => {
|
|
161
163
|
mockInteractionService.setMockConfirmResult({ confirmed: true });
|
|
162
164
|
|
|
163
165
|
// Setup selected items
|
|
164
166
|
importDataManager.selectItems({
|
|
165
|
-
pluginId:
|
|
166
|
-
data: [{ id:
|
|
167
|
-
text: { raw:
|
|
167
|
+
pluginId: "test-plugin",
|
|
168
|
+
data: [{ id: "1", name: "Test Item" }],
|
|
169
|
+
text: { raw: "Test Item", html: "<p>Test Item</p>" },
|
|
168
170
|
});
|
|
169
171
|
|
|
170
|
-
await importDataManager.import(
|
|
172
|
+
await importDataManager.import("test-importer");
|
|
171
173
|
|
|
172
174
|
// Verify state is cleared
|
|
173
|
-
expect(importDataManager.getCurrentImporterId()).toBe(
|
|
175
|
+
expect(importDataManager.getCurrentImporterId()).toBe("");
|
|
174
176
|
|
|
175
177
|
// Verify that subsequent import returns empty data
|
|
176
|
-
const result = await importDataManager.import(
|
|
178
|
+
const result = await importDataManager.import("another-importer");
|
|
177
179
|
expect(result.data).toEqual({});
|
|
178
|
-
expect(result.text.raw).toBe(
|
|
179
|
-
expect(result.text.html).toBe(
|
|
180
|
+
expect(result.text.raw).toBe("");
|
|
181
|
+
expect(result.text.html).toBe("");
|
|
180
182
|
});
|
|
181
183
|
|
|
182
|
-
it(
|
|
184
|
+
it("should clear state after cancelled import", async () => {
|
|
183
185
|
mockInteractionService.setMockConfirmResult({ confirmed: false });
|
|
184
186
|
|
|
185
187
|
// Setup selected items
|
|
186
188
|
importDataManager.selectItems({
|
|
187
|
-
pluginId:
|
|
188
|
-
data: [{ id:
|
|
189
|
-
text: { raw:
|
|
189
|
+
pluginId: "test-plugin",
|
|
190
|
+
data: [{ id: "1", name: "Test Item" }],
|
|
191
|
+
text: { raw: "Test Item", html: "<p>Test Item</p>" },
|
|
190
192
|
});
|
|
191
193
|
|
|
192
|
-
await importDataManager.import(
|
|
194
|
+
await importDataManager.import("test-importer");
|
|
193
195
|
|
|
194
196
|
// Verify state is cleared
|
|
195
|
-
expect(importDataManager.getCurrentImporterId()).toBe(
|
|
197
|
+
expect(importDataManager.getCurrentImporterId()).toBe("");
|
|
196
198
|
});
|
|
197
199
|
|
|
198
|
-
it(
|
|
200
|
+
it("should handle empty selections", async () => {
|
|
199
201
|
mockInteractionService.setMockConfirmResult({ confirmed: true });
|
|
200
202
|
|
|
201
|
-
const result = await importDataManager.import(
|
|
203
|
+
const result = await importDataManager.import("test-importer");
|
|
202
204
|
|
|
203
205
|
expect(result.accepted).toBe(true);
|
|
204
206
|
expect(result.data).toEqual({});
|
|
205
|
-
expect(result.text.raw).toBe(
|
|
206
|
-
expect(result.text.html).toBe(
|
|
207
|
+
expect(result.text.raw).toBe("");
|
|
208
|
+
expect(result.text.html).toBe("");
|
|
207
209
|
});
|
|
208
210
|
|
|
209
|
-
it(
|
|
211
|
+
it("should handle error and clear state", async () => {
|
|
210
212
|
mockInteractionService.setMockConfirmResult({ confirmed: true });
|
|
211
213
|
|
|
212
214
|
// Mock the interaction service to throw an error
|
|
213
|
-
vi.spyOn(mockInteractionService,
|
|
215
|
+
vi.spyOn(mockInteractionService, "confirm").mockRejectedValueOnce(new Error("Test error"));
|
|
214
216
|
|
|
215
217
|
// Setup selected items
|
|
216
218
|
importDataManager.selectItems({
|
|
217
|
-
pluginId:
|
|
218
|
-
data: [{ id:
|
|
219
|
-
text: { raw:
|
|
219
|
+
pluginId: "test-plugin",
|
|
220
|
+
data: [{ id: "1", name: "Test Item" }],
|
|
221
|
+
text: { raw: "Test Item", html: "<p>Test Item</p>" },
|
|
220
222
|
});
|
|
221
223
|
|
|
222
|
-
await expect(importDataManager.import(
|
|
224
|
+
await expect(importDataManager.import("test-importer")).rejects.toThrow("Test error");
|
|
223
225
|
|
|
224
226
|
// Verify state is cleared even after error
|
|
225
|
-
expect(importDataManager.getCurrentImporterId()).toBe(
|
|
227
|
+
expect(importDataManager.getCurrentImporterId()).toBe("");
|
|
226
228
|
});
|
|
227
229
|
|
|
228
|
-
it(
|
|
230
|
+
it("should handle text concatenation correctly with multiple plugins", async () => {
|
|
229
231
|
mockInteractionService.setMockConfirmResult({ confirmed: true });
|
|
230
232
|
|
|
231
233
|
// Mock the import to allow setting up items during the import process
|
|
232
234
|
const originalConfirm = mockInteractionService.confirm.bind(mockInteractionService);
|
|
233
|
-
vi.spyOn(mockInteractionService,
|
|
235
|
+
vi.spyOn(mockInteractionService, "confirm").mockImplementation(async (...args) => {
|
|
234
236
|
importDataManager.selectItems({
|
|
235
|
-
pluginId:
|
|
236
|
-
data: [{ code:
|
|
237
|
-
text: { raw:
|
|
237
|
+
pluginId: "diagnostics",
|
|
238
|
+
data: [{ code: "E11.9", name: "Diabetes" }],
|
|
239
|
+
text: { raw: "E11.9 - Diabetes", html: "<p><strong>E11.9</strong> - Diabetes</p>" },
|
|
238
240
|
});
|
|
239
241
|
|
|
240
242
|
importDataManager.selectItems({
|
|
241
|
-
pluginId:
|
|
242
|
-
data: [{ name:
|
|
243
|
-
text: { raw:
|
|
243
|
+
pluginId: "allergies",
|
|
244
|
+
data: [{ name: "Penicillin", severity: "High" }],
|
|
245
|
+
text: { raw: "Penicillin - High severity", html: "<p><strong>Penicillin</strong> - High severity</p>" },
|
|
244
246
|
});
|
|
245
247
|
|
|
246
248
|
return originalConfirm(...args);
|
|
247
249
|
});
|
|
248
250
|
|
|
249
|
-
const result = await importDataManager.import(
|
|
251
|
+
const result = await importDataManager.import("test-importer");
|
|
250
252
|
|
|
251
|
-
expect(result.text.raw).toBe(
|
|
252
|
-
expect(result.text.html).toBe(
|
|
253
|
+
expect(result.text.raw).toBe("E11.9 - Diabetes\n\nPenicillin - High severity");
|
|
254
|
+
expect(result.text.html).toBe(
|
|
255
|
+
"<p><strong>E11.9</strong> - Diabetes</p><br><br><p><strong>Penicillin</strong> - High severity</p>",
|
|
256
|
+
);
|
|
253
257
|
});
|
|
254
258
|
|
|
255
|
-
it(
|
|
259
|
+
it("should handle empty text values in concatenation", async () => {
|
|
256
260
|
mockInteractionService.setMockConfirmResult({ confirmed: true });
|
|
257
261
|
|
|
258
262
|
// Mock the import to allow setting up items during the import process
|
|
259
263
|
const originalConfirm = mockInteractionService.confirm.bind(mockInteractionService);
|
|
260
|
-
vi.spyOn(mockInteractionService,
|
|
264
|
+
vi.spyOn(mockInteractionService, "confirm").mockImplementation(async (...args) => {
|
|
261
265
|
importDataManager.selectItems({
|
|
262
|
-
pluginId:
|
|
263
|
-
data: [{ id:
|
|
264
|
-
text: { raw:
|
|
266
|
+
pluginId: "plugin-1",
|
|
267
|
+
data: [{ id: "1" }],
|
|
268
|
+
text: { raw: "", html: "" },
|
|
265
269
|
});
|
|
266
270
|
|
|
267
271
|
importDataManager.selectItems({
|
|
268
|
-
pluginId:
|
|
269
|
-
data: [{ id:
|
|
270
|
-
text: { raw:
|
|
272
|
+
pluginId: "plugin-2",
|
|
273
|
+
data: [{ id: "2" }],
|
|
274
|
+
text: { raw: "Item 2", html: "<p>Item 2</p>" },
|
|
271
275
|
});
|
|
272
276
|
|
|
273
277
|
return originalConfirm(...args);
|
|
274
278
|
});
|
|
275
279
|
|
|
276
|
-
const result = await importDataManager.import(
|
|
280
|
+
const result = await importDataManager.import("test-importer");
|
|
277
281
|
|
|
278
|
-
expect(result.text.raw).toBe(
|
|
279
|
-
expect(result.text.html).toBe(
|
|
282
|
+
expect(result.text.raw).toBe("Item 2");
|
|
283
|
+
expect(result.text.html).toBe("<p>Item 2</p>");
|
|
280
284
|
});
|
|
281
285
|
});
|
|
282
|
-
});
|
|
286
|
+
});
|