Skip to content

[qa] Added frontend tests #02 #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

emohk
Copy link
Contributor

@emohk emohk commented Jun 17, 2025

Added frontend tests for the flat JSON widget in Django admin using openwisp_utils.tests.SeleniumTestMixin. The following 5 unit tests are included:

  • Add row test: Simulates adding a row using the “add” button. Verifies that a new row appears and that it is correctly saved to the database after clicking save button.
  • Remove row test: Creates a sample test json document with 3 rows. Removes the second row and verifies that only 2 rows remain, while the first and third rows remain the same.
  • Toggle text area test: Verifies that clicking the “toggle textarea” button hides the form rows and add-row button, and displays the raw JSON textarea instead.
  • Editting json from textarea test: Creates a sample test json document with 3 rows. Switches to textarea mode, removes one row by editing the raw JSON, and verifies that the changes are saved correctly.
  • Widget mode and raw mode sync test: Modifies JSON in the textarea, toggles back to widget mode without saving, and checks that the changes are visible in the form row of widget mode.

Fixes #2

Added frontend tests for the flat JSON widget in Django admin using `openwisp_utils.tests.SeleniumTestMixin`. The following 5 unit tests are included:
- Add row test: Simulates adding a row using the “add” button. Verifies that a new row appears and that it is correctly saved to the database.
- Remove row test: Creates a sample test json document with 3 rows. Removes the second row and verifies that only 2 rows remain, while the first and third rows remain the same.
- Toggle text area test: Verifies that clicking the “toggle textarea” button hides the form rows and add-row button, and displays the raw JSON textarea instead.
- Editting json from textarea test: Creates a sample test json document with 3 rows. Switches to textarea mode, removes one row by editing the raw JSON, and verifies that the changes are saved correctly.
- Widget mode and raw mode sync test: Modifies JSON in the textarea, toggles back to widget mode without saving, and checks that the changes are visible in the form row of widget mode.

Fixes openwisp#2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[django-flat-json-widget] QA: add frontend tests
1 participant