@talkpilot/core-db 1.3.58 → 1.3.60
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/README.md +1 -0
- package/dist/test-utils/factories/websitalk/scans.d.ts.map +1 -1
- package/dist/test-utils/factories/websitalk/scans.js +1 -0
- package/dist/test-utils/factories/websitalk/scans.js.map +1 -1
- package/dist/websitalk/scans/scans.getters.d.ts.map +1 -1
- package/dist/websitalk/scans/scans.getters.js +1 -0
- package/dist/websitalk/scans/scans.getters.js.map +1 -1
- package/dist/websitalk/scans/scans.types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/test-utils/factories/websitalk/scans.ts +1 -0
- package/src/websitalk/scans/__tests__/scans.spec.ts +362 -341
- package/src/websitalk/scans/scans.getters.ts +1 -0
- package/src/websitalk/scans/scans.types.ts +6 -2
package/README.md
CHANGED
|
@@ -178,6 +178,7 @@ Refer to `DEVELOPMENT.md` for the full walkthrough, token instructions, and fact
|
|
|
178
178
|
| 1.3.47 | Added optional `accountOwnerEmail` field to `WebsiteTalkProduct` (CP-1715): the recipient for the end-of-call summary email, set once from the client's login email and editable in Settings. |
|
|
179
179
|
| 1.3.48 | Fixed `getScanPages` search (CP-1726): user search input was passed unescaped into MongoDB's `$regex`, so a URL/title containing regex-special characters (e.g. `?`) failed to match even when the document existed. Added `escapeRegex()` and applied it before building the `url`/`title` `$regex` filter. No API changes. |
|
|
180
180
|
| 1.3.49 | Internal tools configuration on flows (CP-1723): `Flow.internalTools` keyed by tool name (`enabled`, optional `maxCalls`, per-parameter `description`/`value` overrides) with matching `$jsonSchema` validator, plus `createFlow` / `updateFlowById` mutators and the `FlowUpdateParams` type so consumers stop writing to the `flows` collection directly. |
|
|
181
|
+
| 1.3.58 | Pause/Resume support for WebsiteTalk scans (CP-1752): `PAUSED` and `CANCELED` added to `SCAN_STATUSES` (`PAUSED` deliberately excluded from `FINISHED_SCAN_STATUSES` — pausing isn't done, `CANCELED` is). Added `Scan.pausedAt`, tracked across pause/resume so elapsed-time display can freeze correctly instead of counting the paused duration. |
|
|
181
182
|
|
|
182
183
|
### 1.1.9
|
|
183
184
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scans.d.ts","sourceRoot":"","sources":["../../../../src/test-utils/factories/websitalk/scans.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAGlC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE/C,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"scans.d.ts","sourceRoot":"","sources":["../../../../src/test-utils/factories/websitalk/scans.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAGlC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE/C,eAAO,MAAM,WAAW,qEAoBrB,CAAC;AAEJ,wBAAgB,iBAAiB,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAEjE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scans.js","sourceRoot":"","sources":["../../../../src/test-utils/factories/websitalk/scans.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"scans.js","sourceRoot":"","sources":["../../../../src/test-utils/factories/websitalk/scans.ts"],"names":[],"mappings":";;;AA2BA,8CAEC;AA7BD,qCAAkC;AAClC,2CAAwC;AACxC,qCAAmC;AAGtB,QAAA,WAAW,GAAG,iBAAO,CAAC,MAAM,CAAO,GAAG,EAAE,CAAC,CAAC;IACrD,QAAQ,EAAE,aAAK,CAAC,MAAM,CAAC,IAAI,EAAE;IAC7B,YAAY,EAAE,IAAI,kBAAQ,EAAE,CAAC,QAAQ,EAAE;IACvC,MAAM,EAAE,UAAU;IAClB,gBAAgB,EAAE,CAAC;IACnB,YAAY,EAAE,CAAC;IACf,YAAY,EAAE,C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AE,GAAG;QACd,WAAW,EAAE,IAAI;QACjB,cAAc,EAAE,CAAC;QACjB,oBAAoB,EAAE,CAAC;QACvB,cAAc,EAAE,CAAC;KAClB,CAAC,CAAC;AACL,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"scans.getters.js","sourceRoot":"","sources":["../../../src/websitalk/scans/scans.getters.ts"],"names":[],"mappings":";;;AAAA,qCAAuD;AACvD,oCAAiC;AACjC,mEAG2C;AAE3C,uDAA0E;AAC1E,+CAAiD;AAE1C,MAAM,kBAAkB,GAAG,GAAqB,EAAE;IACvD,OAAO,IAAA,aAAK,GAAE,CAAC,UAAU,CAAO,OAAO,CAAC,CAAC;AAC3C,CAAC,CAAC;AAFW,QAAA,kBAAkB,sBAE7B;AAEK,MAAM,4BAA4B,GAAG,CAC1C,QAAgB,EAChB,SAAe,EACf,OAAa,EACO,EAAE;IACtB,OAAO,IAAA,0BAAkB,GAAE;SACxB,IAAI,CAAC;QACJ,QAAQ;QACR,SAAS,EAAE;YACT,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,OAAO;SACd;KACF,CAAC;SACD,OAAO,EAAE,CAAC;AACf,CAAC,CAAC;AAdW,QAAA,4BAA4B,gCAcvC;AAEK,MAAM,iCAAiC,GAAG,CAC/C,QAAgB,EAChB,SAAe,EACf,OAAa,EACb,MAAW,EAC0B,EAAE;IACvC,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAoB,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QACjE,GAAG,CAAC,KAAe,CAAC,GAAG,CAAC,CAAC;QACzB,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,IAAA,0BAAkB,GAAE;SACxB,IAAI,CACH;QACE,QAAQ;QACR,SAAS,EAAE;YACT,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,OAAO;SACd;KACF,EACD,EAAE,UAAU,EAAE,CACf;SACA,OAAO,EAAyC,CAAC;AACtD,CAAC,CAA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AAO,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,341 +1,362 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getScansCollection,
|
|
3
|
-
getScansByClientAndDateRange,
|
|
4
|
-
getScanFieldsByClientAndDateRange,
|
|
5
|
-
findScansByQuery,
|
|
6
|
-
countScans,
|
|
7
|
-
createScanDoc,
|
|
8
|
-
updateScanDoc,
|
|
9
|
-
findInProgressScansByClient,
|
|
10
|
-
getScansByWebsiteUrl,
|
|
11
|
-
getLatestScanByWebsiteUrl,
|
|
12
|
-
getInProgressScanByWebsiteUrl,
|
|
13
|
-
getLatestCompletedScanByWebsiteUrl,
|
|
14
|
-
deleteScansByWebsiteUrl,
|
|
15
|
-
deleteScanById,
|
|
16
|
-
} from "../scans.getters";
|
|
17
|
-
import { FINISHED_SCAN_STATUSES, SCAN_STATUSES } from "../scans.constants";
|
|
18
|
-
import { createScanFixture } from "../../../test-utils/factories";
|
|
19
|
-
import { ObjectId } from "mongodb";
|
|
20
|
-
|
|
21
|
-
describe("db.websitalk.scans", () => {
|
|
22
|
-
describe("getScansByClientAndDateRange()", () => {
|
|
23
|
-
it("should return full scan documents within the date range", async () => {
|
|
24
|
-
const clientId = "dateRangeClient";
|
|
25
|
-
const startDate = new Date("2023-05-01");
|
|
26
|
-
const endDate = new Date("2023-05-31");
|
|
27
|
-
|
|
28
|
-
const scanInside = createScanFixture({ clientId, status: "COMPLETED" });
|
|
29
|
-
const scanBefore = createScanFixture({ clientId });
|
|
30
|
-
const scanAfter = createScanFixture({ clientId });
|
|
31
|
-
|
|
32
|
-
await getScansCollection().insertMany([
|
|
33
|
-
{ ...scanInside, createdAt: new Date("2023-05-15") },
|
|
34
|
-
{ ...scanBefore, createdAt: new Date("2023-04-30") },
|
|
35
|
-
{ ...scanAfter, createdAt: new Date("2023-06-01") },
|
|
36
|
-
]);
|
|
37
|
-
|
|
38
|
-
const result = await getScansByClientAndDateRange(
|
|
39
|
-
clientId,
|
|
40
|
-
startDate,
|
|
41
|
-
endDate,
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
expect(result.length).toBe(1);
|
|
45
|
-
expect(result[0]).toMatchObject({
|
|
46
|
-
clientId,
|
|
47
|
-
websiteUrlId: scanInside.websiteUrlId,
|
|
48
|
-
status: "COMPLETED",
|
|
49
|
-
});
|
|
50
|
-
expect(result[0]).toHaveProperty("siteChrome");
|
|
51
|
-
expect(result[0]).toHaveProperty("skipped");
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("should respect the date range boundaries (inclusive)", async () => {
|
|
55
|
-
const clientId = "boundaryClient";
|
|
56
|
-
const onStart = createScanFixture({ clientId });
|
|
57
|
-
const onEnd = createScanFixture({ clientId });
|
|
58
|
-
|
|
59
|
-
await getScansCollection().insertMany([
|
|
60
|
-
{ ...onStart, createdAt: new Date("2023-05-01") },
|
|
61
|
-
{ ...onEnd, createdAt: new Date("2023-05-31") },
|
|
62
|
-
]);
|
|
63
|
-
|
|
64
|
-
const result = await getScansByClientAndDateRange(
|
|
65
|
-
clientId,
|
|
66
|
-
new Date("2023-05-01"),
|
|
67
|
-
new Date("2023-05-31"),
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
expect(result.length).toBe(2);
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
describe("getScanFieldsByClientAndDateRange()", () => {
|
|
75
|
-
it("should return only the requested fields (plus _id)", async () => {
|
|
76
|
-
const clientId = "projectionClient";
|
|
77
|
-
const scan = createScanFixture({
|
|
78
|
-
clientId,
|
|
79
|
-
status: "COMPLETED",
|
|
80
|
-
siteChrome: { url: "https://example.com", sourceType: "site_chrome" },
|
|
81
|
-
skipped: [{ path: "/broken", reason: "HTTP 500" }],
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
await getScansCollection().insertOne({
|
|
85
|
-
...scan,
|
|
86
|
-
createdAt: new Date("2023-05-15"),
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
const [result] = await getScanFieldsByClientAndDateRange(
|
|
90
|
-
clientId,
|
|
91
|
-
new Date("2023-05-01"),
|
|
92
|
-
new Date("2023-05-31"),
|
|
93
|
-
["clientId", "websiteUrlId", "status"],
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
expect(result).toMatchObject({
|
|
97
|
-
clientId,
|
|
98
|
-
websiteUrlId: scan.websiteUrlId,
|
|
99
|
-
status: "COMPLETED",
|
|
100
|
-
});
|
|
101
|
-
expect(result).toHaveProperty("_id");
|
|
102
|
-
expect(result).not.toHaveProperty("siteChrome");
|
|
103
|
-
expect(result).not.toHaveProperty("skipped");
|
|
104
|
-
expect(result).not.toHaveProperty("createdAt");
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
describe("findScansByQuery() / countScans()", () => {
|
|
109
|
-
it("should find scans matching a raw filter and count them", async () => {
|
|
110
|
-
const clientId = "queryClient";
|
|
111
|
-
const completed = createScanFixture({ clientId, status: "COMPLETED" });
|
|
112
|
-
const scanning = createScanFixture({ clientId, status: "SCANNING" });
|
|
113
|
-
|
|
114
|
-
await getScansCollection().insertMany([completed, scanning]);
|
|
115
|
-
|
|
116
|
-
const result = await findScansByQuery({ clientId, status: "COMPLETED" });
|
|
117
|
-
const count = await countScans({ clientId });
|
|
118
|
-
|
|
119
|
-
expect(result.length).toBe(1);
|
|
120
|
-
expect(result[0].websiteUrlId).toBe(completed.websiteUrlId);
|
|
121
|
-
expect(count).toBe(2);
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
describe("createScanDoc()", () => {
|
|
126
|
-
it("should insert a scan with default values for the rest of the fields", async () => {
|
|
127
|
-
const clientId = "createClient";
|
|
128
|
-
const websiteUrlId = new ObjectId().toString();
|
|
129
|
-
|
|
130
|
-
const { insertedId } = await createScanDoc({ clientId, websiteUrlId });
|
|
131
|
-
|
|
132
|
-
const result = await getScansCollection().findOne({ _id: insertedId });
|
|
133
|
-
|
|
134
|
-
expect(result).toMatchObject({
|
|
135
|
-
clientId,
|
|
136
|
-
websiteUrlId,
|
|
137
|
-
status: "CHECKING",
|
|
138
|
-
activeTasksCount: 0,
|
|
139
|
-
pagesScanned: 0,
|
|
140
|
-
pagesSkipped: 0,
|
|
141
|
-
skipped: [],
|
|
142
|
-
siteChrome: {},
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
expect(result?.
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
const {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
);
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
it("should return
|
|
201
|
-
await getScansCollection().insertMany([
|
|
202
|
-
createScanFixture({
|
|
203
|
-
websiteUrlId,
|
|
204
|
-
status: "COMPLETED",
|
|
205
|
-
createdAt: new Date("2023-05-01"),
|
|
206
|
-
}),
|
|
207
|
-
createScanFixture({
|
|
208
|
-
websiteUrlId,
|
|
209
|
-
status: "
|
|
210
|
-
createdAt: new Date("2023-05-15"),
|
|
211
|
-
}),
|
|
212
|
-
]);
|
|
213
|
-
|
|
214
|
-
const
|
|
215
|
-
expect(
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
await
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
createScanFixture({
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
const
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
).
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
1
|
+
import {
|
|
2
|
+
getScansCollection,
|
|
3
|
+
getScansByClientAndDateRange,
|
|
4
|
+
getScanFieldsByClientAndDateRange,
|
|
5
|
+
findScansByQuery,
|
|
6
|
+
countScans,
|
|
7
|
+
createScanDoc,
|
|
8
|
+
updateScanDoc,
|
|
9
|
+
findInProgressScansByClient,
|
|
10
|
+
getScansByWebsiteUrl,
|
|
11
|
+
getLatestScanByWebsiteUrl,
|
|
12
|
+
getInProgressScanByWebsiteUrl,
|
|
13
|
+
getLatestCompletedScanByWebsiteUrl,
|
|
14
|
+
deleteScansByWebsiteUrl,
|
|
15
|
+
deleteScanById,
|
|
16
|
+
} from "../scans.getters";
|
|
17
|
+
import { FINISHED_SCAN_STATUSES, SCAN_STATUSES } from "../scans.constants";
|
|
18
|
+
import { createScanFixture } from "../../../test-utils/factories";
|
|
19
|
+
import { ObjectId } from "mongodb";
|
|
20
|
+
|
|
21
|
+
describe("db.websitalk.scans", () => {
|
|
22
|
+
describe("getScansByClientAndDateRange()", () => {
|
|
23
|
+
it("should return full scan documents within the date range", async () => {
|
|
24
|
+
const clientId = "dateRangeClient";
|
|
25
|
+
const startDate = new Date("2023-05-01");
|
|
26
|
+
const endDate = new Date("2023-05-31");
|
|
27
|
+
|
|
28
|
+
const scanInside = createScanFixture({ clientId, status: "COMPLETED" });
|
|
29
|
+
const scanBefore = createScanFixture({ clientId });
|
|
30
|
+
const scanAfter = createScanFixture({ clientId });
|
|
31
|
+
|
|
32
|
+
await getScansCollection().insertMany([
|
|
33
|
+
{ ...scanInside, createdAt: new Date("2023-05-15") },
|
|
34
|
+
{ ...scanBefore, createdAt: new Date("2023-04-30") },
|
|
35
|
+
{ ...scanAfter, createdAt: new Date("2023-06-01") },
|
|
36
|
+
]);
|
|
37
|
+
|
|
38
|
+
const result = await getScansByClientAndDateRange(
|
|
39
|
+
clientId,
|
|
40
|
+
startDate,
|
|
41
|
+
endDate,
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
expect(result.length).toBe(1);
|
|
45
|
+
expect(result[0]).toMatchObject({
|
|
46
|
+
clientId,
|
|
47
|
+
websiteUrlId: scanInside.websiteUrlId,
|
|
48
|
+
status: "COMPLETED",
|
|
49
|
+
});
|
|
50
|
+
expect(result[0]).toHaveProperty("siteChrome");
|
|
51
|
+
expect(result[0]).toHaveProperty("skipped");
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("should respect the date range boundaries (inclusive)", async () => {
|
|
55
|
+
const clientId = "boundaryClient";
|
|
56
|
+
const onStart = createScanFixture({ clientId });
|
|
57
|
+
const onEnd = createScanFixture({ clientId });
|
|
58
|
+
|
|
59
|
+
await getScansCollection().insertMany([
|
|
60
|
+
{ ...onStart, createdAt: new Date("2023-05-01") },
|
|
61
|
+
{ ...onEnd, createdAt: new Date("2023-05-31") },
|
|
62
|
+
]);
|
|
63
|
+
|
|
64
|
+
const result = await getScansByClientAndDateRange(
|
|
65
|
+
clientId,
|
|
66
|
+
new Date("2023-05-01"),
|
|
67
|
+
new Date("2023-05-31"),
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
expect(result.length).toBe(2);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
describe("getScanFieldsByClientAndDateRange()", () => {
|
|
75
|
+
it("should return only the requested fields (plus _id)", async () => {
|
|
76
|
+
const clientId = "projectionClient";
|
|
77
|
+
const scan = createScanFixture({
|
|
78
|
+
clientId,
|
|
79
|
+
status: "COMPLETED",
|
|
80
|
+
siteChrome: { url: "https://example.com", sourceType: "site_chrome" },
|
|
81
|
+
skipped: [{ path: "/broken", reason: "HTTP 500" }],
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
await getScansCollection().insertOne({
|
|
85
|
+
...scan,
|
|
86
|
+
createdAt: new Date("2023-05-15"),
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const [result] = await getScanFieldsByClientAndDateRange(
|
|
90
|
+
clientId,
|
|
91
|
+
new Date("2023-05-01"),
|
|
92
|
+
new Date("2023-05-31"),
|
|
93
|
+
["clientId", "websiteUrlId", "status"],
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
expect(result).toMatchObject({
|
|
97
|
+
clientId,
|
|
98
|
+
websiteUrlId: scan.websiteUrlId,
|
|
99
|
+
status: "COMPLETED",
|
|
100
|
+
});
|
|
101
|
+
expect(result).toHaveProperty("_id");
|
|
102
|
+
expect(result).not.toHaveProperty("siteChrome");
|
|
103
|
+
expect(result).not.toHaveProperty("skipped");
|
|
104
|
+
expect(result).not.toHaveProperty("createdAt");
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
describe("findScansByQuery() / countScans()", () => {
|
|
109
|
+
it("should find scans matching a raw filter and count them", async () => {
|
|
110
|
+
const clientId = "queryClient";
|
|
111
|
+
const completed = createScanFixture({ clientId, status: "COMPLETED" });
|
|
112
|
+
const scanning = createScanFixture({ clientId, status: "SCANNING" });
|
|
113
|
+
|
|
114
|
+
await getScansCollection().insertMany([completed, scanning]);
|
|
115
|
+
|
|
116
|
+
const result = await findScansByQuery({ clientId, status: "COMPLETED" });
|
|
117
|
+
const count = await countScans({ clientId });
|
|
118
|
+
|
|
119
|
+
expect(result.length).toBe(1);
|
|
120
|
+
expect(result[0].websiteUrlId).toBe(completed.websiteUrlId);
|
|
121
|
+
expect(count).toBe(2);
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
describe("createScanDoc()", () => {
|
|
126
|
+
it("should insert a scan with default values for the rest of the fields", async () => {
|
|
127
|
+
const clientId = "createClient";
|
|
128
|
+
const websiteUrlId = new ObjectId().toString();
|
|
129
|
+
|
|
130
|
+
const { insertedId } = await createScanDoc({ clientId, websiteUrlId });
|
|
131
|
+
|
|
132
|
+
const result = await getScansCollection().findOne({ _id: insertedId });
|
|
133
|
+
|
|
134
|
+
expect(result).toMatchObject({
|
|
135
|
+
clientId,
|
|
136
|
+
websiteUrlId,
|
|
137
|
+
status: "CHECKING",
|
|
138
|
+
activeTasksCount: 0,
|
|
139
|
+
pagesScanned: 0,
|
|
140
|
+
pagesSkipped: 0,
|
|
141
|
+
skipped: [],
|
|
142
|
+
siteChrome: {},
|
|
143
|
+
pausedAt: null,
|
|
144
|
+
});
|
|
145
|
+
expect(result?.createdAt).toBeInstanceOf(Date);
|
|
146
|
+
expect(result?.updatedAt).toBeInstanceOf(Date);
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
describe("pausedAt", () => {
|
|
151
|
+
it("is set on pause and cleared back to null on resume, via updateScanDoc", async () => {
|
|
152
|
+
const scan = createScanFixture({ status: "SCANNING", pausedAt: null });
|
|
153
|
+
const { insertedId } = await getScansCollection().insertOne(scan);
|
|
154
|
+
|
|
155
|
+
const pausedAt = new Date();
|
|
156
|
+
const paused = await updateScanDoc(insertedId, {
|
|
157
|
+
status: "PAUSED",
|
|
158
|
+
pausedAt,
|
|
159
|
+
});
|
|
160
|
+
expect(paused?.pausedAt).toEqual(pausedAt);
|
|
161
|
+
|
|
162
|
+
const resumed = await updateScanDoc(insertedId, {
|
|
163
|
+
status: "SCANNING",
|
|
164
|
+
pausedAt: null,
|
|
165
|
+
});
|
|
166
|
+
expect(resumed?.pausedAt).toBeNull();
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
describe("updateScanDoc()", () => {
|
|
171
|
+
it("should update the given fields and bump updatedAt", async () => {
|
|
172
|
+
const scan = createScanFixture({ status: "SCANNING", pagesScanned: 0 });
|
|
173
|
+
const { insertedId } = await getScansCollection().insertOne(scan);
|
|
174
|
+
|
|
175
|
+
const result = await updateScanDoc(insertedId, {
|
|
176
|
+
status: "COMPLETED",
|
|
177
|
+
pagesScanned: 10,
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
expect(result).toMatchObject({
|
|
181
|
+
_id: insertedId,
|
|
182
|
+
status: "COMPLETED",
|
|
183
|
+
pagesScanned: 10,
|
|
184
|
+
});
|
|
185
|
+
expect(result?.updatedAt.getTime()).toBeGreaterThan(
|
|
186
|
+
scan.updatedAt.getTime(),
|
|
187
|
+
);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it("should return null when the scan does not exist", async () => {
|
|
191
|
+
const result = await updateScanDoc(new ObjectId(), { status: "FAILED" });
|
|
192
|
+
|
|
193
|
+
expect(result).toBeNull();
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
describe("in-progress scan helpers", () => {
|
|
198
|
+
const websiteUrlId = "website-123";
|
|
199
|
+
|
|
200
|
+
it("should return website scan history newest first", async () => {
|
|
201
|
+
await getScansCollection().insertMany([
|
|
202
|
+
createScanFixture({
|
|
203
|
+
websiteUrlId,
|
|
204
|
+
status: "COMPLETED",
|
|
205
|
+
createdAt: new Date("2023-05-01"),
|
|
206
|
+
}),
|
|
207
|
+
createScanFixture({
|
|
208
|
+
websiteUrlId,
|
|
209
|
+
status: "COMPLETED",
|
|
210
|
+
createdAt: new Date("2023-05-15"),
|
|
211
|
+
}),
|
|
212
|
+
]);
|
|
213
|
+
|
|
214
|
+
const scans = await getScansByWebsiteUrl(websiteUrlId);
|
|
215
|
+
expect(scans).toHaveLength(2);
|
|
216
|
+
expect(scans[0].createdAt.getTime()).toBeGreaterThan(
|
|
217
|
+
scans[1].createdAt.getTime(),
|
|
218
|
+
);
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
it("should return the newest scan for a website", async () => {
|
|
222
|
+
await getScansCollection().insertMany([
|
|
223
|
+
createScanFixture({
|
|
224
|
+
websiteUrlId,
|
|
225
|
+
status: "COMPLETED",
|
|
226
|
+
createdAt: new Date("2023-05-01"),
|
|
227
|
+
}),
|
|
228
|
+
createScanFixture({
|
|
229
|
+
websiteUrlId,
|
|
230
|
+
status: "FAILED",
|
|
231
|
+
createdAt: new Date("2023-05-15"),
|
|
232
|
+
}),
|
|
233
|
+
]);
|
|
234
|
+
|
|
235
|
+
const latest = await getLatestScanByWebsiteUrl(websiteUrlId);
|
|
236
|
+
expect(latest?.status).toBe("FAILED");
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
it("should return in-progress scan and return null when only completed exists", async () => {
|
|
240
|
+
await getScansCollection().insertMany([
|
|
241
|
+
createScanFixture({
|
|
242
|
+
websiteUrlId,
|
|
243
|
+
status: "COMPLETED",
|
|
244
|
+
createdAt: new Date("2023-05-01"),
|
|
245
|
+
}),
|
|
246
|
+
createScanFixture({
|
|
247
|
+
websiteUrlId,
|
|
248
|
+
status: "SCANNING",
|
|
249
|
+
createdAt: new Date("2023-05-15"),
|
|
250
|
+
}),
|
|
251
|
+
]);
|
|
252
|
+
|
|
253
|
+
const inProgressScan = await getInProgressScanByWebsiteUrl(websiteUrlId);
|
|
254
|
+
expect(inProgressScan?.status).toBe("SCANNING");
|
|
255
|
+
|
|
256
|
+
await getScansCollection().deleteMany({ websiteUrlId });
|
|
257
|
+
await getScansCollection().insertOne(
|
|
258
|
+
createScanFixture({
|
|
259
|
+
websiteUrlId,
|
|
260
|
+
status: "COMPLETED",
|
|
261
|
+
createdAt: new Date("2023-05-20"),
|
|
262
|
+
}),
|
|
263
|
+
);
|
|
264
|
+
|
|
265
|
+
expect(await getInProgressScanByWebsiteUrl(websiteUrlId)).toBeNull();
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
it("should return all in-progress scans across websites for a client", async () => {
|
|
269
|
+
const clientId = "multiScanClient";
|
|
270
|
+
await getScansCollection().insertMany([
|
|
271
|
+
createScanFixture({
|
|
272
|
+
clientId,
|
|
273
|
+
websiteUrlId: "website-a",
|
|
274
|
+
status: "SCANNING",
|
|
275
|
+
}),
|
|
276
|
+
createScanFixture({
|
|
277
|
+
clientId,
|
|
278
|
+
websiteUrlId: "website-b",
|
|
279
|
+
status: "PROCESSING",
|
|
280
|
+
}),
|
|
281
|
+
createScanFixture({
|
|
282
|
+
clientId,
|
|
283
|
+
websiteUrlId: "website-c",
|
|
284
|
+
status: "COMPLETED",
|
|
285
|
+
}),
|
|
286
|
+
]);
|
|
287
|
+
|
|
288
|
+
const scans = await findInProgressScansByClient(clientId);
|
|
289
|
+
expect(scans).toHaveLength(2);
|
|
290
|
+
expect(scans.map((s) => s.websiteUrlId).sort()).toEqual([
|
|
291
|
+
"website-a",
|
|
292
|
+
"website-b",
|
|
293
|
+
]);
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
describe("website delete helpers", () => {
|
|
298
|
+
it("should return the newest completed scan only", async () => {
|
|
299
|
+
const websiteUrlId = new ObjectId().toString();
|
|
300
|
+
await getScansCollection().insertMany([
|
|
301
|
+
createScanFixture({
|
|
302
|
+
websiteUrlId,
|
|
303
|
+
status: "FAILED",
|
|
304
|
+
createdAt: new Date("2023-05-25"),
|
|
305
|
+
}),
|
|
306
|
+
createScanFixture({
|
|
307
|
+
websiteUrlId,
|
|
308
|
+
status: "COMPLETED",
|
|
309
|
+
createdAt: new Date("2023-05-20"),
|
|
310
|
+
}),
|
|
311
|
+
createScanFixture({
|
|
312
|
+
websiteUrlId,
|
|
313
|
+
status: "COMPLETED",
|
|
314
|
+
createdAt: new Date("2023-05-22"),
|
|
315
|
+
}),
|
|
316
|
+
]);
|
|
317
|
+
|
|
318
|
+
const latest = await getLatestCompletedScanByWebsiteUrl(websiteUrlId);
|
|
319
|
+
expect(latest?.status).toBe("COMPLETED");
|
|
320
|
+
expect(latest?.createdAt).toEqual(new Date("2023-05-22"));
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
it("should delete all scans for the website and return count", async () => {
|
|
324
|
+
const websiteUrlId = new ObjectId().toString();
|
|
325
|
+
await getScansCollection().insertMany([
|
|
326
|
+
createScanFixture({ websiteUrlId }),
|
|
327
|
+
createScanFixture({ websiteUrlId }),
|
|
328
|
+
createScanFixture({ websiteUrlId: new ObjectId().toString() }),
|
|
329
|
+
]);
|
|
330
|
+
|
|
331
|
+
const deleted = await deleteScansByWebsiteUrl(websiteUrlId);
|
|
332
|
+
expect(deleted).toBe(2);
|
|
333
|
+
expect(await countScans({ websiteUrlId })).toBe(0);
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
describe("deleteScanById()", () => {
|
|
338
|
+
it("should delete the scan and return true", async () => {
|
|
339
|
+
const { insertedId } =
|
|
340
|
+
await getScansCollection().insertOne(createScanFixture());
|
|
341
|
+
|
|
342
|
+
expect(await deleteScanById(insertedId)).toBe(true);
|
|
343
|
+
expect(
|
|
344
|
+
await getScansCollection().findOne({ _id: insertedId }),
|
|
345
|
+
).toBeNull();
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
it("should return false when the scan does not exist", async () => {
|
|
349
|
+
expect(await deleteScanById(new ObjectId())).toBe(false);
|
|
350
|
+
});
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
describe("FINISHED_SCAN_STATUSES", () => {
|
|
354
|
+
it("should include CANCELED — canceling is final, not resumable", () => {
|
|
355
|
+
expect(FINISHED_SCAN_STATUSES).toContain(SCAN_STATUSES.CANCELED);
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
it("should NOT include PAUSED — pausing is reversible", () => {
|
|
359
|
+
expect(FINISHED_SCAN_STATUSES).not.toContain(SCAN_STATUSES.PAUSED);
|
|
360
|
+
});
|
|
361
|
+
});
|
|
362
|
+
});
|
|
@@ -43,11 +43,15 @@ export type Scan = {
|
|
|
43
43
|
createdAt: Date;
|
|
44
44
|
updatedAt: Date;
|
|
45
45
|
|
|
46
|
+
// startedAt: set once at scan creation (WTIS). pausedAt: set/cleared across
|
|
47
|
+
// pause/resume (WTIS) and, unlike the fields below, IS read mid-scan — it's
|
|
48
|
+
// how an active scan's elapsed-time display freezes correctly while PAUSED.
|
|
49
|
+
startedAt?: Date;
|
|
50
|
+
pausedAt?: Date | null;
|
|
51
|
+
|
|
46
52
|
// Terminal-only snapshot, written once at finalize (Brain, outside core-db).
|
|
47
53
|
// Never read for live progress — an active scan's KPIs must come from
|
|
48
54
|
// getScanKpiCounts, not these fields, which are not kept in sync mid-scan.
|
|
49
|
-
startedAt?: Date;
|
|
50
|
-
pausedAt?: Date | null;
|
|
51
55
|
completedAt?: Date | null;
|
|
52
56
|
pagesCompleted?: number;
|
|
53
57
|
pagesFailedPermanent?: number;
|