File tree 1 file changed +30
-0
lines changed
1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change
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
+ } )
You can’t perform that action at this time.
0 commit comments