mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-10 22:21:22 -07:00
fix(test): deflake flicker integration test (#11308)
This commit is contained in:
@@ -20,8 +20,8 @@ describe('Flicker Detector', () => {
|
||||
const hasUserPromptEvent = await rig.waitForTelemetryEvent('user_prompt');
|
||||
expect(hasUserPromptEvent).toBe(true);
|
||||
|
||||
const sessionCountMetric = rig.readMetric('session.count');
|
||||
expect(sessionCountMetric).not.toBeNull();
|
||||
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');
|
||||
|
||||
@@ -910,6 +910,34 @@ export class TestRig {
|
||||
return apiRequests.pop() || null;
|
||||
}
|
||||
|
||||
async waitForMetric(metricName: string, timeout?: number) {
|
||||
await this.waitForTelemetryReady();
|
||||
|
||||
const fullName = metricName.startsWith('gemini_cli.')
|
||||
? metricName
|
||||
: `gemini_cli.${metricName}`;
|
||||
|
||||
return poll(
|
||||
() => {
|
||||
const logs = this._readAndParseTelemetryLog();
|
||||
for (const logData of logs) {
|
||||
if (logData.scopeMetrics) {
|
||||
for (const scopeMetric of logData.scopeMetrics) {
|
||||
for (const metric of scopeMetric.metrics) {
|
||||
if (metric.descriptor.name === fullName) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
timeout ?? getDefaultTimeout(),
|
||||
100,
|
||||
);
|
||||
}
|
||||
|
||||
readMetric(metricName: string): Record<string, unknown> | null {
|
||||
const logs = this._readAndParseTelemetryLog();
|
||||
for (const logData of logs) {
|
||||
|
||||
Reference in New Issue
Block a user