Open
Description
openedon Sep 2, 2024
Feature Description
In #8978 and #8979, the ErrorNotifications.test.js
require "mock" registration of notifications using the new Notifications datastore register function.
This would require us to "copy-paste" code that registers notifications within our tests. In addition to copy-pasting, the main drawback here is that our tests do not actually cover the real production registration code within register-defaults.js
. So we need a way to cover the logic within this code. We could perhaps create a utility function that wraps production registration code and adds it to a test registry.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- Reintroduce test coverage removed as part of Refactor the UnsatisfiedScopesAlert to use the new Notifications datastore and layout components #8978, Refactor
UnsatisfiedScopesAlertGTE
to use the new Notifications datastore and "layout" components #8979 and Refactor GA4AdSenseLinkedNotification to use the new Notifications datastore #9280. - Cover any other logic of rendering any notification that happens as part of the registration process.
Implementation Brief
- Update
tests/js/utils.js
- Add
provideNotificationsRegistration
util function- It should accept
registry
andextraData
arguments - Use
createNotifications
with providedregistry
argument to include notifications into the test registry. You can check its usage inassets/js/googlesitekit-notifications.js
- If
extraData
is passed, it should be object consisting of{id, settings}
data, which can be forwarded to theregisterNotification
action ofCORE_NOTIFICATIONS
datastore, to include extra notification registration if needed .
- It should accept
- Add
- Return referenced tests in AC,
provideNotificationsRegistration
util will include the notifications in the test registry so notifications can be rendered
Test Coverage
- No changes needed, issue is about tests
QA Brief
Changelog entry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment