@rimori/playwright-testing 0.3.19-next.0 → 0.3.19-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.
package/README.md CHANGED
@@ -266,14 +266,14 @@ Mocks a non-streaming text generation response.
266
266
  env.ai.mockGetText({ result: 'Generated text' });
267
267
  ```
268
268
 
269
- #### `mockGetSteamedText(text: string, options?: MockOptions)`
269
+ #### `mockGetStreamedText(text: string, options?: MockOptions)`
270
270
 
271
271
  Mocks a streaming text response formatted as SSE (Server-Sent Events).
272
272
 
273
273
  **Note**: Due to Playwright's `route.fulfill()` limitations, all SSE chunks are sent at once (no visible delays). The client will still parse it correctly as SSE.
274
274
 
275
275
  ```typescript
276
- env.ai.mockGetSteamedText('This is the streaming response text.');
276
+ env.ai.mockGetStreamedText('This is the streaming response text.');
277
277
  ```
278
278
 
279
279
  #### `mockGetObject(value: unknown, options?: MockOptions)`
@@ -506,9 +506,9 @@ test.describe('Translator Plugin', () => {
506
506
  gramatically_corrected_input_text: 'tree',
507
507
  detected_language: 'English',
508
508
  text_type: 'noun',
509
- translation_swedish: 'träd',
509
+ translation_target_language: 'träd',
510
510
  translation_mother_tongue: 'tree',
511
- en_ett_word: 'ett',
511
+ noun_gender: 'neuter',
512
512
  },
513
513
  {
514
514
  matcher: (req) => {
@@ -572,7 +572,7 @@ test('handles side panel action', async ({ page }) => {
572
572
  ```typescript
