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
6 changes: 6 additions & 0 deletions src/client/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ export async function activate(
const basicPanels = RegisterBasicPanels(pacWrapper);
_context.subscriptions.push(...basicPanels);

// Register copilot panels immediately during activation to ensure chat participant is always available
// This ensures @powerpages works even when user is not authenticated
registerCopilotPanels(pacWrapper);

let copilotNotificationShown = false;

const workspaceFolders = getWorkspaceFolders();
Expand Down Expand Up @@ -513,5 +517,7 @@ function registerCopilotPanels(pacWrapper: PacWrapper): void {
copilotPanelsDisposable = RegisterCopilotPanels(pacWrapper, _context);
_context.subscriptions.push(...copilotPanelsDisposable);
copilotPanelsRegistered = true;

oneDSLoggerWrapper.getLogger().traceInfo("CopilotPanelsRegistered");
}
}
52 changes: 52 additions & 0 deletions src/client/test/Integration/copilotRegistration.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import * as vscode from 'vscode';
import { expect } from 'chai';

describe('Copilot Registration Tests', () => {
before(async () => {
// Ensure the extension is activated
const extension = vscode.extensions.getExtension("microsoft-IsvExpTools.powerplatform-vscode");
if (extension && !extension.isActive) {
await extension.activate();
}
});

it('should register @powerpages chat participant during extension activation', async () => {
// Give the extension some time to complete its activation
await new Promise(resolve => setTimeout(resolve, 2000));

// Try to get the chat participants to verify powerpages is registered
// Note: This is a basic test that verifies the participant is available
// The actual VS Code chat API doesn't expose a direct way to enumerate participants
// but we can verify no immediate errors occur when trying to access copilot functionality

// Check if the chat is available and no obvious errors
const chatExtension = vscode.extensions.getExtension('GitHub.copilot-chat');
if (chatExtension && chatExtension.isActive) {
// If GitHub Copilot Chat is available, our participant should be registered
// This is an indirect test - the main validation is that our registration code runs
expect(true).to.be.true; // Registration completed without throwing errors
} else {
// If GitHub Copilot Chat is not available, we can't fully test the chat participant
// but we can at least verify our extension activated without errors
const powerPlatformExtension = vscode.extensions.getExtension("microsoft-IsvExpTools.powerplatform-vscode");
expect(powerPlatformExtension?.isActive).to.be.true;
}
});

it('should handle extension activation without authentication gracefully', async () => {
// This test verifies that even without authentication, the extension activates
// and the chat participant is registered (though it will prompt for auth when used)

const extension = vscode.extensions.getExtension("microsoft-IsvExpTools.powerplatform-vscode");
expect(extension?.isActive).to.be.true;

// No errors should have been thrown during activation
// The chat participant should be registered even if auth is not complete
expect(true).to.be.true;
});
});
Loading