-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add Pushpad provider for web push notifications #4235
Conversation
@parveshsaini @BiswaViraj @scopsy Can you please consider merging or let me know something? 2 weeks have passed and I see that other providers (posted later) are already merged. Since it costed me a lot of work, I would appreciate if you can look at it. Thanks |
@collimarco Sorry for the delay 🙏🏼 , |
Thanks for the reply! It seems that the only conflicts are the package files (some generated automatically)... Maybe it's better to fix them when you are merging this PR (to avoid further conflicts)? Otherwise please let me know what exact steps I should perform |
@collimarco, just saw the spell check CI test is also failing, please fix it by adding the words to the https://github.com/novuhq/novu/blob/next/.cspell.json file |
@@ -72,6 +72,7 @@ | |||
"@novu/netcore": "^0.19.0", | |||
"@novu/nodemailer": "^0.19.0", | |||
"@novu/one-signal": "^0.19.0", | |||
"@novu/pushpad": "^0.16.3", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"@novu/pushpad": "^0.16.3", | |
"@novu/pushpad": "^0.20.0-alpha.1", |
After fixing the merge conflicts, update this version to ^0.20.0-alpha.1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@collimarco , I think this change was removed after the rebase, can you update this and then run npm run setup:project to generate the new pnpm-lock file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BiswaViraj Ok, done! Do you need anything else for merging?
providers/pushpad/README.md
Outdated
## Usage | ||
|
||
```javascript | ||
FILL IN THE INITIALIZATION USAGE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add an example usage here
providers/pushpad/package.json
Outdated
@@ -0,0 +1,82 @@ | |||
{ | |||
"name": "@novu/pushpad", | |||
"version": "0.16.3", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"version": "0.16.3", | |
"version": "0.20.0-alpha.1", |
providers/pushpad/package.json
Outdated
"pnpm": "^7.26.0" | ||
}, | ||
"dependencies": { | ||
"@novu/stateless": "0.16.3", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"@novu/stateless": "0.16.3", | |
"@novu/stateless": "^0.20.0-alpha.1", |
import { PushpadPushProvider } from './pushpad.provider'; | ||
|
||
test('should trigger pushpad library correctly', async () => { | ||
const provider = new PushpadPushProvider({ | ||
apiKey: 'test-token', | ||
appId: '012345', | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a test case where the response is mocked,
For reference, you can check other providers spec files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add dark Square version of the logo here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add light square version of logo here.
Thanks for the suggestions! I made the requested changes. For the test I see that other providers do this for example:
However the Pushpad library uses |
@collimarco , umm, I see what you mean, it will be difficult, in that case, you can try to mock the provider's const spy = jest
.spyOn(provider, 'sendMessage')
.mockImplementation(async () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return {} as any;
}); |
@BiswaViraj Yes it's hard to test. Do you mean something like this?
That would mock the entire method and nothing is tested... that is why I omitted the test. Otherwise the only solution would be to extract this code to a separate method:
And then stub the method that instantiates the new notification. However, again, all the testing would be against a mock notification, and that is not really useful. |
hey @collimarco! 👋 thanks a lot for your contribution to Novu, we really appreciate that 🤝 A few suggestions from my side about the mocking. Basically in your tests, you need to cover the logic that is in the In order to do that you have to mock the Something like this should work:
Then in your tests, you can create the instance of the Hope this helps ;) |
@LetItRock Thanks for the suggestion, I appreciate it! I was already working on this and found a similar solution: can you check if it's ok? (test is passing) Otherwise if you prefer your code I can change it.
I only see the package files conflicting: can you please fix that when you merge the branch? Otherwise, how do you recommend to proceed? Do you want me to make a |
yes, this approach also works 🙌 but please just add one more test that will cover the case when the
you can follow the suggested steps here: https://stackoverflow.com/a/7244456/2383407, the branch that you have to merge/rebase is |
@LetItRock Yes, no problem. But I have a doubt about the Novu architecture that is blocking me: is |
If you check the |
I have:
Please merge it or let me know something. Thanks |
If you want to try the Pushpad provider directly with Novu you can create a free account:
|
hey 👋 I was able to successfully integrate Novu with a Pushpad. |
Thanks! I have fixed the error with this commit: Let me know |
Looks good, thanks! 🙌 let's see if the pipelines will pass :) |
@collimarco can you please pull the latest and resolve the conflicts? thanks! 🤝 |
@LetItRock Thanks for approving this! I already rebased everything the other day, spending a lot of time, then the branch next moved forward, and now I would need to rebase again... It's really a waste of time. Can you please rebase it when you actually merge it? Otherwise if I do the work again and you don't merge immediately it's useless... |
ok, we will handle it, thanks! ;) |
hey @collimarco! 👋 can you please give me permission to push to your fork? |
@LetItRock I have added you to the forked repository with write access. Let me know if you need anything else. |
@LetItRock Thanks for merging this! Do you know when this will become available in the next release and in your cloud version? When it becomes publicly available and released, I am planning to publish a blog post or documentation on our website. |
hey @collimarco 👋 thank you too for the contribution 🤝
that's cool, let us know about that ;) |
@LetItRock Sure, I'll let you know :) |
Here's the blog post 🎉 https://pushpad.xyz/blog/sending-web-push-notifications-from-novu-notification-center |
What change does this PR introduce?
Add Pushpad provider for web push notifications.
Why was this change needed?
Closes #4218