|
| 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('Model type hinting', 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 customers_revenue_by_day model |
| 24 | + await window |
| 25 | + .getByRole('treeitem', { name: 'customer_revenue_by_day.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 | + // Wait a moment for hints to appear |
| 33 | + await window.waitForTimeout(500) |
| 34 | + |
| 35 | + // Check if the hints are visible |
| 36 | + expect( |
| 37 | + await window.locator('text=customer_id::INT').count(), |
| 38 | + ).toBe(1) |
| 39 | + expect( |
| 40 | + await window.locator('text=revenue::DOUBLE').count(), |
| 41 | + ).toBe(1) |
| 42 | + expect( |
| 43 | + await window.locator('text="country code"::INT').count(), |
| 44 | + ).toBe(1) |
| 45 | + expect( |
| 46 | + await window.locator('text=event_date::DATE').count(), |
| 47 | + ).toBe(1) |
| 48 | + |
| 49 | + await close() |
| 50 | + } finally { |
| 51 | + await fs.remove(tempDir) |
| 52 | + } |
| 53 | +}) |
0 commit comments