-
Notifications
You must be signed in to change notification settings - Fork 109
fix(vscode): Remove defaultLogicAppPath context #9588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Andrew Eldridge (andrew-eldridge)
merged 3 commits into
main
from
aeldridge/vscode-remove-default-la
Sep 1, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
134 changes: 134 additions & 0 deletions
134
apps/vs-code-designer/src/app/commands/dataMapper/__test__/DataMapperExt.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| * Licensed under the MIT License. See License.txt in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
| import { beforeEach, describe, expect, it, vi } from 'vitest'; | ||
| import type { IActionContext } from '@microsoft/vscode-azext-utils'; | ||
| import { ViewColumn, window } from 'vscode'; | ||
| import { ext } from '../../../../extensionVariables'; | ||
| import DataMapperExt, { getDataMapPanelKey } from '../DataMapperExt'; | ||
|
|
||
| const mocks = vi.hoisted(() => { | ||
| const dataMapperPanelConstructor = vi.fn(function (panel: any, dataMapName: string, panelKey: string, projectPath: string) { | ||
| return { | ||
| panel, | ||
| dataMapName, | ||
| panelKey, | ||
| projectPath, | ||
| updateWebviewPanelTitle: vi.fn(), | ||
| mapDefinitionData: undefined, | ||
| }; | ||
| }); | ||
|
|
||
| return { | ||
| dataMapperPanelConstructor, | ||
| startBackendRuntime: vi.fn().mockResolvedValue(undefined), | ||
| }; | ||
| }); | ||
|
|
||
| vi.mock('../DataMapperPanel', () => ({ | ||
| default: mocks.dataMapperPanelConstructor, | ||
| })); | ||
|
|
||
| vi.mock('../FxWorkflowRuntime', () => ({ | ||
| startBackendRuntime: mocks.startBackendRuntime, | ||
| })); | ||
|
|
||
| vi.mock('../../../../localize', () => ({ | ||
| localize: (_key: string, defaultMessage: string) => defaultMessage, | ||
| })); | ||
|
|
||
| interface MockWebviewPanel { | ||
| iconPath?: unknown; | ||
| reveal: ReturnType<typeof vi.fn>; | ||
| webview: { | ||
| html: string; | ||
| onDidReceiveMessage: ReturnType<typeof vi.fn>; | ||
| postMessage: ReturnType<typeof vi.fn>; | ||
| }; | ||
| } | ||
|
|
||
| describe('DataMapperExt panel identity', () => { | ||
| const context = { | ||
| ui: { | ||
| showInputBox: vi.fn(), | ||
| }, | ||
| } as unknown as IActionContext; | ||
|
|
||
| beforeEach(() => { | ||
| vi.clearAllMocks(); | ||
| (ext as any).dataMapPanelManagers ??= {}; | ||
| for (const panelKey of Object.keys(ext.dataMapPanelManagers)) { | ||
| delete ext.dataMapPanelManagers[panelKey]; | ||
| } | ||
|
|
||
| (ext as any).context = { | ||
| extensionPath: '/extension', | ||
| subscriptions: [], | ||
| }; | ||
|
|
||
| vi.mocked(window.createWebviewPanel).mockImplementation( | ||
| () => | ||
| ({ | ||
| iconPath: undefined, | ||
| reveal: vi.fn(), | ||
| webview: { | ||
| html: '', | ||
| onDidReceiveMessage: vi.fn(), | ||
| postMessage: vi.fn(), | ||
| }, | ||
| }) as any | ||
| ); | ||
| }); | ||
|
|
||
| it('reveals the existing panel for the same project path and map name', async () => { | ||
| const projectPath = '/projects/alpha'; | ||
| const dataMapName = 'orders'; | ||
|
|
||
| await DataMapperExt.openDataMapperPanel(context, projectPath, dataMapName); | ||
| const existingManager = ext.dataMapPanelManagers[getDataMapPanelKey(projectPath, dataMapName)]; | ||
| const existingPanel = existingManager.panel as unknown as MockWebviewPanel; | ||
|
|
||
| await DataMapperExt.openDataMapperPanel(context, projectPath, dataMapName); | ||
|
|
||
| expect(window.createWebviewPanel).toHaveBeenCalledTimes(1); | ||
| expect(mocks.dataMapperPanelConstructor).toHaveBeenCalledTimes(1); | ||
| expect(existingPanel.reveal).toHaveBeenCalledWith(ViewColumn.Active); | ||
| expect(ext.dataMapPanelManagers[getDataMapPanelKey(projectPath, dataMapName)]).toBe(existingManager); | ||
| }); | ||
|
|
||
| it('registers identically named maps from different projects under separate composite keys', async () => { | ||
| const dataMapName = 'orders'; | ||
| const firstProjectPath = '/projects/alpha'; | ||
| const secondProjectPath = '/projects/beta'; | ||
|
|
||
| await DataMapperExt.openDataMapperPanel(context, firstProjectPath, dataMapName); | ||
| await DataMapperExt.openDataMapperPanel(context, secondProjectPath, dataMapName); | ||
|
|
||
| const firstKey = getDataMapPanelKey(firstProjectPath, dataMapName); | ||
| const secondKey = getDataMapPanelKey(secondProjectPath, dataMapName); | ||
| const firstManager = ext.dataMapPanelManagers[firstKey]; | ||
| const secondManager = ext.dataMapPanelManagers[secondKey]; | ||
|
|
||
| expect(firstKey).not.toBe(secondKey); | ||
| expect(firstManager).toBeDefined(); | ||
| expect(secondManager).toBeDefined(); | ||
| expect(firstManager).not.toBe(secondManager); | ||
| expect(mocks.dataMapperPanelConstructor).toHaveBeenNthCalledWith(1, expect.anything(), dataMapName, firstKey, firstProjectPath); | ||
| expect(mocks.dataMapperPanelConstructor).toHaveBeenNthCalledWith(2, expect.anything(), dataMapName, secondKey, secondProjectPath); | ||
| }); | ||
|
|
||
| it('attaches map definition data only to the manager for its project', async () => { | ||
| const dataMapName = 'orders'; | ||
| const firstProjectPath = '/projects/alpha'; | ||
| const secondProjectPath = '/projects/beta'; | ||
| const firstMapDefinitionData = { mapDefinition: { source: 'alpha' } } as any; | ||
| const secondMapDefinitionData = { mapDefinition: { source: 'beta' } } as any; | ||
|
|
||
| await DataMapperExt.openDataMapperPanel(context, firstProjectPath, dataMapName, firstMapDefinitionData); | ||
| await DataMapperExt.openDataMapperPanel(context, secondProjectPath, dataMapName, secondMapDefinitionData); | ||
|
|
||
| expect(ext.dataMapPanelManagers[getDataMapPanelKey(firstProjectPath, dataMapName)].mapDefinitionData).toBe(firstMapDefinitionData); | ||
| expect(ext.dataMapPanelManagers[getDataMapPanelKey(secondProjectPath, dataMapName)].mapDefinitionData).toBe(secondMapDefinitionData); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.