@n8n/frontend-module-sdk 0.4.3 → 0.5.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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@n8n/frontend-module-sdk",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.5.0",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"import": "src/index.ts",
|
|
7
7
|
"exports": {
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"vue": "^3.5.13",
|
|
12
12
|
"vue-router": "^4.5.0",
|
|
13
|
-
"@n8n/
|
|
14
|
-
"@n8n/
|
|
13
|
+
"@n8n/api-types": "1.35.0",
|
|
14
|
+
"@n8n/design-system": "2.34.0"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"typescript": "6.0.2",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"vitest": "^4.1.9",
|
|
21
21
|
"vue-tsc": "^2.2.8",
|
|
22
22
|
"@n8n/typescript-config": "1.9.0",
|
|
23
|
-
"@n8n/vitest-config": "1.
|
|
23
|
+
"@n8n/vitest-config": "1.20.0",
|
|
24
24
|
"@n8n/eslint-config": "0.0.1"
|
|
25
25
|
},
|
|
26
26
|
"license": "SEE LICENSE IN LICENSE.md",
|
package/src/__tests__/setup.ts
CHANGED
|
@@ -1,4 +1 @@
|
|
|
1
|
-
|
|
2
|
-
// (`@n8n/vitest-config/frontend` points `setupFiles` here). The registry suites
|
|
3
|
-
// need no global setup, so this file intentionally stays empty.
|
|
4
|
-
export {};
|
|
1
|
+
import '@n8n/vitest-config/setup/frontend';
|
|
@@ -28,9 +28,7 @@ describe('modalRegistry', () => {
|
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
beforeEach(() => {
|
|
31
|
-
|
|
32
|
-
const keys = modalRegistry.getKeys();
|
|
33
|
-
keys.forEach((key) => modalRegistry.unregister(key));
|
|
31
|
+
modalRegistry.clear();
|
|
34
32
|
});
|
|
35
33
|
|
|
36
34
|
describe('register', () => {
|
|
@@ -112,6 +110,53 @@ describe('modalRegistry', () => {
|
|
|
112
110
|
expect(listener).toHaveBeenCalledWith(expect.any(Map));
|
|
113
111
|
expect(listener).toHaveBeenCalledTimes(1);
|
|
114
112
|
});
|
|
113
|
+
|
|
114
|
+
it('should allow a key to be registered again after it was unregistered', () => {
|
|
115
|
+
modalRegistry.register(mockModal1);
|
|
116
|
+
modalRegistry.unregister('test-modal-1');
|
|
117
|
+
|
|
118
|
+
const replacement: ModalDefinition = {
|
|
119
|
+
key: 'test-modal-1',
|
|
120
|
+
component: mockComponent2,
|
|
121
|
+
initialState: { open: true },
|
|
122
|
+
};
|
|
123
|
+
modalRegistry.register(replacement);
|
|
124
|
+
|
|
125
|
+
expect(modalRegistry.get('test-modal-1')).toEqual(replacement);
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
describe('clear', () => {
|
|
130
|
+
it('should remove all registered modals', () => {
|
|
131
|
+
modalRegistry.register(mockModal1);
|
|
132
|
+
modalRegistry.register(mockModal2);
|
|
133
|
+
|
|
134
|
+
modalRegistry.clear();
|
|
135
|
+
|
|
136
|
+
expect(modalRegistry.getKeys()).toEqual([]);
|
|
137
|
+
expect(modalRegistry.has('test-modal-1')).toBe(false);
|
|
138
|
+
expect(modalRegistry.getAll().size).toBe(0);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('should notify listeners so renderers drop the cleared modals', () => {
|
|
142
|
+
modalRegistry.register(mockModal1);
|
|
143
|
+
const listener = vi.fn<(modals: Map<string, ModalDefinition>) => void>();
|
|
144
|
+
modalRegistry.subscribe(listener);
|
|
145
|
+
|
|
146
|
+
modalRegistry.clear();
|
|
147
|
+
|
|
148
|
+
expect(listener).toHaveBeenCalledTimes(1);
|
|
149
|
+
expect(listener.mock.calls[0][0].size).toBe(0);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it('should allow registration again after clearing', () => {
|
|
153
|
+
modalRegistry.register(mockModal1);
|
|
154
|
+
modalRegistry.clear();
|
|
155
|
+
|
|
156
|
+
modalRegistry.register(mockModal1);
|
|
157
|
+
|
|
158
|
+
expect(modalRegistry.get('test-modal-1')).toEqual(mockModal1);
|
|
159
|
+
});
|
|
115
160
|
});
|
|
116
161
|
|
|
117
162
|
describe('get', () => {
|
|
@@ -45,3 +45,11 @@ export function subscribe(listener: (modals: Map<string, ModalDefinition>) => vo
|
|
|
45
45
|
listeners.delete(listener);
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Remove all registered modals. Primarily for test isolation.
|
|
51
|
+
*/
|
|
52
|
+
export function clear(): void {
|
|
53
|
+
modals.clear();
|
|
54
|
+
notifyListeners();
|
|
55
|
+
}
|