@@ -2,15 +2,8 @@ import { test, expect } from './fixtures'
22import fs from 'fs-extra'
33import os from 'os'
44import path from 'path'
5- import {
6- openLineageView ,
7- runCommand ,
8- saveFile ,
9- SUSHI_SOURCE_PATH ,
10- } from './utils'
5+ import { openLineageView , saveFile , SUSHI_SOURCE_PATH } from './utils'
116import { createPythonInterpreterSettingsSpecifier } from './utils_code_server'
12- import { execAsync } from '../src/utilities/exec'
13- import yaml from 'yaml'
147
158test ( 'bad project, double model' , async ( { page, sharedCodeServer } ) => {
169 const tempDir = await fs . mkdtemp (
@@ -260,181 +253,3 @@ test('bad project, double model, check lineage', async ({
260253
261254 await page . waitForTimeout ( 500 )
262255} )
263-
264- const setup = async ( tempDir : string ) => {
265- // Run the sqlmesh CLI from the root of the repo using the local path
266- const sqlmeshCliPath = path . resolve ( __dirname , '../../../.venv/bin/sqlmesh' )
267- const result = await execAsync ( sqlmeshCliPath , [ 'init' , 'duckdb' ] , {
268- cwd : tempDir ,
269- } )
270- expect ( result . exitCode ) . toBe ( 0 )
271- }
272-
273- test . describe ( 'Bad config.py/config.yaml file issues' , ( ) => {
274- test ( 'sqlmesh init, then corrupted config.yaml, bad yaml' , async ( {
275- page,
276- sharedCodeServer,
277- } ) => {
278- const tempDir = await fs . mkdtemp (
279- path . join ( os . tmpdir ( ) , 'vscode-test-tcloud-' ) ,
280- )
281- await setup ( tempDir )
282- await createPythonInterpreterSettingsSpecifier ( tempDir )
283-
284- const configYamlPath = path . join ( tempDir , 'config.yaml' )
285- // Write an invalid YAML to config.yaml
286- await fs . writeFile ( configYamlPath , 'invalid_yaml; asdfasudfy' )
287-
288- await page . goto (
289- `http://127.0.0.1:${ sharedCodeServer . codeServerPort } /?folder=${ tempDir } ` ,
290- )
291- await page . waitForLoadState ( 'networkidle' )
292-
293- // Open full_model.sql model
294- await page
295- . getByRole ( 'treeitem' , { name : 'models' , exact : true } )
296- . locator ( 'a' )
297- . click ( )
298- await page
299- . getByRole ( 'treeitem' , { name : 'full_model.sql' , exact : true } )
300- . locator ( 'a' )
301- . click ( )
302-
303- // Wait for the error to appear
304- await page . waitForSelector ( 'text=Error creating context' )
305-
306- // Open the problems view
307- await runCommand ( page , 'View: Focus Problems' )
308-
309- // Asser that the error is present in the problems view
310- await page
311- . getByText ( 'Invalid YAML configuration:' )
312- . first ( )
313- . isVisible ( { timeout : 5_000 } )
314- } )
315-
316- test ( 'sqlmesh init, then corrupted config.yaml, bad parameters' , async ( {
317- page,
318- sharedCodeServer,
319- } ) => {
320- const tempDir = await fs . mkdtemp (
321- path . join ( os . tmpdir ( ) , 'vscode-test-tcloud-' ) ,
322- )
323- await setup ( tempDir )
324- await createPythonInterpreterSettingsSpecifier ( tempDir )
325-
326- const configYamlPath = path . join ( tempDir , 'config.yaml' )
327- // Write an invalid YAML to config.yaml
328- const config = {
329- gateway : 'test' ,
330- }
331- // Write config to the yaml file
332- await fs . writeFile ( configYamlPath , yaml . stringify ( config ) )
333-
334- await page . goto (
335- `http://127.0.0.1:${ sharedCodeServer . codeServerPort } /?folder=${ tempDir } ` ,
336- )
337- await page . waitForLoadState ( 'networkidle' )
338-
339- // Open full_model.sql model
340- await page
341- . getByRole ( 'treeitem' , { name : 'models' , exact : true } )
342- . locator ( 'a' )
343- . click ( )
344- await page
345- . getByRole ( 'treeitem' , { name : 'full_model.sql' , exact : true } )
346- . locator ( 'a' )
347- . click ( )
348-
349- // Wait for the error to appear
350- await page . waitForSelector ( 'text=Error creating context' )
351-
352- // Open the problems view
353- await runCommand ( page , 'View: Focus Problems' )
354-
355- // Asser that the error is present in the problems view
356- await page
357- . getByText ( 'Invalid project config:' , { exact : true } )
358- . first ( )
359- . isVisible ( { timeout : 5_000 } )
360- } )
361-
362- test ( 'sushi example, correct python, bad config' , async ( {
363- page,
364- sharedCodeServer,
365- } ) => {
366- const tempDir = await fs . mkdtemp (
367- path . join ( os . tmpdir ( ) , 'vscode-test-tcloud-' ) ,
368- )
369- await fs . copy ( SUSHI_SOURCE_PATH , tempDir )
370- await createPythonInterpreterSettingsSpecifier ( tempDir )
371-
372- const configPyPath = path . join ( tempDir , 'config.py' )
373- // Write an invalid Python to config.py
374- await fs . writeFile ( configPyPath , 'config = {}' )
375-
376- await page . goto (
377- `http://127.0.1:${ sharedCodeServer . codeServerPort } /?folder=${ tempDir } ` ,
378- )
379- await page . waitForLoadState ( 'networkidle' )
380-
381- // Open customers.sql model
382- await page
383- . getByRole ( 'treeitem' , { name : 'models' , exact : true } )
384- . locator ( 'a' )
385- . click ( )
386- await page
387- . getByRole ( 'treeitem' , { name : 'customers.sql' , exact : true } )
388- . locator ( 'a' )
389- . click ( )
390-
391- // Expect the error to appear
392- await page . waitForSelector ( 'text=Error creating context' )
393-
394- // Open the problems view
395- await runCommand ( page , 'View: Focus Problems' )
396-
397- // Assert that the error is present in the problems view
398- const errorElement = page
399- . getByText ( 'Config needs to be a valid object of type' )
400- . first ( )
401- await expect ( errorElement ) . toBeVisible ( { timeout : 5000 } )
402- } )
403-
404- test ( 'sushi example, bad config.py' , async ( { page, sharedCodeServer } ) => {
405- const tempDir = await fs . mkdtemp (
406- path . join ( os . tmpdir ( ) , 'vscode-test-tcloud-' ) ,
407- )
408- await fs . copy ( SUSHI_SOURCE_PATH , tempDir )
409- await createPythonInterpreterSettingsSpecifier ( tempDir )
410-
411- const configPyPath = path . join ( tempDir , 'config.py' )
412- // Write an invalid Python to config.py
413- await fs . writeFile ( configPyPath , 'invalid_python_code = [1, 2, 3' )
414-
415- await page . goto (
416- `http://127.0.1:${ sharedCodeServer . codeServerPort } /?folder=${ tempDir } ` ,
417- )
418- await page . waitForLoadState ( 'networkidle' )
419-
420- // Open customers.sql model
421- await page
422- . getByRole ( 'treeitem' , { name : 'models' , exact : true } )
423- . locator ( 'a' )
424- . click ( )
425- await page
426- . getByRole ( 'treeitem' , { name : 'customers.sql' , exact : true } )
427- . locator ( 'a' )
428- . click ( )
429-
430- // Expect the error to appear
431- await page . waitForSelector ( 'text=Error creating context' )
432-
433- // Open the problems view
434- await runCommand ( page , 'View: Focus Problems' )
435-
436- // Assert that the error is present in the problems view
437- const errorElement = page . getByText ( 'Failed to load config file:' ) . first ( )
438- await expect ( errorElement ) . toBeVisible ( { timeout : 5000 } )
439- } )
440- } )
0 commit comments