File tree Expand file tree Collapse file tree 2 files changed +56
-1
lines changed Expand file tree Collapse file tree 2 files changed +56
-1
lines changed Original file line number Diff line number Diff line change 55 INITIAL_WAIT_MS ,
66 TERMINAL_SELECTOR ,
77 WAIT_MS ,
8- inputLine
8+ inputLine ,
9+ fileContent
910} from './utils/misc' ;
1011
1112// Long wait such as for starting/stopping a complex WebAssembly command.
@@ -60,6 +61,29 @@ test.describe('individual command', () => {
6061 expect ( outputFile ?. content ) . toEqual ( 'mnopqrst\n' ) ;
6162 } ) ;
6263
64+ test ( `EXPT should create new file using ${ stdinOption } for stdin` , async ( {
65+ page
66+ } ) => {
67+ await inputLine ( page , `cockle-config stdin ${ stdinOption } ` ) ;
68+ await page . waitForTimeout ( WAIT_MS ) ;
69+
70+ const filename = 'a.txt'
71+
72+ await inputLine ( page , `nano ${ filename } ` ) ;
73+ await page . waitForTimeout ( LONG_WAIT_MS ) ;
74+
75+ // Insert new characters.
76+ await inputLine ( page , 'mnopqrst' , false ) ;
77+
78+ // Save and quit.
79+ await page . keyboard . press ( 'Control+x' ) ;
80+ await inputLine ( page , 'y' , true ) ;
81+ await page . waitForTimeout ( LONG_WAIT_MS ) ;
82+
83+ const content = await fileContent ( page , filename ) ;
84+ expect ( content ) . toEqual ( 'mnopqrst\n' ) ;
85+ } ) ;
86+
6387 test ( `should delete data from file using ${ stdinOption } for stdin` , async ( {
6488 page
6589 } ) => {
Original file line number Diff line number Diff line change 11import { Buffer } from 'node:buffer' ;
2+ import { expect } from '@jupyterlab/galata' ;
23import type { Page } from '@playwright/test' ;
34
45export const INITIAL_WAIT_MS = 300 ;
@@ -24,3 +25,33 @@ export async function inputLine(
2425 await page . waitForTimeout ( 20 ) ;
2526 }
2627}
28+
29+ async function refreshFilebrowser ( { page } ) : Promise < void > {
30+ try {
31+ await page . filebrowser . refresh ( ) ;
32+ } catch ( e ) {
33+ // no-op
34+ }
35+ }
36+
37+ export async function fileContent ( page : any , filename : string ) : Promise < string | undefined > {
38+ await refreshFilebrowser ( { page } ) ;
39+ expect ( await page . filebrowser . isFileListedInBrowser ( filename ) ) . toBeTruthy ( ) ;
40+ await page . filebrowser . open ( filename ) ;
41+
42+ const clickMenuItem = async ( command ) : Promise < void > => {
43+ await page . menu . openContextMenuLocator (
44+ `.jp-DirListing-content >> text="${ filename } "` ,
45+ ) ;
46+ await page . getByText ( command ) . click ( ) ;
47+ } ;
48+
49+ const [ newTab ] = await Promise . all ( [
50+ page . waitForEvent ( 'popup' ) ,
51+ clickMenuItem ( 'Open in New Browser Tab' ) ,
52+ ] ) ;
53+
54+ await newTab . waitForLoadState ( 'networkidle' ) ;
55+ const content = await newTab . textContent ( 'body' ) ;
56+ return content ;
57+ }
You can’t perform that action at this time.
0 commit comments