mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
chore(core): Add inviteAcceptUrl to users list schema (#16871)
This commit is contained in:
@@ -37,6 +37,7 @@ export const userListItemSchema = z.object({
|
||||
projectRelations: z.array(userProjectSchema).nullable().optional(),
|
||||
mfaEnabled: z.boolean().optional(),
|
||||
lastActiveAt: z.string().nullable().optional(),
|
||||
inviteAcceptUrl: z.string().optional(),
|
||||
});
|
||||
|
||||
export const usersListSchema = z.object({
|
||||
|
||||
@@ -561,6 +561,55 @@ describe('GET /users', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('inviteAcceptUrl', () => {
|
||||
test('should include inviteAcceptUrl for pending users', async () => {
|
||||
// Create a pending user
|
||||
const pendingUser = await createUser({
|
||||
role: 'global:member',
|
||||
email: 'pending@n8n.io',
|
||||
firstName: 'PendingFirstName',
|
||||
lastName: 'PendingLastName',
|
||||
});
|
||||
|
||||
await userRepository.update(
|
||||
{ id: pendingUser.id },
|
||||
{
|
||||
password: null as unknown as string,
|
||||
},
|
||||
);
|
||||
|
||||
try {
|
||||
const response = await ownerAgent.get('/users').expect(200);
|
||||
|
||||
expect(response.body.data).toHaveProperty('count');
|
||||
expect(response.body.data).toHaveProperty('items');
|
||||
|
||||
// Find the pending user in the response
|
||||
const pendingUserInResponse = response.body.data.items.find(
|
||||
(user: any) => user.id === pendingUser.id,
|
||||
);
|
||||
|
||||
expect(pendingUserInResponse).toBeDefined();
|
||||
expect(pendingUserInResponse.inviteAcceptUrl).toBeDefined();
|
||||
expect(pendingUserInResponse.inviteAcceptUrl).toMatch(
|
||||
new RegExp(`/signup\\?inviterId=${owner.id}&inviteeId=${pendingUser.id}`),
|
||||
);
|
||||
|
||||
// Verify that non-pending users don't have inviteAcceptUrl
|
||||
const nonPendingUser = response.body.data.items.find(
|
||||
(user: any) => user.id === member1.id,
|
||||
);
|
||||
|
||||
expect(nonPendingUser).toBeDefined();
|
||||
expect(nonPendingUser.isPending).toBe(false);
|
||||
expect(nonPendingUser.inviteAcceptUrl).toBeUndefined();
|
||||
} finally {
|
||||
// Clean up
|
||||
await userRepository.delete({ id: pendingUser.id });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('sortBy', () => {
|
||||
test('should sort by role:asc', async () => {
|
||||
const response = await ownerAgent.get('/users').query('sortBy[]=role:asc').expect(200);
|
||||
|
||||
Reference in New Issue
Block a user