Skip to content

Commit c61e7f2

Browse files
committed
Rename sendContextData to sendContextDataFromControllerState for clarity and update references in tests
1 parent e7df0e5 commit c61e7f2

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

src/views/manage-solution/manage-solution-webview-main.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ describe('ContextSelectionWebviewMain', () => {
259259
callOrder.push('loadSolution');
260260
return ETextFileResult.Success;
261261
});
262-
const sendContextDataSpy = jest.spyOn(main as any, 'sendContextData').mockResolvedValue(undefined);
262+
const sendContextDataFromControllerStateSpy = jest.spyOn(main as any, 'sendContextDataFromControllerState').mockResolvedValue(undefined);
263263

264264
const hasExternalFileChangesSpy = jest.spyOn(main.controller, 'hasExternalFileChanges').mockImplementation(() => {
265265
callOrder.push('hasExternalFileChanges');
@@ -284,19 +284,19 @@ describe('ContextSelectionWebviewMain', () => {
284284
'loadSolution',
285285
'ensureActiveTargetTypeName',
286286
]);
287-
expect(sendContextDataSpy).toHaveBeenCalledTimes(1);
287+
expect(sendContextDataFromControllerStateSpy).toHaveBeenCalledTimes(1);
288288
});
289289

290-
it('calls sendContextData when transitioning to active state', async () => {
290+
it('calls sendContextDataFromControllerState when transitioning to active state', async () => {
291291
const solutionManager = solutionManagerFactory();
292292
const main = manageSolutionWebviewMainFactory({
293293
solutionManager,
294294
webviewManager
295295
});
296296
(main as any).webviewManager.isPanelActive = jest.fn().mockReturnValue(true); // Simulate active panel
297297

298-
// Spy on sendContextData to verify it gets called
299-
const sendContextDataSpy = jest.spyOn(main as any, 'sendContextData').mockResolvedValue(undefined);
298+
// Spy on broadcast helper to verify it gets called
299+
const sendContextDataFromControllerStateSpy = jest.spyOn(main as any, 'sendContextDataFromControllerState').mockResolvedValue(undefined);
300300

301301
await main.activate(context as vscode.ExtensionContext);
302302

@@ -307,19 +307,19 @@ describe('ContextSelectionWebviewMain', () => {
307307

308308
await waitTimeout();
309309

310-
expect(sendContextDataSpy).toHaveBeenCalled();
310+
expect(sendContextDataFromControllerStateSpy).toHaveBeenCalled();
311311
expect(webviewManager.sendMessage).toHaveBeenCalledWith({ type: 'IS_BUSY', data: true });
312312
});
313313

314-
it('calls sendContextData when transitioning from idle to active', async () => {
314+
it('calls sendContextDataFromControllerState when transitioning from idle to active', async () => {
315315
const solutionManager = solutionManagerFactory();
316316
const main = manageSolutionWebviewMainFactory({
317317
solutionManager,
318318
webviewManager
319319
});
320320
(main as any).webviewManager.isPanelActive = jest.fn().mockReturnValue(true); // Simulate active panel
321321

322-
const sendContextDataSpy = jest.spyOn(main as any, 'sendContextData').mockResolvedValue(undefined);
322+
const sendContextDataFromControllerStateSpy = jest.spyOn(main as any, 'sendContextDataFromControllerState').mockResolvedValue(undefined);
323323

324324
await main.activate(context as vscode.ExtensionContext);
325325

@@ -333,7 +333,7 @@ describe('ContextSelectionWebviewMain', () => {
333333

334334
await waitTimeout();
335335

336-
expect(sendContextDataSpy).toHaveBeenCalled();
336+
expect(sendContextDataFromControllerStateSpy).toHaveBeenCalled();
337337
});
338338

339339
it('does call sendContextData when transitioning from active to idle', async () => {

src/views/manage-solution/manage-solution-webview-main.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export class ManageSolutionWebviewMain {
122122
const activeTargetTypeUpdated = await this.controller.ensureActiveTargetTypeName();
123123

124124
if (csolutionChanged || externalFilesChanged || activeTargetTypeUpdated) {
125-
await this.sendContextData();
125+
await this.sendContextDataFromControllerState();
126126
}
127127

128128
this.setBusyState(false);
@@ -381,6 +381,10 @@ export class ManageSolutionWebviewMain {
381381
return;
382382
}
383383

384+
await this.sendContextDataFromControllerState();
385+
}
386+
387+
private async sendContextDataFromControllerState(): Promise<void> {
384388
const controller = this.controller;
385389
await controller.getAvailableCoreNames();
386390
await Promise.all([

0 commit comments

Comments
 (0)