Add test cases for the GitHub getOrganizationUsers call

Signed-off-by: Valério Valério <vdv100@gmail.com>
This commit is contained in:
Valério Valério
2025-10-07 15:30:46 +03:00
parent b0ff0d2579
commit 70666ee784
@@ -166,6 +166,54 @@ describe('github', () => {
getOrganizationUsers(graphql, 'a', 'token'),
).resolves.toEqual(output);
});
it('reads members excluding suspended users', async () => {
const input: QueryResponse = {
organization: {
membersWithRole: {
pageInfo: { hasNextPage: false },
nodes: [
{
login: 'a',
name: 'b',
bio: 'c',
email: 'd',
avatarUrl: 'e',
suspendedAt: '2025-01-01',
},
{
login: 'a',
name: 'b',
bio: 'c',
email: 'd',
avatarUrl: 'e',
suspendedAt: undefined,
},
],
},
},
};
const output = {
users: [
expect.objectContaining({
metadata: expect.objectContaining({ name: 'a', description: 'c' }),
spec: {
profile: { displayName: 'b', email: 'd', picture: 'e' },
memberOf: [],
},
}),
],
};
server.use(
graphqlMsw.query('users', () => HttpResponse.json({ data: input })),
);
await expect(
getOrganizationUsers(graphql, 'a', 'token', true),
).resolves.toEqual(output);
});
});
describe('getOrganizationUsers using custom UserTransformer', () => {
@@ -226,7 +274,13 @@ describe('github', () => {
);
await expect(
getOrganizationUsers(graphql, 'a', 'token', customUserTransformer),
getOrganizationUsers(
graphql,
'a',
'token',
false,
customUserTransformer,
),
).resolves.toEqual(output);
});
@@ -273,12 +327,69 @@ describe('github', () => {
graphql,
'a',
'token',
false,
customUserTransformer,
);
expect(users.users).toHaveLength(1);
expect(users).toEqual(output);
});
it('reads members including suspended users', async () => {
const input: QueryResponse = {
organization: {
membersWithRole: {
pageInfo: { hasNextPage: false },
nodes: [
{
login: 'a',
name: 'b',
bio: 'c',
email: 'd',
avatarUrl: 'e',
},
{
login: 'ab',
name: 'bb',
bio: 'cc',
email: 'dd',
avatarUrl: 'ee',
suspendedAt: '2025-01-01',
},
],
},
},
};
const output = {
users: [
expect.objectContaining({
metadata: expect.objectContaining({
name: 'a-custom',
}),
}),
expect.objectContaining({
metadata: expect.objectContaining({
name: 'ab-custom',
}),
}),
],
};
server.use(
graphqlMsw.query('users', () => HttpResponse.json({ data: input })),
);
await expect(
getOrganizationUsers(
graphql,
'a',
'token',
true,
customUserTransformer,
),
).resolves.toEqual(output);
});
});
describe('getOrganizationTeams using default TeamTransformer', () => {