@aws/mynah-ui 4.35.5 → 4.35.7-beta.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.
Files changed (37) hide show
  1. package/Dockerfile +21 -4
  2. package/dist/components/chat-item/chat-prompt-input.d.ts +3 -0
  3. package/dist/components/chat-item/chat-wrapper.d.ts +7 -0
  4. package/dist/components/chat-item/prompt-input/prompt-text-input.d.ts +4 -0
  5. package/dist/components/icon.d.ts +2 -1
  6. package/dist/main.d.ts +3 -0
  7. package/dist/main.js +1 -1
  8. package/dist/main.js.map +1 -1
  9. package/dist/static.d.ts +24 -1
  10. package/docs/DATAMODEL.md +42 -1
  11. package/docs/PROPERTIES.md +63 -0
  12. package/docs/USAGE.md +32 -1
  13. package/docs/img/data-model/chatItems/formItemsTooltip.png +0 -0
  14. package/docs/img/data-model/chatItems/options-all-filled.png +0 -0
  15. package/docs/img/data-model/chatItems/options-mandatory-filled.png +0 -0
  16. package/docs/img/data-model/chatItems/options-submitted.png +0 -0
  17. package/docs/img/data-model/chatItems/options.png +0 -0
  18. package/docs/img/data-model/tabStore/quickActionCommandsHeader.png +0 -0
  19. package/package.json +11 -5
  20. package/scripts/docker-build.js +36 -0
  21. package/scripts/docker-health-check.js +45 -0
  22. package/scripts/get-playwright-version.js +62 -0
  23. package/scripts/pre-test-setup.js +80 -0
  24. package/scripts/setup-playwright.js +61 -0
  25. package/scripts/test-webkit.js +44 -0
  26. package/ui-tests/__snapshots__/chromium/Open-MynahUI-Forms-should-render-form-elements-correctly/Open-MynahUI-Forms-should-render-form-elements-correctly-1.png +0 -0
  27. package/ui-tests/__snapshots__/chromium/Open-MynahUI-Quick-Action-Commands-Header-should-handle-quick-action-commands-header-interaction/quick-action-commands-header-hover.png +0 -0
  28. package/ui-tests/__snapshots__/chromium/Open-MynahUI-Quick-Action-Commands-Header-should-not-render-header-when-not-applicable/quick-action-commands-header-not-present.png +0 -0
  29. package/ui-tests/__snapshots__/chromium/Open-MynahUI-Quick-Action-Commands-Header-should-render-header-with-correct-status-styling/quick-action-commands-header-status.png +0 -0
  30. package/ui-tests/__snapshots__/chromium/Open-MynahUI-Quick-Action-Commands-Header-should-render-the-quick-action-commands-header/quick-action-commands-header.png +0 -0
  31. package/ui-tests/__snapshots__/webkit/Open-MynahUI-Forms-should-render-form-elements-correctly/Open-MynahUI-Forms-should-render-form-elements-correctly-1.png +0 -0
  32. package/ui-tests/__snapshots__/webkit/Open-MynahUI-Quick-Action-Commands-Header-should-handle-quick-action-commands-header-interaction/quick-action-commands-header-hover.png +0 -0
  33. package/ui-tests/__snapshots__/webkit/Open-MynahUI-Quick-Action-Commands-Header-should-not-render-header-when-not-applicable/quick-action-commands-header-not-present.png +0 -0
  34. package/ui-tests/__snapshots__/webkit/Open-MynahUI-Quick-Action-Commands-Header-should-render-header-with-correct-status-styling/quick-action-commands-header-status.png +0 -0
  35. package/ui-tests/__snapshots__/webkit/Open-MynahUI-Quick-Action-Commands-Header-should-render-the-quick-action-commands-header/quick-action-commands-header.png +0 -0
  36. package/ui-tests/package.json +10 -6
  37. package/ui-tests/playwright.config.ts +13 -1
package/dist/static.d.ts CHANGED
@@ -19,12 +19,21 @@ export interface QuickActionCommand {
19
19
  children?: QuickActionCommandGroup[];
20
20
  route?: string[];
21
21
  }
