Add tests for refresh scripting action (#8648)

* Add tests for refresh action

* Revert changes to make tree public

* Move tests into subsuite
This commit is contained in:
Charles Gagnon
2019-12-12 16:04:28 -08:00
committed by GitHub
parent 829717f5de
commit 5bf85a2855
5 changed files with 340 additions and 24 deletions

View File

@@ -26,6 +26,7 @@ import { ILogService } from 'vs/platform/log/common/log';
import { getErrorMessage } from 'vs/base/common/errors';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { localize } from 'vs/nls';
import { ServicesAccessor } from 'vs/editor/browser/editorExtensions';
//#region -- Data Explorer
export const SCRIPT_AS_CREATE_COMMAND_ID = 'dataExplorer.scriptAsCreate';
@@ -310,22 +311,24 @@ CommandsRegistry.registerCommand({
// Refresh Action for Scriptable objects
CommandsRegistry.registerCommand({
id: OE_REFRESH_COMMAND_ID,
handler: async (accessor, args: ObjectExplorerActionsContext): Promise<void> => {
const objectExplorerService = accessor.get(IObjectExplorerService);
const logService = accessor.get(ILogService);
const notificationService = accessor.get(INotificationService);
const treeNode = await getTreeNode(args, objectExplorerService);
const tree = objectExplorerService.getServerTreeView().tree;
try {
await objectExplorerService.refreshTreeNode(treeNode.getSession(), treeNode);
await tree.refresh(treeNode);
} catch (err) {
// Display message to the user but also log the entire error to the console for the stack trace
notificationService.error(localize('refreshError', "An error occurred refreshing node '{0}': {1}", args.nodeInfo.label, getErrorMessage(err)));
logService.error(err);
}
}
handler: handleOeRefreshCommand
});
export async function handleOeRefreshCommand(accessor: ServicesAccessor, args: ObjectExplorerActionsContext): Promise<void> {
const objectExplorerService = accessor.get(IObjectExplorerService);
const logService = accessor.get(ILogService);
const notificationService = accessor.get(INotificationService);
const treeNode = await getTreeNode(args, objectExplorerService);
const tree = objectExplorerService.getServerTreeView().tree;
try {
await objectExplorerService.refreshTreeNode(treeNode.getSession(), treeNode);
await tree.refresh(treeNode);
} catch (err) {
// Display message to the user but also log the entire error to the console for the stack trace
notificationService.error(localize('refreshError', "An error occurred refreshing node '{0}': {1}", args.nodeInfo.label, getErrorMessage(err)));
logService.error(err);
}
}
//#endregion
//#region -- explorer widget