-
Notifications
You must be signed in to change notification settings - Fork 380
Expand file tree
/
Copy pathbad_setup.spec.ts
More file actions
137 lines (119 loc) · 4.34 KB
/
bad_setup.spec.ts
File metadata and controls
137 lines (119 loc) · 4.34 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
import { expect, test } from './fixtures'
import fs from 'fs-extra'
import os from 'os'
import path from 'path'
import {
createVirtualEnvironment,
openFile,
openLineageView,
openServerPage,
pipInstall,
REPO_ROOT,
SUSHI_SOURCE_PATH,
waitForLoadedSQLMesh,
} from './utils'
test('missing LSP dependencies shows install prompt', async ({
page,
sharedCodeServer,
}) => {
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])
// 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,
})
await openServerPage(page, tempDir, sharedCodeServer)
// Open a top_waiters model to trigger SQLMesh activation
await page
.getByRole('treeitem', { name: 'models', exact: true })
.locator('a')
.click()
await page
.getByRole('treeitem', { name: 'customers.sql', exact: true })
.locator('a')
.click()
// Wait for the message to show that LSP extras need to be installed
await page.waitForSelector('text=LSP dependencies missing')
expect(await page.locator('text=Install').count()).toBeGreaterThanOrEqual(1)
})
test('lineage, no sqlmesh found', async ({ page, sharedCodeServer }) => {
const tempDir = await fs.mkdtemp(
path.join(os.tmpdir(), 'vscode-test-tcloud-'),
)
const pythonEnvDir = path.join(tempDir, '.venv')
const pythonDetails = await createVirtualEnvironment(pythonEnvDir)
// 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,
})
// navigate to code-server instance
await openServerPage(page, tempDir, sharedCodeServer)
await openLineageView(page)
// Assert shows that sqlmesh is not installed
await page.waitForSelector('text=SQLMesh LSP not found')
})
// Checks that if you have another file open like somewhere else, it still checks the workspace first for a successful context
// it's very flaky but runs when debugging
// - the typing in of the file name is very flaky
test.skip('check that the LSP runs correctly by opening lineage when looking at another file before not in workspace', async ({
page,
sharedCodeServer,
}) => {
const tempDir = await fs.mkdtemp(
path.join(os.tmpdir(), 'vscode-test-tcloud-'),
)
await fs.copy(SUSHI_SOURCE_PATH, tempDir)
const pythonEnvDir = path.join(tempDir, '.venv')
const pythonDetails = await createVirtualEnvironment(pythonEnvDir)
const sqlmeshWithExtras = `${REPO_ROOT}[lsp, bigquery]`
const custom_materializations = path.join(
REPO_ROOT,
'examples',
'custom_materializations',
)
await pipInstall(pythonDetails, [sqlmeshWithExtras, custom_materializations])
// Configure VS Code settings to use our Python environment
const settings = {
'python.defaultInterpreterPath': pythonDetails.pythonPath,
'sqlmesh.environmentPath': tempDir,
}
await fs.ensureDir(path.join(tempDir, '.vscode'))
await fs.writeJson(path.join(tempDir, '.vscode', 'settings.json'), settings, {
spaces: 2,
})
// Write a sql file in another folder
const tempDir2 = await fs.mkdtemp(
path.join(os.tmpdir(), 'vscode-test-tcloud-2-'),
)
const sqlFile = path.join(tempDir2, 'models', 'customers.sql')
await fs.ensureDir(path.dirname(sqlFile))
await fs.writeFile(sqlFile, 'SELECT 1')
await openServerPage(page, tempDir, sharedCodeServer)
// Open the SQL file from the other directory
await openFile(page, sqlFile)
await waitForLoadedSQLMesh(page)
})