Skip to content

Commit b4a673b

Browse files
committed
feat: add test for markdown webview
1 parent 2530a0d commit b4a673b

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/e2e/webview.test.ts

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { promises as fs } from "fs"
2+
import * as path from "path"
3+
import { describe, test, expect } from "./baseFixture"
4+
5+
describe("Webviews", ["--disable-workspace-trust"], {}, () => {
6+
test("should preview a Markdown file", async ({ codeServerPage }) => {
7+
// Create Markdown file
8+
const heading = "Hello world"
9+
const dir = await codeServerPage.workspaceDir
10+
const file = path.join(dir, "text.md")
11+
await fs.writeFile(file, `# ${heading}`)
12+
await codeServerPage.openFile(file)
13+
14+
// Open Preview
15+
await codeServerPage.executeCommandViaMenus("Markdown: Open Preview to the Side")
16+
// Wait for the iframe to open and load
17+
await codeServerPage.page.waitForTimeout(2000)
18+
await codeServerPage.waitForTab(`Preview ${file}`)
19+
20+
let totalCount = 0
21+
for (const frame of codeServerPage.page.frames()) {
22+
// Check for heading in frames
23+
const count = await frame.locator(`text=${heading}`).count()
24+
totalCount += count
25+
}
26+
27+
// One in the file and one in the preview
28+
expect(totalCount).toBe(2)
29+
})
30+
})

0 commit comments

Comments
 (0)