Skip to content

Commit 9af6393

Browse files
committed
ci: update pipeline
1 parent 7565208 commit 9af6393

File tree

2 files changed

+79
-15
lines changed

2 files changed

+79
-15
lines changed

test/e2e/fixtures/baseTest.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,23 @@ export const test = base.extend<TestFixtures>({
5151
const projectDir = path.join(tmpDir, projectName);
5252
fs.copySync(path.join(TEST_DATA_ROOT, testProjectDir), projectDir);
5353

54+
// Write VS Code settings to suppress telemetry prompts and notification noise
55+
const vscodeDir = path.join(projectDir, ".vscode");
56+
fs.ensureDirSync(vscodeDir);
57+
const settingsPath = path.join(vscodeDir, "settings.json");
58+
const existingSettings = fs.existsSync(settingsPath)
59+
? JSON.parse(fs.readFileSync(settingsPath, "utf-8"))
60+
: {};
61+
const mergedSettings = {
62+
...existingSettings,
63+
"telemetry.telemetryLevel": "off",
64+
"redhat.telemetry.enabled": false,
65+
"workbench.colorTheme": "Default Dark Modern",
66+
"update.mode": "none",
67+
"extensions.ignoreRecommendations": true,
68+
};
69+
fs.writeFileSync(settingsPath, JSON.stringify(mergedSettings, null, 4));
70+
5471
// 2. Resolve VS Code executable.
5572
const vscodePath = await downloadAndUnzipVSCode(vscodeVersion);
5673
const [, ...cliArgs] = resolveCliArgsFromVSCodeExecutablePath(vscodePath);
@@ -67,6 +84,8 @@ export const test = base.extend<TestFixtures>({
6784
"--skip-release-notes",
6885
"--disable-workspace-trust",
6986
"--password-store=basic",
87+
// Suppress notifications that block UI interactions
88+
"--disable-telemetry",
7089
...cliArgs,
7190
`--extensionDevelopmentPath=${EXTENSION_ROOT}`,
7291
projectDir,
@@ -75,6 +94,10 @@ export const test = base.extend<TestFixtures>({
7594

7695
const page = await electronApp.firstWindow();
7796

97+
// Dismiss any startup notifications/dialogs before handing off to tests
98+
await page.waitForTimeout(3_000);
99+
await dismissAllNotifications(page);
100+
78101
// 4. Optional tracing
79102
if (testInfo.retry > 0 || !process.env.CI) {
80103
await page.context().tracing.start({ screenshots: true, snapshots: true, title: testInfo.title });
@@ -105,3 +128,36 @@ export const test = base.extend<TestFixtures>({
105128
}
106129
},
107130
});
131+
132+
/**
133+
* Dismiss all VS Code notification toasts (telemetry prompts, theme suggestions, etc.).
134+
* These notifications can steal focus and block Quick Open / Command Palette interactions.
135+
*/
136+
async function dismissAllNotifications(page: Page): Promise<void> {
137+
try {
138+
// Click "Clear All Notifications" if the notification center button is visible
139+
const clearAll = page.locator(".notifications-toasts .codicon-notifications-clear-all, .notification-toast .codicon-close");
140+
let count = await clearAll.count().catch(() => 0);
141+
while (count > 0) {
142+
await clearAll.first().click();
143+
await page.waitForTimeout(500);
144+
count = await clearAll.count().catch(() => 0);
145+
}
146+
147+
// Also try the command palette approach as a fallback
148+
const notificationToasts = page.locator(".notification-toast");
149+
if (await notificationToasts.count().catch(() => 0) > 0) {
150+
// Use keyboard shortcut to clear all notifications
151+
await page.keyboard.press("Control+Shift+P");
152+
const input = page.locator(".quick-input-widget input.input");
153+
if (await input.isVisible({ timeout: 3_000 }).catch(() => false)) {
154+
await input.fill("Notifications: Clear All Notifications");
155+
await page.waitForTimeout(500);
156+
await input.press("Enter");
157+
await page.waitForTimeout(500);
158+
}
159+
}
160+
} catch {
161+
// Best effort
162+
}
163+
}

test/e2e/utils/vscodeOperator.ts

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -172,28 +172,36 @@ export default class VscodeOperator {
172172
static async dismissModalDialog(page: Page): Promise<void> {
173173
const acceptLabels = ["Yes, I trust the authors", "OK", "Yes", "Continue", "I Trust the Authors"];
174174
try {
175+
// Handle modal dialogs
175176
const dialog = page.locator(".monaco-dialog-box");
176-
if (!await dialog.isVisible({ timeout: 2_000 }).catch(() => false)) {
177-
return;
178-
}
179-
for (const label of acceptLabels) {
180-
const btn = dialog.getByRole(VSCode.BUTTON_ROLE, { name: label });
181-
if (await btn.isVisible().catch(() => false)) {
182-
await btn.click();
183-
await page.waitForTimeout(Timeout.CLICK);
184-
return;
177+
if (await dialog.isVisible({ timeout: 2_000 }).catch(() => false)) {
178+
for (const label of acceptLabels) {
179+
const btn = dialog.getByRole(VSCode.BUTTON_ROLE, { name: label });
180+
if (await btn.isVisible().catch(() => false)) {
181+
await btn.click();
182+
await page.waitForTimeout(Timeout.CLICK);
183+
break;
184+
}
185185
}
186186
}
187-
// Fallback: click first button
188-
const firstBtn = dialog.getByRole(VSCode.BUTTON_ROLE).first();
189-
if (await firstBtn.isVisible().catch(() => false)) {
190-
await firstBtn.click();
191-
await page.waitForTimeout(Timeout.CLICK);
187+
} catch {
188+
// No modal dialog — nothing to dismiss
189+
}
190+
191+
// Also dismiss notification toasts (telemetry prompts, theme suggestions, etc.)
192+
try {
193+
const closeButtons = page.locator(".notification-toast .codicon-close");
194+
let count = await closeButtons.count().catch(() => 0);
195+
while (count > 0) {
196+
await closeButtons.first().click();
197+
await page.waitForTimeout(500);
198+
count = await closeButtons.count().catch(() => 0);
192199
}
193200
} catch {
194-
// No dialog — nothing to do
201+
// Best effort
195202
}
196203
}
204+
}
197205

198206
/**
199207
* Waits for a modal dialog to appear and clicks a button by its label.

0 commit comments

Comments
 (0)