Skip to content

Commit 47b5330

Browse files
luizhf42gustavosbarreto
authored andcommitted
test(ui): add API mocks to DevicesDropdown tests
1 parent f3768fb commit 47b5330

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

ui/tests/components/AppBar/DevicesDropdown.spec.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ const mockSnackbar = {
4848
showError: vi.fn(),
4949
};
5050

51+
const mockStats = {
52+
registered_devices: 10,
53+
online_devices: 6,
54+
pending_devices: 2,
55+
rejected_devices: 1,
56+
active_sessions: 0,
57+
};
58+
5159
const mockPendingDevices: IDevice[] = [
5260
{
5361
uid: "pending-device-1",
@@ -165,6 +173,10 @@ describe("Device Management Dropdown", () => {
165173
devicesStore.offlineDevicesCount = 0;
166174
devicesStore.pendingDevicesCount = 0;
167175

176+
mockDevicesApi
177+
.onGet("http://localhost:3000/api/stats")
178+
.reply(200, mockStats);
179+
168180
mockDevicesApi
169181
.onGet("http://localhost:3000/api/devices?page=1&per_page=100&status=pending")
170182
.reply(200, mockPendingDevices, { "x-total-count": "2" });
@@ -177,6 +189,16 @@ describe("Device Management Dropdown", () => {
177189
.onGet("http://localhost:3000/api/devices?page=1&per_page=1&status=accepted")
178190
.reply(200, [], { "x-total-count": "10" });
179191

192+
mockDevicesApi
193+
// eslint-disable-next-line vue/max-len
194+
.onGet("http://localhost:3000/api/devices?filter=W3sidHlwZSI6InByb3BlcnR5IiwicGFyYW1zIjp7Im5hbWUiOiJvbmxpbmUiLCJvcGVyYXRvciI6ImVxIiwidmFsdWUiOnRydWV9fV0%3D&page=1&per_page=1&status=accepted")
195+
.reply(200, [], { "x-total-count": "10" });
196+
197+
mockDevicesApi
198+
// eslint-disable-next-line vue/max-len
199+
.onGet("http://localhost:3000/api/devices?filter=W3sidHlwZSI6InByb3BlcnR5IiwicGFyYW1zIjp7Im5hbWUiOiJvbmxpbmUiLCJvcGVyYXRvciI6ImVxIiwidmFsdWUiOmZhbHNlfX1d&page=1&per_page=1&status=accepted")
200+
.reply(200, [], { "x-total-count": "10" });
201+
180202
mockDevicesApi
181203
.onGet("http://localhost:3000/api/devices?page=1&per_page=1&status=pending")
182204
.reply(200, [], { "x-total-count": "2" });

0 commit comments

Comments
 (0)