Skip to content

Commit acd4a88

Browse files
committed
chore(vscode): add e2e test
1 parent ff87b03 commit acd4a88

File tree

4 files changed

+78
-49
lines changed

4 files changed

+78
-49
lines changed

.github/workflows/pr.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
on:
2+
pull_request:
3+
branches:
4+
- main
5+
jobs:
6+
test-vscode-e2e:
7+
env:
8+
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
9+
runs-on: macos-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
- uses: actions/setup-python@v4
13+
with:
14+
python-version: '3.12'
15+
- name: Install Python dependencies
16+
run: make install-dev
17+
- uses: actions/setup-node@v3
18+
with:
19+
node-version: '20'
20+
- uses: pnpm/action-setup@v2
21+
with:
22+
version: latest
23+
- name: Install dependencies
24+
run: pnpm install
25+
- name: Run CI
26+
run: pnpm run ci
27+
- name: Fetch VSCode
28+
working-directory: vscode/extension
29+
run: pnpm run fetch-vscode
30+
- name: Run E2E tests
31+
working-directory: vscode/extension
32+
run: pnpm run test:e2e
33+
- name: Upload test videos
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: test-videos
37+
path: vscode/extension/test-videos/

vscode/extension/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ out
55
*.vsix
66
LICENSE
77
src_react
8-
!src_react/.gitkeep
8+
!src_react/.gitkeep
9+
test-videos

vscode/extension/tests/hints.spec.ts

Lines changed: 37 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,41 @@ import os from 'os'
55
import { startVSCode, SUSHI_SOURCE_PATH } from './utils'
66

77
test('Model type hinting', async () => {
8-
const tempDir = await fs.mkdtemp(
9-
path.join(os.tmpdir(), 'vscode-test-sushi-'),
10-
)
11-
await fs.copy(SUSHI_SOURCE_PATH, tempDir)
12-
13-
try {
14-
const { window, close } = await startVSCode(tempDir)
15-
16-
// Wait for the models folder to be visible
17-
await window.waitForSelector('text=models')
18-
19-
// Click on the models folder
20-
await window
21-
.getByRole('treeitem', { name: 'models', exact: true })
22-
.locator('a')
23-
.click()
24-
25-
// Open the customers_revenue_by_day model
26-
await window
27-
.getByRole('treeitem', {
28-
name: 'customer_revenue_by_day.sql',
29-
exact: true,
30-
})
31-
.locator('a')
32-
.click()
33-
34-
await window.waitForSelector('text=grain')
35-
await window.waitForSelector('text=Loaded SQLMesh Context')
36-
37-
// Wait a moment for hints to appear
38-
await window.waitForTimeout(500)
39-
40-
// Check if the hint is visible
41-
expect(await window.locator('text="country code"::INT').count()).toBe(1)
42-
43-
await close()
44-
} finally {
45-
await fs.remove(tempDir)
46-
}
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 customers_revenue_by_day model
24+
await window
25+
.getByRole('treeitem', {
26+
name: 'customer_revenue_by_day.sql',
27+
exact: true,
28+
})
29+
.locator('a')
30+
.click()
31+
32+
await window.waitForSelector('text=grain')
33+
await window.waitForSelector('text=Loaded SQLMesh Context')
34+
35+
// Wait a moment for hints to appear
36+
await window.waitForTimeout(500)
37+
38+
// Check if the hint is visible
39+
expect(await window.locator('text="country code"::INT').count()).toBe(1)
40+
41+
await close()
42+
} finally {
43+
await fs.remove(tempDir)
44+
}
4745
})

vscode/extension/tests/utils.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,7 @@ export const startVSCode = async (
3333
const userDataDir = await fs.mkdtemp(
3434
path.join(os.tmpdir(), 'vscode-user-data-'),
3535
)
36-
const ciArgs = process.env.CI
37-
? [
38-
'--disable-gpu',
39-
'--headless',
40-
'--no-sandbox',
41-
'--disable-dev-shm-usage',
42-
'--window-position=-10000,0',
43-
]
44-
: []
36+
const ciArgs = process.env.CI ? ['--window-position=-10000,0'] : []
4537
const args = [
4638
...ciArgs,
4739
`--extensionDevelopmentPath=${EXT_PATH}`,
@@ -54,6 +46,7 @@ export const startVSCode = async (
5446
const electronApp = await electron.launch({
5547
executablePath: VS_CODE_EXE,
5648
args,
49+
recordVideo: { dir: 'test-videos' },
5750
})
5851
const window = await electronApp.firstWindow()
5952
await window.waitForLoadState('domcontentloaded')

0 commit comments

Comments
 (0)