@@ -19,38 +19,96 @@ import { TheiaExplorerView } from '../theia-explorer-view';
1919import { TheiaAboutDialog } from '../theia-about-dialog' ;
2020import { ElectronLaunchOptions , TheiaElectronAppLoader } from '../theia-app-loader' ;
2121import { TheiaWorkspace } from '../theia-workspace' ;
22+ import { TheiaApp } from '../theia-app' ;
2223
24+ test . describe . configure ( { mode : 'serial' } ) ;
2325test . describe ( 'Theia Electron Application' , ( ) => {
2426
27+ let app : TheiaApp ;
28+ let ws : TheiaWorkspace ;
29+
30+ test . beforeAll ( async ( ) => {
31+ ws = new TheiaWorkspace ( [ 'src/tests/resources/sample-files1' ] ) ;
32+ app = await TheiaElectronAppLoader . load ( new ElectronLaunchOptions ( '../electron' , '../../plugins' ) , ws ) ;
33+ } ) ;
34+
35+ test . afterAll ( async ( ) => {
36+ await app . page . close ( ) ;
37+ } ) ;
38+
2539 test ( 'should load and show main content panel' , async ( ) => {
26- const ws = new TheiaWorkspace ( [ 'src/tests/resources/sample-files1' ] ) ;
27- const app = await TheiaElectronAppLoader . load ( new ElectronLaunchOptions ( '../electron' , '../../plugins' ) , ws ) ;
2840 expect ( await app . isMainContentPanelVisible ( ) ) . toBe ( true ) ;
41+ } ) ;
2942
30- const quickCommand = app . quickCommandPalette ;
43+ test ( 'open about dialog using menu' , async ( ) => {
44+ await ( await app . menuBar . openMenu ( 'Help' ) ) . clickMenuItem ( 'About' ) ;
45+ const aboutDialog = new TheiaAboutDialog ( app ) ;
46+ expect ( await aboutDialog . isVisible ( ) ) . toBe ( true ) ;
47+ await aboutDialog . page . getByRole ( 'button' , { name : 'OK' } ) . click ( ) ;
48+ expect ( await aboutDialog . isVisible ( ) ) . toBe ( false ) ;
49+ } ) ;
3150
32- await quickCommand . open ( ) ;
33- expect ( await quickCommand . isOpen ( ) ) . toBe ( true ) ;
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+ const menuEntry = 'Open File...' ;
61+
62+ await ( await app . menuBar . openMenu ( 'File' ) ) . clickMenuItem ( menuEntry ) ;
63+
64+ const fileDialog = await app . page . waitForSelector ( 'div[class="dialogBlock"]' ) ;
65+ expect ( await fileDialog . isVisible ( ) ) . toBe ( true ) ;
66+
67+ const fileEntry = app . page . getByText ( 'sample.txt' ) ;
68+ await fileEntry . click ( ) ;
69+ await app . page . getByRole ( 'button' , { name : 'Open' } ) . click ( ) ;
3470
71+ const span = await app . page . waitForSelector ( 'span:has-text("content line 2")' ) ;
72+ expect ( await span . isVisible ( ) ) . toBe ( true ) ;
73+ } ) ;
74+
75+ test ( 'open about dialog using command' , async ( ) => {
76+ const quickCommand = app . quickCommandPalette ;
3577 await quickCommand . open ( ) ;
3678 await quickCommand . type ( 'About' ) ;
3779 await quickCommand . trigger ( 'About' ) ;
38- expect ( await quickCommand . isOpen ( ) ) . toBe ( false ) ;
3980 const aboutDialog = new TheiaAboutDialog ( app ) ;
4081 expect ( await aboutDialog . isVisible ( ) ) . toBe ( true ) ;
41- await aboutDialog . close ( ) ;
82+ await aboutDialog . page . getByRole ( 'button' , { name : 'OK' } ) . click ( ) ;
4283 expect ( await aboutDialog . isVisible ( ) ) . toBe ( false ) ;
84+ } ) ;
4385
86+ test ( 'select all using command' , async ( ) => {
87+ const quickCommand = app . quickCommandPalette ;
4488 await quickCommand . type ( 'Select All' ) ;
4589 await quickCommand . trigger ( 'Select All' ) ;
4690 expect ( await quickCommand . isOpen ( ) ) . toBe ( false ) ;
91+ } ) ;
4792
93+ test ( 'toggle explorer view using command' , async ( ) => {
94+ const quickCommand = app . quickCommandPalette ;
4895 await quickCommand . open ( ) ;
4996 await quickCommand . type ( 'Toggle Explorer' ) ;
5097 await quickCommand . trigger ( 'Toggle Explorer View' ) ;
51- expect ( await quickCommand . isOpen ( ) ) . toBe ( false ) ;
5298 const explorerView = new TheiaExplorerView ( app ) ;
5399 expect ( await explorerView . isDisplayed ( ) ) . toBe ( true ) ;
100+ await quickCommand . open ( ) ;
101+ await quickCommand . type ( 'Toggle Explorer' ) ;
102+ await quickCommand . trigger ( 'Toggle Explorer View' ) ;
103+ expect ( await explorerView . isDisplayed ( ) ) . toBe ( false ) ;
54104 } ) ;
55105
106+ test ( 'toggle explorer view using menu' , async ( ) => {
107+ await ( await app . menuBar . openMenu ( 'View' ) ) . clickMenuItem ( 'Explorer' ) ;
108+ const explorerView = new TheiaExplorerView ( app ) ;
109+ expect ( await explorerView . isDisplayed ( ) ) . toBe ( true ) ;
110+ await ( await app . menuBar . openMenu ( 'View' ) ) . clickMenuItem ( 'Explorer' ) ;
111+ expect ( await explorerView . isDisplayed ( ) ) . toBe ( false ) ;
112+ } ) ;
56113} ) ;
114+
0 commit comments