site-kit-wp icon indicating copy to clipboard operation
site-kit-wp copied to clipboard

Test logic within notification registration

Open jimmymadon opened this issue 1 year ago • 3 comments

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 provideNotificationsRegistration util function
      • It should accept registry and extraData arguments
      • Use createNotifications with provided registry argument to include notifications into the test registry. You can check its usage in assets/js/googlesitekit-notifications.js
      • If extraData is passed, it should be object consisting of {id, settings} data, which can be forwarded to the registerNotification action of CORE_NOTIFICATIONS datastore, to include extra notification registration if needed .
  • [ ] 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

jimmymadon avatar Sep 02 '24 21:09 jimmymadon

ACs here make sense, moving to IB 🙂

tofumatt avatar Sep 03 '24 09:09 tofumatt

IB ✔️

eugene-manuilov avatar Sep 06 '24 16:09 eugene-manuilov

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.

jimmymadon avatar Sep 22 '24 11:09 jimmymadon

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.

Image

Image

SC is in gathering and Analytic is in zero

Image

Both SC and analytics is in zero data state

Image

Analytics is in gathering state and SC is in zero data state

Image

Scope Alert

Image

https://github.com/user-attachments/assets/635f2a8e-efdd-4925-a830-eb993fdacd66

mohitwp avatar Nov 11 '24 15:11 mohitwp