Skip to content

Commit 2b88c6e

Browse files
author
Guilherme Saraiva
committed
E2E extension tests new function
This patch creates the function 'removeAllDatabaseConnections()'. This function is now not only called at the end of each test suite, but also at the beginning of each test suite. It has happened that because of buggy tests, the DB connections are not removed at the end of the tests, causing test failures on further executions. With this patch, we ensure there are no DB connections at the beginning of the tests Change-Id: Idc1bada93a288e6749292e539231b2e67d2c0c33
1 parent bdebdc5 commit 2b88c6e

File tree

6 files changed

+21
-31
lines changed

6 files changed

+21
-31
lines changed

gui/extension/tests/e2e/lib/workbench.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,4 +498,15 @@ export class Workbench {
498498
await (await new ActivityBar().getViewControl(constants.extensionName))?.openView();
499499
};
500500

501+
/**
502+
* Removes all existing database connections from the DATABASE CONNECTIONS section
503+
* @returns A promise resolving when all connections are deleted
504+
*/
505+
public static removeAllDatabaseConnections = async (): Promise<void> => {
506+
const dbConnections = await Tree.getDatabaseConnections();
507+
await Workbench.closeAllEditors();
508+
for (const dbConnection of dbConnections) {
509+
await Tree.deleteDatabaseConnection(dbConnection.name, dbConnection.isMySQL, false);
510+
}
511+
};
501512
}

