From 96d7eb296601e3da583f8c2da6bcac3745fbef68 Mon Sep 17 00:00:00 2001 From: shishu314 Date: Tue, 4 Nov 2025 11:08:46 -0500 Subject: [PATCH] fix(infra) - Use canned response for flicker test (#12377) Co-authored-by: gemini-cli-robot --- .../flicker-detector.max-height.responses | 3 ++ integration-tests/flicker.test.ts | 38 +++++++++++-------- 2 files changed, 26 insertions(+), 15 deletions(-) create mode 100644 integration-tests/flicker-detector.max-height.responses diff --git a/integration-tests/flicker-detector.max-height.responses b/integration-tests/flicker-detector.max-height.responses new file mode 100644 index 0000000000..b905b3d866 --- /dev/null +++ b/integration-tests/flicker-detector.max-height.responses @@ -0,0 +1,3 @@ +{"method":"generateContent","response":{"candidates":[{"content":{"parts":[{"text":"{\n \"reasoning\": \"The user is asking for a simple piece of information ('a fun fact'). This is a direct, bounded request with low operational complexity and does not require strategic planning, extensive investigation, or debugging.\",\n \"model_choice\": \"flash\"\n}"}],"role":"model"},"finishReason":"STOP","index":0}],"usageMetadata":{"promptTokenCount":1173,"candidatesTokenCount":59,"totalTokenCount":1344,"promptTokensDetails":[{"modality":"TEXT","tokenCount":1173}],"thoughtsTokenCount":112}}} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"thought":true,"text":"**Locating a fun fact**\n\nI'm now searching for a fun fact using the web search tool, focusing on finding something engaging and potentially surprising. The goal is to provide a brief, interesting piece of information.\n\n\n"}],"role":"model"},"index":0}],"usageMetadata":{"promptTokenCount":12226,"totalTokenCount":12255,"promptTokensDetails":[{"modality":"TEXT","tokenCount":12226}],"thoughtsTokenCount":29}},{"candidates":[{"content":{"parts":[{"thoughtSignature":"CikB0e2Kb1vYSbIdmBfclWY7z4mOZgPxUGi3CtNXYYV9CSmG+SpVXZZkmQpZAdHtim9HVruyrUZZcHKDvIfn3j6/zLMgepC4Pqd79pG641PkPJnnCqEfVFRxmE2NX3Tj2lwRhtuIYT9Cc3CfvWGjbuuvwzynMCApxpIvxdXac/fXJYeRHTsKQQHR7Ypv6eOvWUFUTRGm1x29v8ZnGjtudG31H/Dgc65Y47c594ZJfX9RqJJil0I52Bxsm8UQ74rbARqwT7zYEbNO","functionCall":{"name":"google_web_search","args":{"query":"fun fact"}}}],"role":"model"},"finishReason":"STOP","index":0}],"usageMetadata":{"promptTokenCount":12226,"candidatesTokenCount":17,"totalTokenCount":12272,"promptTokensDetails":[{"modality":"TEXT","tokenCount":12226}],"thoughtsTokenCount":29}}]} +{"method":"generateContent","response":{"candidates":[{"content":{"parts":[{"text":"Here's a fun fact: A day on Venus is longer than a year on Venus. It takes approximately 243 Earth days for Venus to rotate once on its axis, while its orbit around the Sun is about 225 Earth days."}],"role":"model"},"finishReason":"STOP","groundingMetadata":{"searchEntryPoint":{"renderedContent":"\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n
\n
\n fun fact\n
\n
\n"},"groundingChunks":[{"web":{"uri":"https://vertexaisearch.cloud.google.com/grounding-api-redirect/AUZIYQF-NBVWZeEqhT2BixBuiSaCHeF50iewha2f3M2FfpiNsStuPxhc3sLEzXLR7IFsBbzUBO2kbUmm-usnToWabMSvOIT4ZnTXedj5ZkpwFlYyuadyuBhLNKKJQtOGgg9JTNiwvKxBWt2beHYUjelTJXfVPb0Iy8SVJTahtA3GDA==","title":"hellosubs.co"}}],"groundingSupports":[{"segment":{"startIndex":66,"endIndex":197,"text":"It takes approximately 243 Earth days for Venus to rotate once on its axis, while its orbit around the Sun is about 225 Earth days."},"groundingChunkIndices":[0]}],"webSearchQueries":["fun fact"]},"index":0}],"usageMetadata":{"promptTokenCount":8186,"candidatesTokenCount":65,"totalTokenCount":16468,"cachedContentTokenCount":5360,"promptTokensDetails":[{"modality":"TEXT","tokenCount":8186}],"cacheTokensDetails":[{"modality":"TEXT","tokenCount":5360}],"toolUsePromptTokenCount":8207,"toolUsePromptTokensDetails":[{"modality":"TEXT","tokenCount":8207}],"thoughtsTokenCount":10}}} diff --git a/integration-tests/flicker.test.ts b/integration-tests/flicker.test.ts index a7ed9fcf2e..7d6a33a3c1 100644 --- a/integration-tests/flicker.test.ts +++ b/integration-tests/flicker.test.ts @@ -6,26 +6,34 @@ import { describe, it, expect } from 'vitest'; import { TestRig } from './test-helper.js'; +import { join } from 'node:path'; describe('Flicker Detector', () => { - // TODO: https://github.com/google-gemini/gemini-cli/issues/11170 - it.skip('should not detect a flicker under the max height budget', async () => { + it('should not detect a flicker under the max height budget', async () => { const rig = new TestRig(); - await rig.setup('flicker-detector-test'); + rig.setup('flicker-detector-test', { + fakeResponsesPath: join( + import.meta.dirname, + 'flicker-detector.max-height.responses', + ), + }); + try { + const run = await rig.runInteractive(); + const prompt = 'Tell me a fun fact.'; + await run.type(prompt); + await run.type('\r'); - const run = await rig.runInteractive(); - const prompt = 'Tell me a fun fact.'; - await run.type(prompt); - await run.type('\r'); + const hasUserPromptEvent = await rig.waitForTelemetryEvent('user_prompt'); + expect(hasUserPromptEvent).toBe(true); - const hasUserPromptEvent = await rig.waitForTelemetryEvent('user_prompt'); - expect(hasUserPromptEvent).toBe(true); + const hasSessionCountMetric = await rig.waitForMetric('session.count'); + expect(hasSessionCountMetric).toBe(true); - const hasSessionCountMetric = await rig.waitForMetric('session.count'); - expect(hasSessionCountMetric).toBe(true); - - // We expect NO flicker event to be found. - const flickerMetric = rig.readMetric('ui.flicker.count'); - expect(flickerMetric).toBeNull(); + // We expect NO flicker event to be found. + const flickerMetric = rig.readMetric('ui.flicker.count'); + expect(flickerMetric).toBeNull(); + } finally { + await rig.cleanup(); + } }); });