Skip to content

Commit 0e0aed8

Browse files
SteRiccioclaude
andauthored
Job/jobbase unification test fixtures (#177)
* job: update test fixtures for JobBase's renamed generateResult/innerJobs * job: guard onMessage against undefined userUuid from JobBase JobBase.userUuid (and JobSerialized.userUuid) was widened from string to string | undefined upstream in arena-core as a defensive null-safety change. Add an early return in JobManager.onMessage() so tsc can narrow userUuid to a definite string for the rest of the method, instead of failing to type-check the Map lookup, the WebSocketServer.notifyUser call, and the workers.delete() call inside the setTimeout closure. Fixes TS2345 errors reported against jobManager.ts:22,24,30. A job update message always carries a userUuid in practice (every job is created for a specific user), so this is a no-op guard rather than a change in expected behavior. * Bump @openforis/arena-core to published v2.1.2 Points at the real published JobBase unification (was verified locally via yarn link during development; this replaces that local link with the actual published package now that the arena-core PR has merged). Re-verified against the published package: tsc clean, full test suite 16/16 suites, 67/67 tests passing. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 048fe83 commit 0e0aed8

5 files changed

Lines changed: 11 additions & 11 deletions

File tree

.yarn/install-state.gz

500 Bytes
Binary file not shown.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"dependencies": {
4747
"@aws-sdk/client-s3": "^3.1112.0",
4848
"@godaddy/terminus": "^4.12.1",
49-
"@openforis/arena-core": "^2.1.1",
49+
"@openforis/arena-core": "^2.1.2",
5050
"bcryptjs": "^3.0.3",
5151
"compression": "^1.8.1",
5252
"cookie-parser": "^1.4.7",

src/job/jobManager.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export class JobManager {
1919

2020
const { job } = msg
2121
const { userUuid, ended } = job
22+
if (!userUuid) return
23+
2224
const worker = JobManager.workers.get(userUuid)
2325

2426
WebSocketServer.notifyUser(userUuid, WebSocketEvent.jobUpdate, job)

src/job/tests/testJobs.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ export class SimpleJob extends JobServer<SimpleJobContext, number> {
1818
return Promise.resolve()
1919
}
2020

21-
protected async prepareResult(): Promise<number> {
22-
await super.prepareResult()
21+
protected async generateResult(): Promise<number> {
2322
return this.context.result ?? 3
2423
}
2524
}
@@ -31,8 +30,7 @@ export class SimpleJobWithJobs extends SimpleJob {
3130
super(data, [new SimpleJob({ ...data, result: 4 }), new SimpleJob({ ...data, result: 2 })])
3231
}
3332

34-
protected async prepareResult(): Promise<number> {
35-
await super.prepareResult()
36-
return this.jobs.reduce<number>((total, job) => total + (job.result ?? 0), 0)
33+
protected async generateResult(): Promise<number> {
34+
return this.innerJobs.reduce<number>((total, job) => total + (job.result ?? 0), 0)
3735
}
3836
}

yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,9 +1217,9 @@ __metadata:
12171217
languageName: node
12181218
linkType: hard
12191219

1220-
"@openforis/arena-core@npm:^2.1.1":
1221-
version: 2.1.1
1222-
resolution: "@openforis/arena-core@npm:2.1.1::__archiveUrl=https%3A%2F%2Fnpm.pkg.github.com%2Fdownload%2F%40openforis%2Farena-core%2F2.1.1%2F299f3875319599f29e4d843261684beb48dbd742"
1220+
"@openforis/arena-core@npm:^2.1.2":
1221+
version: 2.1.2
1222+
resolution: "@openforis/arena-core@npm:2.1.2::__archiveUrl=https%3A%2F%2Fnpm.pkg.github.com%2Fdownload%2F%40openforis%2Farena-core%2F2.1.2%2F15b52b1957c9acf1e050177ace9f617841e3eebe"
12231223
dependencies:
12241224
"@jsep-plugin/regex": "npm:^1.0.4"
12251225
"@turf/bearing": "npm:^7.3.5"
@@ -1235,7 +1235,7 @@ __metadata:
12351235
moment: "npm:^2.30.1"
12361236
proj4: "npm:^2.20.9"
12371237
uuid: "npm:^14.0.1"
1238-
checksum: 10c0/cf1425c772e2abb27dd32b3c62dc8edee625b518144d6952e9197f0d781dac80cfde6a3de2c31f5451afc878a8a6d0e4b82173fc16da3020363fd60a73561cc0
1238+
checksum: 10c0/8fc2ddac5cf6bb07f483d743dadf3b2f3c845218a7b8ad98b4ed65183f93acc95ed6a921de28746b7e17a5350df3a9cb6739258433d28eba6af8aca78fc14bf4
12391239
languageName: node
12401240
linkType: hard
12411241

@@ -1247,7 +1247,7 @@ __metadata:
12471247
"@eslint/js": "npm:^10.0.1"
12481248
"@godaddy/terminus": "npm:^4.12.1"
12491249
"@machinomy/types-node-db-migrate": "npm:^0.0.2"
1250-
"@openforis/arena-core": "npm:^2.1.1"
1250+
"@openforis/arena-core": "npm:^2.1.2"
12511251
"@types/bcryptjs": "npm:^3.0.0"
12521252
"@types/compression": "npm:^1.8.1"
12531253
"@types/cookie-parser": "npm:^1.4.10"

0 commit comments

Comments
 (0)