Skip to content

Commit

Permalink
Fallbacks to old behaviour if no widgets version is found in config.
Browse files Browse the repository at this point in the history
  • Loading branch information
jwhardwick committed Sep 25, 2024
1 parent 8c05404 commit 3f415c8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion packages/checkout/sdk/src/widgets/version.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,18 @@ describe('CheckoutWidgets', () => {
},
{
title: 'no version config provided',
expectedVersion: 'latest',
expectedVersion: '1.2.0',
validatedBuildVersion: '1.2.0',
initVersionProvided: false,
checkoutVersionConfig: undefined,
},
{
title: 'invalid version config provided',
expectedVersion: '1.2.0',
validatedBuildVersion: '1.2.0',
initVersionProvided: false,
checkoutVersionConfig: { compatibleVersionMarkers: undefined as unknown as string[] },
},
];

determineWidgetVersionTestCases.forEach((testCase) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/checkout/sdk/src/widgets/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ export function determineWidgetsVersion(
return validatedBuildVersion;
}

// If there's no version config, default to 'latest'
// If there's version config is invalid, default to use current build version
if (!versionConfig || !Array.isArray(versionConfig.compatibleVersionMarkers)) {
return 'latest';
return validatedBuildVersion;
}

return latestCompatibleVersion(validatedBuildVersion, versionConfig.compatibleVersionMarkers);
Expand Down

0 comments on commit 3f415c8

Please sign in to comment.