diff --git a/src/redux/reducers/configSlice.ts b/src/redux/reducers/configSlice.ts index e6ed195d38..cbe4aa6f84 100644 --- a/src/redux/reducers/configSlice.ts +++ b/src/redux/reducers/configSlice.ts @@ -203,7 +203,7 @@ export const getIsLightColorScheme = createSelector( // Helpers const getProductDeterminedMode = (config: { - data_request?: { products?: string[] | null } | null + data_request?: Pick['data_request'] }) => { const products = config?.data_request?.products diff --git a/src/utilities/JobSchedule.js b/src/utilities/JobSchedule.js index 0d9f421c45..37b979a623 100644 --- a/src/utilities/JobSchedule.js +++ b/src/utilities/JobSchedule.js @@ -17,16 +17,10 @@ const shouldUseComboJobs = (config, isComboJobsEnabled) => { isComboJobsEnabled && config.data_request.products.length > 0 /** - * We know the customer is using products for their URL request if this returns true. - * The only way to have multiple products using the mode/boolean strategy is to pass in - * at least one of the existing booleans along with a mode: - * - include_identity: true - * - include_transactions: true + * We know the customer is explicitly using products in their widget URL request if inferred is type-equal to false. + * When the product values are not inferred, the widget SHOULD USE COMBOJOBS for this session. */ - const customerOptedThemselvesIntoCombojobs = - config.data_request.products.length > 1 && - !config.include_identity && - !config.include_transactions + const customerOptedThemselvesIntoCombojobs = config.data_request?.inferred === false return customerIsConfiguredToUseCombojobs || customerOptedThemselvesIntoCombojobs } diff --git a/src/utilities/__tests__/JobSchedule-test.js b/src/utilities/__tests__/JobSchedule-test.js index 24f641819e..884ac2f76b 100644 --- a/src/utilities/__tests__/JobSchedule-test.js +++ b/src/utilities/__tests__/JobSchedule-test.js @@ -99,6 +99,64 @@ describe('JobSchedule.initialize', () => { }, ]) }) + + describe('combo jobs inferred logic', () => { + const member = { is_being_aggregated: false } + const recentJob = null + const isComboJobFeatureFlagOn = false // This covers the feature flag behavior, when true it means combo jobs are expected + const baseConfig = { + data_request: { + products: ['foo'], + }, + mode: undefined, + include_identity: false, + } + + test('schedules COMBINATION job when inferred is false, and single product', () => { + const config = { + ...baseConfig, + data_request: { ...baseConfig.data_request, inferred: false }, + } + const schedule = JobSchedule.initialize(member, recentJob, config, isComboJobFeatureFlagOn) + expect(schedule.jobs[0].type).toBe(JOB_TYPES.COMBINATION) + }) + + test('schedules COMBINATION job when inferred is false and multiple products', () => { + const config = { ...baseConfig, data_request: { products: ['foo', 'bar'], inferred: false } } + const schedule = JobSchedule.initialize(member, recentJob, config, isComboJobFeatureFlagOn) + expect(schedule.jobs[0].type).toBe(JOB_TYPES.COMBINATION) + }) + + test('does not schedule COMBINATION job when inferred is true, single product', () => { + const config = { ...baseConfig, data_request: { ...baseConfig.data_request, inferred: true } } + const schedule = JobSchedule.initialize(member, recentJob, config, isComboJobFeatureFlagOn) + expect(schedule.jobs[0].type).not.toBe(JOB_TYPES.COMBINATION) + }) + + test('does not schedule COMBINATION job when inferred is true, multiple products', () => { + const config = { ...baseConfig, data_request: { products: ['foo', 'bar'], inferred: true } } + const schedule = JobSchedule.initialize(member, recentJob, config, isComboJobFeatureFlagOn) + expect(schedule.jobs[0].type).not.toBe(JOB_TYPES.COMBINATION) + }) + + test('does not schedule COMBINATION job when inferred is undefined and feature flag is off', () => { + const config = { ...baseConfig, data_request: { products: ['foo', 'bar'] } } + const schedule = JobSchedule.initialize(member, recentJob, config, isComboJobFeatureFlagOn) + expect(schedule.jobs[0].type).not.toBe(JOB_TYPES.COMBINATION) + }) + + test('does schedule COMBINATION job when inferred is undefined and feature flag is on', () => { + const config = { ...baseConfig, data_request: { products: ['foo', 'bar'] } } + const schedule = JobSchedule.initialize(member, recentJob, config, true) + expect(schedule.jobs[0].type).toBe(JOB_TYPES.COMBINATION) + }) + + test('does schedule COMBINATION job when inferred is true and feature flag is on', () => { + const config = { ...baseConfig, data_request: { products: ['foo', 'bar'], inferred: true } } + const schedule = JobSchedule.initialize(member, recentJob, config, true) + expect(schedule.jobs[0].type).toBe(JOB_TYPES.COMBINATION) + }) + }) }) describe('JobSchedule.onJobFinished', () => { diff --git a/typings/connectProps.d.ts b/typings/connectProps.d.ts index ad4a4fa6a5..65a9b06c7e 100644 --- a/typings/connectProps.d.ts +++ b/typings/connectProps.d.ts @@ -64,7 +64,7 @@ interface ClientConfigType { oauth_referral_source: string update_credentials: boolean wait_for_full_aggregation: boolean - data_request?: { products?: string[] | null } | null + data_request?: { products?: string[] | null; inferred?: boolean } | null use_cases?: UseCaseType[] | null additional_product_option?: string | null show_back_button?: boolean | null