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
This commit is contained in:
@@ -7,22 +7,22 @@ import {
|
|||||||
|
|
||||||
describe("Antigravity Constants", () => {
|
describe("Antigravity Constants", () => {
|
||||||
describe("ANTIGRAVITY_TOKEN_REFRESH_BUFFER_MS", () => {
|
describe("ANTIGRAVITY_TOKEN_REFRESH_BUFFER_MS", () => {
|
||||||
it("should be 50 minutes (3,000,000ms) to match CLIProxyAPI", () => {
|
it("should be 60 seconds (60,000ms) to refresh before expiry", () => {
|
||||||
// #given
|
// #given
|
||||||
const FIFTY_MINUTES_MS = 50 * 60 * 1000 // 3,000,000
|
const SIXTY_SECONDS_MS = 60 * 1000 // 60,000
|
||||||
|
|
||||||
// #when
|
// #when
|
||||||
const actual = ANTIGRAVITY_TOKEN_REFRESH_BUFFER_MS
|
const actual = ANTIGRAVITY_TOKEN_REFRESH_BUFFER_MS
|
||||||
|
|
||||||
// #then
|
// #then
|
||||||
expect(actual).toBe(FIFTY_MINUTES_MS)
|
expect(actual).toBe(SIXTY_SECONDS_MS)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("ANTIGRAVITY_ENDPOINT_FALLBACKS", () => {
|
describe("ANTIGRAVITY_ENDPOINT_FALLBACKS", () => {
|
||||||
it("should have exactly 2 endpoints (daily → prod)", () => {
|
it("should have exactly 3 endpoints (sandbox → daily → prod)", () => {
|
||||||
// #given
|
// #given
|
||||||
const expectedCount = 2
|
const expectedCount = 3
|
||||||
|
|
||||||
// #when
|
// #when
|
||||||
const actual = ANTIGRAVITY_ENDPOINT_FALLBACKS
|
const actual = ANTIGRAVITY_ENDPOINT_FALLBACKS
|
||||||
@@ -31,16 +31,23 @@ describe("Antigravity Constants", () => {
|
|||||||
expect(actual).toHaveLength(expectedCount)
|
expect(actual).toHaveLength(expectedCount)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should have daily endpoint first", () => {
|
it("should have sandbox endpoint first", () => {
|
||||||
// #then
|
// #then
|
||||||
expect(ANTIGRAVITY_ENDPOINT_FALLBACKS[0]).toBe(
|
expect(ANTIGRAVITY_ENDPOINT_FALLBACKS[0]).toBe(
|
||||||
"https://daily-cloudcode-pa.sandbox.googleapis.com"
|
"https://daily-cloudcode-pa.sandbox.googleapis.com"
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should have prod endpoint second", () => {
|
it("should have daily endpoint second", () => {
|
||||||
// #then
|
// #then
|
||||||
expect(ANTIGRAVITY_ENDPOINT_FALLBACKS[1]).toBe(
|
expect(ANTIGRAVITY_ENDPOINT_FALLBACKS[1]).toBe(
|
||||||
|
"https://daily-cloudcode-pa.googleapis.com"
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it("should have prod endpoint third", () => {
|
||||||
|
// #then
|
||||||
|
expect(ANTIGRAVITY_ENDPOINT_FALLBACKS[2]).toBe(
|
||||||
"https://cloudcode-pa.googleapis.com"
|
"https://cloudcode-pa.googleapis.com"
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { describe, it, expect } from "bun:test"
|
|||||||
import { isTokenExpired } from "./token"
|
import { isTokenExpired } from "./token"
|
||||||
import type { AntigravityTokens } from "./types"
|
import type { AntigravityTokens } from "./types"
|
||||||
|
|
||||||
describe("Token Expiry with 50-minute Buffer", () => {
|
describe("Token Expiry with 60-second Buffer", () => {
|
||||||
const createToken = (expiresInSeconds: number): AntigravityTokens => ({
|
const createToken = (expiresInSeconds: number): AntigravityTokens => ({
|
||||||
type: "antigravity",
|
type: "antigravity",
|
||||||
access_token: "test-access",
|
access_token: "test-access",
|
||||||
@@ -11,10 +11,10 @@ describe("Token Expiry with 50-minute Buffer", () => {
|
|||||||
timestamp: Date.now(),
|
timestamp: Date.now(),
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should NOT be expired if token expires in 51 minutes", () => {
|
it("should NOT be expired if token expires in 2 minutes", () => {
|
||||||
// #given
|
// #given
|
||||||
const fiftyOneMinutes = 51 * 60 // 3060 seconds
|
const twoMinutes = 2 * 60
|
||||||
const token = createToken(fiftyOneMinutes)
|
const token = createToken(twoMinutes)
|
||||||
|
|
||||||
// #when
|
// #when
|
||||||
const expired = isTokenExpired(token)
|
const expired = isTokenExpired(token)
|
||||||
@@ -23,10 +23,10 @@ describe("Token Expiry with 50-minute Buffer", () => {
|
|||||||
expect(expired).toBe(false)
|
expect(expired).toBe(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should be expired if token expires in 49 minutes", () => {
|
it("should be expired if token expires in 30 seconds", () => {
|
||||||
// #given
|
// #given
|
||||||
const fortyNineMinutes = 49 * 60 // 2940 seconds
|
const thirtySeconds = 30
|
||||||
const token = createToken(fortyNineMinutes)
|
const token = createToken(thirtySeconds)
|
||||||
|
|
||||||
// #when
|
// #when
|
||||||
const expired = isTokenExpired(token)
|
const expired = isTokenExpired(token)
|
||||||
@@ -35,10 +35,10 @@ describe("Token Expiry with 50-minute Buffer", () => {
|
|||||||
expect(expired).toBe(true)
|
expect(expired).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should be expired at exactly 50 minutes (boundary)", () => {
|
it("should be expired at exactly 60 seconds (boundary)", () => {
|
||||||
// #given
|
// #given
|
||||||
const fiftyMinutes = 50 * 60 // 3000 seconds
|
const sixtySeconds = 60
|
||||||
const token = createToken(fiftyMinutes)
|
const token = createToken(sixtySeconds)
|
||||||
|
|
||||||
// #when
|
// #when
|
||||||
const expired = isTokenExpired(token)
|
const expired = isTokenExpired(token)
|
||||||
@@ -53,8 +53,8 @@ describe("Token Expiry with 50-minute Buffer", () => {
|
|||||||
type: "antigravity",
|
type: "antigravity",
|
||||||
access_token: "test-access",
|
access_token: "test-access",
|
||||||
refresh_token: "test-refresh",
|
refresh_token: "test-refresh",
|
||||||
expires_in: 3600, // 1 hour originally
|
expires_in: 3600,
|
||||||
timestamp: Date.now() - 4000 * 1000, // 4000 seconds ago
|
timestamp: Date.now() - 4000 * 1000,
|
||||||
}
|
}
|
||||||
|
|
||||||
// #when
|
// #when
|
||||||
@@ -66,7 +66,7 @@ describe("Token Expiry with 50-minute Buffer", () => {
|
|||||||
|
|
||||||
it("should NOT be expired if token has plenty of time", () => {
|
it("should NOT be expired if token has plenty of time", () => {
|
||||||
// #given
|
// #given
|
||||||
const twoHours = 2 * 60 * 60 // 7200 seconds
|
const twoHours = 2 * 60 * 60
|
||||||
const token = createToken(twoHours)
|
const token = createToken(twoHours)
|
||||||
|
|
||||||
// #when
|
// #when
|
||||||
|
|||||||
@@ -586,10 +586,13 @@ export function createSisyphusOrchestratorHook(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (WRITE_EDIT_TOOLS.includes(input.tool)) {
|
if (WRITE_EDIT_TOOLS.includes(input.tool)) {
|
||||||
const filePath = input.callID ? pendingFilePaths.get(input.callID) : undefined
|
let filePath = input.callID ? pendingFilePaths.get(input.callID) : undefined
|
||||||
if (input.callID) {
|
if (input.callID) {
|
||||||
pendingFilePaths.delete(input.callID)
|
pendingFilePaths.delete(input.callID)
|
||||||
}
|
}
|
||||||
|
if (!filePath) {
|
||||||
|
filePath = output.metadata?.filePath as string | undefined
|
||||||
|
}
|
||||||
if (filePath && !filePath.includes(ALLOWED_PATH_PREFIX)) {
|
if (filePath && !filePath.includes(ALLOWED_PATH_PREFIX)) {
|
||||||
output.output = (output.output || "") + DIRECT_WORK_REMINDER
|
output.output = (output.output || "") + DIRECT_WORK_REMINDER
|
||||||
log(`[${HOOK_NAME}] Direct work reminder appended`, {
|
log(`[${HOOK_NAME}] Direct work reminder appended`, {
|
||||||
|
|||||||
Reference in New Issue
Block a user