@playwright-orchestrator/mongo 1.4.3 → 1.5.0

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.
@@ -16,4 +16,8 @@ export declare class MongoShardHandler implements ShardHandler {
16
16
  private get runs();
17
17
  private get tests();
18
18
  private generateTestIdQuery;
19
+ getRemainingCounters(_config: TestRunConfig): Promise<{
20
+ remainingCount: number;
21
+ remainingTime: number;
22
+ }>;
19
23
  }
@@ -42,6 +42,8 @@ let MongoShardHandler = class MongoShardHandler {
42
42
  });
43
43
  if (!result)
44
44
  return undefined;
45
+ const effectiveEma = result.ema;
46
+ await this.runs.updateOne({ _id: generateRunId(runId) }, { $inc: { 'config.remainingCount': -1, 'config.remainingTime': -effectiveEma } });
45
47
  const { file, line, column, projects, timeout, ema, children, testId } = result;
46
48
  const { order } = parseTestId(result._id);
47
49
  return { file, position: `${line}:${column}`, projects, timeout, ema, order, children, testId };
@@ -74,6 +76,15 @@ let MongoShardHandler = class MongoShardHandler {
74
76
  await this.tests.updateMany(this.generateTestIdQuery(runId, TestStatus.Failed), {
75
77
  $set: { status: TestStatus.Ready, updated: now },
76
78
  });
79
+ if (statusBefore === RunStatus.Finished) {
80
+ const [agg] = await this.tests
81
+ .aggregate([
82
+ { $match: this.generateTestIdQuery(runId, TestStatus.Ready) },
83
+ { $group: { _id: null, count: { $sum: 1 }, totalEma: { $sum: '$ema' } } },
84
+ ])
85
+ .toArray();
86
+ await this.runs.updateOne({ _id: generateRunId(runId) }, { $set: { 'config.remainingCount': agg?.count ?? 0, 'config.remainingTime': agg?.totalEma ?? 0 } });
87
+ }
77
88
  }
78
89
  return run.config;
79
90
  }
@@ -108,6 +119,13 @@ let MongoShardHandler = class MongoShardHandler {
108
119
  status: { $in: statuses },
109
120
  };
110
121
  }
122
+ async getRemainingCounters(_config) {
123
+ const run = await this.runs.findOne({ _id: generateRunId(this.runContext.runId) }, { projection: { 'config.remainingCount': 1, 'config.remainingTime': 1 } });
124
+ return {
125
+ remainingCount: Math.max(0, run?.config?.remainingCount ?? 0),
126
+ remainingTime: Math.max(0, run?.config?.remainingTime ?? 0),
127
+ };
128
+ }
111
129
  };
112
130
  MongoShardHandler = __decorate([
113
131
  injectable(),
@@ -52,6 +52,8 @@ let MongoTestRunCreator = class MongoTestRunCreator extends BaseTestRunCreator {
52
52
  }
53
53
  async saveRunData(runId, testRun, tests) {
54
54
  const now = new Date();
55
+ testRun.config.remainingCount = tests.length;
56
+ testRun.config.remainingTime = tests.reduce((sum, t) => sum + t.ema, 0);
55
57
  const run = {
56
58
  _id: generateRunId(runId),
57
59
  ...testRun,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playwright-orchestrator/mongo",
3
- "version": "1.4.3",
3
+ "version": "1.5.0",
4
4
  "keywords": [],
5
5
  "author": "Rostyslav Kudrevatykh",
6
6
  "license": "Apache-2.0",
@@ -18,7 +18,7 @@
18
18
  "inversify": "^8.0.0-beta.0",
19
19
  "mongodb": "^6.12.0",
20
20
  "uuid": "^11.0.0",
21
- "@playwright-orchestrator/core": "1.4.3"
21
+ "@playwright-orchestrator/core": "1.5.0"
22
22
  },
23
23
  "devDependencies": {},
24
24
  "main": "dist/index.js",