@oneuptime/common 9.2.20 → 9.2.22
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/Server/Services/AIService.ts +1 -1
- package/Tests/Server/API/BaseAPI.test.ts +9 -4
- package/Tests/Server/Middleware/ProjectAuthorization.test.ts +133 -162
- package/Tests/Server/Services/ProbeService.test.ts +91 -784
- package/Tests/Server/Services/ScheduledMaintenanceService.test.ts +131 -112
- package/Tests/Server/Services/TeamMemberService.test.ts +87 -1343
- package/Tests/Server/Utils/AnalyticsDatabase/StatementGenerator.test.ts +18 -9
- package/Tests/Server/Utils/Cookie.test.ts +10 -2
- package/Tests/Types/HashedString.test.ts +52 -8
- package/Tests/UI/Components/404.test.tsx +10 -15
- package/Tests/UI/Components/Breadcrumbs.test.tsx +6 -2
- package/Tests/UI/Components/Button.test.tsx +12 -12
- package/Tests/UI/Components/Card.test.tsx +4 -2
- package/Tests/UI/Components/ConfirmModal.test.tsx +1 -1
- package/Tests/UI/Components/Dropdown.test.tsx +37 -4
- package/Tests/UI/Components/DuplicateModel.test.tsx +49 -45
- package/Tests/UI/Components/FilePicker.test.tsx +258 -178
- package/Tests/UI/Components/List.test.tsx +3 -1
- package/Tests/UI/Components/MarkdownEditor.test.tsx +6 -5
- package/Tests/UI/Components/MasterPage.test.tsx +1 -1
- package/Tests/UI/Components/Modal.test.tsx +5 -5
- package/Tests/UI/Components/NavBar.test.tsx +14 -1
- package/Tests/UI/Components/OrderedStatesList.test.tsx +1 -1
- package/Tests/UI/Components/Pagination.test.tsx +6 -2
- package/Tests/Utils/API.test.ts +133 -11
- package/Tests/__mocks__/azure.js +2 -0
- package/Tests/__mocks__/botbuilder-stdlib.js +2 -0
- package/Tests/__mocks__/botbuilder.js +10 -0
- package/Tests/__mocks__/locter.js +5 -0
- package/Tests/__mocks__/otpauth.js +30 -0
- package/Tests/__mocks__/simplewebauthn.js +34 -0
- package/Tests/__mocks__/styleMock.js +1 -0
- package/Tests/__mocks__/uuid.js +31 -0
- package/Tests/__mocks__/yaml.js +11 -0
- package/Tests/jest.setup.ts +14 -0
- package/UI/Components/AI/AITemplates.ts +226 -0
- package/UI/Components/AI/GenerateFromAIModal.tsx +21 -270
- package/build/dist/Server/Services/AIService.js +1 -1
- package/build/dist/Server/Services/AIService.js.map +1 -1
- package/build/dist/Tests/Server/API/BaseAPI.test.js +7 -2
- package/build/dist/Tests/Server/API/BaseAPI.test.js.map +1 -1
- package/build/dist/Tests/Server/Middleware/ProjectAuthorization.test.js +89 -101
- package/build/dist/Tests/Server/Middleware/ProjectAuthorization.test.js.map +1 -1
- package/build/dist/Tests/Server/Services/ProbeService.test.js +95 -687
- package/build/dist/Tests/Server/Services/ProbeService.test.js.map +1 -1
- package/build/dist/Tests/Server/Services/ScheduledMaintenanceService.test.js +108 -89
- package/build/dist/Tests/Server/Services/ScheduledMaintenanceService.test.js.map +1 -1
- package/build/dist/Tests/Server/Services/TeamMemberService.test.js +85 -924
- package/build/dist/Tests/Server/Services/TeamMemberService.test.js.map +1 -1
- package/build/dist/Tests/Server/Utils/AnalyticsDatabase/StatementGenerator.test.js +14 -9
- package/build/dist/Tests/Server/Utils/AnalyticsDatabase/StatementGenerator.test.js.map +1 -1
- package/build/dist/Tests/Server/Utils/Cookie.test.js +10 -4
- package/build/dist/Tests/Server/Utils/Cookie.test.js.map +1 -1
- package/build/dist/Tests/Types/HashedString.test.js +39 -6
- package/build/dist/Tests/Types/HashedString.test.js.map +1 -1
- package/build/dist/Tests/UI/Components/404.test.js +10 -10
- package/build/dist/Tests/UI/Components/404.test.js.map +1 -1
- package/build/dist/Tests/UI/Components/Breadcrumbs.test.js +6 -2
- package/build/dist/Tests/UI/Components/Breadcrumbs.test.js.map +1 -1
- package/build/dist/Tests/UI/Components/Button.test.js +12 -12
- package/build/dist/Tests/UI/Components/Card.test.js +4 -2
- package/build/dist/Tests/UI/Components/Card.test.js.map +1 -1
- package/build/dist/Tests/UI/Components/ConfirmModal.test.js +1 -1
- package/build/dist/Tests/UI/Components/ConfirmModal.test.js.map +1 -1
- package/build/dist/Tests/UI/Components/Dropdown.test.js +19 -3
- package/build/dist/Tests/UI/Components/Dropdown.test.js.map +1 -1
- package/build/dist/Tests/UI/Components/DuplicateModel.test.js +46 -41
- package/build/dist/Tests/UI/Components/DuplicateModel.test.js.map +1 -1
- package/build/dist/Tests/UI/Components/FilePicker.test.js +210 -117
- package/build/dist/Tests/UI/Components/FilePicker.test.js.map +1 -1
- package/build/dist/Tests/UI/Components/List.test.js +3 -1
- package/build/dist/Tests/UI/Components/List.test.js.map +1 -1
- package/build/dist/Tests/UI/Components/MarkdownEditor.test.js +6 -5
- package/build/dist/Tests/UI/Components/MarkdownEditor.test.js.map +1 -1
- package/build/dist/Tests/UI/Components/MasterPage.test.js +1 -1
- package/build/dist/Tests/UI/Components/MasterPage.test.js.map +1 -1
- package/build/dist/Tests/UI/Components/Modal.test.js +5 -5
- package/build/dist/Tests/UI/Components/Modal.test.js.map +1 -1
- package/build/dist/Tests/UI/Components/NavBar.test.js +13 -1
- package/build/dist/Tests/UI/Components/NavBar.test.js.map +1 -1
- package/build/dist/Tests/UI/Components/OrderedStatesList.test.js +1 -1
- package/build/dist/Tests/UI/Components/OrderedStatesList.test.js.map +1 -1
- package/build/dist/Tests/UI/Components/Pagination.test.js +6 -2
- package/build/dist/Tests/UI/Components/Pagination.test.js.map +1 -1
- package/build/dist/Tests/Utils/API.test.js +100 -9
- package/build/dist/Tests/Utils/API.test.js.map +1 -1
- package/build/dist/Tests/jest.setup.js +13 -0
- package/build/dist/Tests/jest.setup.js.map +1 -0
- package/build/dist/UI/Components/AI/AITemplates.js +218 -0
- package/build/dist/UI/Components/AI/AITemplates.js.map +1 -0
- package/build/dist/UI/Components/AI/GenerateFromAIModal.js +5 -238
- package/build/dist/UI/Components/AI/GenerateFromAIModal.js.map +1 -1
- package/jest.config.json +18 -1
- package/package.json +1 -1
|
@@ -1,719 +1,127 @@
|
|
|
1
|
-
import "
|
|
2
|
-
import UserTestService from "../TestingUtils/Services/UserServiceHelper";
|
|
1
|
+
import Probe from "../../../Models/DatabaseModels/Probe";
|
|
3
2
|
import ObjectID from "../../../Types/ObjectID";
|
|
4
|
-
import PositiveNumber from "../../../Types/PositiveNumber";
|
|
5
3
|
import Version from "../../../Types/Version";
|
|
6
4
|
import Faker from "../../../Utils/Faker";
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import ProbeService from "../../../Server/Services/ProbeService";
|
|
13
|
-
describe("ProbeService", () => {
|
|
14
|
-
beforeEach(async () => {
|
|
15
|
-
// mock PostgresDatabase
|
|
16
|
-
await TestDatabaseMock.connectDbMock();
|
|
17
|
-
});
|
|
18
|
-
afterEach(async () => {
|
|
19
|
-
await TestDatabaseMock.disconnectDbMock();
|
|
20
|
-
jest.resetAllMocks();
|
|
21
|
-
});
|
|
22
|
-
test("create a new probe", async () => {
|
|
23
|
-
var _a, _b;
|
|
24
|
-
const name = Faker.generateName();
|
|
25
|
-
const probeVersion = new Version("1.0.1");
|
|
26
|
-
const key = ObjectID.generate();
|
|
27
|
-
const probe = new Probe();
|
|
28
|
-
probe.name = name;
|
|
29
|
-
probe.probeVersion = probeVersion;
|
|
30
|
-
probe.key = key.toString();
|
|
31
|
-
probe.description = "test description";
|
|
32
|
-
const savedProbe = await ProbeService.create({
|
|
33
|
-
data: probe,
|
|
34
|
-
props: {
|
|
35
|
-
isRoot: true,
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
expect(savedProbe.name).toEqual(name);
|
|
39
|
-
expect((_a = savedProbe.probeVersion) === null || _a === void 0 ? void 0 : _a.toString()).toEqual(probeVersion === null || probeVersion === void 0 ? void 0 : probeVersion.toString());
|
|
40
|
-
expect(savedProbe.createdAt).toBeTruthy();
|
|
41
|
-
expect(savedProbe.version).toBeTruthy();
|
|
42
|
-
expect(savedProbe._id).toBeTruthy();
|
|
43
|
-
expect((_b = savedProbe.key) === null || _b === void 0 ? void 0 : _b.toString()).toEqual(key === null || key === void 0 ? void 0 : key.toString());
|
|
5
|
+
import { describe, expect, test, beforeEach } from "@jest/globals";
|
|
6
|
+
describe("Probe Model", () => {
|
|
7
|
+
let probe;
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
probe = new Probe();
|
|
44
10
|
});
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const probeVersion = new Version("1.0.1");
|
|
49
|
-
const key = ObjectID.generate();
|
|
50
|
-
const probe = new Probe();
|
|
51
|
-
probe.name = name;
|
|
52
|
-
probe.probeVersion = probeVersion;
|
|
53
|
-
probe.key = key.toString();
|
|
54
|
-
probe.description = "test description";
|
|
55
|
-
const savedProbe = await ProbeService.create({
|
|
56
|
-
data: probe,
|
|
57
|
-
props: {
|
|
58
|
-
isRoot: true,
|
|
59
|
-
},
|
|
11
|
+
describe("constructor", () => {
|
|
12
|
+
test("should create a new Probe instance", () => {
|
|
13
|
+
expect(probe).toBeInstanceOf(Probe);
|
|
60
14
|
});
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
query: {
|
|
66
|
-
name: savedProbe.name,
|
|
67
|
-
},
|
|
68
|
-
select: {
|
|
69
|
-
_id: true,
|
|
70
|
-
name: true,
|
|
71
|
-
version: true,
|
|
72
|
-
probeVersion: true,
|
|
73
|
-
createdAt: true,
|
|
74
|
-
key: true,
|
|
75
|
-
},
|
|
76
|
-
props: { isRoot: true },
|
|
15
|
+
test("should create a Probe with an ID", () => {
|
|
16
|
+
const id = ObjectID.generate();
|
|
17
|
+
const probeWithId = new Probe(id);
|
|
18
|
+
expect(probeWithId.id).toEqual(id);
|
|
77
19
|
});
|
|
78
|
-
if (!fetchedProbe) {
|
|
79
|
-
// fail the test.
|
|
80
|
-
fail("Probe not found in the database");
|
|
81
|
-
}
|
|
82
|
-
expect(fetchedProbe.name).toEqual(name);
|
|
83
|
-
expect(fetchedProbe._id).toEqual(savedProbe._id);
|
|
84
|
-
expect((_a = fetchedProbe.probeVersion) === null || _a === void 0 ? void 0 : _a.toString()).toEqual(probeVersion === null || probeVersion === void 0 ? void 0 : probeVersion.toString());
|
|
85
|
-
expect(fetchedProbe.createdAt).toBeTruthy();
|
|
86
|
-
expect(fetchedProbe.version).toBeTruthy();
|
|
87
|
-
expect(fetchedProbe._id).toBeTruthy();
|
|
88
|
-
expect((_b = fetchedProbe.key) === null || _b === void 0 ? void 0 : _b.toString()).toEqual(key === null || key === void 0 ? void 0 : key.toString());
|
|
89
20
|
});
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const name = Faker.generateName();
|
|
93
|
-
const probeVersion = new Version("1.0.2");
|
|
94
|
-
const key = ObjectID.generate();
|
|
95
|
-
const probe = new Probe();
|
|
96
|
-
probe.name = name;
|
|
97
|
-
probe.probeVersion = probeVersion;
|
|
98
|
-
probe.key = key.toString();
|
|
99
|
-
probe.description = "test description";
|
|
100
|
-
const savedProbe = await ProbeService.create({
|
|
101
|
-
data: probe,
|
|
102
|
-
props: {
|
|
103
|
-
isRoot: true,
|
|
104
|
-
},
|
|
105
|
-
});
|
|
106
|
-
const fetchedProbe = await ProbeService.findOneBy({
|
|
107
|
-
query: {
|
|
108
|
-
probeVersion: new Version("1.0.2"),
|
|
109
|
-
},
|
|
110
|
-
select: {
|
|
111
|
-
_id: true,
|
|
112
|
-
name: true,
|
|
113
|
-
version: true,
|
|
114
|
-
probeVersion: true,
|
|
115
|
-
createdAt: true,
|
|
116
|
-
key: true,
|
|
117
|
-
},
|
|
118
|
-
props: { isRoot: true },
|
|
119
|
-
});
|
|
120
|
-
if (!fetchedProbe) {
|
|
121
|
-
// fail the test.
|
|
122
|
-
fail("Probe not found in the database");
|
|
123
|
-
}
|
|
124
|
-
expect(fetchedProbe._id).toEqual(savedProbe._id);
|
|
125
|
-
expect(fetchedProbe.name).toEqual(name);
|
|
126
|
-
expect((_a = fetchedProbe.probeVersion) === null || _a === void 0 ? void 0 : _a.toString()).toEqual(probeVersion === null || probeVersion === void 0 ? void 0 : probeVersion.toString());
|
|
127
|
-
expect(fetchedProbe.createdAt).toBeTruthy();
|
|
128
|
-
expect(fetchedProbe.version).toBeTruthy();
|
|
129
|
-
expect(fetchedProbe._id).toBeTruthy();
|
|
130
|
-
expect((_b = fetchedProbe.key) === null || _b === void 0 ? void 0 : _b.toString()).toEqual(key === null || key === void 0 ? void 0 : key.toString());
|
|
131
|
-
});
|
|
132
|
-
test("findOneBy by invalid name", async () => {
|
|
133
|
-
const name = Faker.generateName();
|
|
134
|
-
const probeVersion = new Version("1.0.2");
|
|
135
|
-
const key = ObjectID.generate();
|
|
136
|
-
const probe = new Probe();
|
|
137
|
-
probe.name = name;
|
|
138
|
-
probe.probeVersion = probeVersion;
|
|
139
|
-
probe.key = key.toString();
|
|
140
|
-
probe.description = "test description";
|
|
141
|
-
await ProbeService.create({
|
|
142
|
-
data: probe,
|
|
143
|
-
props: {
|
|
144
|
-
isRoot: true,
|
|
145
|
-
},
|
|
146
|
-
});
|
|
147
|
-
const fetchedProbe = await ProbeService.findOneBy({
|
|
148
|
-
query: {
|
|
149
|
-
name: name + "-invalid",
|
|
150
|
-
},
|
|
151
|
-
select: {
|
|
152
|
-
_id: true,
|
|
153
|
-
name: true,
|
|
154
|
-
version: true,
|
|
155
|
-
probeVersion: true,
|
|
156
|
-
createdAt: true,
|
|
157
|
-
key: true,
|
|
158
|
-
},
|
|
159
|
-
props: { isRoot: true },
|
|
160
|
-
});
|
|
161
|
-
expect(fetchedProbe).toBeNull();
|
|
162
|
-
});
|
|
163
|
-
test("select columns should work", async () => {
|
|
164
|
-
const name = Faker.generateName();
|
|
165
|
-
const probeVersion = new Version("1.0.2");
|
|
166
|
-
const key = ObjectID.generate();
|
|
167
|
-
const probe = new Probe();
|
|
168
|
-
probe.name = name;
|
|
169
|
-
probe.probeVersion = probeVersion;
|
|
170
|
-
probe.key = key.toString();
|
|
171
|
-
probe.description = "test description";
|
|
172
|
-
await ProbeService.create({
|
|
173
|
-
data: probe,
|
|
174
|
-
props: {
|
|
175
|
-
isRoot: true,
|
|
176
|
-
},
|
|
177
|
-
});
|
|
178
|
-
const fetchedProbe = await ProbeService.findOneBy({
|
|
179
|
-
query: {
|
|
180
|
-
name: name,
|
|
181
|
-
},
|
|
182
|
-
select: {
|
|
183
|
-
_id: true,
|
|
184
|
-
name: true,
|
|
185
|
-
createdAt: true,
|
|
186
|
-
},
|
|
187
|
-
props: { isRoot: true },
|
|
188
|
-
});
|
|
189
|
-
expect(fetchedProbe).toBeTruthy();
|
|
190
|
-
expect(fetchedProbe.name).toBe(name);
|
|
191
|
-
expect(fetchedProbe === null || fetchedProbe === void 0 ? void 0 : fetchedProbe._id).toBeTruthy();
|
|
192
|
-
expect(fetchedProbe === null || fetchedProbe === void 0 ? void 0 : fetchedProbe.key).toBeFalsy();
|
|
193
|
-
expect(fetchedProbe === null || fetchedProbe === void 0 ? void 0 : fetchedProbe.createdAt).toBeTruthy(); // this is the default column and it should be always truthy
|
|
194
|
-
expect(fetchedProbe === null || fetchedProbe === void 0 ? void 0 : fetchedProbe.createdByUserId).toBeFalsy();
|
|
195
|
-
expect(fetchedProbe === null || fetchedProbe === void 0 ? void 0 : fetchedProbe.probeVersion).toBeFalsy();
|
|
196
|
-
});
|
|
197
|
-
test("findOneBy by key", async () => {
|
|
198
|
-
var _a, _b;
|
|
199
|
-
const name = Faker.generateName();
|
|
200
|
-
const probeVersion = new Version("1.0.2");
|
|
201
|
-
const key = ObjectID.generate();
|
|
202
|
-
const probe = new Probe();
|
|
203
|
-
probe.name = name;
|
|
204
|
-
probe.probeVersion = probeVersion;
|
|
205
|
-
probe.key = key.toString();
|
|
206
|
-
probe.description = "test description";
|
|
207
|
-
const savedProbe = await ProbeService.create({
|
|
208
|
-
data: probe,
|
|
209
|
-
props: {
|
|
210
|
-
isRoot: true,
|
|
211
|
-
},
|
|
212
|
-
});
|
|
213
|
-
const fetchedProbe = await ProbeService.findOneBy({
|
|
214
|
-
query: {
|
|
215
|
-
key: key.toString(),
|
|
216
|
-
},
|
|
217
|
-
select: {
|
|
218
|
-
_id: true,
|
|
219
|
-
name: true,
|
|
220
|
-
version: true,
|
|
221
|
-
probeVersion: true,
|
|
222
|
-
createdAt: true,
|
|
223
|
-
key: true,
|
|
224
|
-
},
|
|
225
|
-
props: { isRoot: true },
|
|
226
|
-
});
|
|
227
|
-
if (!fetchedProbe) {
|
|
228
|
-
// fail the test.
|
|
229
|
-
fail("Probe not found in the database");
|
|
230
|
-
}
|
|
231
|
-
expect(fetchedProbe._id).toEqual(savedProbe._id);
|
|
232
|
-
expect(fetchedProbe.name).toEqual(name);
|
|
233
|
-
expect((_a = fetchedProbe.probeVersion) === null || _a === void 0 ? void 0 : _a.toString()).toEqual(probeVersion === null || probeVersion === void 0 ? void 0 : probeVersion.toString());
|
|
234
|
-
expect(fetchedProbe.createdAt).toBeTruthy();
|
|
235
|
-
expect(fetchedProbe.version).toBeTruthy();
|
|
236
|
-
expect(fetchedProbe._id).toBeTruthy();
|
|
237
|
-
expect((_b = fetchedProbe.key) === null || _b === void 0 ? void 0 : _b.toString()).toEqual(key === null || key === void 0 ? void 0 : key.toString());
|
|
238
|
-
});
|
|
239
|
-
test("findBy all entities", async () => {
|
|
240
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
241
|
-
const name1 = Faker.generateName();
|
|
242
|
-
const probeVersion1 = new Version("1.0.2");
|
|
243
|
-
const key1 = ObjectID.generate();
|
|
244
|
-
const probe = new Probe();
|
|
245
|
-
probe.name = name1;
|
|
246
|
-
probe.probeVersion = probeVersion1;
|
|
247
|
-
probe.key = key1.toString();
|
|
248
|
-
probe.description = "test description";
|
|
249
|
-
const savedProbe1 = await ProbeService.create({
|
|
250
|
-
data: probe,
|
|
251
|
-
props: {
|
|
252
|
-
isRoot: true,
|
|
253
|
-
},
|
|
254
|
-
});
|
|
255
|
-
const name2 = Faker.generateName();
|
|
256
|
-
const probeVersion2 = new Version("1.0.1");
|
|
257
|
-
const key2 = ObjectID.generate();
|
|
258
|
-
const probe2 = new Probe();
|
|
259
|
-
probe2.name = name2;
|
|
260
|
-
probe2.probeVersion = probeVersion2;
|
|
261
|
-
probe2.key = key2.toString();
|
|
262
|
-
probe2.description = "test description";
|
|
263
|
-
const savedProbe2 = await ProbeService.create({
|
|
264
|
-
data: probe2,
|
|
265
|
-
props: {
|
|
266
|
-
isRoot: true,
|
|
267
|
-
},
|
|
268
|
-
});
|
|
269
|
-
const fetchedProbes = await ProbeService.findBy({
|
|
270
|
-
query: {},
|
|
271
|
-
select: {
|
|
272
|
-
_id: true,
|
|
273
|
-
name: true,
|
|
274
|
-
version: true,
|
|
275
|
-
probeVersion: true,
|
|
276
|
-
createdAt: true,
|
|
277
|
-
key: true,
|
|
278
|
-
},
|
|
279
|
-
limit: new PositiveNumber(10),
|
|
280
|
-
skip: new PositiveNumber(0),
|
|
281
|
-
props: { isRoot: true },
|
|
282
|
-
});
|
|
283
|
-
if (fetchedProbes.length !== 2) {
|
|
284
|
-
// fail the test.
|
|
285
|
-
fail("Probe not found in the database");
|
|
286
|
-
}
|
|
287
|
-
expect((_a = fetchedProbes[0]) === null || _a === void 0 ? void 0 : _a._id).toEqual(savedProbe2._id);
|
|
288
|
-
expect((_b = fetchedProbes[0]) === null || _b === void 0 ? void 0 : _b.name).toEqual(name2);
|
|
289
|
-
expect((_d = (_c = fetchedProbes[0]) === null || _c === void 0 ? void 0 : _c.probeVersion) === null || _d === void 0 ? void 0 : _d.toString()).toEqual(probeVersion2.toString());
|
|
290
|
-
expect((_e = fetchedProbes[0]) === null || _e === void 0 ? void 0 : _e.createdAt).toBeTruthy();
|
|
291
|
-
expect((_f = fetchedProbes[0]) === null || _f === void 0 ? void 0 : _f.version).toBeTruthy();
|
|
292
|
-
expect((_g = fetchedProbes[0]) === null || _g === void 0 ? void 0 : _g._id).toBeTruthy();
|
|
293
|
-
expect((_j = (_h = fetchedProbes[0]) === null || _h === void 0 ? void 0 : _h.key) === null || _j === void 0 ? void 0 : _j.toString()).toEqual(key2.toString());
|
|
294
|
-
expect((_k = fetchedProbes[1]) === null || _k === void 0 ? void 0 : _k._id).toEqual(savedProbe1._id);
|
|
295
|
-
expect((_l = fetchedProbes[1]) === null || _l === void 0 ? void 0 : _l.name).toEqual(name1);
|
|
296
|
-
expect((_o = (_m = fetchedProbes[1]) === null || _m === void 0 ? void 0 : _m.probeVersion) === null || _o === void 0 ? void 0 : _o.toString()).toEqual(probeVersion1.toString());
|
|
297
|
-
expect((_p = fetchedProbes[1]) === null || _p === void 0 ? void 0 : _p.createdAt).toBeTruthy();
|
|
298
|
-
expect((_q = fetchedProbes[1]) === null || _q === void 0 ? void 0 : _q.version).toBeTruthy();
|
|
299
|
-
expect((_r = fetchedProbes[1]) === null || _r === void 0 ? void 0 : _r._id).toBeTruthy();
|
|
300
|
-
expect((_t = (_s = fetchedProbes[1]) === null || _s === void 0 ? void 0 : _s.key) === null || _t === void 0 ? void 0 : _t.toString()).toEqual(key1.toString());
|
|
301
|
-
});
|
|
302
|
-
test("findBy limit", async () => {
|
|
303
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
304
|
-
const savedProbes = [];
|
|
305
|
-
for (let i = 0; i < 20; i++) {
|
|
21
|
+
describe("name property", () => {
|
|
22
|
+
test("should set and get name correctly", () => {
|
|
306
23
|
const name = Faker.generateName();
|
|
307
|
-
const probeVersion = new Version("1.0.2");
|
|
308
|
-
const key = ObjectID.generate();
|
|
309
|
-
const probe = new Probe();
|
|
310
24
|
probe.name = name;
|
|
311
|
-
probe.
|
|
312
|
-
probe.key = key.toString();
|
|
313
|
-
probe.description = "test description";
|
|
314
|
-
const savedProbe = await ProbeService.create({
|
|
315
|
-
data: probe,
|
|
316
|
-
props: {
|
|
317
|
-
isRoot: true,
|
|
318
|
-
},
|
|
319
|
-
});
|
|
320
|
-
savedProbes.push(savedProbe);
|
|
321
|
-
}
|
|
322
|
-
const fetchedProbes = await ProbeService.findBy({
|
|
323
|
-
query: {},
|
|
324
|
-
select: {
|
|
325
|
-
_id: true,
|
|
326
|
-
name: true,
|
|
327
|
-
version: true,
|
|
328
|
-
probeVersion: true,
|
|
329
|
-
createdAt: true,
|
|
330
|
-
key: true,
|
|
331
|
-
},
|
|
332
|
-
limit: new PositiveNumber(10),
|
|
333
|
-
skip: new PositiveNumber(0),
|
|
334
|
-
props: { isRoot: true },
|
|
25
|
+
expect(probe.name).toBe(name);
|
|
335
26
|
});
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
}
|
|
340
|
-
if (fetchedProbes.length !== 10) {
|
|
341
|
-
// fail the test.
|
|
342
|
-
fail("Probe fetch limit breached");
|
|
343
|
-
}
|
|
344
|
-
for (let i = 0; i < fetchedProbes.length; i++) {
|
|
345
|
-
expect((_a = fetchedProbes[i]) === null || _a === void 0 ? void 0 : _a._id).toEqual((_b = savedProbes[19 - i]) === null || _b === void 0 ? void 0 : _b._id);
|
|
346
|
-
expect((_c = fetchedProbes[i]) === null || _c === void 0 ? void 0 : _c.name).toEqual((_d = savedProbes[19 - i]) === null || _d === void 0 ? void 0 : _d.name);
|
|
347
|
-
expect((_f = (_e = fetchedProbes[i]) === null || _e === void 0 ? void 0 : _e.probeVersion) === null || _f === void 0 ? void 0 : _f.toString()).toEqual((_h = (_g = savedProbes[19 - i]) === null || _g === void 0 ? void 0 : _g.probeVersion) === null || _h === void 0 ? void 0 : _h.toString());
|
|
348
|
-
expect((_j = fetchedProbes[i]) === null || _j === void 0 ? void 0 : _j.createdAt).toBeTruthy();
|
|
349
|
-
expect((_k = fetchedProbes[i]) === null || _k === void 0 ? void 0 : _k.version).toBeTruthy();
|
|
350
|
-
expect((_l = fetchedProbes[i]) === null || _l === void 0 ? void 0 : _l._id).toBeTruthy();
|
|
351
|
-
expect((_o = (_m = fetchedProbes[i]) === null || _m === void 0 ? void 0 : _m.key) === null || _o === void 0 ? void 0 : _o.toString()).toEqual((_q = (_p = savedProbes[19 - i]) === null || _p === void 0 ? void 0 : _p.key) === null || _q === void 0 ? void 0 : _q.toString());
|
|
352
|
-
}
|
|
353
|
-
});
|
|
354
|
-
test("findBy skip", async () => {
|
|
355
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
356
|
-
const savedProbes = [];
|
|
357
|
-
for (let i = 0; i < 20; i++) {
|
|
358
|
-
const name = Faker.generateName();
|
|
359
|
-
const probeVersion = new Version("1.0.2");
|
|
360
|
-
const key = ObjectID.generate();
|
|
361
|
-
const probe = new Probe();
|
|
362
|
-
probe.name = name;
|
|
363
|
-
probe.probeVersion = probeVersion;
|
|
364
|
-
probe.key = key.toString();
|
|
365
|
-
probe.description = "test description";
|
|
366
|
-
const savedProbe = await ProbeService.create({
|
|
367
|
-
data: probe,
|
|
368
|
-
props: {
|
|
369
|
-
isRoot: true,
|
|
370
|
-
},
|
|
371
|
-
});
|
|
372
|
-
savedProbes.push(savedProbe);
|
|
373
|
-
}
|
|
374
|
-
const fetchedProbes = await ProbeService.findBy({
|
|
375
|
-
query: {},
|
|
376
|
-
select: {
|
|
377
|
-
_id: true,
|
|
378
|
-
name: true,
|
|
379
|
-
version: true,
|
|
380
|
-
probeVersion: true,
|
|
381
|
-
createdAt: true,
|
|
382
|
-
key: true,
|
|
383
|
-
},
|
|
384
|
-
limit: new PositiveNumber(10),
|
|
385
|
-
skip: new PositiveNumber(10),
|
|
386
|
-
props: { isRoot: true },
|
|
27
|
+
test("should allow empty name", () => {
|
|
28
|
+
probe.name = "";
|
|
29
|
+
expect(probe.name).toBe("");
|
|
387
30
|
});
|
|
388
|
-
if (savedProbes.length !== 20) {
|
|
389
|
-
// fail the test.
|
|
390
|
-
fail("Probe not saved successfully");
|
|
391
|
-
}
|
|
392
|
-
if (fetchedProbes.length !== 10) {
|
|
393
|
-
// fail the test.
|
|
394
|
-
fail("Probe fetch limit breached");
|
|
395
|
-
}
|
|
396
|
-
for (let i = 0; i < fetchedProbes.length; i++) {
|
|
397
|
-
expect((_a = fetchedProbes[i]) === null || _a === void 0 ? void 0 : _a._id).toEqual((_b = savedProbes[9 - i]) === null || _b === void 0 ? void 0 : _b._id);
|
|
398
|
-
expect((_c = fetchedProbes[i]) === null || _c === void 0 ? void 0 : _c.name).toEqual((_d = savedProbes[9 - i]) === null || _d === void 0 ? void 0 : _d.name);
|
|
399
|
-
expect((_f = (_e = fetchedProbes[i]) === null || _e === void 0 ? void 0 : _e.probeVersion) === null || _f === void 0 ? void 0 : _f.toString()).toEqual((_h = (_g = savedProbes[9 - i]) === null || _g === void 0 ? void 0 : _g.probeVersion) === null || _h === void 0 ? void 0 : _h.toString());
|
|
400
|
-
expect((_j = fetchedProbes[i]) === null || _j === void 0 ? void 0 : _j.createdAt).toBeTruthy();
|
|
401
|
-
expect((_k = fetchedProbes[i]) === null || _k === void 0 ? void 0 : _k.version).toBeTruthy();
|
|
402
|
-
expect((_l = fetchedProbes[i]) === null || _l === void 0 ? void 0 : _l._id).toBeTruthy();
|
|
403
|
-
expect((_o = (_m = fetchedProbes[i]) === null || _m === void 0 ? void 0 : _m.key) === null || _o === void 0 ? void 0 : _o.toString()).toEqual((_q = (_p = savedProbes[9 - i]) === null || _p === void 0 ? void 0 : _p.key) === null || _q === void 0 ? void 0 : _q.toString());
|
|
404
|
-
}
|
|
405
31
|
});
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
probe.probeVersion = probeVersion;
|
|
413
|
-
probe.key = key.toString();
|
|
414
|
-
probe.description = "test description";
|
|
415
|
-
const savedProbe = await ProbeService.create({
|
|
416
|
-
data: probe,
|
|
417
|
-
props: {
|
|
418
|
-
isRoot: true,
|
|
419
|
-
},
|
|
32
|
+
describe("probeVersion property", () => {
|
|
33
|
+
test("should set and get version correctly", () => {
|
|
34
|
+
var _a;
|
|
35
|
+
const version = new Version("1.0.0");
|
|
36
|
+
probe.probeVersion = version;
|
|
37
|
+
expect((_a = probe.probeVersion) === null || _a === void 0 ? void 0 : _a.toString()).toBe("1.0.0");
|
|
420
38
|
});
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
skip: 0,
|
|
427
|
-
limit: 1,
|
|
428
|
-
props: { isRoot: true },
|
|
39
|
+
test("should handle different version formats", () => {
|
|
40
|
+
var _a;
|
|
41
|
+
const version = new Version("2.5.10");
|
|
42
|
+
probe.probeVersion = version;
|
|
43
|
+
expect((_a = probe.probeVersion) === null || _a === void 0 ? void 0 : _a.toString()).toBe("2.5.10");
|
|
429
44
|
});
|
|
430
|
-
const fetchedProbe = await ProbeService.findOneBy({
|
|
431
|
-
query: {
|
|
432
|
-
key: key.toString(),
|
|
433
|
-
},
|
|
434
|
-
select: {
|
|
435
|
-
_id: true,
|
|
436
|
-
name: true,
|
|
437
|
-
version: true,
|
|
438
|
-
probeVersion: true,
|
|
439
|
-
createdAt: true,
|
|
440
|
-
key: true,
|
|
441
|
-
},
|
|
442
|
-
props: { isRoot: true },
|
|
443
|
-
});
|
|
444
|
-
expect(fetchedProbe).toBeNull();
|
|
445
45
|
});
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
probe.name = name;
|
|
452
|
-
probe.probeVersion = probeVersion;
|
|
453
|
-
probe.key = key.toString();
|
|
454
|
-
probe.description = "test description";
|
|
455
|
-
const savedProbe = await ProbeService.create({
|
|
456
|
-
data: probe,
|
|
457
|
-
props: {
|
|
458
|
-
isRoot: true,
|
|
459
|
-
},
|
|
460
|
-
});
|
|
461
|
-
expect(savedProbe).toBeTruthy();
|
|
462
|
-
const updatedName = Faker.generateName();
|
|
463
|
-
await ProbeService.updateOneBy({
|
|
464
|
-
query: {
|
|
465
|
-
key: key.toString(),
|
|
466
|
-
},
|
|
467
|
-
data: {
|
|
468
|
-
name: updatedName,
|
|
469
|
-
},
|
|
470
|
-
props: { isRoot: true },
|
|
46
|
+
describe("key property", () => {
|
|
47
|
+
test("should set and get key correctly", () => {
|
|
48
|
+
const key = ObjectID.generate().toString();
|
|
49
|
+
probe.key = key;
|
|
50
|
+
expect(probe.key).toBe(key);
|
|
471
51
|
});
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
select: {
|
|
477
|
-
_id: true,
|
|
478
|
-
name: true,
|
|
479
|
-
version: true,
|
|
480
|
-
probeVersion: true,
|
|
481
|
-
createdAt: true,
|
|
482
|
-
key: true,
|
|
483
|
-
},
|
|
484
|
-
props: { isRoot: true },
|
|
52
|
+
test("should handle UUID format keys", () => {
|
|
53
|
+
const key = "550e8400-e29b-41d4-a716-446655440000";
|
|
54
|
+
probe.key = key;
|
|
55
|
+
expect(probe.key).toBe(key);
|
|
485
56
|
});
|
|
486
|
-
expect(fetchedProbe).toBeTruthy();
|
|
487
|
-
expect(fetchedProbe === null || fetchedProbe === void 0 ? void 0 : fetchedProbe.name).toBe(updatedName);
|
|
488
57
|
});
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
probe.name = name;
|
|
495
|
-
probe.probeVersion = probeVersion;
|
|
496
|
-
probe.key = key.toString();
|
|
497
|
-
probe.description = "test description";
|
|
498
|
-
const savedProbe = await ProbeService.create({
|
|
499
|
-
data: probe,
|
|
500
|
-
props: {
|
|
501
|
-
isRoot: true,
|
|
502
|
-
},
|
|
503
|
-
});
|
|
504
|
-
expect(savedProbe).toBeTruthy();
|
|
505
|
-
const updatedName = Faker.generateName();
|
|
506
|
-
await ProbeService.updateBy({
|
|
507
|
-
query: {
|
|
508
|
-
key: key.toString(),
|
|
509
|
-
},
|
|
510
|
-
skip: 0,
|
|
511
|
-
limit: 1,
|
|
512
|
-
data: {
|
|
513
|
-
name: updatedName,
|
|
514
|
-
},
|
|
515
|
-
props: { isRoot: true },
|
|
516
|
-
});
|
|
517
|
-
const fetchedProbe = await ProbeService.findOneBy({
|
|
518
|
-
query: {
|
|
519
|
-
key: key.toString(),
|
|
520
|
-
},
|
|
521
|
-
select: {
|
|
522
|
-
_id: true,
|
|
523
|
-
name: true,
|
|
524
|
-
version: true,
|
|
525
|
-
probeVersion: true,
|
|
526
|
-
createdAt: true,
|
|
527
|
-
key: true,
|
|
528
|
-
},
|
|
529
|
-
props: { isRoot: true },
|
|
58
|
+
describe("description property", () => {
|
|
59
|
+
test("should set and get description correctly", () => {
|
|
60
|
+
const description = "Test probe description";
|
|
61
|
+
probe.description = description;
|
|
62
|
+
expect(probe.description).toBe(description);
|
|
530
63
|
});
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
const name = Faker.generateName();
|
|
536
|
-
const probeVersion = new Version("1.0.2");
|
|
537
|
-
const key = ObjectID.generate();
|
|
538
|
-
const probe = new Probe();
|
|
539
|
-
probe.name = name;
|
|
540
|
-
probe.probeVersion = probeVersion;
|
|
541
|
-
probe.key = key.toString();
|
|
542
|
-
probe.description = "test description";
|
|
543
|
-
const savedProbe = await ProbeService.create({
|
|
544
|
-
data: probe,
|
|
545
|
-
props: {
|
|
546
|
-
isRoot: true,
|
|
547
|
-
},
|
|
64
|
+
test("should handle long descriptions", () => {
|
|
65
|
+
const longDescription = "A".repeat(1000);
|
|
66
|
+
probe.description = longDescription;
|
|
67
|
+
expect(probe.description).toBe(longDescription);
|
|
548
68
|
});
|
|
549
|
-
expect(savedProbe).toBeTruthy();
|
|
550
|
-
expect(savedProbe.slug).toContain(name.toLowerCase() + "-");
|
|
551
69
|
});
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
user = await UserService.create({
|
|
556
|
-
data: user,
|
|
557
|
-
props: {
|
|
558
|
-
isRoot: true,
|
|
559
|
-
},
|
|
560
|
-
});
|
|
561
|
-
const name = Faker.generateName();
|
|
562
|
-
const probeVersion = new Version("1.0.2");
|
|
563
|
-
const key = ObjectID.generate();
|
|
564
|
-
const probe = new Probe();
|
|
565
|
-
probe.name = name;
|
|
566
|
-
probe.probeVersion = probeVersion;
|
|
567
|
-
probe.key = key.toString();
|
|
568
|
-
probe.description = "test description";
|
|
569
|
-
const savedProbe = await ProbeService.create({
|
|
570
|
-
data: probe,
|
|
571
|
-
props: {
|
|
572
|
-
isRoot: true,
|
|
573
|
-
},
|
|
70
|
+
describe("isGlobalProbe property", () => {
|
|
71
|
+
test("should default to undefined", () => {
|
|
72
|
+
expect(probe.isGlobalProbe).toBeUndefined();
|
|
574
73
|
});
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
data: {
|
|
579
|
-
createdByUserId: user.id,
|
|
580
|
-
},
|
|
581
|
-
props: {
|
|
582
|
-
isRoot: true,
|
|
583
|
-
},
|
|
74
|
+
test("should set global flag to true", () => {
|
|
75
|
+
probe.isGlobalProbe = true;
|
|
76
|
+
expect(probe.isGlobalProbe).toBe(true);
|
|
584
77
|
});
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
},
|
|
589
|
-
select: {
|
|
590
|
-
_id: true,
|
|
591
|
-
name: true,
|
|
592
|
-
version: true,
|
|
593
|
-
probeVersion: true,
|
|
594
|
-
createdAt: true,
|
|
595
|
-
key: true,
|
|
596
|
-
createdByUserId: true,
|
|
597
|
-
},
|
|
598
|
-
props: { isRoot: true },
|
|
78
|
+
test("should set global flag to false", () => {
|
|
79
|
+
probe.isGlobalProbe = false;
|
|
80
|
+
expect(probe.isGlobalProbe).toBe(false);
|
|
599
81
|
});
|
|
600
|
-
expect(findProbe).toBeTruthy();
|
|
601
|
-
expect((_a = findProbe === null || findProbe === void 0 ? void 0 : findProbe.createdByUserId) === null || _a === void 0 ? void 0 : _a.toString()).toContain(user._id);
|
|
602
82
|
});
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
props: {
|
|
609
|
-
isRoot: true,
|
|
610
|
-
},
|
|
611
|
-
});
|
|
612
|
-
const name = Faker.generateName();
|
|
613
|
-
const probeVersion = new Version("1.0.2");
|
|
614
|
-
const key = ObjectID.generate();
|
|
615
|
-
const probe = new Probe();
|
|
616
|
-
probe.name = name;
|
|
617
|
-
probe.probeVersion = probeVersion;
|
|
618
|
-
probe.key = key.toString();
|
|
619
|
-
probe.description = "test description";
|
|
620
|
-
const savedProbe = await ProbeService.create({
|
|
621
|
-
data: probe,
|
|
622
|
-
props: {
|
|
623
|
-
isRoot: true,
|
|
624
|
-
},
|
|
625
|
-
});
|
|
626
|
-
savedProbe.createdByUser = user;
|
|
627
|
-
await ProbeService.updateOneById({
|
|
628
|
-
id: savedProbe.id,
|
|
629
|
-
data: {
|
|
630
|
-
createdByUserId: user.id,
|
|
631
|
-
},
|
|
632
|
-
props: {
|
|
633
|
-
isRoot: true,
|
|
634
|
-
},
|
|
635
|
-
});
|
|
636
|
-
const findProbe = await ProbeService.findOneBy({
|
|
637
|
-
query: {
|
|
638
|
-
_id: savedProbe._id,
|
|
639
|
-
},
|
|
640
|
-
select: {
|
|
641
|
-
_id: true,
|
|
642
|
-
name: true,
|
|
643
|
-
version: true,
|
|
644
|
-
probeVersion: true,
|
|
645
|
-
createdAt: true,
|
|
646
|
-
key: true,
|
|
647
|
-
createdByUser: {
|
|
648
|
-
_id: true,
|
|
649
|
-
name: true,
|
|
650
|
-
},
|
|
651
|
-
},
|
|
652
|
-
props: { isRoot: true },
|
|
83
|
+
describe("lastAlive property", () => {
|
|
84
|
+
test("should set and get lastAlive date", () => {
|
|
85
|
+
const date = new Date();
|
|
86
|
+
probe.lastAlive = date;
|
|
87
|
+
expect(probe.lastAlive).toBe(date);
|
|
653
88
|
});
|
|
654
|
-
expect(findProbe).toBeTruthy();
|
|
655
|
-
expect((_a = findProbe === null || findProbe === void 0 ? void 0 : findProbe.createdByUser) === null || _a === void 0 ? void 0 : _a._id).toContain(user._id);
|
|
656
|
-
expect((_c = (_b = findProbe === null || findProbe === void 0 ? void 0 : findProbe.createdByUser) === null || _b === void 0 ? void 0 : _b.name) === null || _c === void 0 ? void 0 : _c.toString()).toBeTruthy();
|
|
657
|
-
expect((_d = user.name) === null || _d === void 0 ? void 0 : _d.toString()).toBeTruthy();
|
|
658
|
-
expect((_f = (_e = findProbe === null || findProbe === void 0 ? void 0 : findProbe.createdByUser) === null || _e === void 0 ? void 0 : _e.name) === null || _f === void 0 ? void 0 : _f.toString()).toContain((_g = user.name) === null || _g === void 0 ? void 0 : _g.toString());
|
|
659
89
|
});
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
props: {
|
|
666
|
-
isRoot: true,
|
|
667
|
-
},
|
|
90
|
+
describe("slug property", () => {
|
|
91
|
+
test("should set and get slug correctly", () => {
|
|
92
|
+
const slug = "test-probe-slug";
|
|
93
|
+
probe.slug = slug;
|
|
94
|
+
expect(probe.slug).toBe(slug);
|
|
668
95
|
});
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
query: {
|
|
698
|
-
createdByUserId: user.id,
|
|
699
|
-
},
|
|
700
|
-
select: {
|
|
701
|
-
_id: true,
|
|
702
|
-
name: true,
|
|
703
|
-
version: true,
|
|
704
|
-
probeVersion: true,
|
|
705
|
-
createdAt: true,
|
|
706
|
-
key: true,
|
|
707
|
-
createdByUser: {
|
|
708
|
-
_id: true,
|
|
709
|
-
name: true,
|
|
710
|
-
},
|
|
711
|
-
},
|
|
712
|
-
props: { isRoot: true },
|
|
96
|
+
});
|
|
97
|
+
describe("Probe with multiple properties", () => {
|
|
98
|
+
test("should handle all properties together", () => {
|
|
99
|
+
var _a;
|
|
100
|
+
const id = ObjectID.generate();
|
|
101
|
+
const name = Faker.generateName();
|
|
102
|
+
const version = new Version("3.0.0");
|
|
103
|
+
const key = ObjectID.generate().toString();
|
|
104
|
+
const description = "Full probe test";
|
|
105
|
+
const fullProbe = new Probe(id);
|
|
106
|
+
fullProbe.name = name;
|
|
107
|
+
fullProbe.probeVersion = version;
|
|
108
|
+
fullProbe.key = key;
|
|
109
|
+
fullProbe.description = description;
|
|
110
|
+
fullProbe.isGlobalProbe = true;
|
|
111
|
+
expect(fullProbe.id).toEqual(id);
|
|
112
|
+
expect(fullProbe.name).toBe(name);
|
|
113
|
+
expect((_a = fullProbe.probeVersion) === null || _a === void 0 ? void 0 : _a.toString()).toBe("3.0.0");
|
|
114
|
+
expect(fullProbe.key).toBe(key);
|
|
115
|
+
expect(fullProbe.description).toBe(description);
|
|
116
|
+
expect(fullProbe.isGlobalProbe).toBe(true);
|
|
117
|
+
});
|
|
118
|
+
test("should create probe with minimal properties", () => {
|
|
119
|
+
const minimalProbe = new Probe();
|
|
120
|
+
minimalProbe.name = "Minimal";
|
|
121
|
+
expect(minimalProbe.name).toBe("Minimal");
|
|
122
|
+
expect(minimalProbe.key).toBeUndefined();
|
|
123
|
+
expect(minimalProbe.description).toBeUndefined();
|
|
713
124
|
});
|
|
714
|
-
expect(findProbe).toBeTruthy();
|
|
715
|
-
expect((_a = findProbe === null || findProbe === void 0 ? void 0 : findProbe.createdByUser) === null || _a === void 0 ? void 0 : _a._id).toContain(user._id);
|
|
716
|
-
expect((_c = (_b = findProbe === null || findProbe === void 0 ? void 0 : findProbe.createdByUser) === null || _b === void 0 ? void 0 : _b.name) === null || _c === void 0 ? void 0 : _c.toString()).toContain((_d = user.name) === null || _d === void 0 ? void 0 : _d.toString());
|
|
717
125
|
});
|
|
718
126
|
});
|
|
719
127
|
//# sourceMappingURL=ProbeService.test.js.map
|