diff --git a/plugins/catalog-backend-module-github/src/lib/github.test.ts b/plugins/catalog-backend-module-github/src/lib/github.test.ts index ca9b3eb692..2af60d2bb1 100644 --- a/plugins/catalog-backend-module-github/src/lib/github.test.ts +++ b/plugins/catalog-backend-module-github/src/lib/github.test.ts @@ -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', () => {