Skip to content

Commit a195ed2

Browse files
committed
chore: further testing error scenarios
1 parent 578d5ab commit a195ed2

3 files changed

Lines changed: 64 additions & 7 deletions

File tree

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import os from 'os'
44
import path from 'path'
55
import {
66
createVirtualEnvironment,
7+
openLineageView,
78
pipInstall,
89
REPO_ROOT,
910
startVSCode,
@@ -72,3 +73,53 @@ test('missing LSP dependencies shows install prompt', async ({}, testInfo) => {
7273
await fs.remove(tempDir)
7374
}
7475
})
76+
77+
test('lineage, no sqlmesh found', async ({}, testInfo) => {
78+
testInfo.setTimeout(120_000) // 2 minutes for venv creation and package installation
79+
const tempDir = await fs.mkdtemp(
80+
path.join(os.tmpdir(), 'vscode-test-tcloud-'),
81+
)
82+
const pythonEnvDir = path.join(tempDir, '.venv')
83+
const pythonDetails = await createVirtualEnvironment(pythonEnvDir)
84+
const custom_materializations = path.join(
85+
REPO_ROOT,
86+
'examples',
87+
'custom_materializations',
88+
)
89+
const sqlmeshWithExtras = `${REPO_ROOT}[bigquery]`
90+
await pipInstall(pythonDetails, [sqlmeshWithExtras, custom_materializations])
91+
92+
try {
93+
// Copy sushi project
94+
await fs.copy(SUSHI_SOURCE_PATH, tempDir)
95+
96+
// Configure VS Code settings to use our Python environment
97+
const settings = {
98+
'python.defaultInterpreterPath': pythonDetails.pythonPath,
99+
'sqlmesh.environmentPath': pythonEnvDir,
100+
}
101+
await fs.ensureDir(path.join(tempDir, '.vscode'))
102+
await fs.writeJson(
103+
path.join(tempDir, '.vscode', 'settings.json'),
104+
settings,
105+
{ spaces: 2 },
106+
)
107+
108+
const { window, close } = await startVSCode(tempDir)
109+
110+
// Open lineage view
111+
await openLineageView(window)
112+
113+
await window.waitForTimeout(1_000)
114+
115+
// Assert cannot see the Loading models text
116+
await expect(
117+
window.locator('text=Loading models...'),
118+
).not.toBeVisible()
119+
120+
await close()
121+
} finally {
122+
// Clean up
123+
await fs.remove(tempDir)
124+
}
125+
})

vscode/extension/tests/lineage.spec.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,14 @@ import { test, expect, Page } from '@playwright/test'
22
import path from 'path'
33
import fs from 'fs-extra'
44
import os from 'os'
5-
import { startVSCode, SUSHI_SOURCE_PATH } from './utils'
5+
import { openLineageView, startVSCode, SUSHI_SOURCE_PATH } from './utils'
66
import { writeFileSync } from 'fs'
77

88
/**
99
* Helper function to launch VS Code and test lineage with given project path config
1010
*/
1111
async function testLineageWithProjectPath(window: Page): Promise<void> {
12-
// Trigger lineage command
13-
await window.keyboard.press(
14-
process.platform === 'darwin' ? 'Meta+Shift+P' : 'Control+Shift+P',
15-
)
16-
await window.keyboard.type('Lineage: Focus On View')
17-
await window.keyboard.press('Enter')
12+
await openLineageView(window)
1813

1914
// Wait for "Loaded SQLMesh context" text to appear
2015
const loadedContextText = window.locator('text=Loaded SQLMesh context')

vscode/extension/tests/utils.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,14 @@ export const pipInstall = async (
137137
throw new Error(`Failed to install package: ${stderr}`)
138138
}
139139
}
140+
141+
/**
142+
* Open the lineage view in the given window.
143+
*/
144+
export const openLineageView = async (window: Page): Promise<void> => {
145+
await window.keyboard.press(
146+
process.platform === 'darwin' ? 'Meta+Shift+P' : 'Control+Shift+P',
147+
)
148+
await window.keyboard.type('Lineage: Focus On View')
149+
await window.keyboard.press('Enter')
150+
}

0 commit comments

Comments
 (0)