Skip to content

Conversation

@pawellewandowski98
Copy link
Contributor

@pawellewandowski98 pawellewandowski98 commented Feb 26, 2025

Description:

  • Migrate contact endpoints to v2 version (user and admin)
  • Create new UserContacts table
  • Create v2 contacts service and repository
  • Cover all endpoints in tests

Pull Request Checklist

  • 📖 I created my PR using provided : CODE_STANDARDS
  • 📖 I have read the short Code of Conduct: CODE_OF_CONDUCT
  • 🏠 I tested my changes locally.
  • ✅ I have provided tests for my changes.
  • 📝 I have used conventional commits.
  • 📗 I have updated any related documentation.
  • 💾 PR was issued based on the Github or Jira issue.

@pawellewandowski98 pawellewandowski98 self-assigned this Feb 26, 2025
@github-actions
Copy link

Manual Tests

ℹ️ Remember to ask team members to perform manual tests and to assign tested label after testing.

@pawellewandowski98 pawellewandowski98 marked this pull request as ready for review March 5, 2025 09:55
@pawellewandowski98 pawellewandowski98 requested a review from a team as a code owner March 5, 2025 09:55
@codecov-commenter
Copy link

codecov-commenter commented Mar 5, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 9.10152% with 1558 lines in your changes missing coverage. Please review.

Project coverage is 32.68%. Comparing base (3ad6ae4) to head (7cc7c62).

Files with missing lines Patch % Lines
api/gen.models.go 0.00% 674 Missing ⚠️
engine/v2/contacts/contacts_service.go 0.00% 294 Missing ⚠️
api/gen.api.go 0.00% 263 Missing ⚠️
engine/v2/database/repository/contacts.go 0.00% 143 Missing ⚠️
engine/testabilities/fixture_contacts.go 0.00% 52 Missing ⚠️
actions/v2/internal/mapping/contact.go 0.00% 23 Missing ⚠️
actions/v2/contacts/upsert.go 64.28% 11 Missing and 4 partials ⚠️
...ngine/v2/paymailserver/paymail_service_provider.go 0.00% 12 Missing ⚠️
engine/tester/jsonrequire/getter.go 0.00% 10 Missing ⚠️
engine/testabilities/fixture_engine.go 0.00% 9 Missing ⚠️
... and 17 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #931      +/-   ##
==========================================
- Coverage   34.50%   32.68%   -1.83%     
==========================================
  Files         437      457      +20     
  Lines       20826    22469    +1643     
==========================================
+ Hits         7186     7343     +157     
- Misses      13041    14511    +1470     
- Partials      599      615      +16     
Flag Coverage Δ
unittests 32.68% <9.10%> (-1.83%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ions/testabilities/assert_spvwallet_application.go 0.00% <ø> (ø)
actions/v2/admin/contacts/accept.go 100.00% <100.00%> (ø)
actions/v2/admin/contacts/reject.go 100.00% <100.00%> (ø)
actions/v2/admin/contacts/server.go 100.00% <100.00%> (ø)
actions/v2/admin/contacts/update.go 100.00% <100.00%> (ø)
actions/v2/admin/server.go 100.00% <100.00%> (ø)
actions/v2/contacts/server.go 100.00% <100.00%> (ø)
engine/v2/database/user.go 0.00% <ø> (ø)
actions/v2/api.go 0.00% <0.00%> (ø)
engine/v2/database/dbquery/paginate.go 0.00% <0.00%> (ø)
... and 25 more

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3ad6ae4...7cc7c62. Read the comment docs.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.


// when:
res, _ := client.R().
Post("/api/v2/admin/invitations/" + strconv.Itoa(int(contact.ID)))
Copy link
Contributor

@chris-4chain chris-4chain Mar 5, 2025

Choose a reason for hiding this comment

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

Suggested change
Post("/api/v2/admin/invitations/" + strconv.Itoa(int(contact.ID)))
Post(fmt.Sprintf("/api/v2/admin/invitations/%d",contact.ID))

Also, applicable to other, similar places.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

}

// ContactsFixture is a test fixture for the contacts service
type ContactsFixture interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would rename it to UserFixture because, in the future, it might be extended by other, not-contact-related features.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

return contact
}

func (f *contactFixture) removeContactIfExists(userB fixtures.User) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would try to avoid situations when fixtures need to remove/clear some data (most probably after previous test case).

Maybe you should separate test cases and avoid givenForAllTests and create "fresh" given for each case (given, when := testabilities.New())

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, removed deleting contact and created fresh tests where it was required

"status": contactsmodels.ContactNotConfirmed,
})

// and:
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove unnecessary and

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


// AdminAcceptInvitation accepts an invitation from a contact.
func (s *APIAdminContacts) AdminAcceptInvitation(c *gin.Context, id uint) {
contact, err := s.engine.ContactService().AcceptContactByID(c.Request.Context(), id)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
contact, err := s.engine.ContactService().AcceptContactByID(c.Request.Context(), id)
contact, err := s.engine.ContactService().AcceptContactByID(c, id)

And for other, similar places.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

then.Response(res).IsOK()

// and:
// when:
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove unnecessary // and:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

}`, map[string]any{
"code": spverrors.ErrNotAnAdminKey.Code,
"message": spverrors.ErrNotAnAdminKey.Message,
})
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

)

// AdminGetContacts returns a list of contacts for the admin.
func (s *APIAdminContacts) AdminGetContacts(c *gin.Context, params api.AdminGetContactsParams) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@mgosek-4chain is doing a task for filters and pagination.
I would postpone this after he finishes.

For now, I would suggest to remove all code/endpoints related to this and create a task for the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, removed endpoints but created a copy of the branch (feat/add-contacts-search-v2) to use them when new changes will be merged


import "gorm.io/gorm"

func mapConditionsToScopes(conditions map[string]interface{}) []func(tx *gorm.DB) *gorm.DB {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be handled differently. And, as I said above - it is already been researched by @mgosek-4chain.

I would remove this function for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants