Path: blob/main/src/vs/platform/extensionManagement/test/common/extensionGalleryService.test.ts
5283 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import assert from 'assert';6import { joinPath } from '../../../../base/common/resources.js';7import { URI } from '../../../../base/common/uri.js';8import { isUUID } from '../../../../base/common/uuid.js';9import { mock } from '../../../../base/test/common/mock.js';10import { IConfigurationService } from '../../../configuration/common/configuration.js';11import { TestConfigurationService } from '../../../configuration/test/common/testConfigurationService.js';12import { IEnvironmentService } from '../../../environment/common/environment.js';13import { IRawGalleryExtensionVersion, sortExtensionVersions, filterLatestExtensionVersionsForTargetPlatform } from '../../common/extensionGalleryService.js';14import { IFileService } from '../../../files/common/files.js';15import { FileService } from '../../../files/common/fileService.js';16import { InMemoryFileSystemProvider } from '../../../files/common/inMemoryFilesystemProvider.js';17import { NullLogService } from '../../../log/common/log.js';18import product from '../../../product/common/product.js';19import { IProductService } from '../../../product/common/productService.js';20import { resolveMarketplaceHeaders } from '../../../externalServices/common/marketplace.js';21import { InMemoryStorageService, IStorageService } from '../../../storage/common/storage.js';22import { TelemetryConfiguration, TELEMETRY_SETTING_ID } from '../../../telemetry/common/telemetry.js';23import { TargetPlatform } from '../../../extensions/common/extensions.js';24import { NullTelemetryService } from '../../../telemetry/common/telemetryUtils.js';25import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../base/test/common/utils.js';2627class EnvironmentServiceMock extends mock<IEnvironmentService>() {28override readonly serviceMachineIdResource: URI;29constructor(serviceMachineIdResource: URI) {30super();31this.serviceMachineIdResource = serviceMachineIdResource;32this.isBuilt = true;33}34}3536suite('Extension Gallery Service', () => {37const disposables = ensureNoDisposablesAreLeakedInTestSuite();38let fileService: IFileService, environmentService: IEnvironmentService, storageService: IStorageService, productService: IProductService, configurationService: IConfigurationService;3940setup(() => {41const serviceMachineIdResource = joinPath(URI.file('tests').with({ scheme: 'vscode-tests' }), 'machineid');42environmentService = new EnvironmentServiceMock(serviceMachineIdResource);43fileService = disposables.add(new FileService(new NullLogService()));44const fileSystemProvider = disposables.add(new InMemoryFileSystemProvider());45disposables.add(fileService.registerProvider(serviceMachineIdResource.scheme, fileSystemProvider));46storageService = disposables.add(new InMemoryStorageService());47configurationService = new TestConfigurationService({ [TELEMETRY_SETTING_ID]: TelemetryConfiguration.ON });48configurationService.updateValue(TELEMETRY_SETTING_ID, TelemetryConfiguration.ON);49productService = { _serviceBrand: undefined, ...product, enableTelemetry: true };50});5152test('marketplace machine id', async () => {53const headers = await resolveMarketplaceHeaders(product.version, productService, environmentService, configurationService, fileService, storageService, NullTelemetryService);54assert.ok(headers['X-Market-User-Id']);55assert.ok(isUUID(headers['X-Market-User-Id']));56const headers2 = await resolveMarketplaceHeaders(product.version, productService, environmentService, configurationService, fileService, storageService, NullTelemetryService);57assert.strictEqual(headers['X-Market-User-Id'], headers2['X-Market-User-Id']);58});5960test('sorting single extension version without target platform', async () => {61const actual = [aExtensionVersion('1.1.2')];62const expected = [...actual];63sortExtensionVersions(actual, TargetPlatform.DARWIN_X64);64assert.deepStrictEqual(actual, expected);65});6667test('sorting single extension version with preferred target platform', async () => {68const actual = [aExtensionVersion('1.1.2', TargetPlatform.DARWIN_X64)];69const expected = [...actual];70sortExtensionVersions(actual, TargetPlatform.DARWIN_X64);71assert.deepStrictEqual(actual, expected);72});7374test('sorting single extension version with not compatible target platform', async () => {75const actual = [aExtensionVersion('1.1.2', TargetPlatform.DARWIN_ARM64)];76const expected = [...actual];77sortExtensionVersions(actual, TargetPlatform.WIN32_X64);78assert.deepStrictEqual(actual, expected);79});8081test('sorting multiple extension versions without target platforms', async () => {82const actual = [aExtensionVersion('1.2.4'), aExtensionVersion('1.1.3'), aExtensionVersion('1.1.2'), aExtensionVersion('1.1.1')];83const expected = [...actual];84sortExtensionVersions(actual, TargetPlatform.WIN32_ARM64);85assert.deepStrictEqual(actual, expected);86});8788test('sorting multiple extension versions with target platforms - 1', async () => {89const actual = [aExtensionVersion('1.2.4', TargetPlatform.DARWIN_ARM64), aExtensionVersion('1.2.4', TargetPlatform.WIN32_ARM64), aExtensionVersion('1.2.4', TargetPlatform.LINUX_ARM64), aExtensionVersion('1.1.3'), aExtensionVersion('1.1.2'), aExtensionVersion('1.1.1')];90const expected = [actual[1], actual[0], actual[2], actual[3], actual[4], actual[5]];91sortExtensionVersions(actual, TargetPlatform.WIN32_ARM64);92assert.deepStrictEqual(actual, expected);93});9495test('sorting multiple extension versions with target platforms - 2', async () => {96const actual = [aExtensionVersion('1.2.4'), aExtensionVersion('1.2.3', TargetPlatform.DARWIN_ARM64), aExtensionVersion('1.2.3', TargetPlatform.WIN32_ARM64), aExtensionVersion('1.2.3', TargetPlatform.LINUX_ARM64), aExtensionVersion('1.1.2'), aExtensionVersion('1.1.1')];97const expected = [actual[0], actual[3], actual[1], actual[2], actual[4], actual[5]];98sortExtensionVersions(actual, TargetPlatform.LINUX_ARM64);99assert.deepStrictEqual(actual, expected);100});101102test('sorting multiple extension versions with target platforms - 3', async () => {103const actual = [aExtensionVersion('1.2.4'), aExtensionVersion('1.1.2'), aExtensionVersion('1.1.1'), aExtensionVersion('1.0.0', TargetPlatform.DARWIN_ARM64), aExtensionVersion('1.0.0', TargetPlatform.WIN32_ARM64)];104const expected = [actual[0], actual[1], actual[2], actual[4], actual[3]];105sortExtensionVersions(actual, TargetPlatform.WIN32_ARM64);106assert.deepStrictEqual(actual, expected);107});108109function aExtensionVersion(version: string, targetPlatform?: TargetPlatform): IRawGalleryExtensionVersion {110return { version, targetPlatform } as IRawGalleryExtensionVersion;111}112113function aPreReleaseExtensionVersion(version: string, targetPlatform?: TargetPlatform): IRawGalleryExtensionVersion {114return {115version,116targetPlatform,117properties: [{ key: 'Microsoft.VisualStudio.Code.PreRelease', value: 'true' }]118} as IRawGalleryExtensionVersion;119}120121suite('filterLatestExtensionVersionsForTargetPlatform', () => {122123test('should return empty array for empty input', () => {124const result = filterLatestExtensionVersionsForTargetPlatform([], TargetPlatform.WIN32_X64, [TargetPlatform.WIN32_X64]);125assert.deepStrictEqual(result, []);126});127128test('should return single version when only one version provided', () => {129const versions = [aExtensionVersion('1.0.0', TargetPlatform.WIN32_X64)];130const allTargetPlatforms = [TargetPlatform.WIN32_X64];131const result = filterLatestExtensionVersionsForTargetPlatform(versions, TargetPlatform.WIN32_X64, allTargetPlatforms);132assert.deepStrictEqual(result, versions);133});134135test('should include latest release and latest pre-release versions for same platform', () => {136const release = aExtensionVersion('1.0.0', TargetPlatform.WIN32_X64);137const prerelease = aPreReleaseExtensionVersion('0.9.0', TargetPlatform.WIN32_X64);138const versions = [release, prerelease];139const allTargetPlatforms = [TargetPlatform.WIN32_X64];140141const result = filterLatestExtensionVersionsForTargetPlatform(versions, TargetPlatform.WIN32_X64, allTargetPlatforms);142143// Should include both since they have different version numbers144assert.strictEqual(result.length, 2);145assert.strictEqual(result[0], release);146assert.strictEqual(result[1], prerelease);147});148149test('should include latest prerelease and latest release versions for same platform', () => {150const prerelease = aPreReleaseExtensionVersion('1.1.0', TargetPlatform.WIN32_X64);151const release = aExtensionVersion('1.0.0', TargetPlatform.WIN32_X64);152const versions = [prerelease, release];153const allTargetPlatforms = [TargetPlatform.WIN32_X64];154155const result = filterLatestExtensionVersionsForTargetPlatform(versions, TargetPlatform.WIN32_X64, allTargetPlatforms);156157// Should include both since they have different version numbers158assert.strictEqual(result.length, 2);159assert.strictEqual(result[0], prerelease);160assert.strictEqual(result[1], release);161});162163test('should include one version per target platform for release versions', () => {164const version1 = aExtensionVersion('1.0.0', TargetPlatform.WIN32_X64);165const version2 = aExtensionVersion('1.0.0', TargetPlatform.DARWIN_X64);166const version3 = aExtensionVersion('1.0.0', TargetPlatform.LINUX_X64);167const versions = [version1, version2, version3];168const allTargetPlatforms = [TargetPlatform.WIN32_X64, TargetPlatform.DARWIN_X64, TargetPlatform.LINUX_X64];169170const result = filterLatestExtensionVersionsForTargetPlatform(versions, TargetPlatform.WIN32_X64, allTargetPlatforms);171172// Should include all three versions: WIN32_X64 (compatible, first of type) + DARWIN_X64 & LINUX_X64 (non-compatible)173assert.strictEqual(result.length, 3);174assert.ok(result.includes(version1)); // Compatible with target platform175assert.ok(result.includes(version2)); // Non-compatible, included176assert.ok(result.includes(version3)); // Non-compatible, included177});178179180test('should handle versions without target platform (UNDEFINED)', () => {181const version1 = aExtensionVersion('1.0.0'); // No target platform specified182const version2 = aExtensionVersion('0.9.0'); // No target platform specified183const versions = [version1, version2];184const allTargetPlatforms = [TargetPlatform.WIN32_X64];185186const result = filterLatestExtensionVersionsForTargetPlatform(versions, TargetPlatform.WIN32_X64, allTargetPlatforms);187188// Should only include the first version since they both have UNDEFINED platform189assert.strictEqual(result.length, 1);190assert.strictEqual(result[0], version1);191});192193test('should handle mixed release and pre-release versions across multiple platforms', () => {194const releaseWin = aExtensionVersion('1.0.0', TargetPlatform.WIN32_X64);195const releaseMac = aExtensionVersion('1.0.0', TargetPlatform.DARWIN_X64);196const preReleaseWin = aPreReleaseExtensionVersion('1.1.0', TargetPlatform.WIN32_X64);197const preReleaseMac = aPreReleaseExtensionVersion('1.1.0', TargetPlatform.DARWIN_X64);198199const versions = [releaseWin, releaseMac, preReleaseWin, preReleaseMac];200const allTargetPlatforms = [TargetPlatform.WIN32_X64, TargetPlatform.DARWIN_X64];201202const result = filterLatestExtensionVersionsForTargetPlatform(versions, TargetPlatform.WIN32_X64, allTargetPlatforms);203204// Should include: WIN32_X64 compatible (release + prerelease) + DARWIN_X64 non-compatible (all versions)205assert.strictEqual(result.length, 4);206assert.ok(result.includes(releaseWin)); // Compatible release207assert.ok(result.includes(releaseMac)); // Non-compatible, included208assert.ok(result.includes(preReleaseWin)); // Compatible pre-release209assert.ok(result.includes(preReleaseMac)); // Non-compatible, included210});211212test('should handle complex scenario with multiple versions and platforms', () => {213const versions = [214aExtensionVersion('2.0.0', TargetPlatform.WIN32_X64),215aExtensionVersion('2.0.0', TargetPlatform.DARWIN_X64),216aPreReleaseExtensionVersion('2.1.0', TargetPlatform.WIN32_X64),217aPreReleaseExtensionVersion('2.1.0', TargetPlatform.LINUX_X64),218aExtensionVersion('2.0.0'), // No platform specified219aPreReleaseExtensionVersion('2.1.0'), // Pre-release, no platform specified220];221const allTargetPlatforms = [TargetPlatform.WIN32_X64, TargetPlatform.DARWIN_X64, TargetPlatform.LINUX_X64];222223const result = filterLatestExtensionVersionsForTargetPlatform(versions, TargetPlatform.WIN32_X64, allTargetPlatforms);224225// Expected for WIN32_X64 target platform:226// - Compatible (WIN32_X64 + UNDEFINED): release (2.0.0 WIN32_X64) and pre-release (2.1.0 WIN32_X64)227// - Non-compatible: DARWIN_X64 release, LINUX_X64 pre-release228// Total: 4 versions (1 compatible release + 1 compatible pre-release + 2 non-compatible)229assert.strictEqual(result.length, 4);230231// Check specific versions are included232assert.ok(result.includes(versions[0])); // 2.0.0 WIN32_X64 (compatible release)233assert.ok(result.includes(versions[1])); // 2.0.0 DARWIN_X64 (non-compatible)234assert.ok(result.includes(versions[2])); // 2.1.0 WIN32_X64 (compatible pre-release)235assert.ok(result.includes(versions[3])); // 2.1.0 LINUX_X64 (non-compatible)236});237238test('should keep only first compatible version when specific platform comes before undefined', () => {239// Test how UNDEFINED platform interacts with specific platforms240const versions = [241aExtensionVersion('1.0.0', TargetPlatform.WIN32_X64),242aExtensionVersion('1.0.0'), // UNDEFINED platform - compatible with all243];244const allTargetPlatforms = [TargetPlatform.WIN32_X64, TargetPlatform.DARWIN_X64];245246const result = filterLatestExtensionVersionsForTargetPlatform(versions, TargetPlatform.WIN32_X64, allTargetPlatforms);247248// Both are compatible with WIN32_X64, first one should be included (specific platform preferred)249assert.strictEqual(result.length, 1);250assert.ok(result.includes(versions[0])); // WIN32_X64 should be included (specific platform)251});252253test('should handle higher version with specific platform vs lower version with universal platform', () => {254// Scenario: newer version for specific platform vs older version with universal compatibility255const higherVersionSpecificPlatform = aExtensionVersion('2.0.0', TargetPlatform.WIN32_X64);256const lowerVersionUniversal = aExtensionVersion('1.5.0'); // UNDEFINED/universal platform257258const versions = [higherVersionSpecificPlatform, lowerVersionUniversal];259const allTargetPlatforms = [TargetPlatform.WIN32_X64, TargetPlatform.DARWIN_X64];260261const result = filterLatestExtensionVersionsForTargetPlatform(versions, TargetPlatform.WIN32_X64, allTargetPlatforms);262263// Both are compatible with WIN32_X64, but only the first release version should be included264assert.strictEqual(result.length, 1);265assert.ok(result.includes(higherVersionSpecificPlatform)); // First compatible release266assert.ok(!result.includes(lowerVersionUniversal)); // Filtered (second compatible release)267});268269test('should handle higher version with universal platform vs lower version with specific platform', () => {270// Scenario: higher universal version comes first, then lower platform-specific version271const higherVersionUniversal = aExtensionVersion('2.0.0'); // UNDEFINED/universal platform272const lowerVersionSpecificPlatform = aExtensionVersion('1.0.0', TargetPlatform.WIN32_X64);273274const versions = [higherVersionUniversal, lowerVersionSpecificPlatform];275const allTargetPlatforms = [TargetPlatform.WIN32_X64, TargetPlatform.DARWIN_X64];276277const result = filterLatestExtensionVersionsForTargetPlatform(versions, TargetPlatform.WIN32_X64, allTargetPlatforms);278279// Both are compatible with WIN32_X64, the first (higher) version should be kept280// Platform-specific version should NOT replace since it has a different (lower) version number281assert.strictEqual(result.length, 1);282assert.ok(result.includes(higherVersionUniversal)); // First compatible release (higher version)283assert.ok(!result.includes(lowerVersionSpecificPlatform)); // Filtered (lower version)284});285286test('should handle multiple specific platforms vs universal platform with version differences', () => {287// Complex scenario with multiple platforms and universal compatibility288const versions = [289aExtensionVersion('2.0.0', TargetPlatform.WIN32_X64), // Highest version, specific platform290aExtensionVersion('1.9.0', TargetPlatform.DARWIN_X64), // Lower version, different specific platform291aExtensionVersion('1.8.0'), // Lowest version, universal platform292];293const allTargetPlatforms = [TargetPlatform.WIN32_X64, TargetPlatform.DARWIN_X64, TargetPlatform.LINUX_X64];294295const result = filterLatestExtensionVersionsForTargetPlatform(versions, TargetPlatform.WIN32_X64, allTargetPlatforms);296297// Should include:298// - 2.0.0 WIN32_X64 (specific target platform match - replaces UNDEFINED if it came first)299// - 1.9.0 DARWIN_X64 (non-compatible, included)300assert.strictEqual(result.length, 2);301assert.ok(result.includes(versions[0])); // 2.0.0 WIN32_X64302assert.ok(result.includes(versions[1])); // 1.9.0 DARWIN_X64303});304305test('should include universal platform when no specific platforms conflict', () => {306// Test where universal platform is included because no specific platforms conflict307const universalVersion = aExtensionVersion('1.0.0'); // UNDEFINED/universal platform308const specificVersion = aExtensionVersion('1.0.0', TargetPlatform.LINUX_ARM64);309310const versions = [universalVersion, specificVersion];311const allTargetPlatforms = [TargetPlatform.WIN32_X64, TargetPlatform.DARWIN_X64]; // Note: LINUX_ARM64 not in target platforms312313const result = filterLatestExtensionVersionsForTargetPlatform(versions, TargetPlatform.WIN32_X64, allTargetPlatforms);314315// Universal is compatible with WIN32_X64, specific version is not compatible316// So we should get: universal (first compatible release) + specific (non-compatible)317assert.strictEqual(result.length, 2);318assert.ok(result.includes(universalVersion)); // Compatible with WIN32_X64319assert.ok(result.includes(specificVersion)); // Non-compatible, included320});321322test('should include all non-compatible platform versions', () => {323const version1 = aExtensionVersion('1.0.0', TargetPlatform.WIN32_X64);324const version2 = aExtensionVersion('1.0.0', TargetPlatform.DARWIN_X64);325const version3 = aPreReleaseExtensionVersion('1.1.0', TargetPlatform.LINUX_X64);326const versions = [version1, version2, version3];327const allTargetPlatforms = [TargetPlatform.WIN32_X64, TargetPlatform.DARWIN_X64, TargetPlatform.LINUX_X64];328329const result = filterLatestExtensionVersionsForTargetPlatform(versions, TargetPlatform.WIN32_X64, allTargetPlatforms);330331assert.ok(result.includes(version2)); // Non-compatible, included332assert.ok(result.includes(version3)); // Non-compatible, included333});334335test('should prefer specific target platform over undefined when same version exists for both', () => {336const undefinedVersion = aExtensionVersion('1.0.0'); // UNDEFINED platform, appears first337const specificVersion = aExtensionVersion('1.0.0', TargetPlatform.WIN32_X64); // Specific platform, appears second338339const versions = [undefinedVersion, specificVersion];340const allTargetPlatforms = [TargetPlatform.WIN32_X64];341342const result = filterLatestExtensionVersionsForTargetPlatform(versions, TargetPlatform.WIN32_X64, allTargetPlatforms);343344// Should return the specific platform version (WIN32_X64), not the undefined one345assert.strictEqual(result.length, 1);346assert.strictEqual(result[0], specificVersion);347assert.ok(!result.includes(undefinedVersion));348});349350test('should replace undefined pre-release with specific platform pre-release', () => {351const undefinedPreRelease = aPreReleaseExtensionVersion('1.0.0'); // UNDEFINED platform pre-release, appears first352const specificPreRelease = aPreReleaseExtensionVersion('1.0.0', TargetPlatform.WIN32_X64); // Specific platform pre-release, appears second353354const versions = [undefinedPreRelease, specificPreRelease];355const allTargetPlatforms = [TargetPlatform.WIN32_X64];356357const result = filterLatestExtensionVersionsForTargetPlatform(versions, TargetPlatform.WIN32_X64, allTargetPlatforms);358359// Should return the specific platform pre-release, not the undefined one360assert.strictEqual(result.length, 1);361assert.strictEqual(result[0], specificPreRelease);362assert.ok(!result.includes(undefinedPreRelease));363});364365test('should handle explicit UNIVERSAL platform', () => {366const universalVersion = aExtensionVersion('1.0.0', TargetPlatform.UNIVERSAL);367const specificVersion = aExtensionVersion('1.0.0', TargetPlatform.WIN32_X64);368369const versions = [universalVersion, specificVersion];370const allTargetPlatforms = [TargetPlatform.WIN32_X64];371372const result = filterLatestExtensionVersionsForTargetPlatform(versions, TargetPlatform.WIN32_X64, allTargetPlatforms);373374// Should return the specific platform version, not the universal one375assert.strictEqual(result.length, 1);376assert.strictEqual(result[0], specificVersion);377assert.ok(!result.includes(universalVersion));378});379380test('should handle both release and pre-release with same version replacement', () => {381// Both release and pre-release with undefined platform, then specific platform with same versions382// Versions sorted by version descending (pre-release 1.1.0, release 1.0.0, then same versions with specific platform)383const undefinedPreRelease = aPreReleaseExtensionVersion('1.1.0'); // UNDEFINED pre-release384const specificPreRelease = aPreReleaseExtensionVersion('1.1.0', TargetPlatform.WIN32_X64); // Specific pre-release (same version)385const undefinedRelease = aExtensionVersion('1.0.0'); // UNDEFINED release386const specificRelease = aExtensionVersion('1.0.0', TargetPlatform.WIN32_X64); // Specific release (same version)387388const versions = [undefinedPreRelease, specificPreRelease, undefinedRelease, specificRelease];389const allTargetPlatforms = [TargetPlatform.WIN32_X64];390391const result = filterLatestExtensionVersionsForTargetPlatform(versions, TargetPlatform.WIN32_X64, allTargetPlatforms);392393// Should return both specific platform versions (they replaced the undefined ones)394assert.strictEqual(result.length, 2);395assert.ok(result.includes(specificRelease));396assert.ok(result.includes(specificPreRelease));397assert.ok(!result.includes(undefinedRelease));398assert.ok(!result.includes(undefinedPreRelease));399});400401test('should not replace when specific platform is for different platform', () => {402const undefinedVersion = aExtensionVersion('1.0.0'); // UNDEFINED, compatible with WIN32_X64403const specificVersionDarwin = aExtensionVersion('1.0.0', TargetPlatform.DARWIN_X64); // Specific for DARWIN, not compatible with WIN32_X64404405const versions = [undefinedVersion, specificVersionDarwin];406const allTargetPlatforms = [TargetPlatform.WIN32_X64, TargetPlatform.DARWIN_X64];407408const result = filterLatestExtensionVersionsForTargetPlatform(versions, TargetPlatform.WIN32_X64, allTargetPlatforms);409410// Should return undefined version (compatible with WIN32_X64) and specific DARWIN version (non-compatible, always included)411assert.strictEqual(result.length, 2);412assert.ok(result.includes(undefinedVersion));413assert.ok(result.includes(specificVersionDarwin));414});415416test('should handle replacement with non-compatible versions in between', () => {417// Versions sorted by version descending418const undefinedVersion = aExtensionVersion('1.0.0'); // UNDEFINED, compatible with WIN32_X64419const specificVersion = aExtensionVersion('1.0.0', TargetPlatform.WIN32_X64); // Specific for WIN32_X64 (same version)420const nonCompatibleVersion = aExtensionVersion('0.9.0', TargetPlatform.LINUX_ARM64); // Non-compatible platform (lower version)421422const versions = [undefinedVersion, specificVersion, nonCompatibleVersion];423const allTargetPlatforms = [TargetPlatform.WIN32_X64, TargetPlatform.DARWIN_X64];424425const result = filterLatestExtensionVersionsForTargetPlatform(versions, TargetPlatform.WIN32_X64, allTargetPlatforms);426427// Should return specific WIN32_X64 version (replacing undefined since same version) and non-compatible LINUX_ARM64 version428assert.strictEqual(result.length, 2);429assert.ok(result.includes(specificVersion));430assert.ok(result.includes(nonCompatibleVersion));431assert.ok(!result.includes(undefinedVersion));432});433434test('should filter versions for linux-x64 target platform with mixed universal and platform-specific versions', () => {435// Data from real extension versions (sorted by version descending, as returned by gallery API):436// 0.15.0 - pre-release, universal437// 0.14.0 - release, universal438// 0.6.0 - release, linux-x64439// 0.5.1 - pre-release, linux-x64440const versions = [441aPreReleaseExtensionVersion('0.15.0'), // pre-release, universal (highest version)442aExtensionVersion('0.14.0'), // release, universal443aExtensionVersion('0.6.0', TargetPlatform.LINUX_X64), // release, linux-x64444aPreReleaseExtensionVersion('0.5.1', TargetPlatform.LINUX_X64), // pre-release, linux-x64 (lowest version)445];446const allTargetPlatforms = [TargetPlatform.LINUX_X64];447448const result = filterLatestExtensionVersionsForTargetPlatform(versions, TargetPlatform.LINUX_X64, allTargetPlatforms);449450// Expected:451// - 0.15.0 universal (first compatible pre-release, higher version than 0.5.1 linux-x64)452// - 0.14.0 universal (first compatible release, higher version than 0.6.0 linux-x64)453// Platform-specific versions are NOT preferred when they have lower version numbers454assert.strictEqual(result.length, 2);455assert.ok(result.includes(versions[0])); // 0.15.0 universal (pre-release)456assert.ok(result.includes(versions[1])); // 0.14.0 universal (release)457});458459});460});461462463