@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/.tsbuildinfo +1 -1
- package/dist/cli.js +60 -2
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +60 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +60 -2
- package/dist/index.js.map +1 -1
- package/dist/types/codegen-api.d.ts.map +1 -1
- package/dist/types/test-suite-runner.d.ts.map +1 -1
- package/package.json +2 -2
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
|
|
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
|
|
@@ -6089,7 +6102,52 @@ export default class ProboReporter implements Reporter {
|
|
|
6089
6102
|
if (codeGenResult.scenarios.length === 0) {
|
|
6090
6103
|
throw new Error(`No scenarios found in test suite ${testSuiteId}. Cannot generate test files.`);
|
|
6091
6104
|
}
|
|
6092
|
-
//
|
|
6105
|
+
// Delete everything in the test suite directory except node_modules
|
|
6106
|
+
// This ensures a clean state while preserving dependencies for faster subsequent runs
|
|
6107
|
+
if (fs__namespace.existsSync(testSuiteDir)) {
|
|
6108
|
+
try {
|
|
6109
|
+
const nodeModulesPath = path__namespace.join(testSuiteDir, 'node_modules');
|
|
6110
|
+
const hasNodeModules = fs__namespace.existsSync(nodeModulesPath);
|
|
6111
|
+
// Temporarily move node_modules out of the way if it exists
|
|
6112
|
+
let tempNodeModulesPath = null;
|
|
6113
|
+
if (hasNodeModules) {
|
|
6114
|
+
tempNodeModulesPath = path__namespace.join(testSuiteDir, '..', `node_modules.temp.${testSuiteId}`);
|
|
6115
|
+
// Remove temp directory if it exists from a previous failed run
|
|
6116
|
+
if (fs__namespace.existsSync(tempNodeModulesPath)) {
|
|
6117
|
+
fs__namespace.rmSync(tempNodeModulesPath, { recursive: true, force: true });
|
|
6118
|
+
}
|
|
6119
|
+
fs__namespace.renameSync(nodeModulesPath, tempNodeModulesPath);
|
|
6120
|
+
console.log(`📦 Preserved node_modules temporarily`);
|
|
6121
|
+
}
|
|
6122
|
+
// Delete everything in the directory
|
|
6123
|
+
const entries = fs__namespace.readdirSync(testSuiteDir, { withFileTypes: true });
|
|
6124
|
+
for (const entry of entries) {
|
|
6125
|
+
const entryPath = path__namespace.join(testSuiteDir, entry.name);
|
|
6126
|
+
try {
|
|
6127
|
+
if (entry.isDirectory()) {
|
|
6128
|
+
fs__namespace.rmSync(entryPath, { recursive: true, force: true });
|
|
6129
|
+
}
|
|
6130
|
+
else {
|
|
6131
|
+
fs__namespace.unlinkSync(entryPath);
|
|
6132
|
+
}
|
|
6133
|
+
}
|
|
6134
|
+
catch (error) {
|
|
6135
|
+
console.warn(`⚠️ Failed to delete ${entry.name}:`, error);
|
|
6136
|
+
}
|
|
6137
|
+
}
|
|
6138
|
+
console.log(`🗑️ Cleaned test suite directory (preserved node_modules)`);
|
|
6139
|
+
// Move node_modules back
|
|
6140
|
+
if (hasNodeModules && tempNodeModulesPath) {
|
|
6141
|
+
fs__namespace.renameSync(tempNodeModulesPath, nodeModulesPath);
|
|
6142
|
+
console.log(`📦 Restored node_modules`);
|
|
6143
|
+
}
|
|
6144
|
+
}
|
|
6145
|
+
catch (error) {
|
|
6146
|
+
console.warn(`⚠️ Failed to clean test suite directory ${testSuiteDir}:`, error);
|
|
6147
|
+
// Continue anyway - we'll overwrite files as needed
|
|
6148
|
+
}
|
|
6149
|
+
}
|
|
6150
|
+
// Ensure directories exist (will recreate after deletion)
|
|
6093
6151
|
ensureDirectoryExists(testSuiteDir);
|
|
6094
6152
|
const testsDir = path__namespace.join(testSuiteDir, 'tests');
|
|
6095
6153
|
ensureDirectoryExists(testsDir);
|