Skip to content

Commit

Permalink
fix: platform release version ordering
Browse files Browse the repository at this point in the history
Signed-off-by: Akos Kitta <[email protected]>
  • Loading branch information
Akos Kitta committed Jan 18, 2024
1 parent d5b0a4d commit 6f5feb3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
5 changes: 4 additions & 1 deletion arduino-ide-extension/src/node/boards-service-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,9 @@ function createBoardsPackage(
return undefined; // never show incompatible platforms
}
const { id, website, maintainer } = summary.metadata;
const availableVersions = Array.from(versionReleaseMap.keys())
.sort(Installable.Version.COMPARATOR)
.reverse();
return {
id,
name,
Expand All @@ -602,7 +605,7 @@ function createBoardsPackage(
moreInfoLink: website,
author: maintainer,
deprecated,
availableVersions: Array.from(versionReleaseMap.keys()),
availableVersions,
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DisposableCollection } from '@theia/core/lib/common/disposable';
import { Container } from '@theia/core/shared/inversify';
import { expect } from 'chai';
import { BoardSearch, BoardsService } from '../../common/protocol';
import { BoardSearch, BoardsService, Installable } from '../../common/protocol';
import { createBaseContainer, startDaemon } from './node-test-bindings';

describe('boards-service-impl', () => {
Expand All @@ -24,6 +24,29 @@ describe('boards-service-impl', () => {
expect(result).is.not.empty;
});

it('should order the available platform release versions in descending order', async function () {
const result = await boardService.search({});
result.forEach((platform) =>
platform.availableVersions.forEach(
(currentVersion, index, versions) => {
if (index < versions.length - 2) {
const nextArrayElement = versions[index + 1];
const actual = Installable.Version.COMPARATOR(
currentVersion,
nextArrayElement
);
expect(actual).to.be.greaterThan(
0,
`Expected '${currentVersion}' to be gt '${nextArrayElement}'. All versions: ${JSON.stringify(
versions
)}`
);
}
}
)
);
});

it("should boost a result when 'types' includes 'arduino', and lower the score if deprecated", async () => {
const result = await boardService.search({});
const arduinoIndexes: number[] = [];
Expand Down

0 comments on commit 6f5feb3

Please sign in to comment.