Skip to content

Commit f56ce5b

Browse files
authored
feat: add test for markdown webview (#5740)
* feat: add test for markdown webview * fixup!: use frameLocator
1 parent 2530a0d commit f56ce5b

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/e2e/webview.test.ts

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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.waitForTab(`Preview ${file}`)
18+
19+
// It's an iframe within an iframe
20+
// so we have to do .frameLocator twice
21+
const renderedText = await codeServerPage.page
22+
.frameLocator("iframe.webview.ready")
23+
.frameLocator("#active-frame")
24+
.locator("text=Hello world")
25+
26+
expect(renderedText).toBeVisible
27+
})
28+
})

0 commit comments

Comments
 (0)