Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions extension/src/server/interactionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ export class InteractionService implements IInteractionService {

extensionLogOutputChannel.info(`Displaying message: ${emoji} ${message}`);
vscode.window.showInformationMessage(formatText(message));
this.clearProgressNotification();
}

// There is no need for a different success message handler, as a general informative message ~= success
Expand All @@ -223,6 +224,7 @@ export class InteractionService implements IInteractionService {

extensionLogOutputChannel.info(`Displaying success message: ${message}`);
vscode.window.showInformationMessage(formatText(message));
this.clearProgressNotification();
}

displaySubtleMessage(message: string) {
Expand All @@ -238,6 +240,7 @@ export class InteractionService implements IInteractionService {
displayPlainText(message: string) {
extensionLogOutputChannel.info(`Displaying plain text: ${message}`);
vscode.window.showInformationMessage(formatText(message));
this.clearProgressNotification();
}

// No direct equivalent in VS Code, so don't display anything visually, just log to output channel.
Expand Down
39 changes: 39 additions & 0 deletions extension/src/test/rpc/interactionServiceTests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,19 @@ suite('InteractionService endpoints', () => {
showInformationMessageSpy.restore();
});

test('displayMessage clears progress notification', async () => {
const testInfo = await createTestRpcServer();
const showInformationMessageSpy = sinon.spy(vscode.window, 'showInformationMessage');
// Access the private _progressNotifier via casting to any
const progressNotifier = (testInfo.interactionService as any)._progressNotifier;
const clearProgressSpy = sinon.spy(progressNotifier, 'clear');
testInfo.interactionService.displayMessage(":test_emoji:", 'Test info message');
assert.ok(showInformationMessageSpy.calledWith('Test info message'));
assert.ok(clearProgressSpy.calledOnce, 'ProgressNotifier.clear should be called once');
showInformationMessageSpy.restore();
clearProgressSpy.restore();
});

test("displaySuccess endpoint", async () => {
const testInfo = await createTestRpcServer();
const showInformationMessageSpy = sinon.spy(vscode.window, 'showInformationMessage');
Expand All @@ -102,6 +115,19 @@ suite('InteractionService endpoints', () => {
showInformationMessageSpy.restore();
});

test("displaySuccess clears progress notification", async () => {
const testInfo = await createTestRpcServer();
const showInformationMessageSpy = sinon.spy(vscode.window, 'showInformationMessage');
// Access the private _progressNotifier via casting to any
const progressNotifier = (testInfo.interactionService as any)._progressNotifier;
const clearProgressSpy = sinon.spy(progressNotifier, 'clear');
testInfo.interactionService.displaySuccess('Test success message');
assert.ok(showInformationMessageSpy.calledWith('Test success message'));
assert.ok(clearProgressSpy.calledOnce, 'ProgressNotifier.clear should be called once');
showInformationMessageSpy.restore();
clearProgressSpy.restore();
});

test("displaySubtleMessage endpoint", async () => {
const testInfo = await createTestRpcServer();
const setStatusBarMessageSpy = sinon.spy(vscode.window, 'setStatusBarMessage');
Expand Down Expand Up @@ -156,6 +182,19 @@ suite('InteractionService endpoints', () => {
assert.ok(openTextDocumentStub.calledOnce, 'openTextDocument should be called once');
openTextDocumentStub.restore();
});

test("displayPlainText clears progress notification", async () => {
const testInfo = await createTestRpcServer();
const showInformationMessageSpy = sinon.spy(vscode.window, 'showInformationMessage');
// Access the private _progressNotifier via casting to any
const progressNotifier = (testInfo.interactionService as any)._progressNotifier;
const clearProgressSpy = sinon.spy(progressNotifier, 'clear');
testInfo.interactionService.displayPlainText('Test plain text');
assert.ok(showInformationMessageSpy.calledWith('Test plain text'));
assert.ok(clearProgressSpy.calledOnce, 'ProgressNotifier.clear should be called once');
showInformationMessageSpy.restore();
clearProgressSpy.restore();
});
});

type RpcServerTestInfo = {
Expand Down