1
- import { test , expect } from '@playwright/test' ;
2
- import path from 'path' ;
3
- import fs from 'fs-extra' ;
4
- import os from 'os' ;
5
- import { startVSCode , SUSHI_SOURCE_PATH } from './utils' ;
1
+ import { test , expect } from '@playwright/test'
2
+ import path from 'path'
3
+ import fs from 'fs-extra'
4
+ import os from 'os'
5
+ import { startVSCode , SUSHI_SOURCE_PATH } from './utils'
6
6
7
7
test ( 'Go to definition for macro' , async ( ) => {
8
- const tempDir = await fs . mkdtemp ( path . join ( os . tmpdir ( ) , 'vscode-test-sushi-' ) ) ;
9
- await fs . copy ( SUSHI_SOURCE_PATH , tempDir ) ;
10
-
11
- try {
12
- const { window, close } = await startVSCode ( tempDir ) ;
13
-
14
- // Wait for the models folder to be visible
15
- await window . waitForSelector ( 'text=models' ) ;
16
-
17
- // Click on the models folder
18
- await window . getByRole ( 'treeitem' , { name : 'models' , exact : true } ) . locator ( 'a' ) . click ( ) ;
19
-
20
- // Open the customer_revenue_lifetime model
21
- await window . getByRole ( 'treeitem' , { name : 'top_waiters.sql' , exact : true } ) . locator ( 'a' ) . click ( ) ;
22
-
23
- await window . waitForSelector ( 'text=grain' ) ;
24
- await window . waitForSelector ( 'text=Loaded SQLMesh Context' )
25
-
26
- // Render the model
27
- await window . locator ( "text=@MULTIPLY" ) . click ( {
28
- modifiers : [ "Meta" ]
29
- } )
30
-
31
- // Check if the model is rendered by check if "`oi`.`order_id` AS `order_id`," is in the window
32
- await expect ( window . locator ( 'text=def multiply(' ) ) . toBeVisible ( ) ;
33
-
34
- await close ( ) ;
35
- } finally {
36
- await fs . removeSync ( tempDir ) ;
37
- }
38
- } ) ;
39
-
40
- test ( "Go to definition for model" , async ( ) => {
41
- const tempDir = await fs . mkdtemp ( path . join ( os . tmpdir ( ) , 'vscode-test-sushi-' ) ) ;
42
- await fs . copy ( SUSHI_SOURCE_PATH , tempDir ) ;
43
-
44
- try {
45
- const { window, close } = await startVSCode ( tempDir ) ;
46
-
47
- // Wait for the models folder to be visible
48
- await window . waitForSelector ( 'text=models' ) ;
49
-
50
- // Click on the models folder
51
- await window . getByRole ( 'treeitem' , { name : 'models' , exact : true } ) . locator ( 'a' ) . click ( ) ;
52
-
53
- // Open the top_waiters model
54
- await window . getByRole ( 'treeitem' , { name : 'top_waiters.sql' , exact : true } ) . locator ( 'a' ) . click ( ) ;
55
-
56
- await window . waitForSelector ( 'text=grain' ) ;
57
- await window . waitForSelector ( 'text=Loaded SQLMesh Context' )
58
-
59
- // Go to definition for the model
60
- await window . locator ( "text=sushi.waiter_revenue_by_day" ) . first ( ) . click ( {
61
- modifiers : [ "Meta" ]
8
+ const tempDir = await fs . mkdtemp ( path . join ( os . tmpdir ( ) , 'vscode-test-sushi-' ) )
9
+ await fs . copy ( SUSHI_SOURCE_PATH , tempDir )
10
+
11
+ try {
12
+ const { window, close } = await startVSCode ( tempDir )
13
+
14
+ // Wait for the models folder to be visible
15
+ await window . waitForSelector ( 'text=models' )
16
+
17
+ // Click on the models folder
18
+ await window
19
+ . getByRole ( 'treeitem' , { name : 'models' , exact : true } )
20
+ . locator ( 'a' )
21
+ . click ( )
22
+
23
+ // Open the customer_revenue_lifetime model
24
+ await window
25
+ . getByRole ( 'treeitem' , { name : 'top_waiters.sql' , exact : true } )
26
+ . locator ( 'a' )
27
+ . click ( )
28
+
29
+ await window . waitForSelector ( 'text=grain' )
30
+ await window . waitForSelector ( 'text=Loaded SQLMesh Context' )
31
+
32
+ // Render the model
33
+ await window . locator ( 'text=@MULTIPLY' ) . click ( {
34
+ modifiers : [ 'Meta' ] ,
35
+ } )
36
+
37
+ // Check if the model is rendered by check if "`oi`.`order_id` AS `order_id`," is in the window
38
+ await expect ( window . locator ( 'text=def multiply(' ) ) . toBeVisible ( )
39
+
40
+ await close ( )
41
+ } finally {
42
+ await fs . removeSync ( tempDir )
43
+ }
44
+ } )
45
+
46
+ test ( 'Go to definition for model' , async ( ) => {
47
+ const tempDir = await fs . mkdtemp ( path . join ( os . tmpdir ( ) , 'vscode-test-sushi-' ) )
48
+ await fs . copy ( SUSHI_SOURCE_PATH , tempDir )
49
+
50
+ try {
51
+ const { window, close } = await startVSCode ( tempDir )
52
+
53
+ // Wait for the models folder to be visible
54
+ await window . waitForSelector ( 'text=models' )
55
+
56
+ // Click on the models folder
57
+ await window
58
+ . getByRole ( 'treeitem' , { name : 'models' , exact : true } )
59
+ . locator ( 'a' )
60
+ . click ( )
61
+
62
+ // Open the top_waiters model
63
+ await window
64
+ . getByRole ( 'treeitem' , { name : 'top_waiters.sql' , exact : true } )
65
+ . locator ( 'a' )
66
+ . click ( )
67
+
68
+ await window . waitForSelector ( 'text=grain' )
69
+ await window . waitForSelector ( 'text=Loaded SQLMesh Context' )
70
+
71
+ // Go to definition for the model
72
+ await window
73
+ . locator ( 'text=sushi.waiter_revenue_by_day' )
74
+ . first ( )
75
+ . click ( {
76
+ modifiers : [ 'Meta' ] ,
62
77
} )
63
- await expect ( window . locator ( 'text=SUM(oi.quantity * i.price)::DOUBLE AS revenue' ) ) . toBeVisible ( ) ;
64
- await close ( ) ;
65
- } finally {
66
- await fs . removeSync ( tempDir ) ;
67
- }
68
- } )
78
+ await expect (
79
+ window . locator ( 'text=SUM(oi.quantity * i.price)::DOUBLE AS revenue' ) ,
80
+ ) . toBeVisible ( )
81
+ await close ( )
82
+ } finally {
83
+ await fs . removeSync ( tempDir )
84
+ }
85
+ } )
0 commit comments