gui/extension/tests/e2e/tests/ui-db.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ describe("DATABASE CONNECTIONS", () => {
9393
await (await activityBare.getViewControl(constants.extensionName))?.openView();
9494
await Workbench.dismissNotifications();
9595
await Workbench.toggleBottomBar(false);
96+
await Workbench.removeAllDatabaseConnections();
9697
await Section.createDatabaseConnection(globalConn);
9798
await Workbench.closeAllEditors();
9899
await new BottomBarPanel().toggle(false);
@@ -110,11 +111,7 @@ describe("DATABASE CONNECTIONS", () => {
110111
after(async function () {
111112
try {
112113
await Os.prepareExtensionLogsForExport(process.env.TEST_SUITE);
113-
const dbConnections = await Tree.getDatabaseConnections();
114-
await Workbench.closeAllEditors();
115-
for (const dbConnection of dbConnections) {
116-
await Tree.deleteDatabaseConnection(dbConnection.name, dbConnection.isMySQL, false);
117-
}
114+
await Workbench.removeAllDatabaseConnections();
118115
} catch (e) {
119116
await Misc.processFailure(this);
120117
throw e;

gui/extension/tests/e2e/tests/ui-notebook.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ describe("NOTEBOOKS", () => {
8989
try {
9090
await driver.wait(waitUntil.extensionIsReady(), constants.wait2minutes);
9191
await Workbench.toggleBottomBar(false);
92+
await Workbench.removeAllDatabaseConnections();
9293
await Section.createDatabaseConnection(globalConn);
9394
await (await DatabaseConnection.getConnection(globalConn.caption)).click();
9495
await driver.wait(waitUntil.dbConnectionIsOpened(globalConn), constants.wait10seconds);
@@ -105,10 +106,7 @@ describe("NOTEBOOKS", () => {
105106
after(async function () {
106107
try {
107108
await Os.prepareExtensionLogsForExport(process.env.TEST_SUITE);
108-
const dbConnections = await Tree.getDatabaseConnections();
109-
for (const dbConnection of dbConnections) {
110-
await Tree.deleteDatabaseConnection(dbConnection.name, dbConnection.isMySQL, false);
111-
}
109+
await Workbench.removeAllDatabaseConnections();
112110
} catch (e) {
113111
await Misc.processFailure(this);
114112
throw e;

gui/extension/tests/e2e/tests/ui-oci.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ describe("ORACLE CLOUD INFRASTRUCTURE", () => {
7474
try {
7575
await driver.wait(waitUntil.extensionIsReady(), constants.wait2minutes);
7676
await Workbench.toggleBottomBar(false);
77+
await Workbench.removeAllDatabaseConnections();
7778
await Section.focus(constants.ociTreeSection);
7879
const treeOCISection = await Section.getSection(constants.ociTreeSection);
7980
await Section.clickToolbarButton(treeOCISection, constants.configureOci);
@@ -91,6 +92,7 @@ describe("ORACLE CLOUD INFRASTRUCTURE", () => {
9192
after(async function () {
9293
try {
9394
await Os.prepareExtensionLogsForExport(process.env.TEST_SUITE);
95+
await Workbench.removeAllDatabaseConnections();
9496
} catch (e) {
9597
await Misc.processFailure(this);
9698
throw e;
@@ -366,20 +368,6 @@ describe("ORACLE CLOUD INFRASTRUCTURE", () => {
366368

367369
});
368370

369-
after(async function () {
370-
try {
371-
await Workbench.closeAllEditors();
372-
await Section.focus(constants.dbTreeSection);
373-
const dbConnections = await Tree.getDatabaseConnections();
374-
for (const dbConnection of dbConnections) {
375-
await Tree.deleteDatabaseConnection(dbConnection.name, dbConnection.isMySQL, false);
376-
}
377-
} catch (e) {
378-
await Misc.processFailure(this);
379-
throw e;
380-
}
381-
});
382-
383371
it("Get Bastion Information and set it as current", async () => {
384372

385373
const treeBastion = await Tree.getOciElementByType(constants.ociTreeSection, constants.bastionType);

gui/extension/tests/e2e/tests/ui-open-editors.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ describe("OPEN EDITORS", () => {
8282
await (await activityBare.getViewControl(constants.extensionName))?.openView();
8383
await Workbench.dismissNotifications();
8484
await Workbench.toggleBottomBar(false);
85+
await Workbench.removeAllDatabaseConnections();
8586
await Section.createDatabaseConnection(globalConn);
8687
await Workbench.closeAllEditors();
8788
await new BottomBarPanel().toggle(false);
@@ -97,10 +98,7 @@ describe("OPEN EDITORS", () => {
9798
after(async function () {
9899
try {
99100
await Os.prepareExtensionLogsForExport(process.env.TEST_SUITE);
100-
const dbConnections = await Tree.getDatabaseConnections();
101-
for (const dbConnection of dbConnections) {
102-
await Tree.deleteDatabaseConnection(dbConnection.name, dbConnection.isMySQL, false);
103-
}
101+
await Workbench.removeAllDatabaseConnections();
104102
} catch (e) {
105103
await Misc.processFailure(this);
106104
throw e;

gui/extension/tests/e2e/tests/ui-rest.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ describe("MySQL REST Service", () => {
8282
await driver.wait(waitUntil.extensionIsReady(), constants.wait2minutes);
8383
await Workbench.toggleBottomBar(false);
8484
await Section.focus(constants.dbTreeSection);
85+
await Workbench.removeAllDatabaseConnections();
8586
await Section.createDatabaseConnection(globalConn);
8687
await (await DatabaseConnection.getConnection(globalConn.caption)).click();
8788
await driver.wait(waitUntil.dbConnectionIsOpened(globalConn), constants.wait10seconds);
@@ -121,10 +122,7 @@ describe("MySQL REST Service", () => {
121122
after(async function () {
122123
try {
123124
await Os.prepareExtensionLogsForExport(process.env.TEST_SUITE);
124-
const dbConnections = await Tree.getDatabaseConnections();
125-
for (const dbConnection of dbConnections) {
126-
await Tree.deleteDatabaseConnection(dbConnection.name, dbConnection.isMySQL, false);
127-
}
125+
await Workbench.removeAllDatabaseConnections();
128126
} catch (e) {
129127
await Misc.processFailure(this);
130128
throw e;

0 commit comments

Comments
 (0)