Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 6 additions & 25 deletions vscode/extension/tests/bad_setup.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
createVirtualEnvironment,
openFile,
openLineageView,
openServerPage,
pipInstall,
REPO_ROOT,
SUSHI_SOURCE_PATH,
Expand Down Expand Up @@ -41,21 +42,13 @@ test('missing LSP dependencies shows install prompt', async ({
spaces: 2,
})

await page.goto(
`http://127.0.0.1:${sharedCodeServer.codeServerPort}/?folder=${tempDir}`,
)

// Open a SQL file to trigger SQLMesh activation
// Wait for the models folder to be visible
await page.waitForSelector('text=models')
await openServerPage(page, tempDir, sharedCodeServer)

// Click on the models folder
// Open a top_waiters model to trigger SQLMesh activation
await page
.getByRole('treeitem', { name: 'models', exact: true })
.locator('a')
.click()

// Open the top_waiters model
await page
.getByRole('treeitem', { name: 'customers.sql', exact: true })
.locator('a')
Expand All @@ -66,12 +59,7 @@ test('missing LSP dependencies shows install prompt', async ({
expect(await page.locator('text=Install').count()).toBeGreaterThanOrEqual(1)
})

test('lineage, no sqlmesh found', async ({
page,
sharedCodeServer,
}, testInfo) => {
testInfo.setTimeout(120_000) // 2 minutes for venv creation and package installation

test('lineage, no sqlmesh found', async ({ page, sharedCodeServer }) => {
const tempDir = await fs.mkdtemp(
path.join(os.tmpdir(), 'vscode-test-tcloud-'),
)
Expand All @@ -92,12 +80,8 @@ test('lineage, no sqlmesh found', async ({
})

// navigate to code-server instance
await page.goto(
`http://127.0.0.1:${sharedCodeServer.codeServerPort}/?folder=${tempDir}`,
)
await page.waitForLoadState('networkidle')
await openServerPage(page, tempDir, sharedCodeServer)

// Open lineage view
await openLineageView(page)

// Assert shows that sqlmesh is not installed
Expand Down Expand Up @@ -143,10 +127,7 @@ test.skip('check that the LSP runs correctly by opening lineage when looking at
await fs.ensureDir(path.dirname(sqlFile))
await fs.writeFile(sqlFile, 'SELECT 1')

await page.goto(
`http://127.0.0.1:${sharedCodeServer.codeServerPort}/?folder=${tempDir}`,
)
await page.waitForLoadState('networkidle')
await openServerPage(page, tempDir, sharedCodeServer)

// Open the SQL file from the other directory
await openFile(page, sqlFile)
Expand Down
26 changes: 6 additions & 20 deletions vscode/extension/tests/broken_project.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import os from 'os'
import path from 'path'
import {
openLineageView,
openServerPage,
runCommand,
saveFile,
SUSHI_SOURCE_PATH,
Expand All @@ -29,9 +30,7 @@ test('bad project, double model', async ({ page, sharedCodeServer }) => {
)

await createPythonInterpreterSettingsSpecifier(tempDir)
await page.goto(
`http://127.0.0.1:${sharedCodeServer.codeServerPort}/?folder=${tempDir}`,
)
await openServerPage(page, tempDir, sharedCodeServer)

await page.waitForSelector('text=models')

Expand Down Expand Up @@ -60,9 +59,7 @@ test('working project, then broken through adding double model, then refixed', a
await fs.copy(SUSHI_SOURCE_PATH, tempDir)

await createPythonInterpreterSettingsSpecifier(tempDir)
await page.goto(
`http://127.0.0.1:${sharedCodeServer.codeServerPort}/?folder=${tempDir}`,
)
await openServerPage(page, tempDir, sharedCodeServer)
await page.waitForLoadState('networkidle')

// Open the lineage view to confirm it loads properly
Expand Down Expand Up @@ -170,13 +167,7 @@ test('bad project, double model, then fixed', async ({
customersSql,
)

await page.goto(
`http://127.0.0.1:${sharedCodeServer.codeServerPort}/?folder=${tempDir}`,
)
await page.waitForLoadState('networkidle')
await page.goto(
`http://127.0.0.1:${sharedCodeServer.codeServerPort}/?folder=${tempDir}`,
)
await openServerPage(page, tempDir, sharedCodeServer)

await page.waitForSelector('text=models')

Expand Down Expand Up @@ -245,10 +236,7 @@ test('bad project, double model, check lineage', async ({
)

await createPythonInterpreterSettingsSpecifier(tempDir)
await page.goto(
`http://127.0.0.1:${sharedCodeServer.codeServerPort}/?folder=${tempDir}`,
)
await page.waitForLoadState('networkidle')
await openServerPage(page, tempDir, sharedCodeServer)

// Open the lineage view
await openLineageView(page)
Expand All @@ -273,9 +261,7 @@ test('bad model block, then fixed', async ({ page, sharedCodeServer }) => {
'MODEL ( name sushi.bad_block, test); SELECT * FROM sushi.customers'
await fs.writeFile(badModelPath, contents)

await page.goto(
`http://127.0.0.1:${sharedCodeServer.codeServerPort}/?folder=${tempDir}`,
)
await openServerPage(page, tempDir, sharedCodeServer)
await page.waitForLoadState('networkidle')

// Open the customers.sql model
Expand Down
15 changes: 4 additions & 11 deletions vscode/extension/tests/completions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@ import { test, expect } from './fixtures'
import path from 'path'
import fs from 'fs-extra'
import os from 'os'
import { SUSHI_SOURCE_PATH } from './utils'
import { openServerPage, SUSHI_SOURCE_PATH } from './utils'
import { createPythonInterpreterSettingsSpecifier } from './utils_code_server'

test('Autocomplete for model names', 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)
await page.goto(
`http://127.0.0.1:${sharedCodeServer.codeServerPort}/?folder=${tempDir}`,
)
await openServerPage(page, tempDir, sharedCodeServer)

// Wait for the models folder to be visible
await page.waitForSelector('text=models')
Expand Down Expand Up @@ -67,9 +65,7 @@ test.describe('Macro Completions', () => {
await fs.copy(SUSHI_SOURCE_PATH, tempDir)

await createPythonInterpreterSettingsSpecifier(tempDir)
await page.goto(
`http://127.0.0.1:${sharedCodeServer.codeServerPort}/?folder=${tempDir}`,
)
await openServerPage(page, tempDir, sharedCodeServer)

// Wait for the models folder to be visible
await page.waitForSelector('text=models')
Expand Down Expand Up @@ -119,10 +115,7 @@ test.describe('Macro Completions', () => {
await fs.copy(SUSHI_SOURCE_PATH, tempDir)

await createPythonInterpreterSettingsSpecifier(tempDir)

await page.goto(
`http://127.0.0.1:${sharedCodeServer.codeServerPort}/?folder=${tempDir}`,
)
await openServerPage(page, tempDir, sharedCodeServer)

// Wait for the models folder to be visible
await page.waitForSelector('text=models')
Expand Down
37 changes: 8 additions & 29 deletions vscode/extension/tests/diagnostics.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { expect, test } from './fixtures'
import path from 'path'
import fs from 'fs-extra'
import os from 'os'
import { runCommand, SUSHI_SOURCE_PATH } from './utils'
import { openServerPage, runCommand, SUSHI_SOURCE_PATH } from './utils'
import { createPythonInterpreterSettingsSpecifier } from './utils_code_server'
import { execAsync } from '../src/utilities/exec'
import yaml from 'yaml'
Expand All @@ -20,10 +20,7 @@ test('Workspace diagnostics show up in the diagnostics panel', async ({
const updatedContent = configContent.replace('enabled=False', 'enabled=True')
await fs.writeFile(configPath, updatedContent)

await page.goto(
`http://127.0.0.1:${sharedCodeServer.codeServerPort}/?folder=${tempDir}`,
)

await openServerPage(page, tempDir, sharedCodeServer)
// Wait for the models folder to be visible
await page.waitForSelector('text=models')

Expand Down Expand Up @@ -70,10 +67,7 @@ test.describe('Bad config.py/config.yaml file issues', () => {
// Write an invalid YAML to config.yaml
await fs.writeFile(configYamlPath, 'invalid_yaml; asdfasudfy')

await page.goto(
`http://127.0.0.1:${sharedCodeServer.codeServerPort}/?folder=${tempDir}`,
)
await page.waitForLoadState('networkidle')
await openServerPage(page, tempDir, sharedCodeServer)

// Open full_model.sql model
await page
Expand Down Expand Up @@ -116,10 +110,7 @@ test.describe('Bad config.py/config.yaml file issues', () => {
// Write config to the yaml file
await fs.writeFile(configYamlPath, yaml.stringify(config))

await page.goto(
`http://127.0.0.1:${sharedCodeServer.codeServerPort}/?folder=${tempDir}`,
)
await page.waitForLoadState('networkidle')
await openServerPage(page, tempDir, sharedCodeServer)

// Open full_model.sql model
await page
Expand Down Expand Up @@ -158,10 +149,7 @@ test.describe('Bad config.py/config.yaml file issues', () => {
// Write an invalid Python to config.py
await fs.writeFile(configPyPath, 'config = {}')

await page.goto(
`http://127.0.1:${sharedCodeServer.codeServerPort}/?folder=${tempDir}`,
)
await page.waitForLoadState('networkidle')
await openServerPage(page, tempDir, sharedCodeServer)

// Open customers.sql model
await page
Expand Down Expand Up @@ -197,10 +185,7 @@ test.describe('Bad config.py/config.yaml file issues', () => {
// Write an invalid Python to config.py
await fs.writeFile(configPyPath, 'invalid_python_code = [1, 2, 3')

await page.goto(
`http://127.0.1:${sharedCodeServer.codeServerPort}/?folder=${tempDir}`,
)
await page.waitForLoadState('networkidle')
await openServerPage(page, tempDir, sharedCodeServer)

// Open customers.sql model
await page
Expand Down Expand Up @@ -242,10 +227,7 @@ test.describe('Diagnostics for bad SQLMesh models', () => {
)
await fs.copy(customersSqlPath, duplicatedCustomersSqlPath)

await page.goto(
`http://127.0.0.1:${sharedCodeServer.codeServerPort}/?folder=${tempDir}`,
)
await page.waitForLoadState('networkidle')
await openServerPage(page, tempDir, sharedCodeServer)

// Open full_model.sql model
await page
Expand Down Expand Up @@ -334,10 +316,7 @@ test.describe('Diagnostics for bad audits', () => {
await fs.writeFile(auditFilePath, updatedContent)

// Navigate to the code-server instance
await page.goto(
`http://127.0.1:${sharedCodeServer.codeServerPort}/?folder=${tempDir}`,
)
await page.waitForLoadState('networkidle')
await openServerPage(page, tempDir, sharedCodeServer)

// Open a the customers.sql model
await page
Expand Down
Loading