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

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
@@ -6070,7 +6083,52 @@ class TestSuiteRunner {
6070
6083
  if (codeGenResult.scenarios.length === 0) {
6071
6084
  throw new Error(`No scenarios found in test suite ${testSuiteId}. Cannot generate test files.`);
6072
6085
  }
6073
- // Ensure directories exist
6086
+ // Delete everything in the test suite directory except node_modules
6087
+ // This ensures a clean state while preserving dependencies for faster subsequent runs
6088
+ if (fs.existsSync(testSuiteDir)) {
6089
+ try {
6090
+ const nodeModulesPath = path.join(testSuiteDir, 'node_modules');
6091
+ const hasNodeModules = fs.existsSync(nodeModulesPath);
6092
+ // Temporarily move node_modules out of the way if it exists
6093
+ let tempNodeModulesPath = null;
6094
+ if (hasNodeModules) {
6095
+ tempNodeModulesPath = path.join(testSuiteDir, '..', `node_modules.temp.${testSuiteId}`);
6096
+ // Remove temp directory if it exists from a previous failed run
6097
+ if (fs.existsSync(tempNodeModulesPath)) {
6098
+ fs.rmSync(tempNodeModulesPath, { recursive: true, force: true });
6099
+ }
6100
+ fs.renameSync(nodeModulesPath, tempNodeModulesPath);
6101
+ console.log(`📦 Preserved node_modules temporarily`);
6102
+ }
6103
+ // Delete everything in the directory
6104
+ const entries = fs.readdirSync(testSuiteDir, { withFileTypes: true });
6105
+ for (const entry of entries) {
6106
+ const entryPath = path.join(testSuiteDir, entry.name);
6107
+ try {
6108
+ if (entry.isDirectory()) {
6109
+ fs.rmSync(entryPath, { recursive: true, force: true });
6110
+ }
6111
+ else {
6112
+ fs.unlinkSync(entryPath);
6113
+ }
6114
+ }
6115
+ catch (error) {
6116
+ console.warn(`⚠️ Failed to delete ${entry.name}:`, error);
6117
+ }
6118
+ }
6119
+ console.log(`🗑️ Cleaned test suite directory (preserved node_modules)`);
6120
+ // Move node_modules back
6121
+ if (hasNodeModules && tempNodeModulesPath) {
6122
+ fs.renameSync(tempNodeModulesPath, nodeModulesPath);
6123
+ console.log(`📦 Restored node_modules`);
6124
+ }
6125
+ }
6126
+ catch (error) {
6127
+ console.warn(`⚠️ Failed to clean test suite directory ${testSuiteDir}:`, error);
6128
+ // Continue anyway - we'll overwrite files as needed
6129
+ }
6130
+ }
6131
+ // Ensure directories exist (will recreate after deletion)
6074
6132
  ensureDirectoryExists(testSuiteDir);
6075
6133
  const testsDir = path.join(testSuiteDir, 'tests');
6076
6134
  ensureDirectoryExists(testsDir);