mirror of
https://github.com/openai/codex.git
synced 2026-11-04 00:24:43 +00:00
## What changed - Move the migration flow, model, and source picker under the `external_agent_config_migration` module. - Keep their tests and snapshots alongside the corresponding module files and update imports and snapshot source paths. GitOrigin-RevId: 4b2f83ca689534e4d9cd1dc7aaa8424e76166bba
44 lines
1.4 KiB
Rust
44 lines
1.4 KiB
Rust
use super::*;
|
|
use crate::test_backend::VT100Backend;
|
|
use crossterm::event::KeyEvent;
|
|
use crossterm::event::KeyModifiers;
|
|
use pretty_assertions::assert_eq;
|
|
use ratatui::Terminal;
|
|
use ratatui::widgets::FrameExt;
|
|
|
|
fn new_screen() -> ExternalAgentConfigSourceScreen {
|
|
ExternalAgentConfigSourceScreen::new(
|
|
FrameRequester::test_dummy(),
|
|
&ExternalAgentConfigMigrationSource::ALL,
|
|
)
|
|
}
|
|
|
|
#[test]
|
|
fn external_agent_config_source_prompt_snapshot() {
|
|
let screen = new_screen();
|
|
let mut terminal =
|
|
Terminal::new(VT100Backend::new(/*width*/ 80, /*height*/ 12)).expect("terminal");
|
|
terminal
|
|
.draw(|frame| frame.render_widget_ref(&screen, frame.area()))
|
|
.expect("render source prompt");
|
|
insta::assert_snapshot!("external_agent_config_source_prompt", terminal.backend());
|
|
}
|
|
|
|
#[test]
|
|
fn external_agent_config_source_prompt_selects_highlighted_source() {
|
|
let mut screen = new_screen();
|
|
screen.handle_key(KeyEvent::new(KeyCode::Down, KeyModifiers::NONE));
|
|
screen.handle_key(KeyEvent::new(KeyCode::Enter, KeyModifiers::NONE));
|
|
assert_eq!(
|
|
screen.selection(),
|
|
Some(ExternalAgentConfigMigrationSource::Cur)
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn external_agent_config_source_prompt_can_cancel() {
|
|
let mut screen = new_screen();
|
|
screen.handle_key(KeyEvent::new(KeyCode::Esc, KeyModifiers::NONE));
|
|
assert_eq!(screen.selection(), None);
|
|
}
|