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
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ describe('OptimizedEntryResolver', () => {
})

describe('resolve', () => {
it('returns the baseline entry and warns when no selected optimizations are provided', () => {
it('returns the baseline entry and logs at debug when no selected optimizations are provided', () => {
const result = OptimizedEntryResolver.resolve(optimizedEntryFixture)

expect(result.entry).toBe(optimizedEntryFixture)
Expand All @@ -391,13 +391,13 @@ describe('OptimizedEntryResolver', () => {
'Optimization',
`Resolving optimized entry for baseline entry ${optimizedEntryFixture.sys.id}`,
)
expect(mockedLogger.warn).toHaveBeenCalledWith(
expect(mockedLogger.debug).toHaveBeenCalledWith(
'Optimization',
`${RESOLUTION_WARNING_BASE} no selectedOptimizations exist for the current profile`,
)
})

it('returns the baseline entry and warns when the entry is not optimized', () => {
it('returns the baseline entry and logs at debug when the entry is not optimized', () => {
const nonOptimizedEntry: Entry = {
...optimizedEntryFixture,
fields: {
Expand All @@ -411,13 +411,17 @@ describe('OptimizedEntryResolver', () => {
expect(result.entry).toBe(nonOptimizedEntry)
expect(result.selectedOptimization).toBeUndefined()

expect(mockedLogger.warn).toHaveBeenCalledWith(
expect(mockedLogger.debug).toHaveBeenCalledWith(
'Optimization',
`${RESOLUTION_WARNING_BASE} entry ${nonOptimizedEntry.sys.id} is not optimized`,
)
expect(mockedLogger.warn).not.toHaveBeenCalledWith(
'Optimization',
`${RESOLUTION_WARNING_BASE} entry ${nonOptimizedEntry.sys.id} is not optimized`,
)
})

it('returns the baseline entry and warns when no optimization entry is found', () => {
it('returns the baseline entry and logs at debug when no optimization entry is found', () => {
const selectedOptimizations: SelectedOptimizationArray = getSelectedOptimizations().filter(
(selection) =>
selection.experienceId !== '2qVK4T5lnScbswoyBuGipd' &&
Expand All @@ -429,7 +433,11 @@ describe('OptimizedEntryResolver', () => {
expect(result.entry).toBe(optimizedEntryFixture)
expect(result.selectedOptimization).toBeUndefined()

expect(mockedLogger.warn).toHaveBeenCalledWith(
expect(mockedLogger.debug).toHaveBeenCalledWith(
'Optimization',
`${RESOLUTION_WARNING_BASE} could not find an optimization entry for ${optimizedEntryFixture.sys.id}`,
)
expect(mockedLogger.warn).not.toHaveBeenCalledWith(
'Optimization',
`${RESOLUTION_WARNING_BASE} could not find an optimization entry for ${optimizedEntryFixture.sys.id}`,
)
Expand Down Expand Up @@ -485,7 +493,7 @@ describe('OptimizedEntryResolver', () => {
}),
)

expect(mockedLogger.warn).toHaveBeenCalledWith(
expect(mockedLogger.debug).toHaveBeenCalledWith(
'Optimization',
`${RESOLUTION_WARNING_BASE} could not find a valid replacement variant entry for ${optimizedEntryFixture.sys.id}`,
)
Expand All @@ -510,7 +518,7 @@ describe('OptimizedEntryResolver', () => {
}),
)

expect(mockedLogger.warn).toHaveBeenCalledWith(
expect(mockedLogger.debug).toHaveBeenCalledWith(
'Optimization',
`${RESOLUTION_WARNING_BASE} could not find a valid replacement variant entry for ${optimizedEntry.sys.id}`,
)
Expand Down Expand Up @@ -698,7 +706,7 @@ describe('OptimizedEntryResolver', () => {
createSelectedOptimizationsForEmptyVariant(baselineEntry),
)

expect(mockedLogger.warn).not.toHaveBeenCalledWith(
expect(mockedLogger.debug).not.toHaveBeenCalledWith(
'Optimization',
expect.stringContaining(RESOLUTION_WARNING_BASE),
)
Expand Down Expand Up @@ -778,7 +786,7 @@ describe('OptimizedEntryResolver', () => {

expect(result.isEmptyVariant).toBeUndefined()
expect(result.entry).toBe(baselineEntry)
expect(mockedLogger.warn).toHaveBeenCalledWith(
expect(mockedLogger.debug).toHaveBeenCalledWith(
'Optimization',
expect.stringContaining(RESOLUTION_WARNING_BASE),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ export interface ResolvedDataWithOptimizationContext<
}

/**
* Base string for resolver warning messages.
* Base string for resolver debug messages.
*
* @internal
*/
const RESOLUTION_WARNING_BASE = 'Could not resolve optimized entry variant:'
const RESOLUTION_DEBUG_LOG_BASE = 'Could not resolve optimized entry variant:'

/** @internal */
function isResolvedEntryForBaseline<
Expand Down Expand Up @@ -167,12 +167,14 @@ function resolveWithContext<
logger.debug(`Resolving optimized entry for baseline entry ${entry.sys.id}`)

if (!selectedOptimizations?.length) {
logger.warn(`${RESOLUTION_WARNING_BASE} no selectedOptimizations exist for the current profile`)
logger.debug(
`${RESOLUTION_DEBUG_LOG_BASE} no selectedOptimizations exist for the current profile`,
)
return { resolvedData: { entry } }
}

if (!isResolvedOptimizedEntry(entry)) {
logger.warn(`${RESOLUTION_WARNING_BASE} entry ${entry.sys.id} is not optimized`)
logger.debug(`${RESOLUTION_DEBUG_LOG_BASE} entry ${entry.sys.id} is not optimized`)
return { resolvedData: { entry } }
}

Expand All @@ -182,8 +184,8 @@ function resolveWithContext<
})

if (!optimizationEntry) {
logger.warn(
`${RESOLUTION_WARNING_BASE} could not find an optimization entry for ${entry.sys.id}`,
logger.debug(
`${RESOLUTION_DEBUG_LOG_BASE} could not find an optimization entry for ${entry.sys.id}`,
)
return { resolvedData: { entry } }
}
Expand Down Expand Up @@ -242,8 +244,8 @@ function resolveWithContext<
})

if (!selectedVariant) {
logger.warn(
`${RESOLUTION_WARNING_BASE} could not find a valid replacement variant entry for ${entry.sys.id}`,
logger.debug(
`${RESOLUTION_DEBUG_LOG_BASE} could not find a valid replacement variant entry for ${entry.sys.id}`,
)
return resolveTo(entry)
}
Expand All @@ -267,8 +269,8 @@ function resolveWithContext<
})

if (!selectedVariantEntry) {
logger.warn(
`${RESOLUTION_WARNING_BASE} could not find a valid replacement variant entry for ${entry.sys.id}`,
logger.debug(
`${RESOLUTION_DEBUG_LOG_BASE} could not find a valid replacement variant entry for ${entry.sys.id}`,
)
return resolveTo(entry, selectedVariant)
} else {
Expand Down
Loading