use opi_ai::message::InputContent;
use opi_ai::test_support::{MockProvider, text_response};
use opi_coding_agent::config::OpiConfig;
use opi_coding_agent::harness::CodingHarness;
#[test]
fn image_slash_command_queues_for_next_prompt() {
let provider = Box::new(MockProvider::new("mock", vec![text_response("ok")]));
let config = OpiConfig::default();
let mut harness = CodingHarness::new(
provider,
"mock:test".into(),
config,
std::env::current_dir().unwrap(),
);
let dir = tempfile::tempdir().unwrap();
let png_path = dir.path().join("test.png");
let minimal_png_bytes: Vec<u8> = vec![
0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x02, 0x00, 0x00, 0x00, 0x90, 0x77, 0x53, 0xDE, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE, 0x42, 0x60, 0x82, ];
std::fs::write(&png_path, &minimal_png_bytes).unwrap();
let img = opi_coding_agent::image::load_image_with_limit(
&png_path,
opi_coding_agent::image::DEFAULT_MAX_IMAGE_BYTES,
)
.unwrap();
harness.queue_images(vec![img]);
let pending = harness.take_pending_images();
assert_eq!(pending.len(), 1);
match &pending[0] {
InputContent::Image { media_type, .. } => {
assert_eq!(*media_type, opi_ai::message::MediaType::Png);
}
other => panic!("expected Image content, got: {other:?}"),
}
}