|
| 1 | +import path from 'path' |
| 2 | +import { startVSCode, SUSHI_SOURCE_PATH } from './utils' |
| 3 | +import os from 'os' |
| 4 | +import { test } from '@playwright/test' |
| 5 | +import fs from 'fs-extra' |
| 6 | + |
| 7 | +test('Stop server works', 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, excluding external_models |
| 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: 'customers.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 | + // Stop the server |
| 33 | + await window.keyboard.press( |
| 34 | + process.platform === 'darwin' ? 'Meta+Shift+P' : 'Control+Shift+P', |
| 35 | + ) |
| 36 | + await window.keyboard.type('SQLMesh: Stop Server') |
| 37 | + await window.keyboard.press('Enter') |
| 38 | + |
| 39 | + // Await LSP server stopped message |
| 40 | + await window.waitForSelector('text=LSP server stopped') |
| 41 | + |
| 42 | + // Render the model |
| 43 | + await window.keyboard.press( |
| 44 | + process.platform === 'darwin' ? 'Meta+Shift+P' : 'Control+Shift+P', |
| 45 | + ) |
| 46 | + await window.keyboard.type('Render Model') |
| 47 | + await window.keyboard.press('Enter') |
| 48 | + |
| 49 | + // Await error message |
| 50 | + await window.waitForSelector( |
| 51 | + 'text="Failed to render model: LSP client not ready."', |
| 52 | + ) |
| 53 | + await close() |
| 54 | + } finally { |
| 55 | + await fs.remove(tempDir) |
| 56 | + } |
| 57 | +}) |
0 commit comments