Integration test for UI flickers (#11067)

This commit is contained in:
Shreya Keshive
2025-10-14 11:41:43 -07:00
committed by GitHub
parent 99c7108bb0
commit 0a3e492e6b
2 changed files with 32 additions and 2 deletions

View File

@@ -0,0 +1,30 @@
/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import { describe, it, expect } from 'vitest';
import { TestRig } from './test-helper.js';
describe('Flicker Detector', () => {
it('should not detect a flicker under the max height budget', async () => {
const rig = new TestRig();
await rig.setup('flicker-detector-test');
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 sessionCountMetric = rig.readMetric('session.count');
expect(sessionCountMetric).not.toBeNull();
// We expect NO flicker event to be found.
const flickerMetric = rig.readMetric('ui.flicker.count');
expect(flickerMetric).toBeNull();
});
});

View File

@@ -545,7 +545,7 @@ export class TestRig {
try {
const content = readFileSync(logFilePath, 'utf-8');
// Check if file has meaningful content (at least one complete JSON object)
return content.includes('"event.name"');
return content.includes('"scopeMetrics"');
} catch {
return false;
}
@@ -908,7 +908,7 @@ export class TestRig {
const options: pty.IPtyForkOptions = {
name: 'xterm-color',
cols: 80,
rows: 30,
rows: 24,
cwd: this.testDir!,
env: Object.fromEntries(
Object.entries(env).filter(([, v]) => v !== undefined),