@@ -21,16 +21,20 @@ import { ElectronLaunchOptions, TheiaElectronAppLoader } from '../theia-app-load
2121import { TheiaWorkspace } from '../theia-workspace' ;
2222import { TheiaApp } from '../theia-app' ;
2323
24+ test . describe . configure ( { mode : 'serial' } ) ;
2425test . describe ( 'Theia Electron Application' , ( ) => {
2526
26- let ws : TheiaWorkspace ;
2727 let app : TheiaApp ;
2828
2929 test . beforeAll ( async ( ) => {
30- ws = new TheiaWorkspace ( [ 'src/tests/resources/sample-files1' ] ) ;
30+ const ws = new TheiaWorkspace ( [ 'src/tests/resources/sample-files1' ] ) ;
3131 app = await TheiaElectronAppLoader . load ( new ElectronLaunchOptions ( '../electron' , '../../plugins' ) , ws ) ;
3232 } ) ;
3333
34+ test . afterAll ( async ( ) => {
35+ await app . page . close ( ) ;
36+ } ) ;
37+
3438 test ( 'should load and show main content panel' , async ( ) => {
3539 expect ( await app . isMainContentPanelVisible ( ) ) . toBe ( true ) ;
3640 } ) ;
@@ -44,6 +48,27 @@ test.describe('Theia Electron Application', () => {
4448 expect ( await aboutDialog . isVisible ( ) ) . toBe ( false ) ;
4549 } ) ;
4650
51+ test ( 'open file via file menu and cancel' , async ( ) => {
52+ await ( await app . menuBar . openMenu ( 'File' ) ) . clickMenuItem ( 'Open File...' ) ;
53+ const fileDialog = await app . page . waitForSelector ( 'div[class="dialogBlock"]' ) ;
54+ expect ( await fileDialog . isVisible ( ) ) . toBe ( true ) ;
55+ await app . page . getByRole ( 'button' , { name : 'Cancel' } ) . click ( ) ;
56+ expect ( await fileDialog . isVisible ( ) ) . toBe ( false ) ;
57+ } ) ;
58+
59+ test ( 'open sample.txt via file menu' , async ( ) => {
60+ await ( await app . menuBar . openMenu ( 'File' ) ) . clickMenuItem ( 'Open File...' ) ;
61+ const fileDialog = await app . page . waitForSelector ( 'div[class="dialogBlock"]' ) ;
62+ expect ( await fileDialog . isVisible ( ) ) . toBe ( true ) ;
63+
64+ const fileEntry = app . page . getByText ( 'sample.txt' ) ;
65+ await fileEntry . click ( ) ;
66+ await app . page . getByRole ( 'button' , { name : 'Open' } ) . click ( ) ;
67+
68+ const span = await app . page . waitForSelector ( 'span:has-text("content line 2")' ) ;
69+ expect ( await span . isVisible ( ) ) . toBe ( true ) ;
70+ } ) ;
71+
4772 test ( 'toggle explorer view using menu' , async ( ) => {
4873 await ( await app . menuBar . openMenu ( 'View' ) ) . clickMenuItem ( 'Explorer' ) ;
4974 const explorerView = new TheiaExplorerView ( app ) ;
0 commit comments