mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Fix/add OE Context Menu tests (#5543)
* Fix/add OE Context Menu tests * Add return types for helper functions
This commit is contained in:
@@ -31,32 +31,64 @@ if (context.RunTest) {
|
|||||||
let server = await getAzureServer();
|
let server = await getAzureServer();
|
||||||
await VerifyOeNode(server, 3000, expectedNodeLabel);
|
await VerifyOeNode(server, 3000, expectedNodeLabel);
|
||||||
});
|
});
|
||||||
test('context menu test', async function () {
|
|
||||||
let server = await getAzureServer();
|
|
||||||
await connectToServer(server, 3000);
|
|
||||||
let nodes = <azdata.objectexplorer.ObjectExplorerNode[]>await azdata.objectexplorer.getActiveConnectionNodes();
|
|
||||||
assert(nodes.length > 0, `Expecting at least one active connection, actual: ${nodes.length}`);
|
|
||||||
|
|
||||||
let index = nodes.findIndex(node => node.nodePath.includes(server.serverName));
|
test('Standard SQL DB context menu test', async function () {
|
||||||
assert(index !== -1, `Failed to find server: "${server.serverName}" in OE tree`);
|
let server = await getStandaloneServer();
|
||||||
|
|
||||||
let node = nodes[index];
|
let expectedActions: string[];
|
||||||
let actions = await azdata.objectexplorer.getNodeActions(node.connectionId, node.nodePath);
|
|
||||||
let expectedActions;
|
|
||||||
|
|
||||||
|
// Properties comes from the admin-tool-ext-win extension which is for Windows only, so the item won't show up on non-Win32 platforms
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
expectedActions = ['Manage', 'New Query', 'Disconnect', 'Delete Connection', 'Refresh', 'New Notebook', 'Data-tier Application wizard', 'Launch Profiler', 'Properties'];
|
expectedActions = ['Manage', 'New Query', 'Disconnect', 'Delete Connection', 'Refresh', 'New Notebook', 'Data-tier Application wizard', 'Launch Profiler', 'Properties'];
|
||||||
} else {
|
} else {
|
||||||
expectedActions = ['Manage', 'New Query', 'Disconnect', 'Delete Connection', 'Refresh', 'New Notebook', 'Data-tier Application wizard', 'Launch Profiler'];
|
expectedActions = ['Manage', 'New Query', 'Disconnect', 'Delete Connection', 'Refresh', 'New Notebook', 'Data-tier Application wizard', 'Launch Profiler'];
|
||||||
}
|
}
|
||||||
|
|
||||||
const expectedString = expectedActions.join(',');
|
await verifyContextMenu(server, expectedActions);
|
||||||
const actualString = actions.join(',');
|
});
|
||||||
assert(expectedActions.length === actions.length && expectedString === actualString, `Expected actions: "${expectedString}", Actual actions: "${actualString}"`);
|
|
||||||
|
test('BDC instance context menu test', async function () {
|
||||||
|
let server = await getBdcServer();
|
||||||
|
|
||||||
|
let expectedActions: string[];
|
||||||
|
|
||||||
|
// Properties comes from the admin-tool-ext-win extension which is for Windows only, so the item won't show up on non-Win32 platforms
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
expectedActions = ['Manage', 'New Query', 'Disconnect', 'Delete Connection', 'Refresh', 'New Notebook', 'Data-tier Application wizard', 'Launch Profiler', 'Properties'];
|
||||||
|
} else {
|
||||||
|
expectedActions = ['Manage', 'New Query', 'Disconnect', 'Delete Connection', 'Refresh', 'New Notebook', 'Data-tier Application wizard', 'Launch Profiler'];
|
||||||
|
}
|
||||||
|
|
||||||
|
await verifyContextMenu(server, expectedActions);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Azure SQL DB context menu test', async function () {
|
||||||
|
const server = await getAzureServer();
|
||||||
|
// Azure DB doesn't have Properties node on server level
|
||||||
|
const expectedActions = ['Manage', 'New Query', 'Disconnect', 'Delete Connection', 'Refresh', 'New Notebook', 'Data-tier Application wizard', 'Launch Profiler'];
|
||||||
|
|
||||||
|
await verifyContextMenu(server, expectedActions);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
async function VerifyOeNode(server: TestServerProfile, timeout: number, expectedNodeLabel: string[]) {
|
|
||||||
|
async function verifyContextMenu(server: TestServerProfile, expectedActions: string[]): Promise<void> {
|
||||||
|
await connectToServer(server, 3000);
|
||||||
|
let nodes = <azdata.objectexplorer.ObjectExplorerNode[]>await azdata.objectexplorer.getActiveConnectionNodes();
|
||||||
|
assert(nodes.length > 0, `Expecting at least one active connection, actual: ${nodes.length}`);
|
||||||
|
|
||||||
|
let index = nodes.findIndex(node => node.nodePath.includes(server.serverName));
|
||||||
|
assert(index !== -1, `Failed to find server: "${server.serverName}" in OE tree`);
|
||||||
|
|
||||||
|
let node = nodes[index];
|
||||||
|
let actions = await azdata.objectexplorer.getNodeActions(node.connectionId, node.nodePath);
|
||||||
|
|
||||||
|
const expectedString = expectedActions.join(',');
|
||||||
|
const actualString = actions.join(',');
|
||||||
|
assert(expectedActions.length === actions.length && expectedString === actualString, `Expected actions: "${expectedString}", Actual actions: "${actualString}"`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function VerifyOeNode(server: TestServerProfile, timeout: number, expectedNodeLabel: string[]): Promise<void> {
|
||||||
await connectToServer(server, timeout);
|
await connectToServer(server, timeout);
|
||||||
let nodes = <azdata.objectexplorer.ObjectExplorerNode[]>await azdata.objectexplorer.getActiveConnectionNodes();
|
let nodes = <azdata.objectexplorer.ObjectExplorerNode[]>await azdata.objectexplorer.getActiveConnectionNodes();
|
||||||
assert(nodes.length > 0, `Expecting at least one active connection, actual: ${nodes.length}`);
|
assert(nodes.length > 0, `Expecting at least one active connection, actual: ${nodes.length}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user