@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.cjs CHANGED
@@ -5867,6 +5867,19 @@ export default class ProboReporter implements Reporter {
5867
5867
  static getDefaultViewPort() {
5868
5868
  return { width: 1280, height: 720 };
5869
5869
  }
5870
+ /**
5871
+ * Validate and normalize viewport dimensions
5872
+ * Returns a valid viewport object with numeric width and height, falling back to defaults if invalid
5873
+ */
5874
+ static normalizeViewPort(viewPort) {
5875
+ const defaultViewPort = this.getDefaultViewPort();
5876
+ if (!viewPort) {
5877
+ return defaultViewPort;
5878
+ }
5879
+ const width = typeof viewPort.width === 'number' && !isNaN(viewPort.width) ? viewPort.width : defaultViewPort.width;
5880
+ const height = typeof viewPort.height === 'number' && !isNaN(viewPort.height) ? viewPort.height : defaultViewPort.height;
5881
+ return { width, height };
5882
+ }
5870
5883
  /**
5871
5884
  * Generate code for a single scenario
5872
5885
  * Fetches scenario data, converts to Interaction[], generates code
@@ -5885,7 +5898,7 @@ export default class ProboReporter implements Reporter {
5885
5898
  const interactions = this.convertBackendInteractionsToInteractionFormat(scenarioData.interactions || []);
5886
5899
  // Get settings and viewport
5887
5900
  const settings = (options === null || options === void 0 ? void 0 : options.recorderSettings) || this.getDefaultRecorderSettings();
5888
- const viewPort = (options === null || options === void 0 ? void 0 : options.viewPort) || scenarioData.viewPort || this.getDefaultViewPort();
5901
+ const viewPort = this.normalizeViewPort((options === null || options === void 0 ? void 0 : options.viewPort) || scenarioData.viewPort);
5889
5902
  // Get parameter table rows
5890
5903
  const rows = scenarioData.parameterTable || [];
5891
5904
  // Generate code
@@ -6071,6 +6084,22 @@ export default class ProboReporter implements Reporter {
6071
6084
  throw new Error(`Failed to lookup test suite: ${response.status} ${errorText}`);
6072
6085
  }
6073
6086
  const data = await response.json();
6087
+ // TEMPORARY DEBUG: Output the full response
6088
+ console.log('🔍 DEBUG: API Response URL:', url);
6089
+ console.log('🔍 DEBUG: API Response Status:', response.status);
6090
+ console.log('🔍 DEBUG: API Response Data:', JSON.stringify(data, null, 2));
6091
+ console.log('🔍 DEBUG: Is Array?', Array.isArray(data));
6092
+ console.log('🔍 DEBUG: Array length:', Array.isArray(data) ? data.length : 'N/A');
6093
+ console.log('🔍 DEBUG: Has results?', !!data.results);
6094
+ console.log('🔍 DEBUG: Results is Array?', Array.isArray(data.results));
6095
+ console.log('🔍 DEBUG: Results length:', Array.isArray(data.results) ? data.results.length : 'N/A');
6096
+ if (Array.isArray(data) && data.length > 0) {
6097
+ console.log('🔍 DEBUG: First item:', JSON.stringify(data[0], null, 2));
6098
+ }
6099
+ if (data.results && Array.isArray(data.results) && data.results.length > 0) {
6100
+ console.log('🔍 DEBUG: First result:', JSON.stringify(data.results[0], null, 2));
6101
+ }
6102
+ console.log('');
6074
6103
  if (Array.isArray(data) && data.length > 0) {
6075
6104
  return data[0].id;
6076
6105
  }
@@ -6089,7 +6118,52 @@ export default class ProboReporter implements Reporter {
6089
6118
  if (codeGenResult.scenarios.length === 0) {
6090
6119
  throw new Error(`No scenarios found in test suite ${testSuiteId}. Cannot generate test files.`);
6091
6120
  }
6092
- // Ensure directories exist
6121
+ // Delete everything in the test suite directory except node_modules
6122
+ // This ensures a clean state while preserving dependencies for faster subsequent runs
6123
+ if (fs__namespace.existsSync(testSuiteDir)) {
6124
+ try {
6125
+ const nodeModulesPath = path__namespace.join(testSuiteDir, 'node_modules');
6126
+ const hasNodeModules = fs__namespace.existsSync(nodeModulesPath);
6127
+ // Temporarily move node_modules out of the way if it exists
6128
+ let tempNodeModulesPath = null;
6129
+ if (hasNodeModules) {
6130
+ tempNodeModulesPath = path__namespace.join(testSuiteDir, '..', `node_modules.temp.${testSuiteId}`);
6131
+ // Remove temp directory if it exists from a previous failed run
6132
+ if (fs__namespace.existsSync(tempNodeModulesPath)) {
6133
+ fs__namespace.rmSync(tempNodeModulesPath, { recursive: true, force: true });
6134
+ }
6135
+ fs__namespace.renameSync(nodeModulesPath, tempNodeModulesPath);
6136
+ console.log(`📦 Preserved node_modules temporarily`);
6137
+ }
6138
+ // Delete everything in the directory
6139
+ const entries = fs__namespace.readdirSync(testSuiteDir, { withFileTypes: true });
6140
+ for (const entry of entries) {
6141
+ const entryPath = path__namespace.join(testSuiteDir, entry.name);
6142
+ try {
6143
+ if (entry.isDirectory()) {
6144
+ fs__namespace.rmSync(entryPath, { recursive: true, force: true });
6145
+ }
6146
+ else {
6147
+ fs__namespace.unlinkSync(entryPath);
6148
+ }
6149
+ }
6150
+ catch (error) {
6151
+ console.warn(`⚠️ Failed to delete ${entry.name}:`, error);
6152
+ }
6153
+ }
6154
+ console.log(`🗑️ Cleaned test suite directory (preserved node_modules)`);
6155
+ // Move node_modules back
6156
+ if (hasNodeModules && tempNodeModulesPath) {
6157
+ fs__namespace.renameSync(tempNodeModulesPath, nodeModulesPath);
6158
+ console.log(`📦 Restored node_modules`);
6159
+ }
6160
+ }
6161
+ catch (error) {
6162
+ console.warn(`⚠️ Failed to clean test suite directory ${testSuiteDir}:`, error);
6163
+ // Continue anyway - we'll overwrite files as needed
6164
+ }
6165
+ }
6166
+ // Ensure directories exist (will recreate after deletion)
6093
6167
  ensureDirectoryExists(testSuiteDir);
6094
6168
  const testsDir = path__namespace.join(testSuiteDir, 'tests');
6095
6169
  ensureDirectoryExists(testsDir);