Skip to content

Commit

Permalink
Merge pull request #4828 from open-formulieren/cleanup/3283-remove-fd…
Browse files Browse the repository at this point in the history
…-translation-converter

💥 Drop legacy formio translation converter
  • Loading branch information
sergei-maertens authored Nov 18, 2024
2 parents 5042ea1 + 595c8ba commit 4b73a1d
Show file tree
Hide file tree
Showing 11 changed files with 100 additions and 650 deletions.
52 changes: 47 additions & 5 deletions docs/developers/backend/core/testing-tools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,78 @@
Test helpers
============

HTML assertions
Open Forms tests are built with the core Django testing helpers defined in
:mod:`django.test`, extended with some third party libraries and project-specific
helpers.

.. contents:: Helpers
:depth: 3
:local:
:backlinks: entry

Third party packages
====================

* `django-webtest <https://pypi.org/project/django-webtest/>`_: acts more like a browser
without being a full-blown browser. Very useful for admin tests, especially when
combined with `pyquery <https://pypi.org/project/pyquery/>`_.
* `hypothesis <https://pypi.org/project/hypothesis/>`_: property based testing, very
good for generating fuzzy data to catch edge cases you never would think of. See
:ref:`developers_backend_core_testing_tools_hypothesis_strategies`.


Project helpers
===============

HTML assertions
---------------

.. automodule:: openforms.utils.tests.html_assert
:members:

.. automodule:: openforms.utils.tests.webtest_base
:members:

Frontend redirects
==================
------------------

.. automodule:: openforms.frontend.tests
:members:

Migrations
==========
----------

.. automodule:: openforms.utils.tests.test_migrations
:members:

Formio assertions
=================
-----------------

.. automodule:: openforms.formio.tests.assertions
:members:
:undoc-members:

Recording HTTP traffic
======================
----------------------

.. automodule:: openforms.utils.tests.vcr
:members:

.. _developers_backend_core_testing_tools_hypothesis_strategies:

Custom Hypothesis strategies
----------------------------

General purpose strategies
~~~~~~~~~~~~~~~~~~~~~~~~~~

.. automodule:: openforms.tests.search_strategies
:members:
:undoc-members:

Formio component strategies
~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. automodule:: openforms.formio.tests.search_strategies
:members:
:undoc-members:
3 changes: 3 additions & 0 deletions docs/developers/backend/tests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ Running tests
The Open Forms backend comes with an extensive test suite to prevent regressions and
also describe intended behaviour.

.. tip:: See the :ref:`developers_backend_core_testing_tools` for a collection of
utilities that you can use when writing tests.

Running the backend tests
=========================

Expand Down
1 change: 0 additions & 1 deletion docs/developers/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ familiarize yourself with the design principles.
extending
extensions
checklists
manual_testing
i18n
csp
npm
Expand Down
42 changes: 0 additions & 42 deletions docs/developers/manual_testing.rst

This file was deleted.

42 changes: 21 additions & 21 deletions docs/developers/npm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Note that we have "two frontends":
Common tooling
==============

The common tooling applies to both Open Forms and the SDK.
The common tooling applies to Open Forms, the SDK and the supporting libraries like
the formio-builder and types repository.

**NVM**

Expand All @@ -38,6 +39,23 @@ formatting when a ``.prettierrc.json`` config file is available.

Currently, Prettier is configured to format ``.js`` and ``.scss`` files.

**Storybook**

All projects/libraries have a Storybook for the UI components. When you're working on
components that aren't in Storybook yet, please add them.

The `SDK Storybook`_ contains more technical documentation for the SDK. You can usually
run storybook with:

.. code-block:: bash
npm run storybook [-- --no-open]
Writing `interaction tests <https://storybook.js.org/docs/essentials/interactions>`_ is
recommended, but please limit those to actual interactions. For more low-level tests,
stick to writing unit tests in Jest, using
`Testing Library <https://www.npmjs.com/package/@testing-library/react>`_.

**Managing translations**

Translations are extracted from the code with helper scripts, and after the
Expand All @@ -48,9 +66,9 @@ as we're currently re-organizing the tooling here.

Cheat sheet:

* SDK: ``yarn makemessages`` and ``yarn compilemessages``
* SDK: ``npm run makemessages`` and ``npm run compilemessages``
* Backend: ``./bin/makemessages_js.sh`` and ``./bin/compilemessages_js.sh``
* Libraries: ``./bin/makemessages.sh`` and ``(yarn|npm run) compilemessages``
* Libraries: ``./bin/makemessages.sh`` and ``npm run compilemessages``

There is also a ``bin/find_untranslated_js.py`` script to point out potentially missed
translations, as the JSON file format is not too friendly to keep track of everything.
Expand All @@ -61,24 +79,6 @@ Indent sizes and other code formatting rules are specified in the ``.editorconfi
which should be supported by most editors. Possibly you need to install a plugin for it
to be activated though.

SDK toolchain
=============

See the `SDK Storybook`_ for more technical documentation.

**Yarn**

In the SDK we use yarn_ rather than NPM. There is no particular version pinned at the
moment (since the lockfile format did not recently change). The node version is pinned
in ``.nvmrc`` though.

The Yarn CLI is almost the same as NPM.

**Storybook**

We are shifting isolated/component development and interaction testing towards
storybook. Make sure to check it out and fill the gaps in documentation!

.. _nvm: https://github.com/nvm-sh/nvm
.. _yarn: https://yarnpkg.com/
.. _Prettier: https://prettier.io/
Expand Down
40 changes: 19 additions & 21 deletions src/openforms/formio/tests/search_strategies.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
"""
Expose hypothesis derived strategies to work with Formio.js data structures.
.. tip:: Use hypothesis strategies to generate random Formio form configurations to
test implementation robustness.
All the formio component definitions must be JSON-serializable. JSON in itself can
handle NULL bytes inside strings (they turn into \u0000), but JSONB as used by
postgresql and Django's model.JSONField - where we persist these component definitions -
Expand Down Expand Up @@ -373,8 +376,8 @@ def map_component():
return st.fixed_dictionaries(_minimal_component_mapping("map"), optional=optional)


def nested_components(max_size=10):
return st.lists(any_component(stop_nesting=True), max_size=max_size)
def nested_components():
return st.lists(any_component, min_size=1, max_size=5)


def edit_grid_component():
Expand Down Expand Up @@ -457,8 +460,9 @@ def cosign_v1_component():
)


def any_component(stop_nesting=False):
inputs = [
any_component = st.deferred(
lambda: st.one_of(
# INPUTS
textfield_component(),
email_component(),
date_component(),
Expand All @@ -473,8 +477,7 @@ def any_component(stop_nesting=False):
selectboxes_component(),
currency_component(),
radio_component(),
]
special = [
# SPECIAL
iban_component(),
license_plate_component(),
bsn_component(),
Expand All @@ -483,22 +486,17 @@ def any_component(stop_nesting=False):
signature_component(),
cosign_v2_component(),
map_component(),
]
# if we keep generating nested structures, we run into Python Recursion limits
if not stop_nesting:
special.append(edit_grid_component())
layout = [
edit_grid_component(),
# LAYOUT
content_component(),
]
if not stop_nesting:
layout += [
columns_component(),
fieldset_component(),
]
deprecated = [
columns_component(),
fieldset_component(),
# DEPRECATED
postcode_component(),
password_component(),
cosign_v1_component(),
]
all_types = inputs + special + layout + deprecated
return st.one_of(all_types)
)
)
"""
A search strategy returning any possible/supported Formio component dictionary.
"""
Loading

0 comments on commit 4b73a1d

Please sign in to comment.