mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-23 19:44:30 -07:00
feat(cli): implement logical component tracking for visual journey testing
- Expose Ink rootNode in AppRig and render utilities for tree traversal - Add toVisuallyContain matcher to verify component presence in the Ink DOM - Inject component metadata as comments into generated SVGs for auditing - Add waitForComponent to AppRig for deterministic UI state synchronization - Implement visual journey test for SuggestionsDisplay
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2026 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
||||
import { AppRig } from '../../test-utils/AppRig.js';
|
||||
import { SuggestionsDisplay } from './SuggestionsDisplay.js';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
describe('SuggestionsDisplay UX Journey', () => {
|
||||
let rig: AppRig;
|
||||
|
||||
beforeEach(async () => {
|
||||
const fakeResponsesPath = path.join(
|
||||
__dirname,
|
||||
'..',
|
||||
'..',
|
||||
'test-utils',
|
||||
'fixtures',
|
||||
'simple.responses',
|
||||
);
|
||||
rig = new AppRig({ fakeResponsesPath });
|
||||
await rig.initialize();
|
||||
rig.render();
|
||||
await rig.waitForIdle();
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await rig.unmount();
|
||||
});
|
||||
|
||||
it('should visually show the suggestions display when / is typed', async () => {
|
||||
// Initially should not have suggestions
|
||||
expect(rig).not.toVisuallyContain(SuggestionsDisplay.name);
|
||||
|
||||
// Type '/' to trigger suggestions
|
||||
await rig.type('/');
|
||||
|
||||
// Wait for SuggestionsDisplay to appear (Automatic lookup!)
|
||||
await rig.waitForComponent(SuggestionsDisplay.name);
|
||||
|
||||
// Assert that the component is now present in the tree
|
||||
expect(rig).toVisuallyContain(SuggestionsDisplay.name);
|
||||
|
||||
// Also verify text for sanity
|
||||
expect(rig.lastFrame).toContain('about');
|
||||
|
||||
// Capture the state for manual inspection if needed
|
||||
await expect(rig).toMatchSvgSnapshot({ name: 'suggestions-opened' });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user