Skip to content

[tests] Added basic test for leaflet plugins #492 #499#503

Merged
nemesifier merged 1 commit intomasterfrom
basic-test-leaflet-plugins
Feb 5, 2026
Merged

[tests] Added basic test for leaflet plugins #492 #499#503
nemesifier merged 1 commit intomasterfrom
basic-test-leaflet-plugins

Conversation

@nemesifier
Copy link
Copy Markdown
Member

Added basic test for leaflet plugins.

Related to #492
Related to #499

Checklist

  • I have read the OpenWISP Contributing Guidelines.
  • I have manually tested the changes proposed in this pull request.
  • I have written new test cases for new code and/or updated existing tests for changes to existing code.
  • N/A I have updated the documentation.

@nemesifier nemesifier self-assigned this Feb 5, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 5, 2026

Walkthrough

This pull request updates the netjsonmap-plugins example template with formatting adjustments, then introduces test infrastructure to verify the example works correctly. The changes consist of: whitespace and indentation corrections in the HTML template file, addition of a new URL mapping for the plugins example in the test utilities, and a new browser test case that navigates to the plugins example, verifies the presence of expected Leaflet UI elements (container, draw toolbar, polyline button, measure control), and confirms no console errors occur during rendering.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested labels

javascript

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding a basic test for leaflet plugins, with issue references included.
Description check ✅ Passed The description covers the main changes and includes all critical checklist items completed; documentation is N/A as expected for test-only changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch basic-test-leaflet-plugins

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6282229 and 630e8f9.

📒 Files selected for processing (3)
  • public/example_templates/netjsonmap-plugins.html
  • test/browser.test.utils.js
  • test/netjsongraph.browser.test.js
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{js,ts,css,scss,json}

📄 CodeRabbit inference engine (AGENTS.md)

Format code using openwisp-qa-format command with Python virtualenv enabled and yarn lint:fix (runs eslint --fix and prettier via lint-staged)

Files:

  • test/netjsongraph.browser.test.js
  • test/browser.test.utils.js
**/*.test.{js,ts}

📄 CodeRabbit inference engine (AGENTS.md)

Write unit tests using Jest with jsdom and run with yarn test

Files:

  • test/netjsongraph.browser.test.js
test/netjsongraph.browser.test.js

📄 CodeRabbit inference engine (AGENTS.md)

Write browser tests in test/netjsongraph.browser.test.js using Chrome/ChromeDriver and run with yarn test test/netjsongraph.browser.test.js

Files:

  • test/netjsongraph.browser.test.js
🧠 Learnings (2)
📚 Learning: 2026-01-22T22:37:11.271Z
Learnt from: CR
Repo: openwisp/netjsongraph.js PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-22T22:37:11.271Z
Learning: Applies to test/netjsongraph.browser.test.js : Write browser tests in test/netjsongraph.browser.test.js using Chrome/ChromeDriver and run with `yarn test test/netjsongraph.browser.test.js`

Applied to files:

  • test/netjsongraph.browser.test.js
📚 Learning: 2026-01-20T00:56:36.062Z
Learnt from: dee077
Repo: openwisp/netjsongraph.js PR: 417
File: src/js/netjsongraph.core.js:132-145
Timestamp: 2026-01-20T00:56:36.062Z
Learning: In the netjsongraph.js codebase, the data model does not support parallel links (multiple links between the same source and target). Ensure nodeLinkIndex is keyed by a single 'source~target' pair and that adding a link does not overwrite existing links for that pair. If parallel links are ever required, the data model must be changed (e.g., allow an array of links per 'source~target' key) rather than storing only one link.

Applied to files:

  • test/netjsongraph.browser.test.js
🧬 Code graph analysis (1)
test/netjsongraph.browser.test.js (1)
test/browser.test.utils.js (8)
  • urls (34-45)
  • urls (34-45)
  • getElementByCss (47-54)
  • getElementByCss (47-54)
  • captureConsoleErrors (137-142)
  • captureConsoleErrors (137-142)
  • printConsoleErrors (144-151)
  • printConsoleErrors (144-151)
🔇 Additional comments (3)
test/browser.test.utils.js (1)

44-44: LGTM!

The new leafletPlugins URL mapping follows the established pattern and correctly points to the plugins example template.

public/example_templates/netjsonmap-plugins.html (1)

30-32: LGTM!

Formatting/whitespace updates in comments only. No functional changes.

Also applies to: 59-61, 102-102

test/netjsongraph.browser.test.js (1)

526-553: LGTM!

The new test case follows established patterns and appropriately validates that Leaflet plugins (draw toolbar, polyline button, measure control) render correctly without console errors. The CSS selectors correctly target the expected plugin UI elements.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot added the javascript Pull requests that update Javascript code label Feb 5, 2026
@nemesifier nemesifier merged commit 630e8f9 into master Feb 5, 2026
8 checks passed
@nemesifier nemesifier deleted the basic-test-leaflet-plugins branch February 5, 2026 17:55
@nemesifier nemesifier mentioned this pull request Feb 5, 2026
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement javascript Pull requests that update Javascript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant