Skip to content

Commit 6df1092

Browse files
authored
Merge pull request #2681 from trycompai/tofik/cherrypick-gws-userfilter-fix
fix(gws): coerce target_org_units to array in check-user-filter
2 parents 5aa5aaf + f5e6754 commit 6df1092

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

packages/integration-platform/src/manifests/google-workspace/__tests__/check-user-filter.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,21 @@ describe('parseGoogleWorkspaceCheckUserFilter', () => {
3636
expect(config.userFilterMode).toBe('exclude');
3737
expect(config.includeSuspended).toBe(false);
3838
});
39+
40+
it('coerces a string target_org_units into an array', () => {
41+
const config = parseGoogleWorkspaceCheckUserFilter({
42+
target_org_units: '/Staff' as unknown as string[],
43+
include_suspended: 'false',
44+
});
45+
expect(config.targetOrgUnits).toEqual(['/Staff']);
46+
});
47+
48+
it('returns undefined for missing target_org_units', () => {
49+
const config = parseGoogleWorkspaceCheckUserFilter({
50+
include_suspended: 'false',
51+
});
52+
expect(config.targetOrgUnits).toBeUndefined();
53+
});
3954
});
4055

4156
describe('shouldIncludeGoogleWorkspaceUserForCheck', () => {

packages/integration-platform/src/manifests/google-workspace/check-user-filter.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ export function parseGoogleWorkspaceCheckUserFilter(
2121
variables: CheckVariableValues,
2222
): GoogleWorkspaceCheckUserFilterConfig {
2323
return {
24-
targetOrgUnits: variables.target_org_units as string[] | undefined,
24+
targetOrgUnits: Array.isArray(variables.target_org_units)
25+
? variables.target_org_units
26+
: typeof variables.target_org_units === 'string'
27+
? [variables.target_org_units]
28+
: undefined,
2529
excludedTerms: parseSyncFilterTerms(
2630
variables.sync_excluded_emails ?? variables.excluded_emails,
2731
),

0 commit comments

Comments
 (0)