Skip to content

feat: add test for markdown webview #5740

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 3, 2022
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
28 changes: 28 additions & 0 deletions test/e2e/webview.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { promises as fs } from "fs"
import * as path from "path"
import { describe, test, expect } from "./baseFixture"

describe("Webviews", ["--disable-workspace-trust"], {}, () => {
test("should preview a Markdown file", async ({ codeServerPage }) => {
// Create Markdown file
const heading = "Hello world"
const dir = await codeServerPage.workspaceDir
const file = path.join(dir, "text.md")
await fs.writeFile(file, `# ${heading}`)
await codeServerPage.openFile(file)

// Open Preview
await codeServerPage.executeCommandViaMenus("Markdown: Open Preview to the Side")
// Wait for the iframe to open and load
await codeServerPage.waitForTab(`Preview ${file}`)

// It's an iframe within an iframe
// so we have to do .frameLocator twice
const renderedText = await codeServerPage.page
.frameLocator("iframe.webview.ready")
.frameLocator("#active-frame")
.locator("text=Hello world")
Comment on lines +19 to +24
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was the hardest part. I didn't realize it was an <iframe> inside of an <iframe> but some rubber-ducking with @code-asher helped me figure it out.


expect(renderedText).toBeVisible
})
})