|
| 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 { openLineageView, SUSHI_SOURCE_PATH } from './utils' |
| 6 | +import { startCodeServer, stopCodeServer } from './utils_code_server' |
| 7 | + |
| 8 | +test('Settings button is visible in the lineage view', async ({ page }) => { |
| 9 | + const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), 'vscode-test-sushi-')) |
| 10 | + await fs.copy(SUSHI_SOURCE_PATH, tempDir) |
| 11 | + |
| 12 | + const context = await startCodeServer({ |
| 13 | + tempDir, |
| 14 | + placeFileWithPythonInterpreter: true, |
| 15 | + }) |
| 16 | + |
| 17 | + try { |
| 18 | + await page.goto(`http://127.0.0.1:${context.codeServerPort}`) |
| 19 | + |
| 20 | + await page.waitForSelector('text=models') |
| 21 | + |
| 22 | + // Click on the models folder, excluding external_models |
| 23 | + await page |
| 24 | + .getByRole('treeitem', { name: 'models', exact: true }) |
| 25 | + .locator('a') |
| 26 | + .click() |
| 27 | + // Open the waiters.py model |
| 28 | + await page |
| 29 | + .getByRole('treeitem', { name: 'waiters.py', exact: true }) |
| 30 | + .locator('a') |
| 31 | + .click() |
| 32 | + await page.waitForSelector('text=Loaded SQLMesh Context') |
| 33 | + |
| 34 | + // Open lineage |
| 35 | + await openLineageView(page) |
| 36 | + |
| 37 | + const iframes = page.locator('iframe') |
| 38 | + const iframeCount = await iframes.count() |
| 39 | + let settingsCount = 0 |
| 40 | + |
| 41 | + for (let i = 0; i < iframeCount; i++) { |
| 42 | + const iframe = iframes.nth(i) |
| 43 | + const contentFrame = iframe.contentFrame() |
| 44 | + if (contentFrame) { |
| 45 | + const activeFrame = contentFrame.locator('#active-frame').contentFrame() |
| 46 | + if (activeFrame) { |
| 47 | + try { |
| 48 | + await activeFrame |
| 49 | + .getByRole('button', { |
| 50 | + name: 'Settings', |
| 51 | + }) |
| 52 | + .waitFor({ timeout: 1000 }) |
| 53 | + settingsCount++ |
| 54 | + } catch { |
| 55 | + // Continue to next iframe if this one doesn't have the error |
| 56 | + continue |
| 57 | + } |
| 58 | + } |
| 59 | + } |
| 60 | + } |
| 61 | + |
| 62 | + expect(settingsCount).toBeGreaterThan(0) |
| 63 | + } finally { |
| 64 | + await stopCodeServer(context) |
| 65 | + } |
| 66 | +}) |
0 commit comments