Skip to content

Commit 490b3ef

Browse files
authored
chore(vscode): test bad audit diagnostic (#4955)
1 parent 76a5420 commit 490b3ef

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

vscode/extension/tests/diagnostics.spec.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,3 +312,53 @@ test.describe('Diagnostics for bad SQLMesh models', () => {
312312
await expect(errorElement).toBeVisible({ timeout: 5000 })
313313
})
314314
})
315+
316+
test.describe('Diagnostics for bad audits', () => {
317+
test('bad audit block in audit', async ({ page, sharedCodeServer }) => {
318+
const tempDir = await fs.mkdtemp(
319+
path.join(os.tmpdir(), 'vscode-test-tcloud-'),
320+
)
321+
322+
// Copy over the sushi project
323+
await fs.copy(SUSHI_SOURCE_PATH, tempDir)
324+
await createPythonInterpreterSettingsSpecifier(tempDir)
325+
326+
// Make an existing audit file a bad audit
327+
const auditFilePath = path.join(
328+
tempDir,
329+
'audits',
330+
'assert_item_price_above_zero.sql',
331+
)
332+
const readFile = await fs.readFile(auditFilePath, 'utf8')
333+
const updatedContent = readFile.replace('AUDIT (', 'AUDIT ( rubbish value,')
334+
await fs.writeFile(auditFilePath, updatedContent)
335+
336+
// Navigate to the code-server instance
337+
await page.goto(
338+
`http://127.0.1:${sharedCodeServer.codeServerPort}/?folder=${tempDir}`,
339+
)
340+
await page.waitForLoadState('networkidle')
341+
342+
// Open a the customers.sql model
343+
await page
344+
.getByRole('treeitem', { name: 'models', exact: true })
345+
.locator('a')
346+
.click()
347+
await page
348+
.getByRole('treeitem', { name: 'customers.sql', exact: true })
349+
.locator('a')
350+
.click()
351+
352+
// Wait for the error to appear
353+
await page.waitForSelector('text=Error creating context')
354+
355+
// Open the problems view
356+
await runCommand(page, 'View: Focus Problems')
357+
358+
// Assert that the error is present in the problems view
359+
const errorElement = page
360+
.getByText("Invalid extra fields {'rubbish'} in the audit definition")
361+
.first()
362+
await expect(errorElement).toBeVisible({ timeout: 5000 })
363+
})
364+
})

0 commit comments

Comments
 (0)