@@ -3,7 +3,7 @@ import electronPath from 'electron'; // Require Electron from the binaries inclu
3
3
import path from 'path' ;
4
4
import fse from 'fs-extra' ;
5
5
import extract from 'extract-zip' ;
6
- import { buildSignedInUserForDatabase } from './utils' ;
6
+ import { buildSignedInUserForDatabase , prepareSpaceForApi } from './utils' ;
7
7
8
8
const getFormattedTime = ( ) => {
9
9
const today = new Date ( ) ;
@@ -71,6 +71,7 @@ const createApplication = async ({
71
71
showOpenDialogResponse : undefined ,
72
72
showTours : 0 ,
73
73
} ,
74
+ api = [ ] ,
74
75
} = { } ) => {
75
76
const {
76
77
showMessageDialogResponse,
@@ -92,9 +93,21 @@ const createApplication = async ({
92
93
env . SHOW_OPEN_DIALOG_RESPONSE = showOpenDialogResponse ;
93
94
}
94
95
96
+ // mock spaces fetch using the api
97
+ // when not defined, provide default api database
98
+ env . API_DATABASE = JSON . stringify (
99
+ api . map ( ( space ) => prepareSpaceForApi ( space ) )
100
+ ) ;
101
+
95
102
// set up database
96
103
const tmpDatabasePath = await setUpDatabase ( database ) ;
97
104
105
+ // locally use the public electron application
106
+ // for CI use the build application
107
+ const applicationPath = process . env . CI
108
+ ? path . join ( __dirname , '../build/electron.js' )
109
+ : path . join ( __dirname , '../public/electron.js' ) ;
110
+
98
111
const app = new Application ( {
99
112
// Your electron path can be any binary
100
113
// i.e for OSX an example path could be '/Applications/MyApp.app/Contents/MacOS/MyApp'
@@ -114,7 +127,7 @@ const createApplication = async ({
114
127
115
128
// The following line tells spectron to look and use the main.js file
116
129
// and the package.json located 1 level above.
117
- args : [ path . join ( __dirname , '../public/electron.js' ) ] ,
130
+ args : [ applicationPath ] ,
118
131
// use a specific application folder and var folder to save data
119
132
chromeDriverArgs : [ `--user-data-dir=${ tmpDatabasePath } ` ] ,
120
133
env,
0 commit comments