Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/redux/reducers/configSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export const getIsLightColorScheme = createSelector(

// Helpers
const getProductDeterminedMode = (config: {
data_request?: { products?: string[] | null } | null
data_request?: Pick<ClientConfigType, 'data_request'>['data_request']
}) => {
const products = config?.data_request?.products

Expand Down
12 changes: 3 additions & 9 deletions src/utilities/JobSchedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
58 changes: 58 additions & 0 deletions src/utilities/__tests__/JobSchedule-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
2 changes: 1 addition & 1 deletion typings/connectProps.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading