Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Commit

Permalink
fix(recommendations): Use Error message instead of Info message on er…
Browse files Browse the repository at this point in the history
…rors

Fixes https://issues.redhat.com/browse/CRW-1714

Change-Id: Id804f5605e5c686a43ad26d7de50fcfd7c7c8f6d
Signed-off-by: Florent Benoit <[email protected]>
  • Loading branch information
benoitf committed May 7, 2021
1 parent a0e12b3 commit d5bdd67
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions plugins/recommendations-plugin/__mocks__/@theia/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ theia.window.createOutputChannel.mockReturnValue(outputChannel);
theia.plugins = {};
theia.plugins.all = [];
theia.window.showInformationMessage = jest.fn();
theia.window.showErrorMessage = jest.fn();
theia.workspace = {
workspaceFolders: undefined,
onDidOpenTextDocument: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class FeaturedFetcher {
featuredList = response.data.featured;
} catch (error) {
featuredList = [];
theia.window.showInformationMessage(`Error while fetching featured recommendation ${error}`);
theia.window.showErrorMessage(`Error while fetching featured recommendation ${error}`);
}
return featuredList;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class PluginsByLanguageFetcher {
languagePlugins = response.data;
} catch (error) {
if (error.response.status !== 404) {
theia.window.showInformationMessage(`Error while fetching featured recommendations ${error}`);
theia.window.showErrorMessage(`Error while fetching featured recommendations ${error}`);
}
}
return languagePlugins;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import 'reflect-metadata';

import * as fs from 'fs-extra';
import * as path from 'path';
import * as theia from '@theia/plugin';

import { ChePluginRegistry } from '../../src/registry/che-plugin-registry';
import { Container } from 'inversify';
Expand Down Expand Up @@ -59,4 +60,21 @@ describe('Test FeaturedFetcher', () => {
expect(featuredList.length).toBe(0);
expect((axios as any).get).toBeCalledWith(`${fakeUrl}/che-theia/featured.json`);
});

test('unexpected error', async () => {
const error = {
response: {
status: 500,
},
};
(axios as any).__setError('https://my.registry/v3/che-theia/recommendations/language/java.json', error);

const featuredFetcher = container.get(FeaturedFetcher);
const featuredList = await featuredFetcher.fetch();
// no content
expect(featuredList).toBeDefined();
expect(featuredList.length).toBe(0);
// notify the user
expect(theia.window.showErrorMessage as jest.Mock).toBeCalled();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,6 @@ describe('Test PluginsByLanguageFetcher', () => {
expect(languageByPlugins).toBeDefined();
expect(languageByPlugins.length).toBe(0);
// notify the user
expect(theia.window.showInformationMessage as jest.Mock).toBeCalled();
expect(theia.window.showErrorMessage as jest.Mock).toBeCalled();
});
});

0 comments on commit d5bdd67

Please sign in to comment.