Unfortunately, it is not possible to perform any end-to-end testing of this feature. The best you can do is to fire the event through JS from a service worker:
function triggerSubscriptionChange() {
registration.pushManager.getSubscription().then(subscription => {
if (subscription) {
console.log("subscribed, subscription", subscription);
return subscription.unsubscribe();
}
}).then(() => {
console.log("unsubscribed");
return registration.pushManager.subscribe({
userVisibleOnly: true
});
}).then(subscription => {
console.log("subscribed, subscription", subscription);
self.dispatchEvent(new ExtendableEvent("pushsubscriptionchange"));
});
}
source
share