Test logic within notification registration
Feature Description
In #8978 and #8979, the ErrorNotifications.test.js require "mock" registration of notifications using the new Notifications datastore register function.
https://github.com/google/site-kit-wp/blob/dc0f77f42b41fa93326ebaa56c473eb2b729726f/assets/js/components/notifications/ErrorNotifications.test.js#L46-L73
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 #8978, #8979 and #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
provideNotificationsRegistrationutil function- It should accept
registryandextraDataarguments - Use
createNotificationswith providedregistryargument to include notifications into the test registry. You can check its usage inassets/js/googlesitekit-notifications.js - If
extraDatais passed, it should be object consisting of{id, settings}data, which can be forwarded to theregisterNotificationaction ofCORE_NOTIFICATIONSdatastore, to include extra notification registration if needed .
- It should accept
- Add
- [ ] Return referenced tests in AC,
provideNotificationsRegistrationutil 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
ACs here make sense, moving to IB 🙂
IB ✔️
I have bumped up the estimate here as this issue will have to fix tests from another newly refactored notification - #9280. Have updated the AC. The IB won't change here - but more work will have to be done in Execution.
QA Update ✅
- Tested on dev environment.
- Verified that gathering and zero data notification are showing as expected.
- Verified that Unsatisfied Scopes Alert notice is showing as expected.
SC is in gathering and Analytic is in zero
Both SC and analytics is in zero data state
Analytics is in gathering state and SC is in zero data state
Scope Alert
https://github.com/user-attachments/assets/635f2a8e-efdd-4925-a830-eb993fdacd66