Skip to content

Commit e438d17

Browse files
committed
temp
1 parent b4d1f03 commit e438d17

File tree

10 files changed

+91
-115
lines changed

10 files changed

+91
-115
lines changed

.github/workflows/pr.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ jobs:
5353
run: pnpm exec playwright install
5454
- name: Run e2e tests
5555
working-directory: ./vscode/extension
56+
timeout-minutes: 90
5657
run: |
5758
source ../../.venv/bin/activate
5859
pnpm run test:e2e

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ vscode/extension/out
2020
vscode/extension/src_react
2121
vscode/extension/tsconfig.tsbuildinfo
2222
vscode/extension/.vscode-test/
23+
vscode/extension/playwright-report/
24+
vscode/extension/test-results/
25+
vscode/extension/.test_setup
2326

2427
sqlmesh
2528
docs

vscode/extension/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ node_modules
22
dist
33
out
44
.vscode-test
5+
.test_setup
56
*.vsix
67
LICENSE
78
src_react
Binary file not shown.

vscode/extension/playwright-report/index.html

Lines changed: 0 additions & 77 deletions
This file was deleted.

vscode/extension/playwright.config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ import { defineConfig } from '@playwright/test'
33
export default defineConfig({
44
testDir: 'tests',
55
timeout: 60_000,
6-
retries: process.env.CI ? 1 : 0,
6+
// TODO: When stable, allow retries in CI
7+
retries: process.env.CI ? 0 : 0,
78
workers: 1,
89
reporter: [['html', { outputFolder: 'playwright-report' }], ['list']],
10+
globalSetup: './tests/global-setup.ts',
911
projects: [
1012
{
1113
name: 'electron-vscode',

vscode/extension/tests/broken_project.spec.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,9 @@ test('working project, then broken through adding double model, then refixed', a
9292
.locator('a')
9393
.click()
9494
// Save to refresh the context
95-
await page.keyboard.press('Control+S')
96-
await page.keyboard.press('Meta+S')
95+
await page.keyboard.press(
96+
process.platform === 'darwin' ? 'Meta+S' : 'Control+S',
97+
)
9798

9899
// Wait for the error to appear
99100
// TODO: Selector doesn't work in the linage view
@@ -103,8 +104,9 @@ test('working project, then broken through adding double model, then refixed', a
103104
await fs.remove(path.join(tempDir, 'models', 'customers_duplicated.sql'))
104105

105106
// Save again to refresh the context
106-
await page.keyboard.press('Control+S')
107-
await page.keyboard.press('Meta+S')
107+
await page.keyboard.press(
108+
process.platform === 'darwin' ? 'Meta+S' : 'Control+S',
109+
)
108110

109111
// Wait for the error to go away and context to reload
110112
// TODO: Selector doesn't work in the linage view
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { execSync } from 'child_process'
2+
import path from 'path'
3+
import fs from 'fs-extra'
4+
5+
async function globalSetup() {
6+
console.log('Setting up extension for Playwright tests...')
7+
8+
const extensionDir = path.join(__dirname, '..')
9+
const testSetupDir = path.join(extensionDir, '.test_setup')
10+
const extensionsDir = path.join(testSetupDir, 'extensions')
11+
12+
// Clean up any existing test setup directory
13+
await fs.remove(testSetupDir)
14+
await fs.ensureDir(extensionsDir)
15+
16+
// Get the extension version from package.json
17+
const packageJson = JSON.parse(
18+
fs.readFileSync(path.join(extensionDir, 'package.json'), 'utf-8'),
19+
)
20+
const version = packageJson.version
21+
const extensionName = packageJson.name || 'sqlmesh'
22+
23+
// Look for the specific version .vsix file
24+
const vsixFileName = `${extensionName}-${version}.vsix`
25+
const vsixPath = path.join(extensionDir, vsixFileName)
26+
27+
if (!fs.existsSync(vsixPath)) {
28+
throw new Error(
29+
`Extension file ${vsixFileName} not found. Run "pnpm run vscode:package" first.`,
30+
)
31+
}
32+
33+
console.log(`Installing extension: ${vsixFileName}`)
34+
35+
// Create a temporary user data directory for the installation
36+
const tempUserDataDir = await fs.mkdtemp(
37+
path.join(require('os').tmpdir(), 'vscode-test-install-user-data-'),
38+
)
39+
40+
try {
41+
execSync(
42+
`pnpm run code-server --user-data-dir "${tempUserDataDir}" --extensions-dir "${extensionsDir}" --install-extension "${vsixPath}"`,
43+
{
44+
stdio: 'inherit',
45+
cwd: extensionDir,
46+
},
47+
)
48+
console.log('Extension installed successfully to .test_setup/extensions')
49+
} finally {
50+
// Clean up temporary user data directory
51+
await fs.remove(tempUserDataDir)
52+
}
53+
}
54+
55+
export default globalSetup

vscode/extension/tests/go_to_definition.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ test('Go to definition for model', async ({ page }) => {
8484
.locator('text=sushi.waiter_revenue_by_day')
8585
.first()
8686
.click({
87-
modifiers: ['Meta'],
87+
modifiers: [process.platform === 'darwin' ? 'Meta' : 'Control'],
8888
})
8989
await expect(
9090
page.locator('text=SUM(oi.quantity * i.price)::DOUBLE AS revenue'),

vscode/extension/tests/utils_code_server.ts

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,23 @@ export interface CodeServerContext {
1010
defaultPythonInterpreter: string
1111
}
1212

13+
/**
14+
* Get the path to the extensions directory set up by global setup
15+
* @returns The extensions directory path
16+
*/
17+
function getExtensionsDir(): string {
18+
const extensionDir = path.join(__dirname, '..')
19+
const extensionsDir = path.join(extensionDir, '.test_setup', 'extensions')
20+
21+
if (!fs.existsSync(extensionsDir)) {
22+
throw new Error(
23+
`Extensions directory not found at ${extensionsDir}. Make sure global setup has run.`,
24+
)
25+
}
26+
27+
return extensionsDir
28+
}
29+
1330
/**
1431
* @param tempDir - The temporary directory to use for the code-server instance
1532
* @param placeFileWithPythonInterpreter - Whether to place a vscode/settings.json file in the temp directory that points to the python interpreter of the environmen the test is running in.
@@ -22,6 +39,9 @@ export async function startCodeServer({
2239
tempDir: string
2340
placeFileWithPythonInterpreter?: boolean
2441
}): Promise<CodeServerContext> {
42+
// Get the extensions directory set up by global setup
43+
const extensionsDir = getExtensionsDir()
44+
2545
// Find an available port
2646
const codeServerPort = Math.floor(Math.random() * 10000) + 50000
2747
const defaultPythonInterpreter = path.join(
@@ -60,38 +80,7 @@ export async function startCodeServer({
6080
)
6181
}
6282

63-
// Get the extension version from package.json
64-
const extensionDir = path.join(__dirname, '..')
65-
const packageJson = JSON.parse(
66-
fs.readFileSync(path.join(extensionDir, 'package.json'), 'utf-8'),
67-
)
68-
const version = packageJson.version
69-
const extensionName = packageJson.name || 'sqlmesh'
70-
71-
// Look for the specific version .vsix file
72-
const vsixFileName = `${extensionName}-${version}.vsix`
73-
const vsixPath = path.join(extensionDir, vsixFileName)
74-
75-
if (!fs.existsSync(vsixPath)) {
76-
throw new Error(
77-
`Extension file ${vsixFileName} not found. Run "pnpm run vscode:package" first.`,
78-
)
79-
}
80-
81-
console.log(`Using extension: ${vsixFileName}`)
82-
83-
// Install the extension first
84-
const extensionsDir = path.join(tempDir, 'extensions')
85-
console.log('Installing extension...')
86-
execSync(
87-
`pnpm run code-server --user-data-dir "${userDataDir}" --extensions-dir "${extensionsDir}" --install-extension "${vsixPath}"`,
88-
{
89-
stdio: 'inherit',
90-
cwd: path.join(__dirname, '..'),
91-
},
92-
)
93-
94-
// Start code-server instance
83+
// Start code-server instance using the shared extensions directory
9584
const codeServerProcess = spawn(
9685
'pnpm',
9786
[

0 commit comments

Comments
 (0)