feat :rephrasing the extension logging messages to run the explore command when there are no extensions installed (#13740)

This commit is contained in:
JAYADITYA
2025-11-24 21:24:15 +05:30
committed by GitHub
parent 7350399a50
commit 569c6f1dd0
2 changed files with 87 additions and 6 deletions
@@ -134,6 +134,21 @@ describe('extensionsCommand', () => {
expect.any(Number),
);
});
it('should show a message if no extensions are installed', async () => {
mockGetExtensions.mockReturnValue([]);
const command = extensionsCommand();
if (!command.action) throw new Error('Action not defined');
await command.action(mockContext, '');
expect(mockContext.ui.addItem).toHaveBeenCalledWith(
{
type: MessageType.INFO,
text: 'No extensions installed. Run `/extensions explore` to check out the gallery.',
},
expect.any(Number),
);
});
});
describe('completeExtensions', () => {
@@ -216,6 +231,19 @@ describe('extensionsCommand', () => {
);
});
it('should show a message if no extensions are installed', async () => {
mockGetExtensions.mockReturnValue([]);
await updateAction(mockContext, 'ext-one');
expect(mockContext.ui.addItem).toHaveBeenCalledWith(
{
type: MessageType.INFO,
text: 'No extensions installed. Run `/extensions explore` to check out the gallery.',
},
expect.any(Number),
);
});
it('should inform user if there are no extensions to update with --all', async () => {
mockDispatchExtensionState.mockImplementationOnce(
(action: ExtensionUpdateAction) => {
@@ -607,6 +635,25 @@ describe('extensionsCommand', () => {
mockContext.invocation!.name = 'restart';
});
it('should show a message if no extensions are installed', async () => {
mockContext.services.config!.getExtensionLoader = vi
.fn()
.mockImplementation(() => ({
getExtensions: () => [],
restartExtension: mockRestartExtension,
}));
await restartAction!(mockContext, '--all');
expect(mockContext.ui.addItem).toHaveBeenCalledWith(
{
type: MessageType.INFO,
text: 'No extensions installed. Run `/extensions explore` to check out the gallery.',
},
expect.any(Number),
);
});
it('restarts all active extensions when --all is provided', async () => {
const mockExtensions = [
{ name: 'ext1', isActive: true },