Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 69 additions & 8 deletions vscode/extension/tests/broken_project.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test } from '@playwright/test'
import { test, expect } from '@playwright/test'
import fs from 'fs-extra'
import os from 'os'
import path from 'path'
Expand Down Expand Up @@ -95,18 +95,59 @@ test('working project, then broken through adding double model, then refixed', a
await saveFile(page)

// Wait for the error to appear
// TODO: Selector doesn't work in the linage view
// await window.waitForSelector('text=Error')
const iframes = page.locator('iframe')
const iframeCount = await iframes.count()
let errorCount = 0

for (let i = 0; i < iframeCount; i++) {
const iframe = iframes.nth(i)
const contentFrame = iframe.contentFrame()
if (contentFrame) {
const activeFrame = contentFrame.locator('#active-frame').contentFrame()
Comment on lines +104 to +106
Copy link

Copilot AI Jul 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to await the call to iframe.contentFrame() to get the actual Frame object before using it.

Suggested change
const contentFrame = iframe.contentFrame()
if (contentFrame) {
const activeFrame = contentFrame.locator('#active-frame').contentFrame()
const contentFrame = await iframe.contentFrame()
if (contentFrame) {
const activeFrame = await contentFrame.locator('#active-frame').contentFrame()

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Jul 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The call to .contentFrame() on the locator must also be awaited to retrieve the nested frame.

Suggested change
const activeFrame = contentFrame.locator('#active-frame').contentFrame()
const activeFrame = await contentFrame.locator('#active-frame').contentFrame()

Copilot uses AI. Check for mistakes.
if (activeFrame) {
try {
await activeFrame
.getByText('Error: Failed to load model')
.waitFor({ timeout: 1000 })
errorCount++
} catch {
// Continue to next iframe if this one doesn't have the error
continue
}
}
}
}
Comment on lines +98 to +119
Copy link

Copilot AI Jul 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] You repeat nearly identical iframe-scanning logic three times. Extract a helper function like countTextInLineageView(page, text) to reduce duplication.

Suggested change
const iframes = page.locator('iframe')
const iframeCount = await iframes.count()
let errorCount = 0
for (let i = 0; i < iframeCount; i++) {
const iframe = iframes.nth(i)
const contentFrame = iframe.contentFrame()
if (contentFrame) {
const activeFrame = contentFrame.locator('#active-frame').contentFrame()
if (activeFrame) {
try {
await activeFrame
.getByText('Error: Failed to load model')
.waitFor({ timeout: 1000 })
errorCount++
} catch {
// Continue to next iframe if this one doesn't have the error
continue
}
}
}
}
const errorCount = await countTextInLineageView(page, 'Error: Failed to load model')

Copilot uses AI. Check for mistakes.
expect(errorCount).toBeGreaterThan(0)

// Remove the duplicated model to fix the project
await fs.remove(path.join(tempDir, 'models', 'customers_duplicated.sql'))

// Save again to refresh the context
await saveFile(page)

// Wait for the error to go away and context to reload
// TODO: Selector doesn't work in the linage view
// await page.waitForSelector('text=raw.demographics')
const iframes2 = page.locator('iframe')
const iframeCount2 = await iframes2.count()
let raw_demographicsCount = 0

for (let i = 0; i < iframeCount2; i++) {
const iframe = iframes2.nth(i)
const contentFrame = iframe.contentFrame()
if (contentFrame) {
const activeFrame = contentFrame.locator('#active-frame').contentFrame()
if (activeFrame) {
try {
await activeFrame
.getByText('raw.demographics')
.waitFor({ timeout: 1000 })
raw_demographicsCount++
} catch {
// Continue to next iframe if this one doesn't have the error
continue
}
}
}
}
expect(raw_demographicsCount).toBeGreaterThan(0)
} finally {
await stopCodeServer(context)
}
Expand Down Expand Up @@ -158,8 +199,28 @@ test('bad project, double model, then fixed', async ({ page }) => {
await openLineageView(page)

// Wait for the error to go away
// TODO: Selector doesn't work in the linage view
// await page.waitForSelector('text=raw.demographics')
const iframes = page.locator('iframe')
const iframeCount = await iframes.count()
let raw_demographicsCount = 0

for (let i = 0; i < iframeCount; i++) {
const iframe = iframes.nth(i)
const contentFrame = iframe.contentFrame()
if (contentFrame) {
const activeFrame = contentFrame.locator('#active-frame').contentFrame()
if (activeFrame) {
try {
await activeFrame
.getByText('sushi.customers')
.waitFor({ timeout: 1000 })
raw_demographicsCount++
} catch {
continue
}
}
}
}
expect(raw_demographicsCount).toBeGreaterThan(0)
} finally {
await stopCodeServer(context)
}
Expand Down