@matterbridge/vitest-utils 3.8.1-dev-20260606-d6bb335 → 3.8.1-dev-20260608-9dc483f
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/vitestMatterTest.d.ts +2 -54
- package/dist/vitestMatterTest.js +53 -35
- package/package.json +3 -3
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import '@matter/nodejs';
|
|
2
2
|
import { Environment } from '@matter/general';
|
|
3
3
|
import { Endpoint, ServerNode } from '@matter/node';
|
|
4
|
-
import { BridgedDeviceBasicInformationServer } from '@matter/node/behaviors/bridged-device-basic-information';
|
|
5
|
-
import { OnOffServer } from '@matter/node/behaviors/on-off';
|
|
6
4
|
import { AggregatorEndpoint } from '@matter/node/endpoints';
|
|
7
5
|
import { DeviceTypeId } from '@matter/types/datatype';
|
|
8
6
|
import { type PlatformMatterbridge } from '@matterbridge/types';
|
|
@@ -11,61 +9,11 @@ export declare let server: ServerNode<ServerNode.RootEndpoint>;
|
|
|
11
9
|
export declare let aggregator: Endpoint<AggregatorEndpoint>;
|
|
12
10
|
export declare function createTestEnvironment(): Promise<Environment>;
|
|
13
11
|
export declare function destroyTestEnvironment(): Promise<void>;
|
|
14
|
-
export declare function getMatterbridge():
|
|
12
|
+
export declare function getMatterbridge(): PlatformMatterbridge;
|
|
15
13
|
export declare const addBridgedEndpointMatterbridgeSpy: import("vitest").Mock<(pluginName: string, device: Endpoint) => Promise<boolean>>;
|
|
16
14
|
export declare const removeBridgedEndpointMatterbridgeSpy: import("vitest").Mock<(pluginName: string, device: Endpoint) => Promise<boolean>>;
|
|
17
15
|
export declare const removeAllBridgedEndpointsMatterbridgeSpy: import("vitest").Mock<(pluginName: string, _delay?: number) => Promise<boolean>>;
|
|
18
|
-
export declare const addVirtualEndpointMatterbridgeSpy: import("vitest").Mock<(pluginName: string, name: string, type: "light" | "outlet" | "switch" | "mounted_switch", callback: () => Promise<void>) => Promise<
|
|
19
|
-
readonly name: "MountedOnOffControl";
|
|
20
|
-
readonly deviceType: 271;
|
|
21
|
-
readonly deviceRevision: 2;
|
|
22
|
-
readonly requirements: typeof import("@matter/node/devices/mounted-on-off-control").MountedOnOffControlRequirements;
|
|
23
|
-
readonly behaviors: {
|
|
24
|
-
readonly identify: import("@matter/node").ClusterBehavior.Type<typeof import("@matter/node/behaviors").IdentifyServer, import("@matter/types").ClusterType.WithEnabledAttributes<import("@matter/types").ClusterType.WithEnabledEvents<import("@matter/types/clusters/identify").Identify, never>, never>, import("@matter/types").ClusterType.Concrete, typeof import("@matter/node/behaviors").IdentifyServer.Internal, "identify">;
|
|
25
|
-
} & {
|
|
26
|
-
readonly groups: typeof import("@matter/node/behaviors").GroupsServer;
|
|
27
|
-
} & {
|
|
28
|
-
readonly onOff: import("@matter/node").ClusterBehavior.Type<typeof OnOffServer, import("@matter/types").ClusterType.WithSupportedFeatures<import("@matter/types").ClusterType.WithSupportedFeatures<import("@matter/types").ClusterType.WithSupportedFeatures<import("@matter/types/clusters/on-off").OnOff, {
|
|
29
|
-
deadFrontBehavior: false;
|
|
30
|
-
lighting: true;
|
|
31
|
-
offOnly: false;
|
|
32
|
-
}>, {
|
|
33
|
-
deadFrontBehavior: false;
|
|
34
|
-
lighting: false;
|
|
35
|
-
offOnly: false;
|
|
36
|
-
}>, {
|
|
37
|
-
deadFrontBehavior: false;
|
|
38
|
-
lighting: true;
|
|
39
|
-
offOnly: false;
|
|
40
|
-
}>, import("@matter/types").ClusterType.Concrete, typeof import("@matter/node/behaviors/on-off").OnOffBaseServer.Internal, "onOff">;
|
|
41
|
-
} & {
|
|
42
|
-
readonly scenesManagement: import("@matter/node").ClusterBehavior.Type<typeof import("@matter/node/behaviors").ScenesManagementServer, import("@matter/types").ClusterType.WithEnabledAttributes<import("@matter/types").ClusterType.WithEnabledEvents<import("@matter/types").ClusterType.WithSupportedFeatures<import("@matter/types/clusters/scenes-management").ScenesManagement, {
|
|
43
|
-
sceneNames: true;
|
|
44
|
-
}>, never>, never>, import("@matter/types").ClusterType.Concrete, typeof import("@matter/node/behaviors").ScenesManagementServer.Internal, "scenesManagement">;
|
|
45
|
-
};
|
|
46
|
-
}>, import("@matter/node").SupportedBehaviors.With<{
|
|
47
|
-
readonly identify: import("@matter/node").ClusterBehavior.Type<typeof import("@matter/node/behaviors").IdentifyServer, import("@matter/types").ClusterType.WithEnabledAttributes<import("@matter/types").ClusterType.WithEnabledEvents<import("@matter/types/clusters/identify").Identify, never>, never>, import("@matter/types").ClusterType.Concrete, typeof import("@matter/node/behaviors").IdentifyServer.Internal, "identify">;
|
|
48
|
-
} & {
|
|
49
|
-
readonly groups: typeof import("@matter/node/behaviors").GroupsServer;
|
|
50
|
-
} & {
|
|
51
|
-
readonly onOff: import("@matter/node").ClusterBehavior.Type<typeof OnOffServer, import("@matter/types").ClusterType.WithSupportedFeatures<import("@matter/types").ClusterType.WithSupportedFeatures<import("@matter/types").ClusterType.WithSupportedFeatures<import("@matter/types/clusters/on-off").OnOff, {
|
|
52
|
-
deadFrontBehavior: false;
|
|
53
|
-
lighting: true;
|
|
54
|
-
offOnly: false;
|
|
55
|
-
}>, {
|
|
56
|
-
deadFrontBehavior: false;
|
|
57
|
-
lighting: false;
|
|
58
|
-
offOnly: false;
|
|
59
|
-
}>, {
|
|
60
|
-
deadFrontBehavior: false;
|
|
61
|
-
lighting: true;
|
|
62
|
-
offOnly: false;
|
|
63
|
-
}>, import("@matter/types").ClusterType.Concrete, typeof import("@matter/node/behaviors/on-off").OnOffBaseServer.Internal, "onOff">;
|
|
64
|
-
} & {
|
|
65
|
-
readonly scenesManagement: import("@matter/node").ClusterBehavior.Type<typeof import("@matter/node/behaviors").ScenesManagementServer, import("@matter/types").ClusterType.WithEnabledAttributes<import("@matter/types").ClusterType.WithEnabledEvents<import("@matter/types").ClusterType.WithSupportedFeatures<import("@matter/types/clusters/scenes-management").ScenesManagement, {
|
|
66
|
-
sceneNames: true;
|
|
67
|
-
}>, never>, never>, import("@matter/types").ClusterType.Concrete, typeof import("@matter/node/behaviors").ScenesManagementServer.Internal, "scenesManagement">;
|
|
68
|
-
}, readonly [typeof BridgedDeviceBasicInformationServer]>, {}>>>>;
|
|
16
|
+
export declare const addVirtualEndpointMatterbridgeSpy: import("vitest").Mock<(pluginName: string, name: string, type: "light" | "outlet" | "switch" | "mounted_switch", callback: () => Promise<void>) => Promise<boolean>>;
|
|
69
17
|
export declare function addMatterbridge(platform: object): void;
|
|
70
18
|
export declare function flushAllEndpointNumberPersistence(targetServer: ServerNode, rounds?: number, ticks?: number, microTurns?: number, pause?: number): Promise<void>;
|
|
71
19
|
export declare function assertAllEndpointNumbersPersisted(targetServer: ServerNode): Promise<number>;
|
package/dist/vitestMatterTest.js
CHANGED
|
@@ -30,20 +30,20 @@ export async function createTestEnvironment() {
|
|
|
30
30
|
}
|
|
31
31
|
export async function destroyTestEnvironment() {
|
|
32
32
|
}
|
|
33
|
-
export
|
|
33
|
+
export function getMatterbridge() {
|
|
34
34
|
const matterbridge = {
|
|
35
35
|
systemInformation: {
|
|
36
36
|
interfaceName: 'eth0',
|
|
37
37
|
macAddress: 'aa:bb:cc:dd:ee:ff',
|
|
38
|
-
ipv4Address: '',
|
|
39
|
-
ipv6Address: '',
|
|
40
|
-
|
|
41
|
-
nodeVersion: '22.1.10',
|
|
38
|
+
ipv4Address: '192.168.68.100',
|
|
39
|
+
ipv6Address: 'fd78:cbf8:4939:46e2:51b2:2163:7f88:c33d',
|
|
40
|
+
nodeVersion: '24.16.0',
|
|
42
41
|
hostname: 'matterbridge',
|
|
43
42
|
user: 'vitest',
|
|
44
43
|
osType: 'Linux',
|
|
44
|
+
osRelease: '6.8.0-xxxx',
|
|
45
45
|
osPlatform: 'linux',
|
|
46
|
-
osArch: '
|
|
46
|
+
osArch: 'arm64',
|
|
47
47
|
totalMemory: '0 B',
|
|
48
48
|
freeMemory: '0 B',
|
|
49
49
|
systemUptime: '0s',
|
|
@@ -76,47 +76,65 @@ export async function getMatterbridge() {
|
|
|
76
76
|
return matterbridge;
|
|
77
77
|
}
|
|
78
78
|
const addBridgedEndpoint = vi.fn(async (pluginName, device) => {
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
try {
|
|
80
|
+
await aggregator.add(device);
|
|
81
|
+
return Promise.resolve(true);
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
return Promise.reject(error);
|
|
85
|
+
}
|
|
81
86
|
});
|
|
82
87
|
const removeBridgedEndpoint = vi.fn(async (pluginName, device) => {
|
|
83
|
-
|
|
84
|
-
|
|
88
|
+
try {
|
|
89
|
+
await device.delete();
|
|
90
|
+
return Promise.resolve(true);
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
return Promise.reject(error);
|
|
94
|
+
}
|
|
85
95
|
});
|
|
86
96
|
const removeAllBridgedEndpoints = vi.fn(async (pluginName, _delay = 0) => {
|
|
87
|
-
|
|
88
|
-
|
|
97
|
+
try {
|
|
98
|
+
for (const device of aggregator.parts) {
|
|
99
|
+
await device.delete();
|
|
100
|
+
}
|
|
101
|
+
return Promise.resolve(true);
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
return Promise.reject(error);
|
|
89
105
|
}
|
|
90
|
-
return Promise.resolve(true);
|
|
91
106
|
});
|
|
92
107
|
const addVirtualEndpoint = vi.fn(async (pluginName, name, type, callback) => {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
108
|
+
try {
|
|
109
|
+
const device = new Endpoint(MountedOnOffControlDevice.with(BridgedDeviceBasicInformationServer), {
|
|
110
|
+
id: name.replaceAll(' ', '') + ':' + type,
|
|
111
|
+
bridgedDeviceBasicInformation: {
|
|
112
|
+
vendorId: VendorId(0xfff1),
|
|
113
|
+
vendorName: 'Matterbridge',
|
|
114
|
+
productName: 'Matterbridge Virtual Device',
|
|
115
|
+
nodeLabel: name.slice(0, 32),
|
|
116
|
+
softwareVersion: 20000,
|
|
117
|
+
softwareVersionString: '2.0.0',
|
|
118
|
+
},
|
|
119
|
+
onOff: { onOff: false },
|
|
120
|
+
});
|
|
121
|
+
device.events.onOff.onOff$Changed.on((value) => {
|
|
122
|
+
if (value) {
|
|
123
|
+
void callback().catch(() => { });
|
|
124
|
+
void device.setStateOf(OnOffServer, { onOff: false }).catch(() => { });
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
await aggregator.add(device);
|
|
113
128
|
await device.act(async (agent) => {
|
|
114
129
|
const descriptor = await agent.load(DescriptorServer);
|
|
115
130
|
descriptor.addDeviceTypes('OnOffPlugInUnit');
|
|
116
131
|
});
|
|
132
|
+
await device.setStateOf(OnOffServer, { onOff: false });
|
|
133
|
+
return Promise.resolve(true);
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
return Promise.reject(error);
|
|
117
137
|
}
|
|
118
|
-
await device.setStateOf(OnOffServer, { onOff: false });
|
|
119
|
-
return device;
|
|
120
138
|
});
|
|
121
139
|
export const addBridgedEndpointMatterbridgeSpy = addBridgedEndpoint;
|
|
122
140
|
export const removeBridgedEndpointMatterbridgeSpy = removeBridgedEndpoint;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matterbridge/vitest-utils",
|
|
3
|
-
"version": "3.8.1-dev-
|
|
3
|
+
"version": "3.8.1-dev-20260608-9dc483f",
|
|
4
4
|
"description": "Matterbridge vitest utility library",
|
|
5
5
|
"author": "https://github.com/Luligu",
|
|
6
6
|
"homepage": "https://matterbridge.io/",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"CHANGELOG.md"
|
|
66
66
|
],
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@matterbridge/types": "3.8.1-dev-
|
|
69
|
-
"node-ansi-logger": "3.3.0-dev-
|
|
68
|
+
"@matterbridge/types": "3.8.1-dev-20260608-9dc483f",
|
|
69
|
+
"node-ansi-logger": "3.3.0-dev-20260607-585945a"
|
|
70
70
|
}
|
|
71
71
|
}
|