From f56ce5b66d9985d1062d14cd317e9ab05607b2e1 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Thu, 3 Nov 2022 15:08:12 -0700 Subject: [PATCH] feat: add test for markdown webview (#5740) * feat: add test for markdown webview * fixup!: use frameLocator --- test/e2e/webview.test.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 test/e2e/webview.test.ts diff --git a/test/e2e/webview.test.ts b/test/e2e/webview.test.ts new file mode 100644 index 000000000..fb6d88667 --- /dev/null +++ b/test/e2e/webview.test.ts @@ -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") + + expect(renderedText).toBeVisible + }) +})