use egui::Modifiers;
use egui_kittest::kittest::Queryable;
use crate::app::{
MainView, OPEN_LABEL,
tests::{
cleanup_test_project, create_app_with_corpus, create_test_harness, open_corpus_structure,
wait_for_editor,
},
};
#[test]
fn go_back_to_start_view() {
let app_state = create_app_with_corpus(
"single_sentence",
&include_bytes!("../../../tests/data/single_sentence.graphml")[..],
);
let (mut harness, app_state) = create_test_harness(app_state);
harness.run();
open_corpus_structure("single_sentence", &mut harness, app_state.clone());
{
let app = app_state.read();
assert_eq!(MainView::CorpusStructure, app.main_view);
}
harness.key_press_modifiers(Modifiers::ALT, egui::Key::ArrowLeft);
harness.run();
{
let app = app_state.read();
assert_eq!(MainView::Start, app.main_view);
}
cleanup_test_project(app_state);
}
#[test]
fn go_back_to_corpus_structure() {
let app_state = create_app_with_corpus(
"single_sentence",
&include_bytes!("../../../tests/data/single_sentence.graphml")[..],
);
let (mut harness, app_state) = create_test_harness(app_state);
harness.run();
open_corpus_structure("single_sentence", &mut harness, app_state.clone());
harness.get_by_label("single_sentence/zossen").click();
harness.run();
harness.get_by_label(OPEN_LABEL.as_str()).click();
wait_for_editor(&mut harness, app_state.clone());
{
let app = app_state.read();
assert_eq!(
MainView::EditDocument {
node_name: "single_sentence/zossen".to_string()
},
app.main_view
);
}
harness.key_press_modifiers(Modifiers::ALT, egui::Key::ArrowLeft);
harness.run();
{
let app = app_state.read();
assert_eq!(MainView::CorpusStructure, app.main_view);
}
cleanup_test_project(app_state);
}