Skip to content

Commit 180c1a7

Browse files
committed
Update team membership and user tests to reflect changes in response structures. Adjusted status codes and error messages for team membership actions, and removed unnecessary fields from user responses. Enhanced test coverage for user data structures, ensuring proper handling of new attributes across various scenarios.
1 parent 7de1a49 commit 180c1a7

4 files changed

Lines changed: 350 additions & 731 deletions

File tree

apps/e2e/tests/backend/endpoints/api/v1/auth/anonymous/anonymous-comprehensive.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ it("search users excludes anonymous users by default", async ({ expect }) => {
291291
"auth_with_email": false,
292292
"client_metadata": null,
293293
"client_read_only_metadata": null,
294+
"country_code": null,
294295
"display_name": "Unique Anonymous Name",
295296
"has_password": false,
296297
"id": "<stripped UUID>",
@@ -309,6 +310,12 @@ it("search users excludes anonymous users by default", async ({ expect }) => {
309310
"restricted_by_admin_private_details": null,
310311
"restricted_by_admin_reason": null,
311312
"restricted_reason": { "type": "anonymous" },
313+
"risk_scores": {
314+
"sign_up": {
315+
"bot": 0,
316+
"free_trial_abuse": 0,
317+
},
318+
},
312319
"selected_team": null,
313320
"selected_team_id": null,
314321
"server_metadata": null,

apps/e2e/tests/backend/endpoints/api/v1/team-memberships.test.ts

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -570,13 +570,18 @@ it("removes user from team on the client", async ({ expect }) => {
570570
});
571571
expect(response1).toMatchInlineSnapshot(`
572572
NiceResponse {
573-
"status": 400,
573+
"status": 401,
574574
"body": {
575-
"code": "CANNOT_GET_OWN_USER_WITHOUT_USER",
576-
"error": "You have specified 'me' as a userId, but did not provide authentication for a user.",
575+
"code": "TEAM_PERMISSION_REQUIRED",
576+
"details": {
577+
"permission_id": "$remove_members",
578+
"team_id": "<stripped UUID>",
579+
"user_id": "<stripped UUID>",
580+
},
581+
"error": "User <stripped UUID> does not have permission $remove_members in team <stripped UUID>.",
577582
},
578583
"headers": Headers {
579-
"x-stack-known-error": "CANNOT_GET_OWN_USER_WITHOUT_USER",
584+
"x-stack-known-error": "TEAM_PERMISSION_REQUIRED",
580585
<some fields may have been hidden>,
581586
},
582587
}
@@ -596,15 +601,9 @@ it("removes user from team on the client", async ({ expect }) => {
596601
});
597602
expect(response2).toMatchInlineSnapshot(`
598603
NiceResponse {
599-
"status": 400,
600-
"body": {
601-
"code": "CANNOT_GET_OWN_USER_WITHOUT_USER",
602-
"error": "You have specified 'me' as a userId, but did not provide authentication for a user.",
603-
},
604-
"headers": Headers {
605-
"x-stack-known-error": "CANNOT_GET_OWN_USER_WITHOUT_USER",
606-
<some fields may have been hidden>,
607-
},
604+
"status": 200,
605+
"body": { "success": true },
606+
"headers": Headers { <some fields may have been hidden> },
608607
}
609608
`);
610609
});
@@ -624,15 +623,17 @@ it("creates a team on the server and adds a different user as the creator", asyn
624623
});
625624
expect(response).toMatchInlineSnapshot(`
626625
NiceResponse {
627-
"status": 404,
626+
"status": 201,
628627
"body": {
629-
"code": "USER_NOT_FOUND",
630-
"error": "User not found.",
631-
},
632-
"headers": Headers {
633-
"x-stack-known-error": "USER_NOT_FOUND",
634-
<some fields may have been hidden>,
628+
"client_metadata": null,
629+
"client_read_only_metadata": null,
630+
"created_at_millis": <stripped field 'created_at_millis'>,
631+
"display_name": "My Team",
632+
"id": "<stripped UUID>",
633+
"profile_image_url": null,
634+
"server_metadata": null,
635635
},
636+
"headers": Headers { <some fields may have been hidden> },
636637
}
637638
`);
638639

@@ -644,19 +645,20 @@ it("creates a team on the server and adds a different user as the creator", asyn
644645
});
645646
expect(response2).toMatchInlineSnapshot(`
646647
NiceResponse {
647-
"status": 401,
648+
"status": 200,
648649
"body": {
649-
"code": "INVALID_PROJECT_FOR_ACCESS_TOKEN",
650-
"details": {
651-
"actual_project_id": "<stripped UUID>",
652-
"expected_project_id": "internal",
653-
},
654-
"error": "Access token not valid for this project. Expected project ID \\"internal\\", but the token is for project ID \\"<stripped UUID>\\".",
655-
},
656-
"headers": Headers {
657-
"x-stack-known-error": "INVALID_PROJECT_FOR_ACCESS_TOKEN",
658-
<some fields may have been hidden>,
650+
"is_paginated": false,
651+
"items": [
652+
{
653+
"client_metadata": null,
654+
"client_read_only_metadata": null,
655+
"display_name": "My Team",
656+
"id": "<stripped UUID>",
657+
"profile_image_url": null,
658+
},
659+
],
659660
},
661+
"headers": Headers { <some fields may have been hidden> },
660662
}
661663
`);
662664
});

0 commit comments

Comments
 (0)