-
Notifications
You must be signed in to change notification settings - Fork 380
Expand file tree
/
Copy pathbad_setup.spec.ts
More file actions
113 lines (97 loc) · 3.16 KB
/
bad_setup.spec.ts
File metadata and controls
113 lines (97 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import { expect, test } from '@playwright/test'
import fs from 'fs-extra'
import os from 'os'
import path from 'path'
import {
createVirtualEnvironment,
openLineageView,
pipInstall,
REPO_ROOT,
startVSCode,
SUSHI_SOURCE_PATH,
} from './utils'
test('missing LSP dependencies shows install prompt', async ({}, testInfo) => {
testInfo.setTimeout(120_000) // 2 minutes for venv creation and package installation
const tempDir = await fs.mkdtemp(
path.join(os.tmpdir(), 'vscode-test-tcloud-'),
)
const pythonEnvDir = path.join(tempDir, '.venv')
const pythonDetails = await createVirtualEnvironment(pythonEnvDir)
const custom_materializations = path.join(
REPO_ROOT,
'examples',
'custom_materializations',
)
const sqlmeshWithExtras = `${REPO_ROOT}[bigquery]`
await pipInstall(pythonDetails, [sqlmeshWithExtras, custom_materializations])
try {
// Copy sushi project
await fs.copy(SUSHI_SOURCE_PATH, tempDir)
// Configure VS Code settings to use our Python environment
const settings = {
'python.defaultInterpreterPath': pythonDetails.pythonPath,
'sqlmesh.environmentPath': pythonEnvDir,
}
await fs.ensureDir(path.join(tempDir, '.vscode'))
await fs.writeJson(
path.join(tempDir, '.vscode', 'settings.json'),
settings,
{ spaces: 2 },
)
// Start VS Code
const { window, close } = await startVSCode(tempDir)
// Open a SQL file to trigger SQLMesh activation
// Wait for the models folder to be visible
await window.waitForSelector('text=models')
// Click on the models folder
await window
.getByRole('treeitem', { name: 'models', exact: true })
.locator('a')
.click()
// Open the top_waiters model
await window
.getByRole('treeitem', { name: 'customers.sql', exact: true })
.locator('a')
.click()
// Wait for the message to show that LSP extras need to be installed
await window.waitForSelector('text=LSP dependencies missing')
expect(await window.locator('text=Install').count()).toBeGreaterThanOrEqual(
1,
)
await close()
} finally {
// Clean up
await fs.remove(tempDir)
}
})
test('lineage, no sqlmesh found', async ({}) => {
const tempDir = await fs.mkdtemp(
path.join(os.tmpdir(), 'vscode-test-tcloud-'),
)
const pythonEnvDir = path.join(tempDir, '.venv')
const pythonDetails = await createVirtualEnvironment(pythonEnvDir)
try {
// Copy sushi project
await fs.copy(SUSHI_SOURCE_PATH, tempDir)
// Configure VS Code settings to use our Python environment
const settings = {
'python.defaultInterpreterPath': pythonDetails.pythonPath,
'sqlmesh.environmentPath': pythonEnvDir,
}
await fs.ensureDir(path.join(tempDir, '.vscode'))
await fs.writeJson(
path.join(tempDir, '.vscode', 'settings.json'),
settings,
{ spaces: 2 },
)
const { window, close } = await startVSCode(tempDir)
// Open lineage view
await openLineageView(window)
// Assert shows that sqlmesh is not installed
await window.waitForSelector('text=SQLMesh LSP not found')
await close()
} finally {
// Clean up
await fs.remove(tempDir)
}
})