22
+ export interface CustomQuickActionCommand extends QuickActionCommand {
23
+ content?: Uint8Array;
24
+ }
22
25
  export interface QuickActionCommandGroup {
23
26
  groupName?: string;
24
27
  icon?: MynahIcons | MynahIconsType;
25
28
  actions?: Action[];
26
29
  commands: QuickActionCommand[];
27
30
  }
31
+ export interface QuickActionCommandsHeader {
32
+ icon?: MynahIcons | MynahIconsType;
33
+ title?: string;
34
+ description?: string;
35
+ status?: Status;
36
+ }
28
37
  /**
29
38
  * data store model to update the mynah ui partially or fully
30
39
  */
@@ -74,6 +83,10 @@ export interface MynahUIDataModel {
74
83
  */
75
84
  quickActionCommands?: QuickActionCommandGroup[];
76
85
  /**
86
+ * Quick Action commands header information block
87
+ */
88
+ quickActionCommandsHeader?: QuickActionCommandsHeader;
89
+ /**
77
90
  * Context commands to show when user hits @ to the input any point
78
91
  */
79
92
  contextCommands?: QuickActionCommandGroup[];
@@ -157,6 +170,10 @@ export interface MynahUIDataModel {
157
170
  tabMetadata?: {
158
171
  [key: string]: string | boolean | number;
159
172
  };
173
+ /**
174
+ * Custom context commands to be inserted into the prompt input.
175
+ */
176
+ customContextCommand?: QuickActionCommand[];
160
177
  }
161
178
  export interface MynahUITabStoreTab {
162
179
  /**
@@ -213,10 +230,14 @@ export declare enum MynahEventNames {
213
230
  PROMPT_PROGRESS_ACTION_CLICK = "promptProgressActionClick",
214
231
  ROOT_RESIZE = "rootResize",
215
232
  CONTEXT_SELECTED = "contextSelected",
233
+ OPEN_FILE_SYSTEM = "openFileSystem",
234
+ ADD_CUSTOM_CONTEXT = "addCustomContext",
216
235
  TOP_BAR_ITEM_ADD = "promptInputTopBarItemAdd",
217
236
  TOP_BAR_ITEM_REMOVE = "promptInputTopBarItemRemove",
218
237
  TOP_BAR_BUTTON_CLICK = "promptInputTopBarButtonClick",
219
- CONTEXT_PINNED = "contextPinned"
238
+ CONTEXT_PINNED = "contextPinned",
239
+ FILES_DROPPED = "filesDropped",
240
+ CONTEXT_INSERTED = "contextInserted"
220
241
  }
221
242
  export declare enum MynahPortalNames {
222
243
  WRAPPER = "wrapper",
@@ -421,6 +442,8 @@ export interface ChatItem extends ChatItemContent {
421
442
  hoverEffect?: boolean;
422
443
  status?: Status;
423
444
  shimmer?: boolean;
445
+ collapse?: boolean;
446
+ border?: boolean;
424
447
  }
425
448
  export interface ValidationPattern {
426
449
  pattern: string | RegExp;
package/docs/DATAMODEL.md CHANGED
@@ -122,6 +122,10 @@ interface MynahUIDataModel {
122
122
  * application state management for that purpose.
123
123
  */
124
124
  tabMetadata?: { [key: string]: string | boolean | number };
125
+ /**
126
+ * Custom context commands to be inserted into the prompt input.
127
+ */
128
+ customContextCommand: []
125
129
  }
126
130
  ```
127
131
 
@@ -3562,4 +3566,41 @@ export interface DetailedListItem {
3562
3566
  keywords?: string[];
3563
3567
  }
3564
3568
  }
3565
- ```
3569
+ ```
3570
+
3571
+ ---
3572
+
3573
+ ### `quickActionCommandsHeader` (default: `{}`)
3574
+ Quick action commands header displays an informational banner above the quick action commands list when users hit `/` in the input. This is useful for providing additional context, warnings, or guidance about the available commands.
3575
+
3576
+ The header supports various status styles (info, success, warning, error) and can include an icon, title, and description.
3577
+
3578
+ ```typescript
3579
+ const mynahUI = new MynahUI({
3580
+ tabs: {
3581
+ 'tab-1': {
3582
+ ...
3583
+ }
3584
+ }
3585
+ });
3586
+
3587
+ mynahUI.updateStore('tab-1', {
3588
+ quickActionCommands: [
3589
+ // ... your commands here
3590
+ ],
3591
+ quickActionCommandsHeader: {
3592
+ status: 'warning',
3593
+ icon: MynahIcons.INFO,
3594
+ title: 'New agentic capabilities',
3595
+ description: 'You can now ask Q directly in the chat. You don\'t need to explicitly use /dev, /test, or /doc commands anymore.',
3596
+ }
3597
+ })
3598
+ ```
3599
+
3600
+ <p align="center">
3601
+ <img src="./img/data-model/tabStore/quickActionCommandsHeader.png" alt="quickActionCommandsHeader" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
3602
+ </p>
3603
+
3604
+ The header will appear above the quick action commands list and provides information to users about new features.
3605
+
3606
+ ---
@@ -189,6 +189,16 @@ export interface MynahUIProps {
189
189
  tabId: string,
190
190
  topBarButton: ChatItemButton,
191
191
  eventId?: string) => void;
192
+ onOpenFileDialogClick?: (
193
+ tabId: string,
194
+ fileType: string,
195
+ insertPosition: number
196
+ ) => void;
197
+ onFilesDropped?: (
198
+ tabId: string,
199
+ files: FileList,
200
+ insertPosition: number
201
+ ) => void;
192
202
  }
193
203
  ```
194
204
  _Let's deep dive into each property you can set._
@@ -1233,3 +1243,56 @@ onPromptTopBarButtonClick?: (
1233
1243
  };
1234
1244
  ...
1235
1245
  ```
1246
+
1247
+ ---
1248
+
1249
+ ### `onOpenFileDialogClick`
1250
+
1251
+ This event will be fired when the user triggers the open file dialog action (for example, by typing `@image:`). It passes the `tabId` of the current tab, the `fileType` (such as 'image', 'file', etc.), and the `insertPosition` indicating where in the prompt input the file should be inserted.
1252
+
1253
+ ```typescript
1254
+ ...
1255
+ onOpenFileDialogClick?: (
1256
+ tabId: string,
1257
+ fileType: string,
1258
+ insertPosition: number
1259
+ ) => void;
1260
+ ...
1261
+ ```
1262
+
1263
+ **Example:**
1264
+ ```typescript
1265
+ onOpenFileDialogClick: (tabId, fileType, insertPosition) => {
1266
+ console.log(`Open file dialog for type '${fileType}' in tab '${tabId}' at position ${insertPosition}`);
1267
+ // You can open your own file picker here
1268
+ },
1269
+ ```
1270
+
1271
+ ---
1272
+
1273
+ ### `onFilesDropped`
1274
+
1275
+ This event will be fired when the user drops files into the chat window. It passes the `tabId` of the current tab, the `files` (as a FileList), and the `insertPosition` indicating where in the prompt input the files should be inserted.
1276
+
1277
+ ```typescript
1278
+ ...
1279
+ onFilesDropped?: (
1280
+ tabId: string,
1281
+ files: FileList,
1282
+ insertPosition: number
1283
+ ) => void;
1284
+ ...
1285
+ ```
1286
+
1287
+ **Example:**
1288
+ ```typescript
1289
+ onFilesDropped: (tabId, files, insertPosition) => {
1290
+ console.log(`Files dropped in tab '${tabId}' at position ${insertPosition}`);
1291
+ for (const file of files) {
1292
+ console.log(`File: ${file.name}`);
1293
+ }
1294
+ // Handle the dropped files as needed
1295
+ },
1296
+ ```
1297
+
1298
+ ---
package/docs/USAGE.md CHANGED
@@ -29,6 +29,7 @@ mynahUI.notify(...);
29
29
  mynahUI.showCustomForm(...);
30
30
  mynahUI.updateTabDefaults(...);
31
31
  mynahUI.toggleSplashLoader(...);
32
+ mynahUI.addCustomContextToPrompt(...);
32
33
  mynahUI.destroy();
33
34
  ```
34
35
 
@@ -678,4 +679,34 @@ The overlay will appear positioned relative to the specified top bar button, dis
678
679
 
679
680
  <p align="center">
680
681
  <img src="./img/topBarButtonOverlay.png" alt="Top Bar Button Overlay" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
681
- </p>
682
+ </p>
683
+
684
+ # Adding Custom Context to Prompt (`addCustomContextToPrompt`)
685
+
686
+ You can programmatically add custom context items to the prompt input of a specific tab using the `addCustomContextToPrompt` function. This is useful for injecting custom context directly into the user's prompt field, and ensures the context is also tracked in the tab's data store.
687
+
688
+ ```typescript
689
+ mynahUI.addCustomContextToPrompt(
690
+ tabId, // The ID of the tab to add the context to
691
+ [
692
+ {
693
+ command: 'sampleimage.png',
694
+ label: 'image',
695
+ description: 'This is a custom context item.',
696
+ icon: MynahIcons.IMAGE,
697
+ },
698
+ // ... more QuickActionCommand objects if needed
699
+ ],
700
+ 0 // (Optional) Insert position in the prompt input. If omitted, appends to the end.
701
+ );
702
+ ```
703
+
704
+ - **tabId**: The string ID of the tab where the context should be added.
705
+ - **contextItem**: An array of `QuickActionCommand` objects to insert. Each object can include `command`, `label`, `description`, `icon`, and other properties as defined in the data model.
706
+ - **insertPosition** (optional): The position in the prompt input where the context should be inserted. If not provided, the context is appended to the end.
707
+
708
+ When called, this function will:
709
+ - Insert the provided context items as context pills in the prompt input field of the specified tab.
710
+ - Update the tab's data store so that the custom context is tracked and can be referenced or removed later.
711
+
712
+ **Note:** If the prompt input is not currently visible or the tab does not exist, the function will have no effect.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@aws/mynah-ui",
3
3
  "displayName": "AWS Mynah UI",
4
- "version": "4.35.5",
4
+ "version": "4.35.7-beta.1",
5
5
  "description": "AWS Toolkit VSCode and Intellij IDE Extension Mynah UI",
6
6
  "publisher": "Amazon Web Services",
7
7
  "license": "Apache License 2.0",
@@ -28,14 +28,20 @@
28
28
  "format:check": "npx prettier --check .",
29
29
  "format:write": "npx prettier --write .",
30
30
  "docker:clean": "docker rm -f mynah-ui-e2e-container || true",
31
- "docker:build": "docker build -t mynah-ui-e2e -f Dockerfile .",
32
- "docker:run": "docker run --name mynah-ui-e2e-container mynah-ui-e2e",
31
+ "docker:build": "node scripts/docker-build.js",
32
+ "docker:run": "docker run --name mynah-ui-e2e-container -e WEBKIT_FORCE_COMPLEX_TEXT=0 -e WEBKIT_DISABLE_COMPOSITING_MODE=1 mynah-ui-e2e",
33
33
  "docker:run:chromium": "docker run -e BROWSER=chromium --name mynah-ui-e2e-container mynah-ui-e2e",
34
- "docker:run:webkit": "docker run -e BROWSER=webkit --name mynah-ui-e2e-container mynah-ui-e2e",
34
+ "docker:run:webkit": "docker run -e BROWSER=webkit -e WEBKIT_FORCE_COMPLEX_TEXT=0 -e WEBKIT_DISABLE_COMPOSITING_MODE=1 --name mynah-ui-e2e-container mynah-ui-e2e",
35
35
  "docker:extract": "docker cp mynah-ui-e2e-container:/app/ui-tests/__results__ ./ui-tests/ && docker cp mynah-ui-e2e-container:/app/ui-tests/__snapshots__ ./ui-tests/__results__/__snapshots__",
36
+ "playwright:setup": "node scripts/setup-playwright.js",
37
+ "playwright:version": "node scripts/get-playwright-version.js",
38
+ "playwright:pre-test": "node scripts/pre-test-setup.js",
36
39
  "tests:e2e": "npm run docker:clean && npm run docker:build && npm run docker:run",
37
40
  "tests:e2e:chromium": "npm run docker:clean && npm run docker:build && npm run docker:run:chromium",
38
41
  "tests:e2e:webkit": "npm run docker:clean && npm run docker:build && npm run docker:run:webkit",
42
+ "tests:e2e:webkit:local": "npm run playwright:pre-test && cd ui-tests && npm run e2e:webkit",
43
+ "tests:webkit:check": "node scripts/test-webkit.js",
44
+ "tests:e2e:local": "npm run playwright:pre-test && cd ui-tests && npm run e2e",
39
45
  "tests:e2e:trace": "cd ./ui-tests && npm run trace",
40
46
  "tests:unit": "jest --collect-coverage",
41
47
  "api-docs": "npx typedoc src/main.ts --out ./api-docs",
@@ -96,7 +102,7 @@
96
102
  "ts-loader": "^9.4.4",
97
103
  "ts-node": "^10.9.1",
98
104
  "typedoc": "^0.25.13",
99
- "typescript": "^5.0.4",
105
+ "typescript": "^5.1.6",
100
106
  "webpack": "5.94.0",
101
107
  "webpack-cli": "4.7.2"
102
108
  }
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Script to build Docker image with detected Playwright version
5
+ */
6
+
7
+ const { execSync } = require('child_process');
8
+ const { getPlaywrightVersion } = require('./get-playwright-version');
9
+
10
+ function buildDockerImage() {
11
+ try {
12
+ const version = getPlaywrightVersion();
13
+ console.log(`Building Docker image with Playwright version: ${version}`);
14
+
15
+ // Use the detected version or fallback to latest
16
+ // Add 'v' prefix for version numbers, but not for 'latest'
17
+ const dockerVersion = version === 'latest' ? 'latest' : `v${version}`;
18
+
19
+ const buildCommand = `docker build --build-arg PLAYWRIGHT_VERSION=${dockerVersion} -t mynah-ui-e2e .`;
20
+
21
+ console.log(`Executing: ${buildCommand}`);
22
+ execSync(buildCommand, { stdio: 'inherit' });
23
+
24
+ console.log('Docker image built successfully!');
25
+ } catch (error) {
26
+ console.error('Error building Docker image:', error.message);
27
+ process.exit(1);
28
+ }
29
+ }
30
+
31
+ // If called directly, run the build
32
+ if (require.main === module) {
33
+ buildDockerImage();
34
+ }
35
+
36
+ module.exports = { buildDockerImage };
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Docker health check script to verify browser installations
5
+ */
6
+
7
+ const { execSync } = require('child_process');
8
+
9
+ function healthCheck() {
10
+ try {
11
+ console.log('=== Docker Health Check ===');
12
+
13
+ // Check if we're in Docker
14
+ console.log('Environment: Docker Container');
15
+
16
+ // Check Playwright installation
17
+ console.log('\n1. Checking Playwright...');
18
+ execSync('npx playwright --version', { stdio: 'inherit' });
19
+
20
+ // Check browser installations
21
+ console.log('\n2. Checking browsers...');
22
+ execSync('npx playwright install --dry-run', { stdio: 'inherit' });
23
+
24
+ // Test WebKit specifically
25
+ console.log('\n3. Testing WebKit launch...');
26
+ execSync('npx playwright test --list --project=webkit | head -5', {
27
+ stdio: 'inherit',
28
+ shell: true,
29
+ });
30
+
31
+ console.log('\n=== Health Check Passed ===');
32
+ return true;
33
+ } catch (error) {
34
+ console.error('Health check failed:', error.message);
35
+ return false;
36
+ }
37
+ }
38
+
39
+ // If called directly, run the health check
40
+ if (require.main === module) {
41
+ const success = healthCheck();
42
+ process.exit(success ? 0 : 1);
43
+ }
44
+
45
+ module.exports = { healthCheck };
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Script to detect and return the appropriate Playwright version
5
+ * Priority: local installation > package.json > latest
6
+ */
7
+
8
+ const fs = require('fs');
9
+ const path = require('path');
10
+ const { execSync } = require('child_process');
11
+
12
+ function getPlaywrightVersion() {
13
+ try {
14
+ // 1. Try to get locally installed version
15
+ try {
16
+ const localVersion = execSync('playwright --version', { encoding: 'utf8', stdio: 'pipe' });
17
+ const versionMatch = localVersion.match(/Version (\d+\.\d+\.\d+)/);
18
+ if (versionMatch) {
19
+ console.log(`Found local Playwright version: ${versionMatch[1]}`);
20
+ return versionMatch[1];
21
+ }
22
+ } catch (error) {
23
+ console.log('No local Playwright installation found');
24
+ }
25
+
26
+ // 2. Try to get version from ui-tests package.json
27
+ const uiTestsPackagePath = path.join(__dirname, '../ui-tests/package.json');
28
+ if (fs.existsSync(uiTestsPackagePath)) {
29
+ const packageJson = JSON.parse(fs.readFileSync(uiTestsPackagePath, 'utf8'));
30
+
31
+ // Check both playwright and @playwright/test dependencies
32
+ const playwrightVersion = packageJson.devDependencies?.playwright || packageJson.dependencies?.playwright;
33
+ const playwrightTestVersion =
34
+ packageJson.devDependencies?.['@playwright/test'] || packageJson.dependencies?.['@playwright/test'];
35
+
36
+ // Prefer @playwright/test version if available, otherwise use playwright
37
+ const version = playwrightTestVersion || playwrightVersion;
38
+
39
+ if (version) {
40
+ // Remove ^ or ~ prefix and get clean version
41
+ const cleanVersion = version.replace(/[\^~]/, '');
42
+ const sourcePackage = playwrightTestVersion ? '@playwright/test' : 'playwright';
43
+ console.log(`Found ${sourcePackage} version in ui-tests package.json: ${cleanVersion}`);
44
+ return cleanVersion;
45
+ }
46
+ }
47
+
48
+ // 3. Fallback to latest
49
+ console.log('No specific version found, using latest');
50
+ return 'latest';
51
+ } catch (error) {
52
+ console.error('Error detecting Playwright version:', error.message);
53
+ return 'latest';
54
+ }
55
+ }
56
+
57
+ // If called directly, output the version
58
+ if (require.main === module) {
59
+ console.log(getPlaywrightVersion());
60
+ }
61
+
62
+ module.exports = { getPlaywrightVersion };
@@ -0,0 +1,80 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Pre-test setup script that ensures Playwright is properly configured
5
+ * This runs before tests to guarantee version consistency
6
+ */
7
+
8
+ const fs = require('fs');
9
+ const path = require('path');
10
+ const { execSync } = require('child_process');
11
+ const { getPlaywrightVersion } = require('./get-playwright-version');
12
+
13
+ function checkPlaywrightInstallation() {
14
+ const uiTestsPath = path.join(__dirname, '../ui-tests');
15
+ const nodeModulesPath = path.join(uiTestsPath, 'node_modules');
16
+ const playwrightPath = path.join(nodeModulesPath, '@playwright');
17
+
18
+ return fs.existsSync(playwrightPath);
19
+ }
20
+
21
+ function getInstalledPlaywrightVersion() {
22
+ try {
23
+ const uiTestsPath = path.join(__dirname, '../ui-tests');
24
+ const packageLockPath = path.join(uiTestsPath, 'package-lock.json');
25
+
26
+ if (fs.existsSync(packageLockPath)) {
27
+ const packageLock = JSON.parse(fs.readFileSync(packageLockPath, 'utf8'));
28
+ return (
29
+ packageLock.packages?.['node_modules/@playwright/test']?.version ||
30
+ packageLock.packages?.['node_modules/playwright']?.version ||
31
+ null
32
+ );
33
+ }
34
+ return null;
35
+ } catch (error) {
36
+ console.warn('Could not read package-lock.json:', error.message);
37
+ return null;
38
+ }
39
+ }
40
+
41
+ function preTestSetup() {
42
+ console.log('🔍 Running pre-test setup...');
43
+
44
+ try {
45
+ const expectedVersion = getPlaywrightVersion();
46
+ console.log(`📋 Expected Playwright version: ${expectedVersion}`);
47
+
48
+ const isInstalled = checkPlaywrightInstallation();
49
+ const installedVersion = getInstalledPlaywrightVersion();
50
+
51
+ console.log(`📦 Playwright installed: ${isInstalled}`);
52
+ console.log(`📦 Installed version: ${installedVersion || 'unknown'}`);
53
+
54
+ // Check if we need to install/update
55
+ const needsSetup = !isInstalled || (expectedVersion !== 'latest' && installedVersion !== expectedVersion);
56
+
57
+ if (needsSetup) {
58
+ console.log('🔧 Setting up Playwright...');
59
+
60
+ // Run setup with target directory
61
+ const { setupPlaywright } = require('./setup-playwright');
62
+ const uiTestsPath = path.join(__dirname, '../ui-tests');
63
+ setupPlaywright(uiTestsPath);
64
+ } else {
65
+ console.log('✅ Playwright is already properly configured');
66
+ }
67
+
68
+ console.log('🎉 Pre-test setup completed successfully!');
69
+ } catch (error) {
70
+ console.error('❌ Pre-test setup failed:', error.message);
71
+ process.exit(1);
72
+ }
73
+ }
74
+
75
+ // If called directly, run the setup
76
+ if (require.main === module) {
77
+ preTestSetup();
78
+ }
79
+
80
+ module.exports = { preTestSetup };
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Script to setup Playwright with version-agnostic approach
5
+ * This ensures consistent versions across local and Docker environments
6
+ */
7
+
8
+ const { execSync } = require('child_process');
9
+ const path = require('path');
10
+ const fs = require('fs');
11
+ const { getPlaywrightVersion } = require('./get-playwright-version');
12
+
13
+ function setupPlaywright(targetDir = null) {
14
+ try {
15
+ const version = getPlaywrightVersion();
16
+ console.log(`Setting up Playwright version: ${version}`);
17
+
18
+ // Determine target directory
19
+ const uiTestsPath = targetDir || path.join(__dirname, '../ui-tests');
20
+
21
+ // Ensure target directory exists
22
+ if (!fs.existsSync(uiTestsPath)) {
23
+ throw new Error(`Target directory does not exist: ${uiTestsPath}`);
24
+ }
25
+
26
+ const installCommand =
27
+ version === 'latest'
28
+ ? 'npm install @playwright/test@latest playwright@latest --save-dev'
29
+ : `npm install @playwright/test@${version} playwright@${version} --save-dev`;
30
+
31
+ console.log(`Installing Playwright in ${uiTestsPath}...`);
32
+ execSync(installCommand, {
33
+ stdio: 'inherit',
34
+ cwd: uiTestsPath,
35
+ });
36
+
37
+ // Install Playwright browsers with dependencies
38
+ console.log('Installing Playwright browsers with dependencies...');
39
+ execSync('npx playwright install --with-deps', {
40
+ stdio: 'inherit',
41
+ cwd: uiTestsPath,
42
+ });
43
+
44
+ console.log('Playwright setup completed successfully!');
45
+ return true;
46
+ } catch (error) {
47
+ console.error('Error setting up Playwright:', error.message);
48
+ throw error; // Re-throw to allow caller to handle
49
+ }
50
+ }
51
+
52
+ // If called directly, run the setup
53
+ if (require.main === module) {
54
+ try {
55
+ setupPlaywright();
56
+ } catch (error) {
57
+ process.exit(1);
58
+ }
59
+ }
60
+
61
+ module.exports = { setupPlaywright };
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Script to test WebKit browser availability and functionality
5
+ */
6
+
7
+ const { execSync } = require('child_process');
8
+ const path = require('path');
9
+
10
+ function testWebKit() {
11
+ try {
12
+ console.log('Testing WebKit browser availability...');
13
+
14
+ const uiTestsPath = path.join(__dirname, '../ui-tests');
15
+
16
+ // Check if WebKit is installed
17
+ console.log('Checking WebKit installation...');
18
+ execSync('npx playwright install webkit --with-deps', {
19
+ stdio: 'inherit',
20
+ cwd: uiTestsPath,
21
+ });
22
+
23
+ // Run a simple WebKit test
24
+ console.log('Running WebKit test...');
25
+ execSync('npx playwright test --project=webkit --grep "should render initial data"', {
26
+ stdio: 'inherit',
27
+ cwd: uiTestsPath,
28
+ });
29
+
30
+ console.log('WebKit test completed successfully!');
31
+ return true;
32
+ } catch (error) {
33
+ console.error('WebKit test failed:', error.message);
34
+ return false;
35
+ }
36
+ }
37
+
38
+ // If called directly, run the test
39
+ if (require.main === module) {
40
+ const success = testWebKit();
41
+ process.exit(success ? 0 : 1);
42
+ }
43
+
44
+ module.exports = { testWebKit };