Skip to content

Commit a3302e4

Browse files
authored
chore(vscode): starts testing the actual contents of the lineage view (#4865)
1 parent c50663c commit a3302e4

File tree

1 file changed

+69
-8
lines changed

1 file changed

+69
-8
lines changed

vscode/extension/tests/broken_project.spec.ts

Lines changed: 69 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { test } from '@playwright/test'
1+
import { test, expect } from '@playwright/test'
22
import fs from 'fs-extra'
33
import os from 'os'
44
import path from 'path'
@@ -95,18 +95,59 @@ test('working project, then broken through adding double model, then refixed', a
9595
await saveFile(page)
9696

9797
// Wait for the error to appear
98-
// TODO: Selector doesn't work in the linage view
99-
// await window.waitForSelector('text=Error')
98+
const iframes = page.locator('iframe')
99+
const iframeCount = await iframes.count()
100+
let errorCount = 0
101+
102+
for (let i = 0; i < iframeCount; i++) {
103+
const iframe = iframes.nth(i)
104+
const contentFrame = iframe.contentFrame()
105+
if (contentFrame) {
106+
const activeFrame = contentFrame.locator('#active-frame').contentFrame()
107+
if (activeFrame) {
108+
try {
109+
await activeFrame
110+
.getByText('Error: Failed to load model')
111+
.waitFor({ timeout: 1000 })
112+
errorCount++
113+
} catch {
114+
// Continue to next iframe if this one doesn't have the error
115+
continue
116+
}
117+
}
118+
}
119+
}
120+
expect(errorCount).toBeGreaterThan(0)
100121

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

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

107-
// Wait for the error to go away and context to reload
108-
// TODO: Selector doesn't work in the linage view
109-
// await page.waitForSelector('text=raw.demographics')
128+
const iframes2 = page.locator('iframe')
129+
const iframeCount2 = await iframes2.count()
130+
let raw_demographicsCount = 0
131+
132+
for (let i = 0; i < iframeCount2; i++) {
133+
const iframe = iframes2.nth(i)
134+
const contentFrame = iframe.contentFrame()
135+
if (contentFrame) {
136+
const activeFrame = contentFrame.locator('#active-frame').contentFrame()
137+
if (activeFrame) {
138+
try {
139+
await activeFrame
140+
.getByText('raw.demographics')
141+
.waitFor({ timeout: 1000 })
142+
raw_demographicsCount++
143+
} catch {
144+
// Continue to next iframe if this one doesn't have the error
145+
continue
146+
}
147+
}
148+
}
149+
}
150+
expect(raw_demographicsCount).toBeGreaterThan(0)
110151
} finally {
111152
await stopCodeServer(context)
112153
}
@@ -158,8 +199,28 @@ test('bad project, double model, then fixed', async ({ page }) => {
158199
await openLineageView(page)
159200

160201
// Wait for the error to go away
161-
// TODO: Selector doesn't work in the linage view
162-
// await page.waitForSelector('text=raw.demographics')
202+
const iframes = page.locator('iframe')
203+
const iframeCount = await iframes.count()
204+
let raw_demographicsCount = 0
205+
206+
for (let i = 0; i < iframeCount; i++) {
207+
const iframe = iframes.nth(i)
208+
const contentFrame = iframe.contentFrame()
209+
if (contentFrame) {
210+
const activeFrame = contentFrame.locator('#active-frame').contentFrame()
211+
if (activeFrame) {
212+
try {
213+
await activeFrame
214+
.getByText('sushi.customers')
215+
.waitFor({ timeout: 1000 })
216+
raw_demographicsCount++
217+
} catch {
218+
continue
219+
}
220+
}
221+
}
222+
}
223+
expect(raw_demographicsCount).toBeGreaterThan(0)
163224
} finally {
164225
await stopCodeServer(context)
165226
}

0 commit comments

Comments
 (0)