Skip to content

Commit 49f4788

Browse files
author
Guilherme Saraiva
committed
Fix Execute with caret button test on E2E FE
This patch fixes a flaky test - Connection toolbar buttons - Execute statement at the caret position Change-Id: I33c9cd1e7d45392de3569b6b02c01374bfec65a1
1 parent 8f356fc commit 49f4788

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed

gui/frontend/src/tests/e2e/lib/dbConnection.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,24 @@ export class DBConnection {
8383
throw new Error(`Could not find button '${button}'`);
8484
};
8585

86+
/**
87+
* Clicks on a toolbar button and waits for the button to be active again.
88+
* Throws an exception if the button is not found.
89+
* @param driver The webdriver
90+
* @param button Toolbar button tooltip
91+
* @returns Promise resolving with the Toolbar button
92+
*/
93+
public static clickToolbarButton = async (driver: WebDriver, button: string): Promise<void> => {
94+
const toolbarButton = await DBConnection.getToolbarButton(driver, button);
95+
await toolbarButton?.click();
96+
await driver.wait(async () => {
97+
return (await toolbarButton?.getAttribute("class"))?.includes("disabled");
98+
}, explicitWait, `The button ${button} should be disabled after clicking it`);
99+
await driver.wait(async () => {
100+
return (await toolbarButton?.getAttribute("class"))?.includes("disabled") === false;
101+
}, explicitWait, `The button ${button} should be enabled`);
102+
};
103+
86104
/**
87105
* Returns the result status of a query or instruction on the DB Editor
88106
*

gui/frontend/src/tests/e2e/tests/dbeditor/notebook.spec.ts

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -283,30 +283,14 @@ describe("Notebook", () => {
283283
await textArea.sendKeys(Key.RETURN);
284284
await DBConnection.writeSQL(driver, query3);
285285
await DBNotebooks.setMouseCursorAt(driver, query2);
286-
287-
let execCaretBtn = await DBConnection.getToolbarButton(driver, execCaret);
288-
await execCaretBtn?.click();
289-
await driver.wait(async () => {
290-
await execCaretBtn?.click();
291-
292-
return DBConnection.getResultColumnName(driver, "address_id") !== undefined;
293-
}, 3000, "No new results block was displayed");
294-
286+
await DBConnection.clickToolbarButton(driver, execCaret);
287+
expect(await DBConnection.getResultColumnName(driver, "address_id")).toBeDefined();
295288
await DBNotebooks.setMouseCursorAt(driver, query1);
296-
execCaretBtn = await DBConnection.getToolbarButton(driver, execCaret);
297-
await driver.wait(new Condition("", async () => {
298-
await execCaretBtn?.click();
299-
300-
return await DBConnection.getResultColumnName(driver, "actor_id") !== undefined;
301-
}), explicitWait, "actor_id column was not found");
302-
289+
await DBConnection.clickToolbarButton(driver, execCaret);
290+
expect(await DBConnection.getResultColumnName(driver, "actor_id")).toBeDefined();
303291
await DBNotebooks.setMouseCursorAt(driver, query3);
304-
execCaretBtn = await DBConnection.getToolbarButton(driver, execCaret);
305-
await driver.wait(new Condition("", async () => {
306-
await execCaretBtn?.click();
307-
308-
return await DBConnection.getResultColumnName(driver, "category_id") !== undefined;
309-
}), explicitWait, "category_id column was not found");
292+
await DBConnection.clickToolbarButton(driver, execCaret);
293+
expect(await DBConnection.getResultColumnName(driver, "category_id")).toBeDefined();
310294
} catch (e) {
311295
testFailed = true;
312296
throw e;

0 commit comments

Comments
 (0)