Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra committed Dec 16, 2024
1 parent f79f738 commit f42475e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,35 +73,41 @@ describe('versionCheckerLogic', () => {
{ versionCount: 1, expectation: null },
{
versionCount: 11,
expectation: null,
},
{
versionCount: 51,
expectation: {
latestUsedVersion: '1.0.0',
latestAvailableVersion: '1.0.10',
numVersionsBehind: 10,
level: 'info',
latestAvailableVersion: '1.0.50',
numVersionsBehind: 50,
level: 'error',
},
},
{
versionCount: 15,
minorUsedVersion: 40,
versionCount: 1,
expectation: {
latestUsedVersion: '1.0.0',
latestAvailableVersion: '1.0.14',
numVersionsBehind: 14,
level: 'info',
latestAvailableVersion: '1.40.0',
numVersionsBehind: 40,
level: 'warning',
},
},
{
versionCount: 25,
majorUsedVersion: 2,
versionCount: 1,
expectation: {
latestUsedVersion: '1.0.0',
latestAvailableVersion: '1.0.24',
numVersionsBehind: 24,
level: 'error',
latestAvailableVersion: '2.0.0',
numVersionsBehind: 1,
level: 'info',
},
},
])('return a version warning if diff is great enough', async (options) => {
// TODO: How do we clear the persisted value?
const versionsList = Array.from({ length: options.versionCount }, (_, i) => ({
version: `1.0.${i}`,
version: `${options.majorUsedVersion || 1}.${options.minorUsedVersion || 0}.${i}`,
})).reverse()

useMockedVersions(
Expand Down Expand Up @@ -143,13 +149,14 @@ describe('versionCheckerLogic', () => {
},
{
usedVersions: [
{ version: '1.80.0', timestamp: '2023-01-01T12:00:00Z' },
{ version: '1.83.1-beta', timestamp: '2023-01-01T10:00:00Z' },
{ version: '1.84.0-delta', timestamp: '2023-01-01T08:00:00Z' },
{ version: '1.40.0', timestamp: '2023-01-01T12:00:00Z' },
{ version: '1.41.1-beta', timestamp: '2023-01-01T10:00:00Z' },
{ version: '1.42.0', timestamp: '2023-01-01T08:00:00Z' },
{ version: '1.42.0-delta', timestamp: '2023-01-01T08:00:00Z' },
],
expectation: {
latestUsedVersion: '1.84.0-delta',
numVersionsBehind: 1,
latestUsedVersion: '1.42.0',
numVersionsBehind: 42,
latestAvailableVersion: '1.84.0',
level: 'warning',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ export const versionCheckerLogic = kea<versionCheckerLogicType>([

if (!warning && sdkVersions && latestAvailableVersion) {
const diff = diffVersions(latestAvailableVersion, latestUsedVersion)

if (diff && diff.diff > 0) {
// there's a difference between the latest used version and the latest available version

Expand All @@ -194,8 +195,8 @@ export const versionCheckerLogic = kea<versionCheckerLogicType>([
level = numVersionsBehind >= 40 ? 'warning' : undefined
}

if (level === undefined && numVersionsBehind > 50) {
level = 'warning'
if (level === undefined && numVersionsBehind >= 50) {
level = 'error'
}

// we check if there is a "latest user version string" to avoid returning odd data in unexpected cases
Expand Down

0 comments on commit f42475e

Please sign in to comment.