Skip to content
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

Move Notification Logic from Discussion Store to Firebase Functions #3620

Conversation

goratt12
Copy link
Collaborator

@goratt12 goratt12 commented Jun 3, 2024

…ebase functions

PR Checklist

PR Type

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Developer experience (improves developer workflows for contributing to the project)

Description

Move Notification Logic from Discussion Store to Firebase Functions
Added tests

Git Issues

Closes #3563

Screenshots/Videos

If useful, provide screenshot or capture to highlight main changes


What happens next?

Thanks for the contribution! We try to make sure all PRs are reviewed ahead of our monthly maintainers call (first Monday of the month)

If the PR is working as intended it'll be merged and included in the next platform release, if not changes will be requested and re-reviewed once updated.

If you need more immediate feedback you can try reaching out on Discord in the Community Platform development channel.

@goratt12 goratt12 requested a review from a team as a code owner June 3, 2024 21:06
@goratt12
Copy link
Collaborator Author

goratt12 commented Jun 3, 2024

Tested manually and it's working.
tested on both research and questions - nested and regular comments.

@davehakkens davehakkens added the Review allow-preview ✅ Has received manual check for malicious code and can be safely built for preview label Jun 3, 2024
Copy link
Contributor

github-actions bot commented Jun 3, 2024

Visit the preview URL for this PR (updated for commit 2997735):

https://onearmy-next--pr3620-3563-move-discussion-0q62o5e1.web.app

(expires Wed, 31 Jul 2024 10:24:30 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 6d65e4f8fee2f6ab2da0c1c3b85b8797d66afa59

Copy link

cypress bot commented Jun 4, 2024

3 failed tests on run #5734 ↗︎

3 74 1 0 Flakiness 0

Details:

fix(functions): changed IDiscussionComment to IComment
Project: onearmy-community-platform Commit: 570d80785b
Status: Failed Duration: 05:02 💡
Started: Jun 4, 2024 8:32 PM Ended: Jun 4, 2024 8:38 PM
Failed  src/integration/questions/discussions.spec.ts • 1 failed test • ci-chrome

View Output Video

Test Artifacts
[Questions.Discussions] > allows authenticated users to contribute to discussions Test Replay Screenshots Video
Failed  src/integration/howto/discussions.spec.ts • 1 failed test • ci-chrome

View Output Video

Test Artifacts
[Howto.Discussions] > allows authenticated users to contribute to discussions Test Replay Screenshots Video
Failed  src/integration/research/discussions.spec.ts • 1 failed test • ci-chrome

View Output Video

Test Artifacts
[Research.Discussions] > allows authenticated users to contribute to discussions Test Replay Screenshots Video

Review all test suite changes for PR #3620 ↗︎

Copy link
Member

@benfurber benfurber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one. Just leaving some code level comments initially. Especially as the cypress tests are failing (which I think we should expect as the functions the ci env are running won't include these changes) I'll checkout the branch and test myself.

functions/src/Utils/db.utils.ts Show resolved Hide resolved
)
})

it('create nested comment and notify parent comment creator - research', async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you have multiple tests that relate to research, then questions, etc. these are the right use case for a nested describle block, literally just with the name 'Research'

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I change the title from 'create nested comment and notify parent comment creator - research' to 'create nested comment and notify parent comment creator'? without the ' - research'

functions/src/discussionUpdates/index.test.ts Outdated Show resolved Hide resolved
Copy link

cypress bot commented Jun 5, 2024

1 failed and 1 flaky tests on run #5904 ↗︎

1 66 1 0 Flakiness 1

Details:

Merge branch 'master' into 3563-move-discussion-notifications-to-functions
Project: onearmy-community-platform Commit: 2997735809
Status: Failed Duration: 07:36 💡
Started: Jul 1, 2024 10:54 AM Ended: Jul 1, 2024 11:02 AM
Failed  src/integration/howto/write.spec.ts • 1 failed test • ci-chrome

View Output Video

Test Artifacts
[How To] > [Create a how-to] > [By Authenticated] Test Replay Screenshots Video
Flakiness  src/integration/settings.spec.ts • 1 flaky test • ci-chrome

View Output Video

Test Artifacts
[Settings] > [Focus Community Builder] > [Edit a new profile] Test Replay Screenshots Video

Review all test suite changes for PR #3620 ↗︎

@benfurber
Copy link
Member

I've deployed these functions to the ci env. Will rerun the tests now and hopefully all will pass...

@benfurber
Copy link
Member

@goratt12. Tests still failing unfortunately. Can I leave it to you please to confirm the functions deployed as expected, etc. and make changes accordingly?

@goratt12
Copy link
Collaborator Author

goratt12 commented Jun 7, 2024

@goratt12. Tests still failing unfortunately. Can I leave it to you please to confirm the functions deployed as expected, etc. and make changes accordingly?

Could you please give me permissions to the onearmy-test-ci Firebase project?

Copy link

codecov bot commented Jun 13, 2024

Codecov Report

Attention: Patch coverage is 95.58824% with 3 lines in your changes missing coverage. Please review.

Project coverage is 74.96%. Comparing base (1db280e) to head (3a9817c).

Current head 3a9817c differs from pull request most recent head fe8a972

Please upload reports for the commit fe8a972 to get more accurate results.

Files Patch % Lines
functions/src/discussionUpdates/index.ts 94.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3620      +/-   ##
==========================================
+ Coverage   73.68%   74.96%   +1.27%     
==========================================
  Files          41       42       +1     
  Lines        1254     1322      +68     
  Branches      253      279      +26     
==========================================
+ Hits          924      991      +67     
- Misses        308      309       +1     
  Partials       22       22              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@benfurber
Copy link
Member

@goratt12 The test comment issue, can you give more of the detail we talked about yesterday please.

Looks like you've still got a merge conflict? Happy to jump on a final manual test once that's sorted.

@mariojsnunes
Copy link
Contributor

For the tests, if they are now invoking cloud functions, maybe we could mock the request?
Did that recently here:
https://github.com/mariojsnunes/community-platform/blob/4f0e648e56a14a9560362879561798c22551bb9e/packages/cypress/src/integration/profile.spec.ts#L18-L21

@goratt12
Copy link
Collaborator Author

For the tests, if they are now invoking cloud functions, maybe we could mock the request? Did that recently here: https://github.com/mariojsnunes/community-platform/blob/4f0e648e56a14a9560362879561798c22551bb9e/packages/cypress/src/integration/profile.spec.ts#L18-L21

That's a good idea, but the functions are internally triggered by Firestore changes, so we cannot intercept them there. The problem is that the function handleDiscussionUpdate listens for changes at this path: discussions_rev20231022/{id}. In our E2E tests, the Firestore collection is {run_id}_discussions_rev20231022. We considered changing the function to listen for changes with a wildcard path, but we decided that altering the environment for the tests is not the correct approach.

@benfurber
Copy link
Member

@goratt12 We decided what to do about this didn't we? If we can't test it without big setup changes, we can't test it without big setup changes.

@benfurber benfurber added the 🤝 Awaiting author Waiting on action from the author label Jun 24, 2024
@goratt12
Copy link
Collaborator Author

@goratt12 We decided what to do about this didn't we? If we can't test it without big setup changes, we can't test it without big setup changes.

Agreed, so currently I'm leaving the relevant tests commented with the explanation

@benfurber benfurber closed this Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤝 Awaiting author Waiting on action from the author Backend Review allow-preview ✅ Has received manual check for malicious code and can be safely built for preview
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Move Notification Logic from Discussion Store to Firebase Functions
4 participants