Fix tiptap selection sync and toolbar event loop
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
use mnote_editor_core::{
|
||||
apply_ai_pipeline, EditorAiScenario, EditorInputKind, EditorPipelineRequest,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn ai_pipeline_turns_meeting_notes_into_todos() {
|
||||
let result = apply_ai_pipeline(EditorPipelineRequest {
|
||||
kind: EditorInputKind::PlainText,
|
||||
scenario: EditorAiScenario::MeetingNotesToTodos,
|
||||
input: "待办:整理会议纪要\n普通段落".into(),
|
||||
})
|
||||
.expect("pipeline should succeed");
|
||||
|
||||
assert_eq!(
|
||||
result.document.blocks()[0].block_type.as_editor_label(),
|
||||
"todo"
|
||||
);
|
||||
assert_eq!(result.audit.len(), 1);
|
||||
assert!(result
|
||||
.change_report
|
||||
.updated_blocks
|
||||
.contains(&"imported_1".to_string()));
|
||||
assert!(result.markdown.contains("待办:整理会议纪要"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ai_pipeline_refines_long_paragraph_to_title() {
|
||||
let result = apply_ai_pipeline(EditorPipelineRequest {
|
||||
kind: EditorInputKind::PlainText,
|
||||
scenario: EditorAiScenario::LongParagraphToTitle,
|
||||
input: "这是一个很长的段落 用于提炼 标题".into(),
|
||||
})
|
||||
.expect("pipeline should succeed");
|
||||
|
||||
assert_eq!(
|
||||
result.document.blocks()[0].block_type.as_editor_label(),
|
||||
"heading"
|
||||
);
|
||||
assert_eq!(result.document.blocks()[0].heading_level, Some(1));
|
||||
assert_eq!(result.audit.len(), 1);
|
||||
assert!(result
|
||||
.change_report
|
||||
.updated_blocks
|
||||
.contains(&"imported_1".to_string()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ai_pipeline_reorders_first_block_after_second() {
|
||||
let result = apply_ai_pipeline(EditorPipelineRequest {
|
||||
kind: EditorInputKind::PlainText,
|
||||
scenario: EditorAiScenario::PageReorder,
|
||||
input: "第一页\n\n第二页".into(),
|
||||
})
|
||||
.expect("pipeline should succeed");
|
||||
|
||||
assert_eq!(result.document.blocks()[0].content.text, "第二页");
|
||||
assert_eq!(result.document.blocks()[1].content.text, "第一页");
|
||||
assert_eq!(result.audit.len(), 1);
|
||||
assert_eq!(
|
||||
result.change_report.moved_blocks,
|
||||
vec!["imported_1".to_string()]
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user