|
| 1 | +import os from 'os' |
| 2 | +import { openServerPage, SUSHI_SOURCE_PATH } from './utils' |
| 3 | +import { createPythonInterpreterSettingsSpecifier } from './utils_code_server' |
| 4 | +import { test, expect } from './fixtures' |
| 5 | +import fs from 'fs-extra' |
| 6 | +import path from 'path' |
| 7 | + |
| 8 | +test.describe('External model files trigger lsp', () => { |
| 9 | + test('external_models.yaml', async ({ page, sharedCodeServer }) => { |
| 10 | + const file = 'external_models.yaml' |
| 11 | + |
| 12 | + const tempDir = await fs.mkdtemp( |
| 13 | + path.join(os.tmpdir(), 'vscode-test-sushi-'), |
| 14 | + ) |
| 15 | + await fs.copy(SUSHI_SOURCE_PATH, tempDir) |
| 16 | + |
| 17 | + // Assert external_models.yaml exists |
| 18 | + const externalModelsYamlPath = path.join(tempDir, file) |
| 19 | + expect(await fs.pathExists(externalModelsYamlPath)).toBe(true) |
| 20 | + |
| 21 | + await createPythonInterpreterSettingsSpecifier(tempDir) |
| 22 | + await openServerPage(page, tempDir, sharedCodeServer) |
| 23 | + |
| 24 | + // Wait for the models folder to be visible |
| 25 | + await page.waitForSelector('text=models') |
| 26 | + |
| 27 | + // Click on the external_models file (e.g., external_models.yaml or external_models.yml) |
| 28 | + await page |
| 29 | + .getByRole('treeitem', { name: file, exact: true }) |
| 30 | + .locator('a') |
| 31 | + .click() |
| 32 | + |
| 33 | + await page.waitForSelector('text=raw.demographics') |
| 34 | + await page.waitForSelector('text=Loaded SQLMesh Context') |
| 35 | + }) |
| 36 | + |
| 37 | + test('external_models.yml', async ({ page, sharedCodeServer }) => { |
| 38 | + const file = 'external_models.yml' |
| 39 | + |
| 40 | + const tempDir = await fs.mkdtemp( |
| 41 | + path.join(os.tmpdir(), 'vscode-test-sushi-'), |
| 42 | + ) |
| 43 | + await fs.copy(SUSHI_SOURCE_PATH, tempDir) |
| 44 | + |
| 45 | + // Move external_models.yaml to external_models.yml |
| 46 | + const externalModelsYamlPath = path.join(tempDir, 'external_models.yaml') |
| 47 | + const externalModelsYmlPath = path.join(tempDir, file) |
| 48 | + await fs.rename(externalModelsYamlPath, externalModelsYmlPath) |
| 49 | + |
| 50 | + // Assert external_models.yml exists |
| 51 | + expect(await fs.pathExists(externalModelsYmlPath)).toBe(true) |
| 52 | + |
| 53 | + await createPythonInterpreterSettingsSpecifier(tempDir) |
| 54 | + await openServerPage(page, tempDir, sharedCodeServer) |
| 55 | + |
| 56 | + // Wait for the models folder to be visible |
| 57 | + await page.waitForSelector('text=models') |
| 58 | + |
| 59 | + // Click on the external_models.yml file |
| 60 | + await page |
| 61 | + .getByRole('treeitem', { name: file, exact: true }) |
| 62 | + .locator('a') |
| 63 | + .click() |
| 64 | + |
| 65 | + await page.waitForSelector('text=raw.demographics') |
| 66 | + await page.waitForSelector('text=Loaded SQLMesh Context') |
| 67 | + }) |
| 68 | +}) |
0 commit comments