diff --git a/apps/dashboard/src/utils.test.ts b/apps/dashboard/src/utils.test.ts index f1165e16..5367cdec 100644 --- a/apps/dashboard/src/utils.test.ts +++ b/apps/dashboard/src/utils.test.ts @@ -17,53 +17,52 @@ describe("computeDuration", () => { expect(result).toBe("-"); }); - it("returns '< 1ms' for negative duration (clock skew)", () => { - const startedAt = new Date("2024-01-01T00:00:01.000Z"); - const finishedAt = new Date("2024-01-01T00:00:00.000Z"); + it.each<[string, Date, Date, string]>([ + [ + "returns '< 1ms' for negative duration (clock skew)", + new Date("2024-01-01T00:00:01.000Z"), + new Date("2024-01-01T00:00:00.000Z"), + "< 1ms", + ], + [ + "returns milliseconds for durations under 1 second", + new Date("2024-01-01T00:00:00.000Z"), + new Date("2024-01-01T00:00:00.500Z"), + "500ms", + ], + [ + "returns seconds with one decimal for durations under 1 minute", + new Date("2024-01-01T00:00:00.000Z"), + new Date("2024-01-01T00:00:05.500Z"), + "5.5s", + ], + [ + "returns minutes only when seconds are 0", + new Date("2024-01-01T00:00:00.000Z"), + new Date("2024-01-01T00:02:00.000Z"), + "2m", + ], + [ + "returns minutes and seconds for durations over 1 minute", + new Date("2024-01-01T00:00:00.000Z"), + new Date("2024-01-01T00:02:30.000Z"), + "2m 30s", + ], + [ + "rounds seconds when formatting minutes and seconds", + new Date("2024-01-01T00:00:00.000Z"), + new Date("2024-01-01T00:02:30.600Z"), + "2m 31s", + ], + [ + "handles 0ms duration", + new Date("2024-01-01T00:00:00.000Z"), + new Date("2024-01-01T00:00:00.000Z"), + "0ms", + ], + ])("%s", (_name, startedAt, finishedAt, expected) => { const result = computeDuration(startedAt, finishedAt); - expect(result).toBe("< 1ms"); - }); - - it("returns milliseconds for durations under 1 second", () => { - const startedAt = new Date("2024-01-01T00:00:00.000Z"); - const finishedAt = new Date("2024-01-01T00:00:00.500Z"); - const result = computeDuration(startedAt, finishedAt); - expect(result).toBe("500ms"); - }); - - it("returns seconds with one decimal for durations under 1 minute", () => { - const startedAt = new Date("2024-01-01T00:00:00.000Z"); - const finishedAt = new Date("2024-01-01T00:00:05.500Z"); - const result = computeDuration(startedAt, finishedAt); - expect(result).toBe("5.5s"); - }); - - it("returns minutes only when seconds are 0", () => { - const startedAt = new Date("2024-01-01T00:00:00.000Z"); - const finishedAt = new Date("2024-01-01T00:02:00.000Z"); - const result = computeDuration(startedAt, finishedAt); - expect(result).toBe("2m"); - }); - - it("returns minutes and seconds for durations over 1 minute", () => { - const startedAt = new Date("2024-01-01T00:00:00.000Z"); - const finishedAt = new Date("2024-01-01T00:02:30.000Z"); - const result = computeDuration(startedAt, finishedAt); - expect(result).toBe("2m 30s"); - }); - - it("rounds seconds when formatting minutes and seconds", () => { - const startedAt = new Date("2024-01-01T00:00:00.000Z"); - const finishedAt = new Date("2024-01-01T00:02:30.600Z"); - const result = computeDuration(startedAt, finishedAt); - expect(result).toBe("2m 31s"); - }); - - it("handles 0ms duration", () => { - const startedAt = new Date("2024-01-01T00:00:00.000Z"); - const finishedAt = new Date("2024-01-01T00:00:00.000Z"); - const result = computeDuration(startedAt, finishedAt); - expect(result).toBe("0ms"); + expect(result).toBe(expected); }); }); diff --git a/package-lock.json b/package-lock.json index 448b41b4..dc51d6ec 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,7 +33,7 @@ "eslint-plugin-functional": "^10.0.0", "eslint-plugin-import": "^2.32.0", "eslint-plugin-jsdoc": "^63.0.10", - "eslint-plugin-sonarjs": "^4.1.0", + "eslint-plugin-sonarjs": "^4.2.0", "eslint-plugin-unicorn": "^65.0.1", "husky": "^9.1.7", "jscpd": "^5.0.12", @@ -9298,9 +9298,9 @@ } }, "node_modules/eslint-plugin-sonarjs": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-sonarjs/-/eslint-plugin-sonarjs-4.1.0.tgz", - "integrity": "sha512-rh+FlVz0yfd2RNIb6WqSkuGh0addX/Qi5scwQ5FphXDFrM6fZKcxP1+attJ78yUKcyYfiu6MTaISPpAFPzqRJw==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-sonarjs/-/eslint-plugin-sonarjs-4.2.0.tgz", + "integrity": "sha512-bqADfuNtTL7VK6RU29eoiFTtaaBKIpVPuX3bOl+rBpWSBa0zIBVZlqZNZQjfP6s4iXkAJokv5IsD8OsACkwApg==", "dev": true, "license": "LGPL-3.0-only", "dependencies": { @@ -9308,14 +9308,14 @@ "builtin-modules": "^3.3.0", "bytes": "^3.1.2", "functional-red-black-tree": "^1.0.1", - "globals": "^17.6.0", + "globals": "^17.7.0", "jsx-ast-utils-x": "^0.1.0", "lodash.merge": "^4.6.2", "minimatch": "^10.2.5", "scslre": "^0.3.0", - "semver": "^7.8.4", + "semver": "^7.8.5", "ts-api-utils": "^2.5.0", - "typescript": ">=5", + "typescript": ">=5 <6.1.0", "yaml": "^2.9.0" }, "peerDependencies": { diff --git a/package.json b/package.json index 1699fe38..7ce54d11 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "eslint-plugin-functional": "^10.0.0", "eslint-plugin-import": "^2.32.0", "eslint-plugin-jsdoc": "^63.0.10", - "eslint-plugin-sonarjs": "^4.1.0", + "eslint-plugin-sonarjs": "^4.2.0", "eslint-plugin-unicorn": "^65.0.1", "husky": "^9.1.7", "jscpd": "^5.0.12", diff --git a/packages/openworkflow/core/cursor.test.ts b/packages/openworkflow/core/cursor.test.ts index d2a5b5cc..2e928bb2 100644 --- a/packages/openworkflow/core/cursor.test.ts +++ b/packages/openworkflow/core/cursor.test.ts @@ -77,34 +77,18 @@ describe("encodeCursor", () => { expect(parsed["extra"]).toBeUndefined(); }); - test("handles empty id", () => { + test.each<[string, string]>([ + ["empty id", ""], + ["ids with special characters", 'weird/"\\id\n\t'], + ["unicode ids", "🚀-café-漢字"], + ])("handles %s", (_name, id) => { const cursor: Cursor = { createdAt: new Date("2026-01-15T12:34:56.789Z"), - id: "", + id, }; const encoded = encodeCursor(cursor); const decoded = decodeCursor(encoded); - expect(decoded.id).toBe(""); - }); - - test("handles ids with special characters", () => { - const cursor: Cursor = { - createdAt: new Date("2026-01-15T12:34:56.789Z"), - id: 'weird/"\\id\n\t', - }; - const encoded = encodeCursor(cursor); - const decoded = decodeCursor(encoded); - expect(decoded.id).toBe('weird/"\\id\n\t'); - }); - - test("handles unicode ids", () => { - const cursor: Cursor = { - createdAt: new Date("2026-01-15T12:34:56.789Z"), - id: "🚀-café-漢字", - }; - const encoded = encodeCursor(cursor); - const decoded = decodeCursor(encoded); - expect(decoded.id).toBe("🚀-café-漢字"); + expect(decoded.id).toBe(id); }); }); diff --git a/packages/openworkflow/core/standard-schema.ts b/packages/openworkflow/core/standard-schema.ts index 5720b323..03c6121f 100644 --- a/packages/openworkflow/core/standard-schema.ts +++ b/packages/openworkflow/core/standard-schema.ts @@ -70,6 +70,5 @@ export declare namespace StandardSchemaV1 { >["output"]; // needed for granular visibility control of the Standard Schema namespace. - // eslint-disable-next-line unicorn/require-module-specifiers export {}; }