|
| 1 | +import { test, expect } from '@playwright/test' |
| 2 | +import path from 'path' |
| 3 | +import fs from 'fs-extra' |
| 4 | +import os from 'os' |
| 5 | +import { startVSCode, SUSHI_SOURCE_PATH } from './utils' |
| 6 | + |
| 7 | +test('Autocomplete for model names', 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 |
| 18 | + await window |
| 19 | + .getByRole('treeitem', { name: 'models', exact: true }) |
| 20 | + .locator('a') |
| 21 | + .click() |
| 22 | + |
| 23 | + // Open the top_waiters model |
| 24 | + await window |
| 25 | + .getByRole('treeitem', { name: 'top_waiters.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 | + await window.locator('text=grain').first().click() |
| 33 | + |
| 34 | + // Move to the end of the file |
| 35 | + await window.keyboard.press('Control+End') |
| 36 | + |
| 37 | + // Add a new line |
| 38 | + await window.keyboard.press('Enter') |
| 39 | + |
| 40 | + // Type the beginning of sushi.customers to trigger autocomplete |
| 41 | + await window.keyboard.type('sushi.cus') |
| 42 | + |
| 43 | + // Wait a moment for autocomplete to appear |
| 44 | + await window.waitForTimeout(500) |
| 45 | + |
| 46 | + // Check if the autocomplete suggestion for sushi.customers is visible |
| 47 | + await expect(window.locator('text=sushi.customers')).toBeVisible() |
| 48 | + |
| 49 | + await close() |
| 50 | + } finally { |
| 51 | + await fs.remove(tempDir) |
| 52 | + } |
| 53 | +}) |
0 commit comments