1- import { expect , test } from '@playwright/test '
1+ import { expect , test } from './fixtures '
22import fs from 'fs-extra'
33import os from 'os'
44import path from 'path'
@@ -10,10 +10,10 @@ import {
1010 REPO_ROOT ,
1111 SUSHI_SOURCE_PATH ,
1212} from './utils'
13- import { startCodeServer , stopCodeServer } from './utils_code_server'
1413
1514test ( 'missing LSP dependencies shows install prompt' , async ( {
1615 page,
16+ sharedCodeServer,
1717} , testInfo ) => {
1818 testInfo . setTimeout ( 120_000 ) // 2 minutes for venv creation and package installation
1919 const tempDir = await fs . mkdtemp (
@@ -29,54 +29,48 @@ test('missing LSP dependencies shows install prompt', async ({
2929 const sqlmeshWithExtras = `${ REPO_ROOT } [bigquery]`
3030 await pipInstall ( pythonDetails , [ sqlmeshWithExtras , custom_materializations ] )
3131
32- // Start VS Code
33- const context = await startCodeServer ( {
34- tempDir,
35- } )
32+ // Copy sushi project
33+ await fs . copy ( SUSHI_SOURCE_PATH , tempDir )
3634
37- try {
38- // Copy sushi project
39- await fs . copy ( SUSHI_SOURCE_PATH , tempDir )
40-
41- // Configure VS Code settings to use our Python environment
42- const settings = {
43- 'python.defaultInterpreterPath' : pythonDetails . pythonPath ,
44- 'sqlmesh.environmentPath' : pythonEnvDir ,
45- }
46- await fs . ensureDir ( path . join ( tempDir , '.vscode' ) )
47- await fs . writeJson (
48- path . join ( tempDir , '.vscode' , 'settings.json' ) ,
49- settings ,
50- { spaces : 2 } ,
51- )
52-
53- await page . goto ( `http://127.0.0.1:${ context . codeServerPort } ` )
54-
55- // Open a SQL file to trigger SQLMesh activation
56- // Wait for the models folder to be visible
57- await page . waitForSelector ( 'text=models' )
58-
59- // Click on the models folder
60- await page
61- . getByRole ( 'treeitem' , { name : 'models' , exact : true } )
62- . locator ( 'a' )
63- . click ( )
64-
65- // Open the top_waiters model
66- await page
67- . getByRole ( 'treeitem' , { name : 'customers.sql' , exact : true } )
68- . locator ( 'a' )
69- . click ( )
70-
71- // Wait for the message to show that LSP extras need to be installed
72- await page . waitForSelector ( 'text=LSP dependencies missing' )
73- expect ( await page . locator ( 'text=Install' ) . count ( ) ) . toBeGreaterThanOrEqual ( 1 )
74- } finally {
75- await stopCodeServer ( context )
35+ // Configure VS Code settings to use our Python environment
36+ const settings = {
37+ 'python.defaultInterpreterPath' : pythonDetails . pythonPath ,
38+ 'sqlmesh.environmentPath' : pythonEnvDir ,
7639 }
40+ await fs . ensureDir ( path . join ( tempDir , '.vscode' ) )
41+ await fs . writeJson ( path . join ( tempDir , '.vscode' , 'settings.json' ) , settings , {
42+ spaces : 2 ,
43+ } )
44+
45+ await page . goto (
46+ `http://127.0.0.1:${ sharedCodeServer . codeServerPort } /?folder=${ tempDir } ` ,
47+ )
48+
49+ // Open a SQL file to trigger SQLMesh activation
50+ // Wait for the models folder to be visible
51+ await page . waitForSelector ( 'text=models' )
52+
53+ // Click on the models folder
54+ await page
55+ . getByRole ( 'treeitem' , { name : 'models' , exact : true } )
56+ . locator ( 'a' )
57+ . click ( )
58+
59+ // Open the top_waiters model
60+ await page
61+ . getByRole ( 'treeitem' , { name : 'customers.sql' , exact : true } )
62+ . locator ( 'a' )
63+ . click ( )
64+
65+ // Wait for the message to show that LSP extras need to be installed
66+ await page . waitForSelector ( 'text=LSP dependencies missing' )
67+ expect ( await page . locator ( 'text=Install' ) . count ( ) ) . toBeGreaterThanOrEqual ( 1 )
7768} )
7869
79- test ( 'lineage, no sqlmesh found' , async ( { page } , testInfo ) => {
70+ test ( 'lineage, no sqlmesh found' , async ( {
71+ page,
72+ sharedCodeServer,
73+ } , testInfo ) => {
8074 testInfo . setTimeout ( 120_000 ) // 2 minutes for venv creation and package installation
8175
8276 const tempDir = await fs . mkdtemp (
@@ -85,46 +79,38 @@ test('lineage, no sqlmesh found', async ({ page }, testInfo) => {
8579 const pythonEnvDir = path . join ( tempDir , '.venv' )
8680 const pythonDetails = await createVirtualEnvironment ( pythonEnvDir )
8781
88- const context = await startCodeServer ( {
89- tempDir,
90- } )
82+ // Copy sushi project
83+ await fs . copy ( SUSHI_SOURCE_PATH , tempDir )
9184
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- // navigate to code-server instance
109- await page . goto ( `http://127.0.0.1:${ context . codeServerPort } ` )
110- await page . waitForLoadState ( 'networkidle' )
111-
112- // Open lineage view
113- await openLineageView ( page )
114-
115- // Assert shows that sqlmesh is not installed
116- await page . waitForSelector ( 'text=SQLMesh LSP not found' )
117- } finally {
118- // Clean up
119- await stopCodeServer ( context )
85+ // Configure VS Code settings to use our Python environment
86+ const settings = {
87+ 'python.defaultInterpreterPath' : pythonDetails . pythonPath ,
88+ 'sqlmesh.environmentPath' : pythonEnvDir ,
12089 }
90+ await fs . ensureDir ( path . join ( tempDir , '.vscode' ) )
91+ await fs . writeJson ( path . join ( tempDir , '.vscode' , 'settings.json' ) , settings , {
92+ spaces : 2 ,
93+ } )
94+
95+ // navigate to code-server instance
96+ await page . goto (
97+ `http://127.0.0.1:${ sharedCodeServer . codeServerPort } /?folder=${ tempDir } ` ,
98+ )
99+ await page . waitForLoadState ( 'networkidle' )
100+
101+ // Open lineage view
102+ await openLineageView ( page )
103+
104+ // Assert shows that sqlmesh is not installed
105+ await page . waitForSelector ( 'text=SQLMesh LSP not found' )
121106} )
122107
123108// Checks that if you have another file open like somewhere else, it still checks the workspace first for a successful context
124109// it's very flaky but runs when debugging
125110// - the typing in of the file name is very flaky
126111test . skip ( 'check that the LSP runs correctly by opening lineage when looking at another file before not in workspace' , async ( {
127112 page,
113+ sharedCodeServer,
128114} , testInfo ) => {
129115 testInfo . setTimeout ( 120_000 ) // 2 minutes for venv creation and package installation
130116 const tempDir = await fs . mkdtemp (
@@ -159,18 +145,13 @@ test.skip('check that the LSP runs correctly by opening lineage when looking at
159145 await fs . ensureDir ( path . dirname ( sqlFile ) )
160146 await fs . writeFile ( sqlFile , 'SELECT 1' )
161147
162- const context = await startCodeServer ( {
163- tempDir,
164- } )
165- try {
166- await page . goto ( `http://127.0.0.1:${ context . codeServerPort } ` )
167- await page . waitForLoadState ( 'networkidle' )
148+ await page . goto (
149+ `http://127.0.0.1:${ sharedCodeServer . codeServerPort } /?folder=${ tempDir } ` ,
150+ )
151+ await page . waitForLoadState ( 'networkidle' )
168152
169- // Open the SQL file from the other directory
170- await openFile ( page , sqlFile )
153+ // Open the SQL file from the other directory
154+ await openFile ( page , sqlFile )
171155
172- await page . waitForSelector ( 'text=Loaded SQLMesh context' )
173- } finally {
174- await stopCodeServer ( context )
175- }
156+ await page . waitForSelector ( 'text=Loaded SQLMesh context' )
176157} )
0 commit comments