-
Notifications
You must be signed in to change notification settings - Fork 380
Expand file tree
/
Copy pathstop.spec.ts
More file actions
134 lines (104 loc) · 3.76 KB
/
stop.spec.ts
File metadata and controls
134 lines (104 loc) · 3.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import path from 'path'
import {
openServerPage,
runCommand,
SUSHI_SOURCE_PATH,
waitForLoadedSQLMesh,
} from './utils'
import os from 'os'
import { test } from './fixtures'
import fs from 'fs-extra'
import { createPythonInterpreterSettingsSpecifier } from './utils_code_server'
test('Stop server works', async ({ page, sharedCodeServer }) => {
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), 'vscode-test-sushi-'))
await fs.copy(SUSHI_SOURCE_PATH, tempDir)
await createPythonInterpreterSettingsSpecifier(tempDir)
// Navigate to code-server instance
await openServerPage(page, tempDir, sharedCodeServer)
// Wait for the models folder to be visible in the file explorer
await page.waitForSelector('text=models')
// Click on the models folder, excluding external_models
await page
.getByRole('treeitem', { name: 'models', exact: true })
.locator('a')
.click()
// Open the customers.sql model
await page
.getByRole('treeitem', { name: 'customers.sql', exact: true })
.locator('a')
.click()
await page.waitForSelector('text=grain')
await waitForLoadedSQLMesh(page)
// Stop the server
await runCommand(page, 'SQLMesh: Stop Server')
// Await LSP server stopped message
await page.waitForSelector('text=LSP server stopped')
// Render the model
await runCommand(page, 'SQLMesh: Render Model')
// Await error message
await page.waitForSelector(
'text="Failed to render model: LSP client not ready."',
)
})
test('Stopped server only restarts when explicitly requested', async ({
page,
sharedCodeServer,
}) => {
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), 'vscode-test-sushi-'))
await fs.copy(SUSHI_SOURCE_PATH, tempDir)
await createPythonInterpreterSettingsSpecifier(tempDir)
// Navigate to code-server instance
await openServerPage(page, tempDir, sharedCodeServer)
// Wait for the models folder to be visible in the file explorer
await page.waitForSelector('text=models')
// Click on the models folder, excluding external_models
await page
.getByRole('treeitem', { name: 'models', exact: true })
.locator('a')
.click()
// Open the customers.sql model
await page
.getByRole('treeitem', { name: 'marketing.sql', exact: true })
.locator('a')
.click()
await page.waitForSelector('text=grain')
await waitForLoadedSQLMesh(page)
// Click on sushi.raw_marketing
await page.getByText('sushi.raw_marketing;').click()
// Open the preview hover
await runCommand(page, 'Show Definition Preview Hover')
// Assert that the hover is visible with text "Table of marketing status."
await page.waitForSelector('text=Table of marketing status.', {
timeout: 5_000,
state: 'visible',
})
// Hit Esc to close the hover
await page.keyboard.press('Escape')
// Assert that the hover is no longer visible
await page.waitForSelector('text=Table of marketing status.', {
timeout: 5_000,
state: 'hidden',
})
// Stop the server
await runCommand(page, 'SQLMesh: Stop Server')
// Await LSP server stopped message
await page.waitForSelector('text=LSP server stopped')
// Open the preview hover again
await runCommand(page, 'Show Definition Preview Hover')
// Assert that the hover is not visible
await page.waitForSelector('text=Table of marketing status.', {
timeout: 5_000,
state: 'hidden',
})
// Restart the server explicitly
await runCommand(page, 'SQLMesh: Restart Server')
// Await LSP server started message
await waitForLoadedSQLMesh(page)
// Open the preview hover again
await runCommand(page, 'Show Definition Preview Hover')
// Assert that the hover is visible with text "Table of marketing status."
await page.waitForSelector('text=Table of marketing status.', {
timeout: 5_000,
state: 'visible',
})
})