Skip to content

Commit

Permalink
Merge pull request #38271 from ShridharGoel/patch-1
Browse files Browse the repository at this point in the history
[NoQA] Add performance tests for getMemberAccountIDsForWorkspace
  • Loading branch information
mountiny authored Mar 18, 2024
2 parents 9e40a11 + de6946b commit e737a63
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/perf-test/PolicyUtils.perf-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import {measureFunction} from 'reassure';
import {getMemberAccountIDsForWorkspace} from '@libs/PolicyUtils';
import type {PersonalDetails, PolicyMember} from '@src/types/onyx';
import createCollection from '../utils/collections/createCollection';
import createPersonalDetails from '../utils/collections/personalDetails';
import createRandomPolicyMember from '../utils/collections/policyMembers';

describe('PolicyUtils', () => {
describe('getMemberAccountIDsForWorkspace', () => {
test('500 policy members with personal details', async () => {
const policyMembers = createCollection<PolicyMember>(
(_, index) => index,
() => createRandomPolicyMember(),
);
const personalDetails = createCollection<PersonalDetails>((_, index) => index, createPersonalDetails);

await measureFunction(() => getMemberAccountIDsForWorkspace(policyMembers, personalDetails));
});

test('500 policy members with errors and personal details', async () => {
const policyMembers = createCollection<PolicyMember>(
(_, index) => index,
() => ({
...createRandomPolicyMember(),
errors: {error: 'Error message'},
}),
);
const personalDetails = createCollection<PersonalDetails>((_, index) => index, createPersonalDetails);

await measureFunction(() => getMemberAccountIDsForWorkspace(policyMembers, personalDetails));
});
});
});
9 changes: 9 additions & 0 deletions tests/utils/collections/policyMembers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {randWord} from '@ngneat/falso';
import type {PolicyMember} from '@src/types/onyx';

export default function createRandomPolicyMember(): PolicyMember {
return {
role: randWord(),
errors: {},
};
}

0 comments on commit e737a63

Please sign in to comment.