Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

test: add delete node test

Lucas.Xu9e4227d3d2b3
diff --git a/frontend/app_flowy/packages/flowy_editor/assets/document.json b/frontend/app_flowy/packages/flowy_editor/assets/document.json
index 715b6c4e64..8aa75717ac 100644
--- a/frontend/app_flowy/packages/flowy_editor/assets/document.json
+++ b/frontend/app_flowy/packages/flowy_editor/assets/document.json
@@ -14,6 +14,13 @@
"tag": "*"
},
"children": [
+ {
+ "type": "text",
+ "attributes": {
+ "text-type": "heading2",
+ "check": true
+ }
+ },
{
"type": "text",
"attributes": {
diff --git a/frontend/app_flowy/packages/flowy_editor/test/flowy_editor_test.dart b/frontend/app_flowy/packages/flowy_editor/test/flowy_editor_test.dart
index 8e3c93b865..e8f14bc9c7 100644
--- a/frontend/app_flowy/packages/flowy_editor/test/flowy_editor_test.dart
+++ b/frontend/app_flowy/packages/flowy_editor/test/flowy_editor_test.dart
@@ -42,19 +42,22 @@ void main() {
final String response = await rootBundle.loadString('assets/document.json');
final data = Map<String, Object>.from(json.decode(response));
final stateTree = StateTree.fromJson(data);
- final deletedNode = stateTree.delete([1, 0]);
+ final deletedNode = stateTree.delete([1, 1]);
expect(deletedNode != null, true);
expect(deletedNode!.attributes['text-type'], 'check-box');
+ final node = stateTree.nodeAtPath([1, 1]);
+ expect(node != null, true);
+ expect(node!.attributes['tag'], '**');
});
test('update node in state tree', () async {
final String response = await rootBundle.loadString('assets/document.json');
final data = Map<String, Object>.from(json.decode(response));
final stateTree = StateTree.fromJson(data);
- final attributes = stateTree.update([1, 0], {'text-type': 'heading1'});
+ final attributes = stateTree.update([1, 1], {'text-type': 'heading1'});
expect(attributes != null, true);
expect(attributes!['text-type'], 'check-box');
- final updatedNode = stateTree.nodeAtPath([1, 0]);
+ final updatedNode = stateTree.nodeAtPath([1, 1]);
expect(updatedNode != null, true);
expect(updatedNode!.attributes['text-type'], 'heading1');
});