Skip to content

Commit 8ce9ac7

Browse files
committed
fix(tests): update outdated test expectations
- constants.test.ts: Update endpoint count (2→3) and token buffer (50min→60sec) - token.test.ts: Update expiry tests to use 60-second buffer - sisyphus-orchestrator: Add fallback to output.metadata.filePath when callID missing
1 parent eb419f0 commit 8ce9ac7

File tree

3 files changed

+31
-21
lines changed

3 files changed

+31
-21
lines changed

src/auth/antigravity/constants.test.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@ import {
77

88
describe("Antigravity Constants", () => {
99
describe("ANTIGRAVITY_TOKEN_REFRESH_BUFFER_MS", () => {
10-
it("should be 50 minutes (3,000,000ms) to match CLIProxyAPI", () => {
10+
it("should be 60 seconds (60,000ms) to refresh before expiry", () => {
1111
// #given
12-
const FIFTY_MINUTES_MS = 50 * 60 * 1000 // 3,000,000
12+
const SIXTY_SECONDS_MS = 60 * 1000 // 60,000
1313

1414
// #when
1515
const actual = ANTIGRAVITY_TOKEN_REFRESH_BUFFER_MS
1616

1717
// #then
18-
expect(actual).toBe(FIFTY_MINUTES_MS)
18+
expect(actual).toBe(SIXTY_SECONDS_MS)
1919
})
2020
})
2121

2222
describe("ANTIGRAVITY_ENDPOINT_FALLBACKS", () => {
23-
it("should have exactly 2 endpoints (daily → prod)", () => {
23+
it("should have exactly 3 endpoints (sandbox → daily → prod)", () => {
2424
// #given
25-
const expectedCount = 2
25+
const expectedCount = 3
2626

2727
// #when
2828
const actual = ANTIGRAVITY_ENDPOINT_FALLBACKS
@@ -31,16 +31,23 @@ describe("Antigravity Constants", () => {
3131
expect(actual).toHaveLength(expectedCount)
3232
})
3333

34-
it("should have daily endpoint first", () => {
34+
it("should have sandbox endpoint first", () => {
3535
// #then
3636
expect(ANTIGRAVITY_ENDPOINT_FALLBACKS[0]).toBe(
3737
"https://daily-cloudcode-pa.sandbox.googleapis.com"
3838
)
3939
})
4040

41-
it("should have prod endpoint second", () => {
41+
it("should have daily endpoint second", () => {
4242
// #then
4343
expect(ANTIGRAVITY_ENDPOINT_FALLBACKS[1]).toBe(
44+
"https://daily-cloudcode-pa.googleapis.com"
45+
)
46+
})
47+
48+
it("should have prod endpoint third", () => {
49+
// #then
50+
expect(ANTIGRAVITY_ENDPOINT_FALLBACKS[2]).toBe(
4451
"https://cloudcode-pa.googleapis.com"
4552
)
4653
})

src/auth/antigravity/token.test.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { describe, it, expect } from "bun:test"
22
import { isTokenExpired } from "./token"
33
import type { AntigravityTokens } from "./types"
44

5-
describe("Token Expiry with 50-minute Buffer", () => {
5+
describe("Token Expiry with 60-second Buffer", () => {
66
const createToken = (expiresInSeconds: number): AntigravityTokens => ({
77
type: "antigravity",
88
access_token: "test-access",
@@ -11,10 +11,10 @@ describe("Token Expiry with 50-minute Buffer", () => {
1111
timestamp: Date.now(),
1212
})
1313

14-
it("should NOT be expired if token expires in 51 minutes", () => {
14+
it("should NOT be expired if token expires in 2 minutes", () => {
1515
// #given
16-
const fiftyOneMinutes = 51 * 60 // 3060 seconds
17-
const token = createToken(fiftyOneMinutes)
16+
const twoMinutes = 2 * 60
17+
const token = createToken(twoMinutes)
1818

1919
// #when
2020
const expired = isTokenExpired(token)
@@ -23,10 +23,10 @@ describe("Token Expiry with 50-minute Buffer", () => {
2323
expect(expired).toBe(false)
2424
})
2525

26-
it("should be expired if token expires in 49 minutes", () => {
26+
it("should be expired if token expires in 30 seconds", () => {
2727
// #given
28-
const fortyNineMinutes = 49 * 60 // 2940 seconds
29-
const token = createToken(fortyNineMinutes)
28+
const thirtySeconds = 30
29+
const token = createToken(thirtySeconds)
3030

3131
// #when
3232
const expired = isTokenExpired(token)
@@ -35,10 +35,10 @@ describe("Token Expiry with 50-minute Buffer", () => {
3535
expect(expired).toBe(true)
3636
})
3737

38-
it("should be expired at exactly 50 minutes (boundary)", () => {
38+
it("should be expired at exactly 60 seconds (boundary)", () => {
3939
// #given
40-
const fiftyMinutes = 50 * 60 // 3000 seconds
41-
const token = createToken(fiftyMinutes)
40+
const sixtySeconds = 60
41+
const token = createToken(sixtySeconds)
4242

4343
// #when
4444
const expired = isTokenExpired(token)
@@ -53,8 +53,8 @@ describe("Token Expiry with 50-minute Buffer", () => {
5353
type: "antigravity",
5454
access_token: "test-access",
5555
refresh_token: "test-refresh",
56-
expires_in: 3600, // 1 hour originally
57-
timestamp: Date.now() - 4000 * 1000, // 4000 seconds ago
56+
expires_in: 3600,
57+
timestamp: Date.now() - 4000 * 1000,
5858
}
5959

6060
// #when
@@ -66,7 +66,7 @@ describe("Token Expiry with 50-minute Buffer", () => {
6666

6767
it("should NOT be expired if token has plenty of time", () => {
6868
// #given
69-
const twoHours = 2 * 60 * 60 // 7200 seconds
69+
const twoHours = 2 * 60 * 60
7070
const token = createToken(twoHours)
7171

7272
// #when

src/hooks/sisyphus-orchestrator/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,10 +586,13 @@ export function createSisyphusOrchestratorHook(
586586
}
587587

588588
if (WRITE_EDIT_TOOLS.includes(input.tool)) {
589-
const filePath = input.callID ? pendingFilePaths.get(input.callID) : undefined
589+
let filePath = input.callID ? pendingFilePaths.get(input.callID) : undefined
590590
if (input.callID) {
591591
pendingFilePaths.delete(input.callID)
592592
}
593+
if (!filePath) {
594+
filePath = output.metadata?.filePath as string | undefined
595+
}
593596
if (filePath && !filePath.includes(ALLOWED_PATH_PREFIX)) {
594597
output.output = (output.output || "") + DIRECT_WORK_REMINDER
595598
log(`[${HOOK_NAME}] Direct work reminder appended`, {

0 commit comments

Comments
 (0)