@webex/internal-plugin-support 3.12.0 → 3.13.0-next.10
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/.repo-context.json +437 -0
- package/.sdd/manifest.json +430 -0
- package/AGENTS.md +197 -0
- package/dist/support.js +13 -3
- package/dist/support.js.map +1 -1
- package/docs/adr/0001-retain-product-readme.md +97 -0
- package/docs/adr/index.md +25 -0
- package/docs/architecture.md +260 -0
- package/docs/getting-started.md +122 -0
- package/docs/index.md +42 -0
- package/docs/specs/README.md +67 -0
- package/package.json +12 -12
- package/schemas/repo-context.schema.json +796 -0
- package/src/docs/README.md +436 -0
- package/src/support.js +20 -3
- package/test/unit/spec/support.js +147 -0
|
@@ -173,6 +173,9 @@ describe('plugin-support', () => {
|
|
|
173
173
|
beforeEach(() => {
|
|
174
174
|
webex.logger = {
|
|
175
175
|
formatLogs: sinon.stub().returns(['fake logs']),
|
|
176
|
+
updateLastSubmittedIndex: sinon.stub(),
|
|
177
|
+
resetBufferToLastSuccessfulUpload: sinon.stub(),
|
|
178
|
+
error: sinon.stub(),
|
|
176
179
|
sdkBuffer: [],
|
|
177
180
|
clientBuffer: [],
|
|
178
181
|
buffer: [],
|
|
@@ -227,5 +230,149 @@ describe('plugin-support', () => {
|
|
|
227
230
|
assert.deepEqual(uploadArgs[0].file, ['test logs']);
|
|
228
231
|
});
|
|
229
232
|
});
|
|
233
|
+
|
|
234
|
+
it('calls updateLastSubmittedIndex() after a successful upload', async () => {
|
|
235
|
+
await webex.internal.support.submitLogs({});
|
|
236
|
+
|
|
237
|
+
assert.calledOnce(webex.logger.updateLastSubmittedIndex);
|
|
238
|
+
assert.notCalled(webex.logger.resetBufferToLastSuccessfulUpload);
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
it('resolves with the response body from upload', async () => {
|
|
242
|
+
const uploadResponse = {logId: 'abc123'};
|
|
243
|
+
|
|
244
|
+
webex.upload = sinon.stub().returns(Promise.resolve(uploadResponse));
|
|
245
|
+
|
|
246
|
+
const result = await webex.internal.support.submitLogs({});
|
|
247
|
+
|
|
248
|
+
assert.deepEqual(result, uploadResponse);
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
it('adds userId from the session to the returned body if not already present', async () => {
|
|
252
|
+
const uploadResponse = {};
|
|
253
|
+
|
|
254
|
+
webex.upload = sinon.stub().callsFake((opts) => {
|
|
255
|
+
opts.phases.finalize.$body({userId: 'session-user-id', logFilename: 'file.txt'});
|
|
256
|
+
|
|
257
|
+
return Promise.resolve(uploadResponse);
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
const result = await webex.internal.support.submitLogs({});
|
|
261
|
+
|
|
262
|
+
assert.equal(result.userId, 'session-user-id');
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
it('does not overwrite userId in the returned body if already present', async () => {
|
|
266
|
+
const uploadResponse = {userId: 'existing-user-id'};
|
|
267
|
+
|
|
268
|
+
webex.upload = sinon.stub().callsFake((opts) => {
|
|
269
|
+
opts.phases.finalize.$body({userId: 'session-user-id', logFilename: 'file.txt'});
|
|
270
|
+
|
|
271
|
+
return Promise.resolve(uploadResponse);
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
const result = await webex.internal.support.submitLogs({});
|
|
275
|
+
|
|
276
|
+
assert.equal(result.userId, 'existing-user-id');
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
[
|
|
280
|
+
{incrementalLogs: true, retryFailedLogUploadsAtNextInterval: true, shouldReset: true},
|
|
281
|
+
{incrementalLogs: false, retryFailedLogUploadsAtNextInterval: true, shouldReset: false},
|
|
282
|
+
{incrementalLogs: true, retryFailedLogUploadsAtNextInterval: false, shouldReset: false},
|
|
283
|
+
{incrementalLogs: false, retryFailedLogUploadsAtNextInterval: false, shouldReset: false},
|
|
284
|
+
].forEach(({incrementalLogs, retryFailedLogUploadsAtNextInterval, shouldReset}) => {
|
|
285
|
+
it(`${
|
|
286
|
+
shouldReset ? 'calls' : 'does not call'
|
|
287
|
+
} resetBufferToLastSuccessfulUpload() when upload fails with incrementalLogs=${incrementalLogs} and retryFailedLogUploadsAtNextInterval=${retryFailedLogUploadsAtNextInterval}`, async () => {
|
|
288
|
+
const uploadError = new Error('upload failed');
|
|
289
|
+
|
|
290
|
+
webex.upload = sinon.stub().returns(Promise.reject(uploadError));
|
|
291
|
+
webex.internal.support.config.incrementalLogs = incrementalLogs;
|
|
292
|
+
webex.internal.support.config.retryFailedLogUploadsAtNextInterval =
|
|
293
|
+
retryFailedLogUploadsAtNextInterval;
|
|
294
|
+
|
|
295
|
+
await webex.internal.support.submitLogs({}).catch(() => {});
|
|
296
|
+
|
|
297
|
+
assert.notCalled(webex.logger.updateLastSubmittedIndex);
|
|
298
|
+
if (shouldReset) {
|
|
299
|
+
assert.calledOnce(webex.logger.resetBufferToLastSuccessfulUpload);
|
|
300
|
+
} else {
|
|
301
|
+
assert.notCalled(webex.logger.resetBufferToLastSuccessfulUpload);
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
[
|
|
307
|
+
{
|
|
308
|
+
type: 'diff',
|
|
309
|
+
incrementalLogs: false,
|
|
310
|
+
retryFailedLogUploadsAtNextInterval: true,
|
|
311
|
+
shouldReset: true,
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
type: 'diff',
|
|
315
|
+
incrementalLogs: false,
|
|
316
|
+
retryFailedLogUploadsAtNextInterval: false,
|
|
317
|
+
shouldReset: false,
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
type: 'full',
|
|
321
|
+
incrementalLogs: true,
|
|
322
|
+
retryFailedLogUploadsAtNextInterval: true,
|
|
323
|
+
shouldReset: false,
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
type: 'full',
|
|
327
|
+
incrementalLogs: true,
|
|
328
|
+
retryFailedLogUploadsAtNextInterval: false,
|
|
329
|
+
shouldReset: false,
|
|
330
|
+
},
|
|
331
|
+
].forEach(({type, incrementalLogs, retryFailedLogUploadsAtNextInterval, shouldReset}) => {
|
|
332
|
+
it(`${
|
|
333
|
+
shouldReset ? 'calls' : 'does not call'
|
|
334
|
+
} resetBufferToLastSuccessfulUpload() when upload fails with options.type=${type}, incrementalLogs=${incrementalLogs}, retryFailedLogUploadsAtNextInterval=${retryFailedLogUploadsAtNextInterval}`, async () => {
|
|
335
|
+
const uploadError = new Error('upload failed');
|
|
336
|
+
|
|
337
|
+
webex.upload = sinon.stub().returns(Promise.reject(uploadError));
|
|
338
|
+
webex.internal.support.config.incrementalLogs = incrementalLogs;
|
|
339
|
+
webex.internal.support.config.retryFailedLogUploadsAtNextInterval =
|
|
340
|
+
retryFailedLogUploadsAtNextInterval;
|
|
341
|
+
|
|
342
|
+
await webex.internal.support.submitLogs({}, undefined, {type}).catch(() => {});
|
|
343
|
+
|
|
344
|
+
assert.notCalled(webex.logger.updateLastSubmittedIndex);
|
|
345
|
+
if (shouldReset) {
|
|
346
|
+
assert.calledOnce(webex.logger.resetBufferToLastSuccessfulUpload);
|
|
347
|
+
} else {
|
|
348
|
+
assert.notCalled(webex.logger.resetBufferToLastSuccessfulUpload);
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
it('logs an error and rejects the promise when upload fails with incrementalLogs and retryFailedLogUploadsAtNextInterval both true', async () => {
|
|
354
|
+
const uploadError = new Error('upload failed');
|
|
355
|
+
|
|
356
|
+
webex.upload = sinon.stub().returns(Promise.reject(uploadError));
|
|
357
|
+
webex.internal.support.config.incrementalLogs = true;
|
|
358
|
+
webex.internal.support.config.retryFailedLogUploadsAtNextInterval = true;
|
|
359
|
+
|
|
360
|
+
await assert.isRejected(webex.internal.support.submitLogs({}), uploadError);
|
|
361
|
+
|
|
362
|
+
assert.calledOnce(webex.logger.error);
|
|
363
|
+
assert.match(webex.logger.error.args[0][0], /Failed to upload logs/);
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
it('rejects the promise when upload fails even without retry config', async () => {
|
|
367
|
+
const uploadError = new Error('upload failed');
|
|
368
|
+
|
|
369
|
+
webex.upload = sinon.stub().returns(Promise.reject(uploadError));
|
|
370
|
+
webex.internal.support.config.incrementalLogs = false;
|
|
371
|
+
webex.internal.support.config.retryFailedLogUploadsAtNextInterval = false;
|
|
372
|
+
|
|
373
|
+
await assert.isRejected(webex.internal.support.submitLogs({}), uploadError);
|
|
374
|
+
|
|
375
|
+
assert.notCalled(webex.logger.error);
|
|
376
|
+
});
|
|
230
377
|
});
|
|
231
378
|
});
|