Skip to content

Commit aae60dc

Browse files
wenytang-msCopilot
andcommitted
refactor: address PR review comments
- Remove unused imports in fileOperations.test.ts and libraries.test.ts - Clean up skipped test bodies and dead beforeEach in libraries.test.ts - Fix JSDoc comment in vscodeOperator.ts to reflect actual CSS fallbacks - Increase Playwright timeout from 180s to 240s for LS readiness margin - Remove cliArgs spread from Electron launch (avoid CLI-only flags) - Remove VSIX install from globalSetup (extensionDevelopmentPath suffices) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ab71b15 commit aae60dc

File tree

6 files changed

+21
-69
lines changed

6 files changed

+21
-69
lines changed

test/e2e/fixtures/baseTest.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717

1818
import { _electron, test as base, type Page } from "@playwright/test";
19-
import { downloadAndUnzipVSCode, resolveCliArgsFromVSCodeExecutablePath } from "@vscode/test-electron";
19+
import { downloadAndUnzipVSCode } from "@vscode/test-electron";
2020
import * as fs from "fs-extra";
2121
import * as os from "os";
2222
import * as path from "path";
@@ -79,7 +79,12 @@ export const test = base.extend<TestFixtures>({
7979

8080
// 2. Resolve VS Code executable.
8181
const vscodePath = await downloadAndUnzipVSCode(vscodeVersion);
82-
const [, ...cliArgs] = resolveCliArgsFromVSCodeExecutablePath(vscodePath);
82+
// resolveCliArgsFromVSCodeExecutablePath returns CLI-specific args
83+
// (e.g. --ms-enable-electron-run-as-node) that are unsuitable for
84+
// Electron UI launch. Extract only --extensions-dir and --user-data-dir.
85+
const vscodeTestDir = path.join(EXTENSION_ROOT, ".vscode-test");
86+
const extensionsDir = path.join(vscodeTestDir, "extensions");
87+
const userDataDir = path.join(vscodeTestDir, "user-data");
8388

8489
// 3. Launch VS Code as an Electron app.
8590
const electronApp = await _electron.launch({
@@ -95,7 +100,8 @@ export const test = base.extend<TestFixtures>({
95100
"--password-store=basic",
96101
// Suppress notifications that block UI interactions
97102
"--disable-telemetry",
98-
...cliArgs,
103+
`--extensions-dir=${extensionsDir}`,
104+
`--user-data-dir=${userDataDir}`,
99105
`--extensionDevelopmentPath=${EXTENSION_ROOT}`,
100106
projectDir,
101107
],

test/e2e/globalSetup.ts

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33

44
import { downloadAndUnzipVSCode, resolveCliArgsFromVSCodeExecutablePath } from "@vscode/test-electron";
55
import * as childProcess from "child_process";
6-
import * as path from "path";
76

87
/**
98
* Global setup runs once before all test files.
10-
* It downloads VS Code, then installs the redhat.java extension and our own
11-
* VSIX so that every test run starts from an identical, pre-provisioned state.
9+
* It downloads VS Code and installs the redhat.java extension so that
10+
* every test run starts from an identical, pre-provisioned state.
11+
*
12+
* Our own extension is loaded at launch time via --extensionDevelopmentPath
13+
* (see baseTest.ts), so there is no need to install a VSIX here.
1214
*/
1315
export default async function globalSetup(): Promise<void> {
1416
// Download VS Code stable (or the version configured via VSCODE_VERSION env).
@@ -29,19 +31,4 @@ export default async function globalSetup(): Promise<void> {
2931
// Install the Language Support for Java extension from the Marketplace.
3032
console.log("[globalSetup] Installing redhat.java extension…");
3133
childProcess.execFileSync(cli, [...cliArgs, "--install-extension", "redhat.java"], execOptions);
32-
33-
// Install our own VSIX if one exists (built by `vsce package`).
34-
const vsixGlob = path.join(__dirname, "..", "..", "*.vsix");
35-
const glob = require("glob");
36-
const vsixFiles: string[] = glob.sync(vsixGlob);
37-
if (vsixFiles.length > 0) {
38-
const vsix = vsixFiles[0];
39-
console.log(`[globalSetup] Installing VSIX ${path.basename(vsix)}…`);
40-
childProcess.execFileSync(cli, [...cliArgs, "--install-extension", vsix], {
41-
...execOptions,
42-
timeout: 60_000,
43-
});
44-
} else {
45-
console.log("[globalSetup] No VSIX found — extension will be loaded via extensionDevelopmentPath");
46-
}
4734
}

test/e2e/playwright.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default defineConfig({
1010
? [["list"], ["junit", { outputFile: path.join(__dirname, "..", "..", "test-results", "e2e-results.xml") }]]
1111
: "list",
1212
// Java Language Server can take 2-3 minutes to fully index on first run.
13-
timeout: 180_000,
13+
timeout: 240_000,
1414
// Run tests sequentially — launching multiple VS Code instances is too resource-heavy.
1515
workers: 1,
1616
// Allow one retry in CI to handle transient environment issues.

test/e2e/tests/fileOperations.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
* - java.view.package.moveFileToTrash
1212
*/
1313

14-
import * as fs from "fs-extra";
15-
import * as path from "path";
1614
import { test, expect } from "../fixtures/baseTest";
1715
import { Timeout, VSCode } from "../utils/constants";
1816
import JavaOperator from "../utils/javaOperator";

test/e2e/tests/libraries.test.ts

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,15 @@
1010
* - java.project.create
1111
*/
1212

13-
import * as fs from "fs-extra";
14-
import * as os from "os";
15-
import * as path from "path";
16-
import { test, expect } from "../fixtures/baseTest";
17-
import { Timeout, VSCode } from "../utils/constants";
18-
import JavaOperator from "../utils/javaOperator";
19-
import VscodeOperator from "../utils/vscodeOperator";
13+
import { test } from "../fixtures/baseTest";
2014

2115
test.describe("Libraries & Project Creation", () => {
2216

2317
test.describe("invisible project library management", () => {
2418

2519
test.use({ testProjectDir: "invisible" });
2620

27-
test.beforeEach(async ({ page }) => {
28-
await VscodeOperator.dismissModalDialog(page);
29-
await JavaOperator.openFile(page, "App.java");
30-
await JavaOperator.waitForJavaLSReady(page);
31-
await JavaOperator.focusJavaProjects(page);
32-
});
33-
34-
test.skip("add and remove JAR library", async ({ page }) => {
21+
test.skip("add and remove JAR library", async () => {
3522
// Skip: the addLibraries command opens a native OS file dialog
3623
// (vscode.window.showOpenDialog) which Playwright cannot automate.
3724
// This test requires Electron dialog mocking support.
@@ -42,38 +29,11 @@ test.describe("Libraries & Project Creation", () => {
4229

4330
test.use({ testProjectDir: "invisible" });
4431

45-
test.skip("java.project.create with no build tools", async ({ page }) => {
32+
test.skip("java.project.create with no build tools", async () => {
4633
// Skip: after selecting "No build tools", scaffoldSimpleProject()
4734
// calls vscode.window.showOpenDialog() which opens a native OS file
4835
// dialog that Playwright cannot automate. This test requires
4936
// Electron dialog mocking support.
50-
await VscodeOperator.dismissModalDialog(page);
51-
await JavaOperator.openFile(page, "App.java");
52-
await JavaOperator.waitForJavaLSReady(page);
53-
54-
// Create a temp folder for the new project
55-
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "java-new-project-"));
56-
57-
await VscodeOperator.executeCommand(page, "Java: Create Java Project");
58-
// The build-tool quick pick may take a moment to appear
59-
await page.waitForTimeout(Timeout.TREE_EXPAND);
60-
61-
// Select "No build tools"
62-
await VscodeOperator.selectQuickPickItem(page, "No build tools");
63-
64-
// The project location dialog uses a native file picker on some platforms.
65-
// Enter the project name when prompted.
66-
await VscodeOperator.fillQuickInput(page, "helloworld");
67-
68-
// Wait for project files to be created
69-
await page.waitForTimeout(Timeout.TREE_EXPAND * 2);
70-
71-
// Clean up
72-
try {
73-
fs.rmSync(tmpDir, { force: true, recursive: true });
74-
} catch {
75-
// Ignore cleanup errors
76-
}
7737
});
7838
});
7939
});

test/e2e/utils/vscodeOperator.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
/**
55
* Generic VS Code UI helpers built on Playwright Page.
66
*
7-
* All methods use ARIA roles / labels rather than CSS classes so that they
8-
* survive VS Code version upgrades.
7+
* These helpers prefer ARIA roles / labels over CSS classes where possible
8+
* to better survive VS Code version upgrades, but some fall back to CSS
9+
* selectors when needed.
910
*/
1011

1112
import { Page } from "@playwright/test";

0 commit comments

Comments
 (0)