@@ -2,7 +2,8 @@ import { test, expect } from "@playwright/test"
22import * as fs from "fs"
33import { tmpdir } from "os"
44import * as path from "path"
5-
5+ import util from "util"
6+ import * as cp from "child_process"
67import { STORAGE } from "../utils/constants"
78import { CodeServer } from "./models/CodeServer"
89
@@ -13,6 +14,8 @@ test.describe("Integrated Terminal", () => {
1314 const testFileName = "test.txt"
1415 const testString = "new string test from e2e test"
1516 let codeServer : CodeServer
17+ let tmpFolderPath :string = ""
18+ let tmpFile : string = ""
1619
1720 // TODO@jsjoeio
1821 // Fix this once https://github.com/microsoft/playwright-test/issues/240
@@ -26,27 +29,45 @@ test.describe("Integrated Terminal", () => {
2629 test . beforeEach ( async ( { page } ) => {
2730 codeServer = new CodeServer ( page )
2831 await codeServer . setup ( )
29- } )
30-
31- test ( "should echo a string to a file" , options , async ( { page } ) => {
3232 // NOTE@jsjoeio
3333 // We're not using tmpdir from src/node/constants
3434 // because Playwright doesn't fully support ES modules from
3535 // the erorrs I'm seeing
36- const tmpFolderPath = fs . mkdtempSync ( path . join ( tmpdir ( ) , "code-server-test" ) )
37- const tmpFile = `${ tmpFolderPath } ${ path . sep } ${ testFileName } `
36+ tmpFolderPath = fs . mkdtempSync ( path . join ( tmpdir ( ) , "code-server-test" ) )
37+ tmpFile = `${ tmpFolderPath } ${ path . sep } ${ testFileName } `
38+ console . log ( "show me the tmpFolderPath" , tmpFolderPath )
39+ console . log ( "show me the tmpFile" , tmpFile )
40+ } )
41+
42+ test . afterEach ( async ( { page} ) => {
43+ // Ensure directory was removed
44+ fs . rmdirSync ( tmpFolderPath , { recursive : true } )
45+ } )
46+
47+ test ( "should echo a string to a file" , options , async ( { page } ) => {
48+ console . log ( 'inside the test' )
49+ const command = `mkfifo '${ tmpFile } ' && cat '${ tmpFile } '`
50+ const exec = util . promisify ( cp . exec )
51+ console . log ( 'right after exec' )
52+
3853 // Open terminal and type in value
3954 await codeServer . focusTerminal ( )
4055
4156 await page . waitForLoadState ( "load" )
42- await page . keyboard . type ( `echo '${ testString } ' > ${ tmpFile } ` )
57+ await page . keyboard . type ( `echo '${ testString } ' > ' ${ tmpFile } ' ` )
4358 // Wait for the typing to finish before hitting enter
4459 await page . waitForTimeout ( 1000 )
4560 await page . keyboard . press ( "Enter" )
4661 // Wait for enter to register and
4762 // and file to be created
4863 await page . waitForTimeout ( 2000 )
4964 // await page.waitForLoadState("networkidle")
65+ const output = await exec ( command , { encoding : "utf8" } )
66+ console . log ( "what is output " , output )
67+
68+ const t = await output
69+ console . log ( 'what is this thing t' , t )
70+ expect ( t ) . toBe ( testString )
5071
5172 // .access checks if the file exists without opening it
5273 // it doesn't return anything hence why we expect it to
0 commit comments