@rimori/playwright-testing 0.3.14 → 0.3.15-next.1

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
  };
@@ -561,9 +567,8 @@ class RimoriTestEnvironment {
561
567
  this.page.route(`${pluginUrl}/locales/**`, async (route) => {
562
568
  const request = route.request();
563
569
  const url = new URL(request.url());
564
- const devServerUrl = `http://${url.host}/locales/en.json`;
570
+ const devServerUrl = `http://${url.host}${url.pathname}`;
565
571
  // console.log('Fetching locales from: ' + devServerUrl);
566
- // throw new Error('Test: ' + devServerUrl);
567
572
  try {
568
573
  // Fetch from the dev server
569
574
  const response = await fetch(devServerUrl);
@@ -605,6 +610,17 @@ class RimoriTestEnvironment {
605
610
  this.setupSettingsRoutes();
606
611
  // Set up default handlers for shared_content routes
607
612
  this.setupSharedContentRoutes();
613
+ // Default handlers for common backend routes so background calls (Avatar, AudioPlayer, etc.)
614
+ // don't cause "no route handler found" errors in tests that don't explicitly mock them.
615
+ // These are registered AFTER any test-level mocks so they act as low-priority fallbacks.
616
+ // POST /ai/session — required by event.request() and any AI call (session.ensure())
617
+ this.addBackendRoute('/ai/session', { session_token_id: 'test-session-token' }, { method: 'POST' });
618
+ // POST /ai/llm — fallback empty stream for Avatar conversations and other background AI calls
619
+ this.addBackendRoute('/ai/llm', '', { method: 'POST', isStreaming: true });
620
+ // POST /voice/tts — fallback empty response for AudioPlayer (test env has no real audio)
621
+ this.addBackendRoute('/voice/tts', {}, { method: 'POST' });
622
+ // POST /knowledge/for-topic — fallback for daily-plan knowledge lookups
623
+ this.addBackendRoute('/knowledge/for-topic', { id: 'test-knowledge-id' }, { method: 'POST' });
608
624
  // Initialize MessageChannelSimulator to simulate parent-iframe communication
609
625
  // This makes the plugin think it's running in an iframe (not standalone mode)
610
626
  // 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
- this.settings = settings;
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
@@ -30,7 +30,7 @@ exports.DEFAULT_USER_INFO = {
30
30
  name: 'Test Buddy',
31
31
  description: 'Test study buddy',
32
32
  avatarUrl: '',
33
- voiceId: 'alloy',
33
+ voiceId: 'openai_alloy',
34
34
  aiPersonality: 'friendly',
35
35
  },
36
36
  study_duration: 30,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rimori/playwright-testing",
3
- "version": "0.3.14",
3
+ "version": "0.3.15-next.1",
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.20"
29
+ "@rimori/client": "2.5.21-next.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@playwright/test": "^1.40.0",
33
- "@rimori/client": "^2.5.20",
33
+ "@rimori/client": "2.5.21-next.0",
34
34
  "@types/node": "^20.12.7",
35
35
  "rimraf": "^5.0.7",
36
36
  "typescript": "^5.7.2"