intellitester 0.2.41 → 0.2.43

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.
@@ -936,18 +936,43 @@ var cleanupStaleSession = async (entry, cleanupConfig) => {
936
936
  } catch {
937
937
  }
938
938
  };
939
+ var cleanupOrphanedTrackFiles = async (cwd, state, trackDir) => {
940
+ const dir = getTrackDir(cwd, trackDir);
941
+ try {
942
+ const files = await fs.readdir(dir);
943
+ const activeFiles = new Set(Object.values(state.sessions).map((s) => path2.basename(s.trackFile)));
944
+ for (const file of files) {
945
+ if (!file.endsWith(".jsonl")) continue;
946
+ if (activeFiles.has(file)) continue;
947
+ const filePath = path2.join(dir, file);
948
+ try {
949
+ const stat = await fs.stat(filePath);
950
+ const staleMs = Number(process.env.INTELLITESTER_STALE_TEST_MS ?? DEFAULT_STALE_MS);
951
+ const isOld = Date.now() - stat.mtimeMs > staleMs;
952
+ const isEmpty = stat.size === 0;
953
+ if (isEmpty || isOld) {
954
+ await fs.rm(filePath, { force: true });
955
+ }
956
+ } catch {
957
+ }
958
+ }
959
+ } catch {
960
+ }
961
+ };
939
962
  var pruneStaleTests = async (cwd, cleanupConfig, trackDir) => {
940
963
  const state = await loadActiveTests(cwd, trackDir);
941
964
  const staleMs = Number(process.env.INTELLITESTER_STALE_TEST_MS ?? DEFAULT_STALE_MS);
942
965
  let changed = false;
943
966
  for (const [sessionId, entry] of Object.entries(state.sessions)) {
944
967
  let missingFile = false;
968
+ let isEmpty = false;
945
969
  try {
946
- await fs.access(entry.trackFile);
970
+ const stat = await fs.stat(entry.trackFile);
971
+ isEmpty = stat.size === 0;
947
972
  } catch {
948
973
  missingFile = true;
949
974
  }
950
- if (!missingFile && !isStale(entry, staleMs)) continue;
975
+ if (!missingFile && !isEmpty && !isStale(entry, staleMs)) continue;
951
976
  changed = true;
952
977
  await cleanupStaleSession(entry, cleanupConfig);
953
978
  try {
@@ -959,6 +984,7 @@ var pruneStaleTests = async (cwd, cleanupConfig, trackDir) => {
959
984
  if (changed) {
960
985
  await saveActiveTests(cwd, state, trackDir);
961
986
  }
987
+ await cleanupOrphanedTrackFiles(cwd, state, trackDir);
962
988
  };
963
989
  async function initFileTracking(options) {
964
990
  const cwd = options.cwd ?? process.cwd();
@@ -3004,7 +3030,7 @@ Starting workflow: ${workflow.name}`);
3004
3030
  executionContext.variables.set(key, interpolated);
3005
3031
  }
3006
3032
  }
3007
- const result = await runTestInWorkflow(test, page, executionContext, options, workflowDir, workflow.config?.web?.baseUrl);
3033
+ const result = await runTestInWorkflow(test, page, executionContext, options, workflowDir, workflow.config?.web?.baseUrl ?? options.baseUrl);
3008
3034
  const testResult = {
3009
3035
  id: testRef.id,
3010
3036
  file: testRef.file,
@@ -3180,7 +3206,7 @@ async function runWorkflow(workflow, workflowFilePath, options = {}) {
3180
3206
  }
3181
3207
  serverProcess = await startWebServer({
3182
3208
  ...effectiveWebServerConfig,
3183
- cwd: effectiveWebServerConfig.workdir ?? effectiveWebServerConfig.cwd ?? serverCwd
3209
+ workdir: path2.resolve(serverCwd, effectiveWebServerConfig.workdir ?? effectiveWebServerConfig.cwd ?? ".")
3184
3210
  });
3185
3211
  } catch (error) {
3186
3212
  console.error("Failed to start web server:", error);
@@ -3342,5 +3368,5 @@ Collected ${serverResources.length} server-tracked resources`);
3342
3368
  }
3343
3369
 
3344
3370
  export { createAIProvider, createTestContext, generateFillerText, generateRandomEmail, generateRandomPhone, generateRandomPhoto, generateRandomUsername, getBrowserLaunchOptions, initFileTracking, interpolateVariables, killServer, mergeFileTrackedResources, runWebTest, runWorkflow, runWorkflowWithContext, setupAppwriteTracking, startTrackingServer, startWebServer };
3345
- //# sourceMappingURL=chunk-UOJUZN2D.js.map
3346
- //# sourceMappingURL=chunk-UOJUZN2D.js.map
3371
+ //# sourceMappingURL=chunk-66ECN3LB.js.map
3372
+ //# sourceMappingURL=chunk-66ECN3LB.js.map