573
573
  test('handles streaming chat responses', async ({ page }) => {
574
574
  // Mock streaming response for chat
575
- env.ai.mockGetSteamedText('This is the AI response that will be streamed.');
575
+ env.ai.mockGetStreamedText('This is the AI response that will be streamed.');
576
576
 
577
577
  await env.setup();
578
578
  await page.goto(`${pluginUrl}/#/sidebar/translate`);
@@ -603,7 +603,7 @@ You can override any of these defaults by calling the appropriate mock methods.
603
603
 
604
604
  ### Streaming Responses
605
605
 
606
- Due to Playwright's `route.fulfill()` requiring a complete response body, streaming responses (via `mockGetSteamedText`) send all SSE chunks at once. The client will parse them correctly as SSE, but incremental timing/delays won't be visible in the UI.
606
+ Due to Playwright's `route.fulfill()` requiring a complete response body, streaming responses (via `mockGetStreamedText`) send all SSE chunks at once. The client will parse them correctly as SSE, but incremental timing/delays won't be visible in the UI.
607
607
 
608
608
  For true streaming with visible delays, use a real HTTP server instead of route mocking.
609
609
 
@@ -240,7 +240,7 @@ export declare class RimoriTestEnvironment {
240
240
  mockGetText: (values: unknown, options?: MockOptions) => void;
241
241
  /**
242
242
  * Mocks a streaming text response from the LLM endpoint.
243
- * The new rimori-client's getSteamedText uses streamObject internally with { result: string } schema,
243
+ * The new rimori-client's getStreamedText uses streamObject internally with { result: string } schema,
244
244
  * so the text is wrapped in a result object.
245
245
  *
246
246
  * **Note**: Due to Playwright's route.fulfill() requiring a complete response body,
@@ -249,7 +249,7 @@ export declare class RimoriTestEnvironment {
249
249
  * @param text - The text to stream. Will be wrapped as { result: text } and formatted as SSE.
250
250
  * @param options - Optional mock options.
251
251
  */
252
- mockGetSteamedText: (text: string, options?: MockOptions) => void;
252
+ mockGetStreamedText: (text: string, options?: MockOptions) => void;
253
253
  mockGetVoice: (values: Buffer, options?: MockOptions) => void;
254
254
  mockGetTextFromVoice: (text: string, options?: MockOptions) => void;
255
255
  /**
@@ -210,7 +210,7 @@ class RimoriTestEnvironment {
210
210
  },
211
211
  /**
212
212
  * Mocks a streaming text response from the LLM endpoint.
213
- * The new rimori-client's getSteamedText uses streamObject internally with { result: string } schema,
213
+ * The new rimori-client's getStreamedText uses streamObject internally with { result: string } schema,
214
214
  * so the text is wrapped in a result object.
215
215
  *
216
216
  * **Note**: Due to Playwright's route.fulfill() requiring a complete response body,
@@ -219,8 +219,8 @@ class RimoriTestEnvironment {
219
219
  * @param text - The text to stream. Will be wrapped as { result: text } and formatted as SSE.
220
220
  * @param options - Optional mock options.
221
221
  */
222
- mockGetSteamedText: (text, options) => {
223
- // getSteamedText() may be preceded by event.request() which calls session.ensure(), so mock the session endpoint too
222
+ mockGetStreamedText: (text, options) => {
223
+ // getStreamedText() may be preceded by event.request() which calls session.ensure(), so mock the session endpoint too
224
224
  this.addBackendRoute('/ai/session', { session_token_id: 'mock-session-token' }, { method: 'POST' });
225
225
  // Wrap text in result object as the new client expects { result: string }
226
226
  this.addBackendRoute('/ai/llm', { result: text }, { ...options, isStreaming: true });
@@ -916,12 +916,12 @@ class RimoriTestEnvironment {
916
916
  if (typeof matchingMock.value === 'function') {
917
917
  responseValue = await matchingMock.value(request);
918
918
  }
919
- // Handle streaming responses (for mockGetSteamedText and mockGetStreamedObject)
919
+ // Handle streaming responses (for mockGetStreamedText and mockGetStreamedObject)
920
920
  // Since Playwright requires complete body, we format as SSE without delays
921
921
  if (matchingMock.isStreaming) {
922
922
  let body;
923
923
  if (typeof responseValue === 'string') {
924
- // Text streaming (mockGetSteamedText)
924
+ // Text streaming (mockGetStreamedText)
925
925
  body = this.formatAsSSE(responseValue);
926
926
  }
927
927
  else {
@@ -14,10 +14,10 @@ test_1.test.describe('Demo Plugin', () => {
14
14
  text_type: 'noun',
15
15
  word_unexisting_likelihood: 0,
16
16
  translation_mother_tongue: 'tree',
17
- translation_swedish: 'träd',
17
+ translation_target_language: 'träd',
18
18
  translation_noun_singular: 'tree',
19
19
  plural: 'träd',
20
- en_ett_word: 'ett',
20
+ noun_gender: 'neuter',
21
21
  alternative_meaning_mother_tongue: '',
22
22
  }, {
23
23
  matcher: (request) => {
@@ -98,7 +98,7 @@ test_1.test.describe('Demo Plugin', () => {
98
98
  });
99
99
  (0, test_1.test)('translates and ask question about the translation', async ({ page }) => {
100
100
  // Mock streaming text response for the chat/question feature
101
- await env.ai.mockGetSteamedText('This is a tree in Swedish: träd. It is an ett word.');
101
+ await env.ai.mockGetStreamedText('This is a tree in Swedish: träd. It is an ett word.');
102
102
  // Set up the listener BEFORE navigating so it's ready when the plugin calls onSidePanelAction
103
103
  await env.event.triggerOnSidePanelAction({
104
104
  action: 'translate',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rimori/playwright-testing",
3
- "version": "0.3.19-next.0",
3
+ "version": "0.3.19-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.28"
29
+ "@rimori/client": "2.5.28-next.7"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@playwright/test": "^1.40.0",
33
- "@rimori/client": "^2.5.28",
33
+ "@rimori/client": "2.5.28-next.7",
34
34
  "@types/node": "^20.12.7",
35
35
  "rimraf": "^5.0.7",
36
36
  "typescript": "^5.7.2"