Commit 5757bab
authored
feat(core): add add_nodes API for batch node creation (#667)
* feat(core): add add_nodes API for batch node creation\n\n- Introduce add_nodes method to add multiple nodes efficiently in a single layout pass\n- Update legacy bundle accordingly\n- Add example/test_batch_add.html to demonstrate and benchmark batch addition\n\nRefs: performance optimization for bulk node insertion
* feat: add add_nodes method for batch node creation
- Refactor add_node to use private helper methods _add_node_data and _refresh_node_ui
- Add add_nodes method for optimized batch node creation
- Improve performance by reducing layout calculations from O(n) to O(1)
- Add unit tests for add_nodes functionality
- Remove add_nodes from legacy version as suggested in PR feedback
Addresses feedback from PR #667:
- Split add_node into smaller, reusable methods
- Simplify condition checking in add_nodes
- Focus only on modern ES6 version in src/ directory
- Add comprehensive unit tests
* test: add comprehensive unit tests for add_nodes method
- Add 10 test cases covering various scenarios:
- Error handling (not editable, parent not found, invalid input)
- Core functionality (method calls, parameter passing)
- Event handling and return values
- Failed node creation scenarios
- Use mocking to avoid DOM-related issues in test environment
- Ensure proper testing of the batch node creation workflow
- All tests pass successfully
* test: enhance add_nodes unit tests with comprehensive coverage
- Add performance test for large-scale node creation (1000 nodes)
- Add complex data structure test with Unicode and multilingual support
- Add comprehensive direction handling test (13 different direction types)
- Refactor create_fake_mind to accept options parameter for better flexibility
- Remove default editable:true from create_fake_mind, require explicit declaration
- Update all test cases to explicitly pass editable:true when needed
- Ensure 100% test pass rate with improved test design and clarity
Performance improvements verified:
- Batch operations call _refresh_node_ui only once (O(1) vs O(n))
- Large node creation completes within 100ms performance threshold
- Complex data structures and Unicode characters handled correctly
Total test coverage: 13 test cases covering error handling, core functionality,
performance optimization, data integrity, and edge cases.1 parent a9a5ce8 commit 5757bab
2 files changed
Lines changed: 477 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
414 | 414 | | |
415 | 415 | | |
416 | 416 | | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
417 | 451 | | |
418 | 452 | | |
419 | 453 | | |
| |||
424 | 458 | | |
425 | 459 | | |
426 | 460 | | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | | - | |
438 | | - | |
439 | | - | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
444 | | - | |
445 | | - | |
446 | | - | |
447 | | - | |
| 461 | + | |
448 | 462 | | |
449 | 463 | | |
450 | 464 | | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
451 | 533 | | |
452 | 534 | | |
453 | 535 | | |
| |||
0 commit comments