You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While working on #6265, we felt a necessity to provide widget registrations to the test registry. Thus, we had come up with something like the following:
However, the above is a bit different than the convention shared by the other provide* utilities which all allow for easily providing something with sensible defaults that can be merged/overridden with customizations, but the utility itself should be useful without any (e.g. provideWidgetRegistrations( registry )).
This is a bit tricky for widgets since we don't support removing them (similar to modules). For a general widget utility like this, I'd imagine it would work very similar to the utility for module registrations (provideModuleRegistrations) which essentially iterates over all the core module JS-modules, and calls its registerModule export if it has one. This requires kind of decorating the module registration API call to allow for merging the extra data but the same should be possible here. We have the same kind of API for modules that have widgets as well via the registerWidgets export.
The difference with widgets is the hierarchical relationships between contexts, areas, and widgets which makes things a bit more complicated but still doable, however this is complicated and it seems out of scope to try and squeeze this much in at this point.
This issue is created with an aim to explore creating such an utility with the above considerations.
Feature Description
While working on #6265, we felt a necessity to provide widget registrations to the test registry. Thus, we had come up with something like the following:
site-kit-wp/tests/js/utils.js
Lines 424 to 460 in 28e454f
However, the above is a bit different than the convention shared by the other
provide*
utilities which all allow for easily providing something with sensible defaults that can be merged/overridden with customizations, but the utility itself should be useful without any (e.g.provideWidgetRegistrations( registry )
).This is a bit tricky for widgets since we don't support removing them (similar to modules). For a general widget utility like this, I'd imagine it would work very similar to the utility for module registrations (
provideModuleRegistrations
) which essentially iterates over all the core module JS-modules, and calls itsregisterModule
export if it has one. This requires kind of decorating the module registration API call to allow for merging the extra data but the same should be possible here. We have the same kind of API for modules that have widgets as well via theregisterWidgets
export.The difference with widgets is the hierarchical relationships between contexts, areas, and widgets which makes things a bit more complicated but still doable, however this is complicated and it seems out of scope to try and squeeze this much in at this point.
This issue is created with an aim to explore creating such an utility with the above considerations.
Read more here.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
Implementation Brief
Test Coverage
QA Brief
Changelog entry
The text was updated successfully, but these errors were encountered: