@rimori/playwright-testing 0.2.3-next.2 → 0.2.3-next.4
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.
|
@@ -54,6 +54,11 @@ export declare class RimoriTestEnvironment {
|
|
|
54
54
|
* GET returns current state, PATCH updates state, POST creates/updates state.
|
|
55
55
|
*/
|
|
56
56
|
private setupSettingsRoutes;
|
|
57
|
+
/**
|
|
58
|
+
* Sets up default handlers for shared_content and shared_content_completed routes.
|
|
59
|
+
* These provide sensible defaults so tests don't need to mock every shared content call.
|
|
60
|
+
*/
|
|
61
|
+
private setupSharedContentRoutes;
|
|
57
62
|
/**
|
|
58
63
|
* Formats text as SSE (Server-Sent Events) response.
|
|
59
64
|
* Since Playwright's route.fulfill() requires complete body, we format as SSE without delays.
|
|
@@ -284,14 +289,43 @@ export declare class RimoriTestEnvironment {
|
|
|
284
289
|
};
|
|
285
290
|
readonly community: {
|
|
286
291
|
sharedContent: {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
292
|
+
/**
|
|
293
|
+
* Mock the shared_content GET endpoint for fetching a single item.
|
|
294
|
+
* Used by SharedContentController.getSharedContent()
|
|
295
|
+
*/
|
|
296
|
+
mockGet: (value: unknown, options?: MockOptions) => void;
|
|
297
|
+
/**
|
|
298
|
+
* Mock the shared_content GET endpoint for fetching multiple items.
|
|
299
|
+
* Used by SharedContentController.getSharedContentList() and getCompletedTopics()
|
|
300
|
+
*/
|
|
301
|
+
mockGetList: (value: unknown[], options?: MockOptions) => void;
|
|
302
|
+
/**
|
|
303
|
+
* Mock the shared_content POST endpoint for creating new content.
|
|
304
|
+
* Used by SharedContentController.createSharedContent() after AI generation.
|
|
305
|
+
* Note: getNewSharedContent() first calls ai.getObject() (mock via env.ai.mockGetObject),
|
|
306
|
+
* then calls createSharedContent() which hits this endpoint.
|
|
307
|
+
*/
|
|
308
|
+
mockCreate: (value: unknown, options?: MockOptions) => void;
|
|
309
|
+
/**
|
|
310
|
+
* Mock the shared_content PATCH endpoint for updating content.
|
|
311
|
+
* Used by SharedContentController.updateSharedContent() and removeSharedContent() (soft delete)
|
|
312
|
+
*/
|
|
313
|
+
mockUpdate: (value: unknown, options?: MockOptions) => void;
|
|
314
|
+
/**
|
|
315
|
+
* Mock the shared_content_completed POST endpoint (upsert).
|
|
316
|
+
* Used by SharedContentController.completeSharedContent() and updateSharedContentState()
|
|
317
|
+
*/
|
|
318
|
+
mockComplete: (value?: unknown, options?: MockOptions) => void;
|
|
319
|
+
/**
|
|
320
|
+
* Mock the shared_content_completed POST endpoint for state updates.
|
|
321
|
+
* Alias for mockComplete since both use upsert via POST.
|
|
322
|
+
*/
|
|
323
|
+
mockUpdateState: (value?: unknown, options?: MockOptions) => void;
|
|
324
|
+
/**
|
|
325
|
+
* Mock removing shared content (soft delete via PATCH).
|
|
326
|
+
* Alias for mockUpdate since removeSharedContent uses PATCH to set deleted_at.
|
|
327
|
+
*/
|
|
328
|
+
mockRemove: (value: unknown, options?: MockOptions) => void;
|
|
295
329
|
};
|
|
296
330
|
};
|
|
297
331
|
readonly exercise: {
|
|
@@ -347,14 +347,57 @@ class RimoriTestEnvironment {
|
|
|
347
347
|
};
|
|
348
348
|
this.community = {
|
|
349
349
|
sharedContent: {
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
350
|
+
/**
|
|
351
|
+
* Mock the shared_content GET endpoint for fetching a single item.
|
|
352
|
+
* Used by SharedContentController.getSharedContent()
|
|
353
|
+
*/
|
|
354
|
+
mockGet: (value, options) => {
|
|
355
|
+
this.addSupabaseRoute('shared_content', value, { ...options, method: 'GET' });
|
|
356
|
+
},
|
|
357
|
+
/**
|
|
358
|
+
* Mock the shared_content GET endpoint for fetching multiple items.
|
|
359
|
+
* Used by SharedContentController.getSharedContentList() and getCompletedTopics()
|
|
360
|
+
*/
|
|
361
|
+
mockGetList: (value, options) => {
|
|
362
|
+
this.addSupabaseRoute('shared_content', value, { ...options, method: 'GET' });
|
|
363
|
+
},
|
|
364
|
+
/**
|
|
365
|
+
* Mock the shared_content POST endpoint for creating new content.
|
|
366
|
+
* Used by SharedContentController.createSharedContent() after AI generation.
|
|
367
|
+
* Note: getNewSharedContent() first calls ai.getObject() (mock via env.ai.mockGetObject),
|
|
368
|
+
* then calls createSharedContent() which hits this endpoint.
|
|
369
|
+
*/
|
|
370
|
+
mockCreate: (value, options) => {
|
|
371
|
+
this.addSupabaseRoute('shared_content', value, { ...options, method: 'POST' });
|
|
372
|
+
},
|
|
373
|
+
/**
|
|
374
|
+
* Mock the shared_content PATCH endpoint for updating content.
|
|
375
|
+
* Used by SharedContentController.updateSharedContent() and removeSharedContent() (soft delete)
|
|
376
|
+
*/
|
|
377
|
+
mockUpdate: (value, options) => {
|
|
378
|
+
this.addSupabaseRoute('shared_content', value, { ...options, method: 'PATCH' });
|
|
379
|
+
},
|
|
380
|
+
/**
|
|
381
|
+
* Mock the shared_content_completed POST endpoint (upsert).
|
|
382
|
+
* Used by SharedContentController.completeSharedContent() and updateSharedContentState()
|
|
383
|
+
*/
|
|
384
|
+
mockComplete: (value = {}, options) => {
|
|
385
|
+
this.addSupabaseRoute('shared_content_completed', value, { ...options, method: 'POST' });
|
|
386
|
+
},
|
|
387
|
+
/**
|
|
388
|
+
* Mock the shared_content_completed POST endpoint for state updates.
|
|
389
|
+
* Alias for mockComplete since both use upsert via POST.
|
|
390
|
+
*/
|
|
391
|
+
mockUpdateState: (value = {}, options) => {
|
|
392
|
+
this.addSupabaseRoute('shared_content_completed', value, { ...options, method: 'POST' });
|
|
393
|
+
},
|
|
394
|
+
/**
|
|
395
|
+
* Mock removing shared content (soft delete via PATCH).
|
|
396
|
+
* Alias for mockUpdate since removeSharedContent uses PATCH to set deleted_at.
|
|
397
|
+
*/
|
|
398
|
+
mockRemove: (value, options) => {
|
|
399
|
+
this.addSupabaseRoute('shared_content', value, { ...options, method: 'PATCH' });
|
|
400
|
+
},
|
|
358
401
|
},
|
|
359
402
|
};
|
|
360
403
|
this.exercise = {
|
|
@@ -419,6 +462,8 @@ class RimoriTestEnvironment {
|
|
|
419
462
|
});
|
|
420
463
|
// Set up default handlers for plugin_settings routes using SettingsStateManager
|
|
421
464
|
this.setupSettingsRoutes();
|
|
465
|
+
// Set up default handlers for shared_content routes
|
|
466
|
+
this.setupSharedContentRoutes();
|
|
422
467
|
// Initialize MessageChannelSimulator to simulate parent-iframe communication
|
|
423
468
|
// This makes the plugin think it's running in an iframe (not standalone mode)
|
|
424
469
|
// Convert RimoriInfo from CommunicationHandler format to MessageChannelSimulator format
|
|
@@ -524,6 +569,51 @@ class RimoriTestEnvironment {
|
|
|
524
569
|
method: 'POST',
|
|
525
570
|
});
|
|
526
571
|
}
|
|
572
|
+
/**
|
|
573
|
+
* Sets up default handlers for shared_content and shared_content_completed routes.
|
|
574
|
+
* These provide sensible defaults so tests don't need to mock every shared content call.
|
|
575
|
+
*/
|
|
576
|
+
setupSharedContentRoutes() {
|
|
577
|
+
// GET: Return empty array for getCompletedTopics and getSharedContentList
|
|
578
|
+
this.addSupabaseRoute('shared_content', [], { method: 'GET' });
|
|
579
|
+
// POST: Return created content with generated ID for createSharedContent
|
|
580
|
+
this.addSupabaseRoute('shared_content', async (request) => {
|
|
581
|
+
try {
|
|
582
|
+
const postData = request.postData();
|
|
583
|
+
if (postData) {
|
|
584
|
+
const content = JSON.parse(postData);
|
|
585
|
+
// Return the content with a generated ID
|
|
586
|
+
return [
|
|
587
|
+
{
|
|
588
|
+
id: `shared-content-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`,
|
|
589
|
+
...content,
|
|
590
|
+
created_at: new Date().toISOString(),
|
|
591
|
+
},
|
|
592
|
+
];
|
|
593
|
+
}
|
|
594
|
+
return [];
|
|
595
|
+
}
|
|
596
|
+
catch {
|
|
597
|
+
return [];
|
|
598
|
+
}
|
|
599
|
+
}, { method: 'POST' });
|
|
600
|
+
// PATCH: Return updated content for updateSharedContent and removeSharedContent
|
|
601
|
+
this.addSupabaseRoute('shared_content', async (request) => {
|
|
602
|
+
try {
|
|
603
|
+
const postData = request.postData();
|
|
604
|
+
if (postData) {
|
|
605
|
+
const updates = JSON.parse(postData);
|
|
606
|
+
return [{ id: 'updated-content', ...updates }];
|
|
607
|
+
}
|
|
608
|
+
return [];
|
|
609
|
+
}
|
|
610
|
+
catch {
|
|
611
|
+
return [];
|
|
612
|
+
}
|
|
613
|
+
}, { method: 'PATCH' });
|
|
614
|
+
// POST: Handle shared_content_completed upserts
|
|
615
|
+
this.addSupabaseRoute('shared_content_completed', {}, { method: 'POST' });
|
|
616
|
+
}
|
|
527
617
|
/**
|
|
528
618
|
* Formats text as SSE (Server-Sent Events) response.
|
|
529
619
|
* Since Playwright's route.fulfill() requires complete body, we format as SSE without delays.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rimori/playwright-testing",
|
|
3
|
-
"version": "0.2.3-next.
|
|
3
|
+
"version": "0.2.3-next.4",
|
|
4
4
|
"description": "Playwright testing utilities for Rimori plugins and workers",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -22,13 +22,12 @@
|
|
|
22
22
|
"test:headed:debug": "playwright test --headed --debug"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@playwright/test": "^1.40.0"
|
|
26
|
-
|
|
27
|
-
"dependencies": {
|
|
28
|
-
"@rimori/client": "2.2.0-next.1"
|
|
25
|
+
"@playwright/test": "^1.40.0",
|
|
26
|
+
"@rimori/client": "2.3.0-next.1"
|
|
29
27
|
},
|
|
30
28
|
"devDependencies": {
|
|
31
29
|
"@playwright/test": "^1.40.0",
|
|
30
|
+
"@rimori/client": "2.3.0-next.1",
|
|
32
31
|
"@types/node": "^20.12.7",
|
|
33
32
|
"rimraf": "^5.0.7",
|
|
34
33
|
"typescript": "^5.7.2"
|