11import { expect , test } from '@jupyterlab/galata' ;
22
33import { ContentsHelper } from './utils/contents' ;
4- import { TERMINAL_SELECTOR , WAIT_MS , inputLine } from './utils/misc' ;
5-
6- // Long wait such as for starting/stopping a complex WebAssembly command.
7- export const LONG_WAIT_MS = 300 ;
4+ import {
5+ LONG_WAIT_MS ,
6+ TERMINAL_SELECTOR ,
7+ WAIT_MS ,
8+ inputLine
9+ } from './utils/misc' ;
810
911test . describe ( 'individual command' , ( ) => {
1012 test . beforeEach ( async ( { page } ) => {
1113 await page . goto ( ) ;
12- await page . waitForTimeout ( WAIT_MS ) ;
14+ await page . waitForTimeout ( LONG_WAIT_MS ) ;
1315
1416 // Overwrite the (read-only) page.contents with our own ContentsHelper.
1517 // @ts -ignore
@@ -18,7 +20,7 @@ test.describe('individual command', () => {
1820 await page . menu . clickMenuItem ( 'File>New>Terminal' ) ;
1921 await page . locator ( TERMINAL_SELECTOR ) . waitFor ( ) ;
2022 await page . locator ( 'div.xterm-screen' ) . click ( ) ; // sets focus for keyboard input
21- await page . waitForTimeout ( WAIT_MS ) ;
23+ await page . waitForTimeout ( LONG_WAIT_MS ) ;
2224 } ) ;
2325
2426 test . describe ( 'nano' , ( ) => {
@@ -28,18 +30,17 @@ test.describe('individual command', () => {
2830 page
2931 } ) => {
3032 await inputLine ( page , `cockle-config stdin ${ stdinOption } ` ) ;
31- await page . waitForTimeout ( WAIT_MS ) ;
33+ await page . waitForTimeout ( LONG_WAIT_MS ) ;
3234
3335 await inputLine ( page , 'nano a.txt' ) ;
3436 await page . waitForTimeout ( LONG_WAIT_MS ) ;
3537
3638 // Insert new characters.
37- await page . keyboard . type ( 'mnopqrst' ) ;
39+ await inputLine ( page , 'mnopqrst' , false ) ;
3840
3941 // Save and quit.
4042 await page . keyboard . press ( 'Control+x' ) ;
41- await page . keyboard . type ( 'y' ) ;
42- await page . keyboard . press ( 'Enter' ) ;
43+ await inputLine ( page , 'y' ) ;
4344 await page . waitForTimeout ( LONG_WAIT_MS ) ;
4445
4546 const outputFile = await page . contents . getContentMetadata ( 'a.txt' ) ;
@@ -50,11 +51,11 @@ test.describe('individual command', () => {
5051 page
5152 } ) => {
5253 await inputLine ( page , `cockle-config stdin ${ stdinOption } ` ) ;
53- await page . waitForTimeout ( WAIT_MS ) ;
54+ await page . waitForTimeout ( LONG_WAIT_MS ) ;
5455
5556 // Prepare file to delete from.
5657 await inputLine ( page , 'echo mnopqrst > b.txt' ) ;
57- await page . waitForTimeout ( WAIT_MS ) ;
58+ await page . waitForTimeout ( LONG_WAIT_MS ) ;
5859
5960 await inputLine ( page , 'nano b.txt' ) ;
6061 await page . waitForTimeout ( LONG_WAIT_MS ) ;
@@ -66,8 +67,7 @@ test.describe('individual command', () => {
6667
6768 // Save and quit.
6869 await page . keyboard . press ( 'Control+x' ) ;
69- await page . keyboard . type ( 'y' ) ;
70- await page . keyboard . press ( 'Enter' ) ;
70+ await inputLine ( page , 'y' ) ;
7171 await page . waitForTimeout ( LONG_WAIT_MS ) ;
7272
7373 const outputFile = await page . contents . getContentMetadata ( 'b.txt' ) ;
@@ -83,13 +83,13 @@ test.describe('individual command', () => {
8383 page
8484 } ) => {
8585 await inputLine ( page , `cockle-config stdin ${ stdinOption } ` ) ;
86- await page . waitForTimeout ( WAIT_MS ) ;
86+ await page . waitForTimeout ( LONG_WAIT_MS ) ;
8787
8888 await inputLine ( page , 'vim c.txt' ) ;
8989 await page . waitForTimeout ( LONG_WAIT_MS ) ;
9090
9191 // Insert new characters.
92- await page . keyboard . type ( 'iabcdefgh' ) ;
92+ await inputLine ( page , 'iabcdefgh' , false ) ;
9393
9494 // Save and quit.
9595 await page . keyboard . press ( 'Escape' ) ;
@@ -104,17 +104,17 @@ test.describe('individual command', () => {
104104 page
105105 } ) => {
106106 await inputLine ( page , `cockle-config stdin ${ stdinOption } ` ) ;
107- await page . waitForTimeout ( WAIT_MS ) ;
107+ await page . waitForTimeout ( LONG_WAIT_MS ) ;
108108
109109 // Prepare file to delete from.
110110 await inputLine ( page , 'echo abcdefgh > d.txt' ) ;
111- await page . waitForTimeout ( WAIT_MS ) ;
111+ await page . waitForTimeout ( LONG_WAIT_MS ) ;
112112
113113 await inputLine ( page , 'vim d.txt' ) ;
114114 await page . waitForTimeout ( LONG_WAIT_MS ) ;
115115
116116 // Delete first 4 characters.
117- await page . keyboard . type ( 'd4l' ) ;
117+ await inputLine ( page , 'd4l' , false ) ;
118118
119119 // Save and quit.
120120 await page . keyboard . press ( 'Escape' ) ;
0 commit comments