@rimori/playwright-testing 0.3.14 → 0.3.15
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.
|
@@ -220,6 +220,8 @@ class RimoriTestEnvironment {
|
|
|
220
220
|
* @param options - Optional mock options.
|
|
221
221
|
*/
|
|
222
222
|
mockGetSteamedText: (text, options) => {
|
|
223
|
+
// getSteamedText() may be preceded by event.request() which calls session.ensure(), so mock the session endpoint too
|
|
224
|
+
this.addBackendRoute('/ai/session', { session_token_id: 'mock-session-token' }, { method: 'POST' });
|
|
223
225
|
// Wrap text in result object as the new client expects { result: string }
|
|
224
226
|
this.addBackendRoute('/ai/llm', { result: text }, { ...options, isStreaming: true });
|
|
225
227
|
},
|
|
@@ -239,6 +241,8 @@ class RimoriTestEnvironment {
|
|
|
239
241
|
* @param options - Optional mock options.
|
|
240
242
|
*/
|
|
241
243
|
mockGetObject: (value, options) => {
|
|
244
|
+
// getObject() may be preceded by event.request() which calls session.ensure(), so mock the session endpoint too
|
|
245
|
+
this.addBackendRoute('/ai/session', { session_token_id: 'mock-session-token' }, { method: 'POST' });
|
|
242
246
|
this.addBackendRoute('/ai/llm', value, { ...options, isStreaming: true });
|
|
243
247
|
},
|
|
244
248
|
/**
|
|
@@ -249,6 +253,8 @@ class RimoriTestEnvironment {
|
|
|
249
253
|
* @param options - Optional mock options.
|
|
250
254
|
*/
|
|
251
255
|
mockGetStreamedObject: (value, options) => {
|
|
256
|
+
// getStreamedObject() may be preceded by event.request() which calls session.ensure(), so mock the session endpoint too
|
|
257
|
+
this.addBackendRoute('/ai/session', { session_token_id: 'mock-session-token' }, { method: 'POST' });
|
|
252
258
|
this.addBackendRoute('/ai/llm', value, { ...options, isStreaming: true });
|
|
253
259
|
},
|
|
254
260
|
};
|
|
@@ -605,6 +611,17 @@ class RimoriTestEnvironment {
|
|
|
605
611
|
this.setupSettingsRoutes();
|
|
606
612
|
// Set up default handlers for shared_content routes
|
|
607
613
|
this.setupSharedContentRoutes();
|
|
614
|
+
// Default handlers for common backend routes so background calls (Avatar, AudioPlayer, etc.)
|
|
615
|
+
// don't cause "no route handler found" errors in tests that don't explicitly mock them.
|
|
616
|
+
// These are registered AFTER any test-level mocks so they act as low-priority fallbacks.
|
|
617
|
+
// POST /ai/session — required by event.request() and any AI call (session.ensure())
|
|
618
|
+
this.addBackendRoute('/ai/session', { session_token_id: 'test-session-token' }, { method: 'POST' });
|
|
619
|
+
// POST /ai/llm — fallback empty stream for Avatar conversations and other background AI calls
|
|
620
|
+
this.addBackendRoute('/ai/llm', '', { method: 'POST', isStreaming: true });
|
|
621
|
+
// POST /voice/tts — fallback empty response for AudioPlayer (test env has no real audio)
|
|
622
|
+
this.addBackendRoute('/voice/tts', {}, { method: 'POST' });
|
|
623
|
+
// POST /knowledge/for-topic — fallback for daily-plan knowledge lookups
|
|
624
|
+
this.addBackendRoute('/knowledge/for-topic', { id: 'test-knowledge-id' }, { method: 'POST' });
|
|
608
625
|
// Initialize MessageChannelSimulator to simulate parent-iframe communication
|
|
609
626
|
// This makes the plugin think it's running in an iframe (not standalone mode)
|
|
610
627
|
// Convert RimoriInfo from CommunicationHandler format to MessageChannelSimulator format
|
|
@@ -31,7 +31,10 @@ export declare class SettingsStateManager {
|
|
|
31
31
|
*/
|
|
32
32
|
insertSettings(newSettings: Partial<PluginSettings>): PluginSettings;
|
|
33
33
|
/**
|
|
34
|
-
* Manually set settings (useful for test setup)
|
|
34
|
+
* Manually set settings (useful for test setup).
|
|
35
|
+
* Accepts either a full PluginSettings row (with `id`, `plugin_id`, `settings`, etc.)
|
|
36
|
+
* or a plain inner-settings object (e.g. `{ skillAssessmentCompletedAt: '...' }`).
|
|
37
|
+
* If an inner-settings object is detected it is automatically wrapped in the proper row structure.
|
|
35
38
|
*/
|
|
36
39
|
setSettings(settings: PluginSettings | null): void;
|
|
37
40
|
/**
|
|
@@ -59,10 +59,34 @@ class SettingsStateManager {
|
|
|
59
59
|
return this.settings;
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
62
|
-
* Manually set settings (useful for test setup)
|
|
62
|
+
* Manually set settings (useful for test setup).
|
|
63
|
+
* Accepts either a full PluginSettings row (with `id`, `plugin_id`, `settings`, etc.)
|
|
64
|
+
* or a plain inner-settings object (e.g. `{ skillAssessmentCompletedAt: '...' }`).
|
|
65
|
+
* If an inner-settings object is detected it is automatically wrapped in the proper row structure.
|
|
63
66
|
*/
|
|
64
67
|
setSettings(settings) {
|
|
65
|
-
|
|
68
|
+
if (settings === null) {
|
|
69
|
+
this.settings = null;
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
// Detect a full PluginSettings row vs a plain inner-settings object.
|
|
73
|
+
// A full row has at least one of these known structural keys.
|
|
74
|
+
const isFullRow = 'id' in settings ||
|
|
75
|
+
'plugin_id' in settings ||
|
|
76
|
+
'guild_id' in settings ||
|
|
77
|
+
'settings' in settings ||
|
|
78
|
+
'is_guild_setting' in settings ||
|
|
79
|
+
'user_id' in settings;
|
|
80
|
+
if (isFullRow) {
|
|
81
|
+
this.settings = settings;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
// Treat as inner settings — wrap in the existing row structure
|
|
85
|
+
this.settings = {
|
|
86
|
+
...(this.settings ?? {}),
|
|
87
|
+
settings: settings,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
66
90
|
}
|
|
67
91
|
/**
|
|
68
92
|
* Check if settings exist
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rimori/playwright-testing",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.15",
|
|
4
4
|
"description": "Playwright testing utilities for Rimori plugins and workers",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"@playwright/test": "^1.40.0",
|
|
29
|
-
"@rimori/client": "^2.5.
|
|
29
|
+
"@rimori/client": "^2.5.21"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@playwright/test": "^1.40.0",
|
|
33
|
-
"@rimori/client": "^2.5.
|
|
33
|
+
"@rimori/client": "^2.5.21",
|
|
34
34
|
"@types/node": "^20.12.7",
|
|
35
35
|
"rimraf": "^5.0.7",
|
|
36
36
|
"typescript": "^5.7.2"
|