Skip to content

Commit 9e653ae

Browse files
committed
chore(vscode): adding tests for bad projects
1 parent 490b3ef commit 9e653ae

1 file changed

Lines changed: 58 additions & 1 deletion

File tree

vscode/extension/tests/broken_project.spec.ts

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ import { test, expect } from './fixtures'
22
import fs from 'fs-extra'
33
import os from 'os'
44
import path from 'path'
5-
import { openLineageView, saveFile, SUSHI_SOURCE_PATH } from './utils'
5+
import {
6+
openLineageView,
7+
runCommand,
8+
saveFile,
9+
SUSHI_SOURCE_PATH,
10+
} from './utils'
611
import { createPythonInterpreterSettingsSpecifier } from './utils_code_server'
712

813
test('bad project, double model', async ({ page, sharedCodeServer }) => {
@@ -253,3 +258,55 @@ test('bad project, double model, check lineage', async ({
253258

254259
await page.waitForTimeout(500)
255260
})
261+
262+
test('bad model block, then fixed', async ({ page, sharedCodeServer }) => {
263+
const tempDir = await fs.mkdtemp(
264+
path.join(os.tmpdir(), 'vscode-test-tcloud-'),
265+
)
266+
// Copy over the sushi project
267+
await fs.copy(SUSHI_SOURCE_PATH, tempDir)
268+
await createPythonInterpreterSettingsSpecifier(tempDir)
269+
270+
// Add a model with a bad model block
271+
const badModelPath = path.join(tempDir, 'models', 'bad_model.sql')
272+
const contents =
273+
'MODEL ( name sushi.bad_block, test); SELECT * FROM sushi.customers'
274+
await fs.writeFile(badModelPath, contents)
275+
276+
await page.goto(
277+
`http://127.0.0.1:${sharedCodeServer.codeServerPort}/?folder=${tempDir}`,
278+
)
279+
await page.waitForLoadState('networkidle')
280+
281+
// Open the customers.sql model
282+
await page
283+
.getByRole('treeitem', { name: 'models', exact: true })
284+
.locator('a')
285+
.click()
286+
await page
287+
.getByRole('treeitem', { name: 'customers.sql', exact: true })
288+
.locator('a')
289+
.click()
290+
291+
// Wait for the error to appear
292+
await page.waitForSelector('text=Error creating context')
293+
294+
// Open the problems view
295+
await runCommand(page, 'View: Focus Problems')
296+
297+
// Assert error is present in the problems view
298+
const errorElement = page
299+
.getByText("Required keyword: 'value' missing for")
300+
.first()
301+
await expect(errorElement).toBeVisible({ timeout: 5000 })
302+
303+
// Remove the bad model file
304+
await fs.remove(badModelPath)
305+
306+
// Click on the grain part of the model and save
307+
await page.getByText('grain').click()
308+
await saveFile(page)
309+
310+
// Wait for successful context load
311+
await page.waitForSelector('text=Loaded SQLMesh context')
312+
})

0 commit comments

Comments
 (0)