mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-01 10:08:12 +08:00
Deprecate LetNodes in favor of new scope API (#1814)
* WIP * Start deprecating let nodes * Replace WasmEditorApi network imports with new Scope input * Add missing unwrap * Add #[serde(default)] to scope_injections * Restructure WasmEditorApi definition to be available as a TaggedValue * Fix text node * Use stable toolchain in nix shell again * Code review * FIx text node and remove all remaining warnings * Require executor input to be 'static --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
co-authored by
Keavon Chambers
parent
a17ed68008
commit
3657b37574
+59
-46
@@ -410,65 +410,78 @@ mod test {
|
||||
assert_eq!(layers_after_copy[5], shape_id);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[test]
|
||||
/// This test will fail when you make changes to the underlying serialization format for a document.
|
||||
async fn check_if_demo_art_opens() {
|
||||
use crate::messages::layout::utility_types::widget_prelude::*;
|
||||
fn check_if_demo_art_opens() {
|
||||
futures::executor::block_on(async {
|
||||
use crate::messages::layout::utility_types::widget_prelude::*;
|
||||
|
||||
let print_problem_to_terminal_on_failure = |value: &String| {
|
||||
println!();
|
||||
println!("-------------------------------------------------");
|
||||
println!("Failed test due to receiving a DisplayDialogError while loading a Graphite demo file.");
|
||||
println!();
|
||||
println!("DisplayDialogError details:");
|
||||
println!();
|
||||
println!("Description: {value}");
|
||||
println!("-------------------------------------------------");
|
||||
println!();
|
||||
let print_problem_to_terminal_on_failure = |value: &String| {
|
||||
println!();
|
||||
println!("-------------------------------------------------");
|
||||
println!("Failed test due to receiving a DisplayDialogError while loading a Graphite demo file.");
|
||||
println!();
|
||||
println!("DisplayDialogError details:");
|
||||
println!();
|
||||
println!("Description: {value}");
|
||||
println!("-------------------------------------------------");
|
||||
println!();
|
||||
|
||||
panic!()
|
||||
};
|
||||
panic!()
|
||||
};
|
||||
|
||||
init_logger();
|
||||
let mut editor = Editor::create();
|
||||
init_logger();
|
||||
let mut editor = Editor::create();
|
||||
|
||||
for (document_name, _, file_name) in crate::messages::dialog::simple_dialogs::ARTWORK {
|
||||
let document_serialized_content = std::fs::read_to_string(format!("../demo-artwork/{file_name}")).unwrap();
|
||||
// UNCOMMENT THIS FOR RUNNING UNDER MIRI
|
||||
//
|
||||
// let files = [
|
||||
// include_str!("../../demo-artwork/isometric-fountain.graphite"),
|
||||
// include_str!("../../demo-artwork/just-a-potted-cactus.graphite"),
|
||||
// include_str!("../../demo-artwork/procedural-string-lights.graphite"),
|
||||
// include_str!("../../demo-artwork/red-dress.graphite"),
|
||||
// include_str!("../../demo-artwork/valley-of-spires.graphite"),
|
||||
// ];
|
||||
// for (id, document_serialized_content) in files.iter().enumerate() {
|
||||
// let document_name = format!("document {id}");
|
||||
|
||||
assert_eq!(
|
||||
document_serialized_content.lines().count(),
|
||||
1,
|
||||
"Demo artwork '{document_name}' has more than 1 line (remember to open and re-save it in Graphite)",
|
||||
);
|
||||
for (document_name, _, file_name) in crate::messages::dialog::simple_dialogs::ARTWORK {
|
||||
let document_serialized_content = std::fs::read_to_string(format!("../demo-artwork/{file_name}")).unwrap();
|
||||
|
||||
let responses = editor.handle_message(PortfolioMessage::OpenDocumentFile {
|
||||
document_name: document_name.into(),
|
||||
document_serialized_content,
|
||||
});
|
||||
println!("Responses:\n{responses:#?}");
|
||||
assert_eq!(
|
||||
document_serialized_content.lines().count(),
|
||||
1,
|
||||
"Demo artwork '{document_name}' has more than 1 line (remember to open and re-save it in Graphite)",
|
||||
);
|
||||
|
||||
// Check if the graph renders
|
||||
let portfolio = &mut editor.dispatcher.message_handlers.portfolio_message_handler;
|
||||
portfolio
|
||||
.executor
|
||||
.submit_node_graph_evaluation(portfolio.documents.get_mut(&portfolio.active_document_id.unwrap()).unwrap(), glam::UVec2::ONE)
|
||||
.expect("submit_node_graph_evaluation failed");
|
||||
crate::node_graph_executor::run_node_graph().await;
|
||||
let mut messages = VecDeque::new();
|
||||
editor.poll_node_graph_evaluation(&mut messages).expect("Graph should render");
|
||||
let responses = editor.handle_message(PortfolioMessage::OpenDocumentFile {
|
||||
document_name: document_name.into(),
|
||||
document_serialized_content: document_serialized_content.into(),
|
||||
});
|
||||
|
||||
for response in responses {
|
||||
// Check for the existence of the file format incompatibility warning dialog after opening the test file
|
||||
if let FrontendMessage::UpdateDialogColumn1 { layout_target: _, diff } = response {
|
||||
if let DiffUpdate::SubLayout(sub_layout) = &diff[0].new_value {
|
||||
if let LayoutGroup::Row { widgets } = &sub_layout[0] {
|
||||
if let Widget::TextLabel(TextLabel { value, .. }) = &widgets[0].widget {
|
||||
print_problem_to_terminal_on_failure(value);
|
||||
// Check if the graph renders
|
||||
let portfolio = &mut editor.dispatcher.message_handlers.portfolio_message_handler;
|
||||
portfolio
|
||||
.executor
|
||||
.submit_node_graph_evaluation(portfolio.documents.get_mut(&portfolio.active_document_id.unwrap()).unwrap(), glam::UVec2::ONE)
|
||||
.expect("submit_node_graph_evaluation failed");
|
||||
crate::node_graph_executor::run_node_graph().await;
|
||||
let mut messages = VecDeque::new();
|
||||
editor.poll_node_graph_evaluation(&mut messages).expect("Graph should render");
|
||||
|
||||
for response in responses {
|
||||
// Check for the existence of the file format incompatibility warning dialog after opening the test file
|
||||
if let FrontendMessage::UpdateDialogColumn1 { layout_target: _, diff } = response {
|
||||
if let DiffUpdate::SubLayout(sub_layout) = &diff[0].new_value {
|
||||
if let LayoutGroup::Row { widgets } = &sub_layout[0] {
|
||||
if let Widget::TextLabel(TextLabel { value, .. }) = &widgets[0].widget {
|
||||
print_problem_to_terminal_on_failure(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user