Skip to content

Commit 43ff794

Browse files
committed
Revert "[WIP] Fix e2e tests (#1812)"
This reverts commit f468d9f.
1 parent 5683768 commit 43ff794

9 files changed

Lines changed: 69 additions & 103 deletions

packages/databricks-vscode/src/test/e2e/auth.e2e.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import assert from "node:assert";
22
import {
33
dismissNotifications,
4-
getActionButton,
54
waitForInput,
65
getViewSection,
76
waitForLogin,
@@ -71,12 +70,8 @@ describe("Configure Databricks Extension", async function () {
7170
const items = await section.getVisibleItems();
7271
for (const item of items) {
7372
const label = await item.getLabel();
74-
console.log(
75-
"Looking for signin button, got item:",
76-
await (await item.elem).getHTML()
77-
);
7873
if (label.toLowerCase().includes("auth type")) {
79-
return getActionButton(item, "Sign in");
74+
return item.getActionButton("Sign in");
8075
}
8176
}
8277
},

packages/databricks-vscode/src/test/e2e/deploy_and_run_job.e2e.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import assert from "node:assert";
22
import {
33
dismissNotifications,
4-
getActionButton,
54
getUniqueResourceName,
65
getViewSection,
7-
selectOutputChannel,
86
waitForDeployment,
97
waitForLogin,
108
waitForTreeItems,
@@ -67,7 +65,7 @@ describe("Deploy and run job", async function () {
6765

6866
it("should deploy and run the current job", async () => {
6967
const outputView = await workbench.getBottomBar().openOutputView();
70-
await selectOutputChannel(outputView, "Databricks Bundle Logs");
68+
await outputView.selectChannel("Databricks Bundle Logs");
7169
await outputView.clearText();
7270

7371
const jobItem = await getResourceViewItem(
@@ -77,8 +75,7 @@ describe("Deploy and run job", async function () {
7775
);
7876
assert(jobItem, `Job ${jobName} not found in resource explorer`);
7977

80-
const deployAndRunButton = await getActionButton(
81-
jobItem,
78+
const deployAndRunButton = await jobItem.getActionButton(
8279
"Deploy the bundle and run the job"
8380
);
8481
assert(deployAndRunButton, "Deploy and run button not found");

packages/databricks-vscode/src/test/e2e/deploy_and_run_pipeline.e2e.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import assert from "node:assert";
22
import {
33
dismissNotifications,
4-
getActionButton,
54
getViewSection,
6-
selectOutputChannel,
75
waitForDeployment,
86
waitForLogin,
97
waitForTreeItems,
@@ -64,7 +62,7 @@ describe("Deploy and run pipeline", async function () {
6462

6563
it("should deploy and run the current pipeline", async () => {
6664
const outputView = await workbench.getBottomBar().openOutputView();
67-
await selectOutputChannel(outputView, "Databricks Bundle Logs");
65+
await outputView.selectChannel("Databricks Bundle Logs");
6866
await outputView.clearText();
6967

7068
const pipelineItem = await getResourceViewItem(
@@ -77,14 +75,13 @@ describe("Deploy and run pipeline", async function () {
7775
`Pipeline ${pipelineName} not found in resource explorer`
7876
);
7977

80-
const deployAndRunButton = await getActionButton(
81-
pipelineItem,
78+
const deployAndRunButton = await pipelineItem.getActionButton(
8279
"Deploy the bundle and run the pipeline"
8380
);
8481
assert(deployAndRunButton, "Deploy and run button not found");
8582
await deployAndRunButton.elem.click();
8683

87-
await waitForDeployment(outputView);
84+
await waitForDeployment();
8885

8986
await waitForRunStatus(
9087
resourceExplorerView,

packages/databricks-vscode/src/test/e2e/destroy.e2e.ts

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
dismissNotifications,
44
getUniqueResourceName,
55
getViewSection,
6-
selectOutputChannel,
76
waitForLogin,
87
waitForTreeItems,
98
} from "./utils/commonUtils.ts";
@@ -72,33 +71,42 @@ describe("Deploy and destroy", async function () {
7271
.replaceAll(/[^a-zA-Z0-9]/g, "_")}]`;
7372

7473
const outputView = await workbench.getBottomBar().openOutputView();
75-
await selectOutputChannel(outputView, "Databricks Bundle Logs");
74+
await outputView.selectChannel("Databricks Bundle Logs");
7675
await outputView.clearText();
7776

7877
await browser.executeWorkbench(async (vscode) => {
7978
await vscode.commands.executeCommand("databricks.bundle.deploy");
8079
});
81-
82-
await browser.executeWorkbench(async (vscode) => {
83-
await vscode.commands.executeCommand(
84-
"workbench.panel.output.focus"
85-
);
86-
});
87-
88-
await selectOutputChannel(outputView, "Databricks Bundle Logs");
89-
9080
console.log("Waiting for deployment to finish");
81+
// Wait for the deployment to finish
9182
await browser.waitUntil(
9283
async () => {
9384
try {
85+
await browser.executeWorkbench(async (vscode) => {
86+
await vscode.commands.executeCommand(
87+
"workbench.panel.output.focus"
88+
);
89+
});
90+
const outputView = await workbench
91+
.getBottomBar()
92+
.openOutputView();
93+
94+
if (
95+
(await outputView.getCurrentChannel()) !==
96+
"Databricks Bundle Logs"
97+
) {
98+
await outputView.selectChannel(
99+
"Databricks Bundle Logs"
100+
);
101+
}
102+
94103
const logs = (await outputView.getText()).join("");
95104
console.log(logs);
96105
return (
97106
logs.includes("Bundle deployed successfully") &&
98107
logs.includes("Bundle configuration refreshed")
99108
);
100109
} catch (e) {
101-
console.log("Error waiting for deployment to finish:", e);
102110
return false;
103111
}
104112
},
@@ -127,19 +135,29 @@ describe("Deploy and destroy", async function () {
127135
);
128136
});
129137

130-
await browser.executeWorkbench(async (vscode) => {
131-
await vscode.commands.executeCommand(
132-
"workbench.panel.output.focus"
133-
);
134-
});
135-
136-
await selectOutputChannel(outputView, "Databricks Bundle Logs");
137-
138138
console.log("Waiting for bundle to destroy");
139139
// Wait for status to reach success
140140
await browser.waitUntil(
141141
async () => {
142142
try {
143+
await browser.executeWorkbench(async (vscode) => {
144+
await vscode.commands.executeCommand(
145+
"workbench.panel.output.focus"
146+
);
147+
});
148+
const outputView = await workbench
149+
.getBottomBar()
150+
.openOutputView();
151+
152+
if (
153+
(await outputView.getCurrentChannel()) !==
154+
"Databricks Bundle Logs"
155+
) {
156+
await outputView.selectChannel(
157+
"Databricks Bundle Logs"
158+
);
159+
}
160+
143161
const logs = (await outputView.getText()).join("");
144162
console.log(logs);
145163
return (

packages/databricks-vscode/src/test/e2e/refresh_resource_explorer_on_yml_change.e2e.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {CustomTreeSection} from "wdio-vscode-service";
33
import {
44
dismissNotifications,
55
getViewSection,
6-
selectOutputChannel,
76
waitForLogin,
87
} from "./utils/commonUtils.ts";
98
import {
@@ -79,8 +78,7 @@ describe("Automatically refresh resource explorer", async function () {
7978
const outputView = await (await browser.getWorkbench())
8079
.getBottomBar()
8180
.openOutputView();
82-
83-
await selectOutputChannel(outputView, "Databricks Bundle Logs");
81+
await outputView.selectChannel("Databricks Bundle Logs");
8482

8583
const jobDef = await createProjectWithJob(
8684
projectName,

packages/databricks-vscode/src/test/e2e/run_dbconnect.ucws.e2e.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,15 +198,9 @@ describe("Run files on serverless compute", async function () {
198198

199199
// Install dependencies from the requirements.txt
200200
const dependenciesInput = await waitForInput();
201-
try {
202-
await dependenciesInput.toggleAllQuickPicks(true);
203-
} catch (e) {
204-
console.log(
205-
"Failed to toggle all quick picks, moving on. Error:",
206-
e
207-
);
208-
}
201+
await dependenciesInput.toggleAllQuickPicks(true);
209202
await dependenciesInput.confirm();
203+
210204
await waitForNotification("The following environment is selected");
211205
await waitForNotification("Databricks Connect", "Install");
212206

packages/databricks-vscode/src/test/e2e/run_files.e2e.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,10 @@ describe("Run files", async function () {
5151
await executeCommandWhenAvailable("Databricks: Upload and Run File");
5252
await browser.waitUntil(async () => {
5353
const notifications = await workbench.getNotifications();
54-
console.log("Notifications:", notifications.length);
5554
for (const notification of notifications) {
5655
const message = await notification.getMessage();
57-
console.log("Message:", message);
5856
if (message.includes("Uploading bundle assets")) {
59-
const elements = await notification.actions$.$$(
60-
notification.locators.action
61-
);
62-
console.log("Elements:", elements.length);
63-
for (const element of elements) {
64-
const text = await element.getText();
65-
if (text === "Cancel") {
66-
await element.click();
67-
break;
68-
}
69-
}
57+
await notification.takeAction("Cancel");
7058
return true;
7159
}
7260
}

packages/databricks-vscode/src/test/e2e/utils/commonUtils.ts

Lines changed: 20 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import {
66
ViewControl,
77
ViewSection,
88
InputBox,
9-
OutputView,
10-
TreeItem,
119
} from "wdio-vscode-service";
1210

1311
// eslint-disable-next-line @typescript-eslint/naming-convention
@@ -21,17 +19,6 @@ const ViewSectionTypes = [
2119
] as const;
2220
export type ViewSectionType = (typeof ViewSectionTypes)[number];
2321

24-
export async function selectOutputChannel(
25-
outputView: OutputView,
26-
channelName: string
27-
) {
28-
if ((await outputView.getCurrentChannel()) === channelName) {
29-
return;
30-
}
31-
outputView.locatorMap.BottomBarViews.outputChannels = `ul[aria-label="Output actions"] select`;
32-
await outputView.selectChannel(channelName);
33-
}
34-
3522
export async function findViewSection(name: ViewSectionType) {
3623
const workbench = await browser.getWorkbench();
3724

@@ -54,14 +41,12 @@ export async function findViewSection(name: ViewSectionType) {
5441
);
5542
const views =
5643
(await (await control?.openView())?.getContent()?.getSections()) ?? [];
57-
console.log("Views:", views.length);
5844
for (const v of views) {
59-
const title = await v.elem.getText();
60-
console.log("View title:", title);
45+
const title = await v.getTitle();
6146
if (title === null) {
6247
continue;
6348
}
64-
if (title.toUpperCase().includes(name)) {
49+
if (title.toUpperCase() === name) {
6550
return v;
6651
}
6752
}
@@ -350,15 +335,28 @@ export async function waitForNotification(message: string, action?: string) {
350335
);
351336
}
352337

353-
export async function waitForDeployment(outputView: OutputView) {
338+
export async function waitForDeployment() {
354339
console.log("Waiting for deployment to finish");
355-
await browser.executeWorkbench(async (vscode) => {
356-
await vscode.commands.executeCommand("workbench.panel.output.focus");
357-
});
358-
await selectOutputChannel(outputView, "Databricks Bundle Logs");
340+
const workbench = await driver.getWorkbench();
359341
await browser.waitUntil(
360342
async () => {
361343
try {
344+
await browser.executeWorkbench(async (vscode) => {
345+
await vscode.commands.executeCommand(
346+
"workbench.panel.output.focus"
347+
);
348+
});
349+
const outputView = await workbench
350+
.getBottomBar()
351+
.openOutputView();
352+
353+
if (
354+
(await outputView.getCurrentChannel()) !==
355+
"Databricks Bundle Logs"
356+
) {
357+
await outputView.selectChannel("Databricks Bundle Logs");
358+
}
359+
362360
const logs = (await outputView.getText()).join("");
363361
console.log("------------ Bundle Output ------------");
364362
console.log(logs);
@@ -378,22 +376,3 @@ export async function waitForDeployment(outputView: OutputView) {
378376
}
379377
);
380378
}
381-
382-
export async function getActionButton(item: TreeItem, label: string) {
383-
const actions = await item.getActionButtons();
384-
if (actions.length > 0) {
385-
for (const item of actions) {
386-
console.log("Checking action button:", item.getLabel());
387-
console.log(
388-
"Action button element:",
389-
await (await item.elem).getHTML()
390-
);
391-
const itemLabel =
392-
item.getLabel() ?? (await item.elem.getAttribute("aria-label"));
393-
if (itemLabel.indexOf(label) > -1) {
394-
return item;
395-
}
396-
}
397-
}
398-
return undefined;
399-
}

packages/databricks-vscode/src/test/e2e/wdio.conf.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ export const config: Options.Testrunner = {
169169
return [
170170
{
171171
"browserName": "vscode",
172-
"browserVersion": engines.vscode.replace(/\^/, ""),
172+
"browserVersion": engines.vscode.replace("^", ""),
173173
"wdio:vscodeOptions": {
174174
extensionPath: path.resolve(
175175
__dirname,

0 commit comments

Comments
 (0)