@rimori/playwright-testing 0.2.1 → 0.2.3-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.
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Manages plugin settings state for test environment.
3
+ * Provides a single source of truth for settings that can be modified by mocked API calls.
4
+ */
5
+ export interface PluginSettings {
6
+ id?: string;
7
+ plugin_id?: string;
8
+ guild_id?: string;
9
+ settings?: Record<string, unknown>;
10
+ is_guild_setting?: boolean;
11
+ user_id?: string | null;
12
+ }
13
+ export declare class SettingsStateManager {
14
+ private settings;
15
+ constructor(initialSettings: PluginSettings | null, pluginId: string, guildId: string);
16
+ /**
17
+ * Get current settings state (for GET requests)
18
+ * Returns null if no settings exist, otherwise returns the full settings object
19
+ */
20
+ getSettings(): PluginSettings | null;
21
+ /**
22
+ * Update settings (for PATCH requests)
23
+ * @param updates - Partial settings to update
24
+ * @returns Array with updated row if settings exist, empty array if no settings exist
25
+ */
26
+ updateSettings(updates: Partial<PluginSettings>): PluginSettings[];
27
+ /**
28
+ * Insert new settings (for POST requests)
29
+ * @param newSettings - Settings to insert
30
+ * @returns The inserted settings object
31
+ */
32
+ insertSettings(newSettings: Partial<PluginSettings>): PluginSettings;
33
+ /**
34
+ * Manually set settings (useful for test setup)
35
+ */
36
+ setSettings(settings: PluginSettings | null): void;
37
+ /**
38
+ * Check if settings exist
39
+ */
40
+ hasSettings(): boolean;
41
+ }
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ /**
3
+ * Manages plugin settings state for test environment.
4
+ * Provides a single source of truth for settings that can be modified by mocked API calls.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.SettingsStateManager = void 0;
8
+ class SettingsStateManager {
9
+ constructor(initialSettings, pluginId, guildId) {
10
+ this.settings = {
11
+ id: initialSettings?.id ?? 'settings-id',
12
+ plugin_id: initialSettings?.plugin_id ?? pluginId,
13
+ guild_id: initialSettings?.guild_id ?? guildId,
14
+ settings: initialSettings?.settings ?? {},
15
+ is_guild_setting: initialSettings?.is_guild_setting ?? false,
16
+ user_id: initialSettings?.user_id ?? null,
17
+ };
18
+ }
19
+ /**
20
+ * Get current settings state (for GET requests)
21
+ * Returns null if no settings exist, otherwise returns the full settings object
22
+ */
23
+ getSettings() {
24
+ return this.settings;
25
+ }
26
+ /**
27
+ * Update settings (for PATCH requests)
28
+ * @param updates - Partial settings to update
29
+ * @returns Array with updated row if settings exist, empty array if no settings exist
30
+ */
31
+ updateSettings(updates) {
32
+ if (this.settings === null) {
33
+ // No settings exist - PATCH returns empty array (triggers INSERT flow)
34
+ return [];
35
+ }
36
+ // Update existing settings
37
+ this.settings = {
38
+ ...this.settings,
39
+ ...updates,
40
+ // Ensure these fields are preserved
41
+ id: this.settings.id,
42
+ plugin_id: this.settings.plugin_id,
43
+ guild_id: this.settings.guild_id,
44
+ };
45
+ // PATCH returns array with updated row
46
+ return [this.settings];
47
+ }
48
+ /**
49
+ * Insert new settings (for POST requests)
50
+ * @param newSettings - Settings to insert
51
+ * @returns The inserted settings object
52
+ */
53
+ insertSettings(newSettings) {
54
+ // Update existing settings with new values
55
+ this.settings = {
56
+ ...this.settings,
57
+ ...newSettings,
58
+ };
59
+ return this.settings;
60
+ }
61
+ /**
62
+ * Manually set settings (useful for test setup)
63
+ */
64
+ setSettings(settings) {
65
+ this.settings = settings;
66
+ }
67
+ /**
68
+ * Check if settings exist
69
+ */
70
+ hasSettings() {
71
+ return this.settings !== null;
72
+ }
73
+ }
74
+ exports.SettingsStateManager = SettingsStateManager;
@@ -40,4 +40,5 @@ exports.DEFAULT_USER_INFO = {
40
40
  user_name: 'Test User',
41
41
  target_country: 'SE',
42
42
  target_city: 'Stockholm',
43
+ user_role: 'user',
43
44
  };
@@ -7,7 +7,7 @@ const pluginUrl = 'http://localhost:3009';
7
7
  test_1.test.describe('Translator Plugin', () => {
8
8
  let env;
9
9
  test_1.test.beforeEach(async ({ page }) => {
10
- env = new RimoriTestEnvironment_1.RimoriTestEnvironment({ page, pluginId });
10
+ env = new RimoriTestEnvironment_1.RimoriTestEnvironment({ page, pluginId, pluginUrl });
11
11
  env.ai.mockGetObject({
12
12
  gramatically_corrected_input_text: 'tree',
13
13
  detected_language: 'English',
package/package.json CHANGED
@@ -1,13 +1,18 @@
1
1
  {
2
2
  "name": "@rimori/playwright-testing",
3
- "version": "0.2.1",
3
+ "version": "0.2.3-next.1",
4
4
  "description": "Playwright testing utilities for Rimori plugins and workers",
5
5
  "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/rimori-org/playwright-testing.git"
9
+ },
6
10
  "main": "dist/index.js",
7
11
  "types": "dist/index.d.ts",
8
12
  "source": "src/index.ts",
9
13
  "scripts": {
10
14
  "build": "tsc -p tsconfig.json",
15
+ "dev": "tsc -w --preserveWatchOutput -p tsconfig.json",
11
16
  "clean": "rimraf dist",
12
17
  "lint": "eslint \"src/**/*.{ts,tsx}\"",
13
18
  "test": "playwright test",
@@ -20,7 +25,7 @@
20
25
  "@playwright/test": "^1.40.0"
21
26
  },
22
27
  "dependencies": {
23
- "@rimori/client": "^2.1.7"
28
+ "@rimori/client": "2.2.0-next.1"
24
29
  },
25
30
  "devDependencies": {
26
31
  "@playwright/test": "^1.40.0",