fix(cli): reset themeManager between tests to ensure isolation#20598
fix(cli): reset themeManager between tests to ensure isolation#20598NTaylorMullen merged 3 commits intomainfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves an issue where test state was leaking between runs, leading to non-deterministic SVG snapshot failures. By introducing a reset mechanism for the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request addresses non-deterministic test failures by resetting the themeManager state in a beforeEach hook. The change is correct in principle, but it's incomplete as it misses resetting themes loaded from extensions, which could lead to continued state leakage between tests. I've added a suggestion to call themeManager.clearExtensionThemes() to ensure complete test isolation.
|
Size Change: +900 B (0%) Total Size: 25.8 MB ℹ️ View Unchanged
|
a0bf29a to
b3741de
Compare
13b5ec2 to
adb9fa9
Compare
adb9fa9 to
627423a
Compare
Summary
Fixes non-deterministic SVG snapshot failures in the CLI package by ensuring that
themeManagerstate (active theme and terminal background) is reset between every test run.Details
Commit
f9f916e1denabled 24-bit color in tests and introduced SVG snapshots viatoMatchSvgSnapshot. SincethemeManageris a global singleton and Vitest reuses worker processes, state from one test (e.g., setting a terminal background or active theme) would leak into subsequent tests. This led to non-deterministic hex code mismatches in SVG snapshots (e.g.,#3d3f51vs#45475a).This PR adds a
beforeEachhook topackages/cli/test-setup.tsto resetthemeManagerto its default state before every test.Related Issues
Fixes the failures reported in the Gemini CLI Maintainers chat thread.
How to Validate
packages/cli/src/ui/themes/leak.test.tsthat explicitly modifiedthemeManagerin one test and verified the leak in the next.test-setup.ts.npm test -w @google/gemini-cli) continue to pass (barring pre-existing failures onmain).Pre-Merge Checklist
Update: Added
themeManager.clearFileThemes()and ensured all theme clearing methods (clearExtensionThemes,clearFileThemes,loadCustomThemes({})) are called intest-setup.tsfor complete isolation, per code review feedback.