@probolabs/playwright 1.4.0-rc.4 → 1.4.0-rc.5

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/dist/index.d.ts CHANGED
@@ -433,6 +433,11 @@ declare class ProboCodeGenerator {
433
433
  * Get default viewport dimensions
434
434
  */
435
435
  private static getDefaultViewPort;
436
+ /**
437
+ * Validate and normalize viewport dimensions
438
+ * Returns a valid viewport object with numeric width and height, falling back to defaults if invalid
439
+ */
440
+ private static normalizeViewPort;
436
441
  /**
437
442
  * Generate code for a single scenario
438
443
  * Fetches scenario data, converts to Interaction[], generates code
package/dist/index.js CHANGED
@@ -5848,6 +5848,19 @@ class ProboCodeGenerator {
5848
5848
  static getDefaultViewPort() {
5849
5849
  return { width: 1280, height: 720 };
5850
5850
  }
5851
+ /**
5852
+ * Validate and normalize viewport dimensions
5853
+ * Returns a valid viewport object with numeric width and height, falling back to defaults if invalid
5854
+ */
5855
+ static normalizeViewPort(viewPort) {
5856
+ const defaultViewPort = this.getDefaultViewPort();
5857
+ if (!viewPort) {
5858
+ return defaultViewPort;
5859
+ }
5860
+ const width = typeof viewPort.width === 'number' && !isNaN(viewPort.width) ? viewPort.width : defaultViewPort.width;
5861
+ const height = typeof viewPort.height === 'number' && !isNaN(viewPort.height) ? viewPort.height : defaultViewPort.height;
5862
+ return { width, height };
5863
+ }
5851
5864
  /**
5852
5865
  * Generate code for a single scenario
5853
5866
  * Fetches scenario data, converts to Interaction[], generates code
@@ -5866,7 +5879,7 @@ class ProboCodeGenerator {
5866
5879
  const interactions = this.convertBackendInteractionsToInteractionFormat(scenarioData.interactions || []);
5867
5880
  // Get settings and viewport
5868
5881
  const settings = (options === null || options === void 0 ? void 0 : options.recorderSettings) || this.getDefaultRecorderSettings();
5869
- const viewPort = (options === null || options === void 0 ? void 0 : options.viewPort) || scenarioData.viewPort || this.getDefaultViewPort();
5882
+ const viewPort = this.normalizeViewPort((options === null || options === void 0 ? void 0 : options.viewPort) || scenarioData.viewPort);
5870
5883
  // Get parameter table rows
5871
5884
  const rows = scenarioData.parameterTable || [];
5872
5885
  // Generate code
@@ -6052,6 +6065,22 @@ class TestSuiteRunner {
6052
6065
  throw new Error(`Failed to lookup test suite: ${response.status} ${errorText}`);
6053
6066
  }
6054
6067
  const data = await response.json();
6068
+ // TEMPORARY DEBUG: Output the full response
6069
+ console.log('🔍 DEBUG: API Response URL:', url);
6070
+ console.log('🔍 DEBUG: API Response Status:', response.status);
6071
+ console.log('🔍 DEBUG: API Response Data:', JSON.stringify(data, null, 2));
6072
+ console.log('🔍 DEBUG: Is Array?', Array.isArray(data));
6073
+ console.log('🔍 DEBUG: Array length:', Array.isArray(data) ? data.length : 'N/A');
6074
+ console.log('🔍 DEBUG: Has results?', !!data.results);
6075
+ console.log('🔍 DEBUG: Results is Array?', Array.isArray(data.results));
6076
+ console.log('🔍 DEBUG: Results length:', Array.isArray(data.results) ? data.results.length : 'N/A');
6077
+ if (Array.isArray(data) && data.length > 0) {
6078
+ console.log('🔍 DEBUG: First item:', JSON.stringify(data[0], null, 2));
6079
+ }
6080
+ if (data.results && Array.isArray(data.results) && data.results.length > 0) {
6081
+ console.log('🔍 DEBUG: First result:', JSON.stringify(data.results[0], null, 2));
6082
+ }
6083
+ console.log('');
6055
6084
  if (Array.isArray(data) && data.length > 0) {
6056
6085
  return data[0].id;
6057
6086
  }
@@ -6070,7 +6099,52 @@ class TestSuiteRunner {
6070
6099
  if (codeGenResult.scenarios.length === 0) {
6071
6100
  throw new Error(`No scenarios found in test suite ${testSuiteId}. Cannot generate test files.`);
6072
6101
  }
6073
- // Ensure directories exist
6102
+ // Delete everything in the test suite directory except node_modules
6103
+ // This ensures a clean state while preserving dependencies for faster subsequent runs
6104
+ if (fs.existsSync(testSuiteDir)) {
6105
+ try {
6106
+ const nodeModulesPath = path.join(testSuiteDir, 'node_modules');
6107
+ const hasNodeModules = fs.existsSync(nodeModulesPath);
6108
+ // Temporarily move node_modules out of the way if it exists
6109
+ let tempNodeModulesPath = null;
6110
+ if (hasNodeModules) {
6111
+ tempNodeModulesPath = path.join(testSuiteDir, '..', `node_modules.temp.${testSuiteId}`);
6112
+ // Remove temp directory if it exists from a previous failed run
6113
+ if (fs.existsSync(tempNodeModulesPath)) {
6114
+ fs.rmSync(tempNodeModulesPath, { recursive: true, force: true });
6115
+ }
6116
+ fs.renameSync(nodeModulesPath, tempNodeModulesPath);
6117
+ console.log(`📦 Preserved node_modules temporarily`);
6118
+ }
6119
+ // Delete everything in the directory
6120
+ const entries = fs.readdirSync(testSuiteDir, { withFileTypes: true });
6121
+ for (const entry of entries) {
6122
+ const entryPath = path.join(testSuiteDir, entry.name);
6123
+ try {
6124
+ if (entry.isDirectory()) {
6125
+ fs.rmSync(entryPath, { recursive: true, force: true });
6126
+ }
6127
+ else {
6128
+ fs.unlinkSync(entryPath);
6129
+ }
6130
+ }
6131
+ catch (error) {
6132
+ console.warn(`⚠️ Failed to delete ${entry.name}:`, error);
6133
+ }
6134
+ }
6135
+ console.log(`🗑️ Cleaned test suite directory (preserved node_modules)`);
6136
+ // Move node_modules back
6137
+ if (hasNodeModules && tempNodeModulesPath) {
6138
+ fs.renameSync(tempNodeModulesPath, nodeModulesPath);
6139
+ console.log(`📦 Restored node_modules`);
6140
+ }
6141
+ }
6142
+ catch (error) {
6143
+ console.warn(`⚠️ Failed to clean test suite directory ${testSuiteDir}:`, error);
6144
+ // Continue anyway - we'll overwrite files as needed
6145
+ }
6146
+ }
6147
+ // Ensure directories exist (will recreate after deletion)
6074
6148
  ensureDirectoryExists(testSuiteDir);
6075
6149
  const testsDir = path.join(testSuiteDir, 'tests');
6076
6150
  ensureDirectoryExists(testsDir);