|
| 1 | +/*--------------------------------------------------------------------------------------------- |
| 2 | + * Copyright (c) Microsoft Corporation. All rights reserved. |
| 3 | + * Licensed under the MIT License. See License.txt in the project root for license information. |
| 4 | + *--------------------------------------------------------------------------------------------*/ |
| 5 | + |
| 6 | +import assert from 'assert'; |
| 7 | +import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../base/test/common/utils.js'; |
| 8 | +import { IOSProperties } from '../../../native/common/native.js'; |
| 9 | +import product from '../../../product/common/product.js'; |
| 10 | +import { IProductService } from '../../../product/common/productService.js'; |
| 11 | +import { createNativeAboutDialogDetails } from '../../electron-browser/dialog.js'; |
| 12 | + |
| 13 | +suite('Dialog', () => { |
| 14 | + |
| 15 | + ensureNoDisposablesAreLeakedInTestSuite(); |
| 16 | + |
| 17 | + const osProperties: IOSProperties = { |
| 18 | + type: 'Test OS', |
| 19 | + release: '1.0', |
| 20 | + arch: 'test-arch', |
| 21 | + platform: 'test', |
| 22 | + cpus: [] |
| 23 | + }; |
| 24 | + |
| 25 | + function getCopilotVersionLines(runtime: string, sdk: string): { details: string[]; detailsToCopy: string[] } { |
| 26 | + const productService: IProductService = { |
| 27 | + _serviceBrand: undefined, |
| 28 | + ...product, |
| 29 | + copilotVersions: { runtime, sdk } |
| 30 | + }; |
| 31 | + const { details, detailsToCopy } = createNativeAboutDialogDetails(productService, osProperties); |
| 32 | + const selectCopilotVersionLines = (value: string) => value.split('\n').filter(line => line.startsWith('@github/copilot')); |
| 33 | + |
| 34 | + return { |
| 35 | + details: selectCopilotVersionLines(details), |
| 36 | + detailsToCopy: selectCopilotVersionLines(detailsToCopy) |
| 37 | + }; |
| 38 | + } |
| 39 | + |
| 40 | + test('formats Copilot canary versions', () => { |
| 41 | + assert.deepStrictEqual( |
| 42 | + getCopilotVersionLines('1.0.84-canary.70.gdb75d0d.unsigned', '0.1.23-canary.45.gabcdef.unsigned'), |
| 43 | + { |
| 44 | + details: [ |
| 45 | + '@github/copilot: 1.0.84.70.gdb75d0d', |
| 46 | + '@github/copilot-sdk: 0.1.23.45.gabcdef' |
| 47 | + ], |
| 48 | + detailsToCopy: [ |
| 49 | + '@github/copilot: 1.0.84.70.gdb75d0d', |
| 50 | + '@github/copilot-sdk: 0.1.23.45.gabcdef' |
| 51 | + ] |
| 52 | + } |
| 53 | + ); |
| 54 | + }); |
| 55 | + |
| 56 | + test('preserves stable Copilot versions', () => { |
| 57 | + assert.deepStrictEqual( |
| 58 | + getCopilotVersionLines('1.0.84', '0.1.23'), |
| 59 | + { |
| 60 | + details: [ |
| 61 | + '@github/copilot: 1.0.84', |
| 62 | + '@github/copilot-sdk: 0.1.23' |
| 63 | + ], |
| 64 | + detailsToCopy: [ |
| 65 | + '@github/copilot: 1.0.84', |
| 66 | + '@github/copilot-sdk: 0.1.23' |
| 67 | + ] |
| 68 | + } |
| 69 | + ); |
| 70 | + }); |
| 71 | +}); |
0 commit comments