Draft: Add membershipType argument
What does this MR do and why?
This MR adds membershipType
argument to the userAddOnAssignmentCreate
.
Following up on the discussion, this addition will help us reduce the check for valid billable membership of user to be assigned from at most 4 to 1.
There are 4 types of billable membership type that we support:
- group_member
- project_member
- group_invite
- project_invite
frontend will send the correct membership type of the user to be assigned based on the response fetched from billable_members endpoint.
Screenshots or screen recordings
Success
Failure
How to set up and validate locally
- Check out the branch
- Create a new root group namespace: "root-group"
- Setup some seed records
namespace = Namespace.last
add_on = GitlabSubscriptions::AddOn.find_or_create_by!(name: "code_suggestions") {|e| e.description = "Test"}
add_on_purchase = GitlabSubscriptions::AddOnPurchase.create!(
add_on: add_on, namespace: namespace, expires_on: 1.month.from_now, quantity: 5, purchase_xid: 'A-S0001'
)
add_on_purchase.to_global_id.to_s # "gid://gitlab/GitlabSubscriptions::AddOnPurchase/9"
# enable the feature flag
Feature.enable(:hamilton_seat_management)
- Create a subgroup for the namespace:
"sub-group"
- Go to Left Panel
Settings -> Manage -> Members -> Invite Members
- Add a user with developer role (or any role higher than guest)
- Go to graphql explorer (logged in as owner/admin): http://gdk.test:3000/-/graphql-explorer, and use following mutation with newly added user's id.
mutation {
userAddOnAssignmentCreate(
input: {
userId: "gid://gitlab/User/85",
addOnPurchaseId: "gid://gitlab/GitlabSubscriptions::AddOnPurchase/9",
membershipType: "project_member"
}) {
errors
}
}
- Check that response should be failure:
"errors": ["INVALID_USER_MEMBERSHIP"]
- Change the
membership_type
of mutation input to correct one:"group_member"
mutation {
userAddOnAssignmentCreate(
input: {
userId: "gid://gitlab/User/85",
addOnPurchaseId: "gid://gitlab/GitlabSubscriptions::AddOnPurchase/9",
membershipType: "group_member"
}) {
errors
}
}
- The response should be success:
errors: []
We can continue similar test for other scenarios too:
- Create a new project named "project-1" for the namespace, and add a new member with role greater than guest
- Run the GraphQL mutation for the new added user with
membershipType: "group_member"
first, and thenmembershipType: "project_member"
- The response should be failure first, and then success, respectively.
- Invite an existing group, say "invited-group-1" to the "sub-group" with role greater than guest
- Get the
user_id
of one of the member of "invited-group-1", and run the mutation withmembershipType: "group_invite"
- It should return success
- Invite an existing group, say "invited-group-2" to the "project-1" with role greater than guest
- Get the
user_id
of member of "invited-group-2", and run the mutation withmembershipType: "project_invite"
- It should return success
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #415584
Edited by Bishwa Hang Rai