-
Notifications
You must be signed in to change notification settings - Fork 12k
fix: atoms e2e test selected managed user #23919
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
Changes from all commits
d598072
ce7b865
cf0d296
2fa5715
5c7aee3
e603771
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -111,10 +111,10 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse< | |
| throw new Error("Failed to create team. Probably your platform team does not have required plan."); | ||
| } | ||
|
|
||
| await createOrgTeamMembershipMember(+organizationId, team.id, managedUserResponseOne.user.id); | ||
| await createOrgTeamMembershipMember(+organizationId, team.id, managedUserResponseTwo.user.id); | ||
| await createOrgTeamMembershipMember(+organizationId, team.id, managedUserResponseThree.user.id); | ||
| await createOrgTeamMembershipMember(+organizationId, team.id, managedUserResponseFour.user.id); | ||
| await createOrgTeamMembershipMember(+organizationId, team.id, managedUserResponseOne.user.id, "MEMBER"); | ||
| await createOrgTeamMembershipMember(+organizationId, team.id, managedUserResponseTwo.user.id, "MEMBER"); | ||
| await createOrgTeamMembershipMember(+organizationId, team.id, managedUserResponseThree.user.id, "MEMBER"); | ||
| await createOrgTeamMembershipMember(+organizationId, team.id, managedUserResponseFour.user.id, "MEMBER"); | ||
|
|
||
| await createCollectiveEventType(+organizationId, team.id, [ | ||
| managedUserResponseOne.user.id, | ||
|
|
@@ -133,10 +133,10 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse< | |
| await createOrgMembershipAdmin(+organizationId, managedUserResponseFive.user.id); | ||
|
|
||
| return res.status(200).json({ | ||
| id: managedUserResponseOne?.user?.id, | ||
| email: (managedUserResponseOne.user.email as string) ?? "", | ||
| username: (managedUserResponseOne.user.username as string) ?? "", | ||
| accessToken: (managedUserResponseOne.accessToken as string) ?? "", | ||
| id: managedUserResponseFive?.user?.id, | ||
| email: (managedUserResponseFive.user.email as string) ?? "", | ||
| username: (managedUserResponseFive.user.username as string) ?? "", | ||
| accessToken: (managedUserResponseFive.accessToken as string) ?? "", | ||
|
Comment on lines
+136
to
+139
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. managed user 5 is the admin with permission to create team event types
Comment on lines
+136
to
+139
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guard against undefined managed user response to avoid runtime crash; then return non-null fields.
- id: managedUserResponseFive?.user?.id,
- email: (managedUserResponseFive.user.email as string) ?? "",
- username: (managedUserResponseFive.user.username as string) ?? "",
- accessToken: (managedUserResponseFive.accessToken as string) ?? "",
+ id: managedUserResponseFive.user.id,
+ email: managedUserResponseFive.user.email as string,
+ username: managedUserResponseFive.user.username as string,
+ accessToken: managedUserResponseFive.accessToken as string,Add this guard just above the return (outside the hunk): if (
!managedUserResponseFive ||
!managedUserResponseFive.user?.id ||
!managedUserResponseFive.user?.email ||
!managedUserResponseFive.user?.username ||
!managedUserResponseFive.accessToken
) {
throw new Error("Failed to create/select Lauris managed user: missing required fields.");
}🤖 Prompt for AI Agents |
||
| }); | ||
| } | ||
|
|
||
|
|
@@ -165,7 +165,12 @@ async function createTeam(orgId: number, name: string) { | |
| return body.data; | ||
| } | ||
|
|
||
| async function createOrgTeamMembershipMember(orgId: number, teamId: number, userId: number) { | ||
| async function createOrgTeamMembershipMember( | ||
| orgId: number, | ||
| teamId: number, | ||
| userId: number, | ||
| role: "MEMBER" | "ADMIN" = "MEMBER" | ||
| ) { | ||
| await fetch( | ||
| // eslint-disable-next-line turbo/no-undeclared-env-vars | ||
| `${process.env.NEXT_PUBLIC_CALCOM_API_URL ?? ""}/organizations/${orgId}/teams/${teamId}/memberships`, | ||
|
|
@@ -182,7 +187,7 @@ async function createOrgTeamMembershipMember(orgId: number, teamId: number, user | |
| body: JSON.stringify({ | ||
| userId, | ||
| accepted: true, | ||
| role: "MEMBER", | ||
| role, | ||
| }), | ||
| } | ||
| ); | ||
|
|
||
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.
default value was not selected properly