Skip to content

Commit 419336a

Browse files
authored
chore(vscode): move e2e test to use temp folder each time (#4521)
1 parent 18911b3 commit 419336a

1 file changed

Lines changed: 50 additions & 42 deletions

File tree

Lines changed: 50 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,60 @@
11
import { test, _electron as electron, expect } from '@playwright/test';
22
import path from 'path';
33
import fs from 'fs-extra';
4+
import os from 'os';
45

56
// Absolute path to the VS Code executable you downloaded in step 1.
67
const VS_CODE_EXE = fs.readJsonSync('.vscode-test/paths.json').executablePath;
78
// Where your extension lives on disk
8-
const EXT_PATH = path.join(__dirname, '..');
9-
// Where the sushi project lives which we open in the webview
10-
const PROJECT_PATH = path.join(__dirname, '..', '..', '..', 'examples', 'sushi');
9+
const EXT_PATH = path.resolve(__dirname, '..');
10+
// Where the sushi project lives which we copy from
11+
const SUSHI_SOURCE_PATH = path.join(__dirname, '..', '..', '..', 'examples', 'sushi');
1112

1213
test('Lineage panel renders correctly', async () => {
13-
const ciArgs = process.env.CI ? [
14-
'--disable-gpu',
15-
'--headless',
16-
'--no-sandbox',
17-
'--disable-dev-shm-usage', // Prevents memory issues in Docker/CI
18-
'--window-position=-10000,0', // Ensures window is off-screen
19-
] : [];
20-
const args = [
21-
...ciArgs,
22-
`--extensionDevelopmentPath=${EXT_PATH}`,
23-
'--disable-workspace-trust', // no modal prompt
24-
'--disable-telemetry',
25-
'--user-data-dir=/tmp/vscode-test', // throwaway profile
26-
`${PROJECT_PATH}`,
27-
];
28-
const electronApp = await electron.launch({
29-
executablePath: VS_CODE_EXE,
30-
args,
31-
});
32-
33-
// ➋ Grab the first window that appears (the Workbench)
34-
const window = await electronApp.firstWindow();
35-
36-
// Wait for VS Code to be ready
37-
await window.waitForLoadState('domcontentloaded');
38-
await window.waitForLoadState('networkidle');
39-
40-
await expect(window.locator("text=lineage").first()).toBeVisible();
41-
42-
// ➌ Trigger our command exactly like a user would
43-
await window.keyboard.press(process.platform === 'darwin' ? 'Meta+Shift+P' : 'Control+Shift+P');
44-
await window.keyboard.type('Lineage: Focus On View');
45-
await window.keyboard.press('Enter');
46-
47-
// Wait for "Loaded SQLmesh Context" text to appear
48-
const loadedContextText = window.locator('text=Loaded SQLmesh Context');
49-
await expect(loadedContextText).toBeVisible({ timeout: 10000 });
50-
51-
await electronApp.close();
14+
// Create a temporary directory and copy sushi example into it
15+
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), 'vscode-test-sushi-'));
16+
await fs.copy(SUSHI_SOURCE_PATH, tempDir);
17+
18+
try {
19+
const ciArgs = process.env.CI ? [
20+
'--disable-gpu',
21+
'--headless',
22+
'--no-sandbox',
23+
'--disable-dev-shm-usage', // Prevents memory issues in Docker/CI
24+
'--window-position=-10000,0', // Ensures window is off-screen
25+
] : [];
26+
const args = [
27+
...ciArgs,
28+
`--extensionDevelopmentPath=${EXT_PATH}`,
29+
'--disable-workspace-trust', // no modal prompt
30+
'--disable-telemetry',
31+
'--user-data-dir=/tmp/vscode-test', // throwaway profile
32+
`${tempDir}`, // Use the temporary directory instead of PROJECT_PATH
33+
];
34+
const electronApp = await electron.launch({
35+
executablePath: VS_CODE_EXE,
36+
args,
37+
});
38+
39+
// ➋ Grab the first window that appears (the Workbench)
40+
const window = await electronApp.firstWindow();
41+
42+
// Wait for VS Code to be ready
43+
await window.waitForLoadState('domcontentloaded');
44+
await window.waitForLoadState('networkidle');
45+
46+
// ➌ Trigger our command exactly like a user would
47+
await window.keyboard.press(process.platform === 'darwin' ? 'Meta+Shift+P' : 'Control+Shift+P');
48+
await window.keyboard.type('Lineage: Focus On View');
49+
await window.keyboard.press('Enter');
50+
51+
// Wait for "Loaded SQLmesh Context" text to appear
52+
const loadedContextText = window.locator('text=Loaded SQLMesh Context');
53+
await expect(loadedContextText.first()).toBeVisible({ timeout: 10000 });
54+
55+
await electronApp.close();
56+
} finally {
57+
// Clean up the temporary directory
58+
await fs.remove(tempDir);
59+
}
5260
});

0 commit comments

Comments
 (0)