-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Config of End-to-End & Search window e2e test code (#164)
* Refactor about constant of path * Config default setting information * Edit unit test config and repair unit test code * Fix title about page html * E2E configure using spectron with jest * Attach ipc handler to use e2e test Spectron doesn't support controll of electron window. So To use end to end test, Attach ipc handler on test environment. * Add E2E support module * Add window manager to control electron window on e2e environment * Add test manager to use convenience * Initial e2e code for search window * E2E test main feature of list on search window * E2E test feature of menu on search window * Fix unit-test snapshot code
- Loading branch information
Showing
34 changed files
with
950 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import { app, remote } from 'electron'; | ||
import path from 'path'; | ||
|
||
const BASIC_PATH = (app || remote.app).getPath('appData'); | ||
const TEMP_DIR = process.platform === 'win32' ? 'C:\\Windows\\Temp' : '/tmp'; | ||
const IS_TEST = process.env.NODE_ENV === 'test'; | ||
const SETTING_FILE = 'store.json'; | ||
|
||
export const SETTING_FILE_PATH = !IS_TEST ? | ||
path.join(BASIC_PATH, 'oh-my-desk', SETTING_FILE) : | ||
path.join(TEMP_DIR, SETTING_FILE); | ||
|
||
const ROOT_PATH = path.resolve(__dirname, '..'); | ||
|
||
function getPagePath(target) { | ||
const ENV = process.env.NODE_ENV; | ||
const MIDDLE_PATH = ENV === 'development' ? | ||
path.join('app', 'renderer', 'pages', target) : | ||
path.join('build'); | ||
|
||
return `file://${path.join(ROOT_PATH, MIDDLE_PATH, `${target}.html`)}`; | ||
} | ||
export const WIDGET_PATH = getPagePath('widget'); | ||
export const PREFERENCE_PATH = getPagePath('preference'); | ||
export const SEARCH_PATH = getPagePath('search'); | ||
export const UPDATE_WINDOW_PATH = getPagePath('UpdateWindow'); | ||
export const UPDATE_PROGRESS_PATH = getPagePath('UpdateProgress'); | ||
|
||
export const TRAY_ICON_PATH = path.join(ROOT_PATH, 'app', 'assets', 'iconTemplate.png'); | ||
export const LOGO_ICON_PATH = path.join(ROOT_PATH, 'app', 'assets', 'oh-my-desk-icon.png'); | ||
|
||
export const DEFAULT_SETTING = { | ||
identification: { | ||
widgetInfoById: { | ||
'fb07e56a-2ef3-4c3f-b7d4-3680a7173dd2': { | ||
size: { | ||
height: 787, | ||
width: 750, | ||
}, | ||
isEditProgress: false, | ||
isMakeProgress: false, | ||
position: { | ||
x: 360, | ||
y: 83, | ||
}, | ||
createTime: '2018-11-13T04:10:58.640Z', | ||
name: 'google', | ||
isOnTop: false, | ||
url: 'https://www.google.com/', | ||
isOpen: true, | ||
favorites: true, | ||
userAgent: 'DESKTOP', | ||
resentFocusTime: '2018-11-26T11:32:48.186Z', | ||
id: 'fb07e56a-2ef3-4c3f-b7d4-3680a7173dd2', | ||
reloadInterval: 5, | ||
}, | ||
'e8581480-cd58-458a-a268-f9869fa5fcfc': { | ||
size: { | ||
height: 777, | ||
width: 821, | ||
}, | ||
isEditProgress: false, | ||
isMakeProgress: false, | ||
position: { | ||
x: 575, | ||
y: 115, | ||
}, | ||
createTime: '2018-11-13T11:32:08.049Z', | ||
name: 'trello', | ||
isOnTop: false, | ||
url: 'https://trello.com', | ||
isOpen: false, | ||
favorites: false, | ||
userAgent: 'DESKTOP', | ||
resentFocusTime: '2018-11-25T16:33:47.625Z', | ||
id: 'e8581480-cd58-458a-a268-f9869fa5fcfc', | ||
}, | ||
'd5db9663-4879-47ca-ab63-10cf74de2967': { | ||
size: { | ||
height: 600, | ||
width: 500, | ||
}, | ||
isEditProgress: false, | ||
isMakeProgress: false, | ||
position: { | ||
x: 600, | ||
y: 99, | ||
}, | ||
createTime: '2018-11-25T16:34:16.673Z', | ||
name: 'translator', | ||
isOnTop: false, | ||
url: 'https://translate.google.com/', | ||
isOpen: false, | ||
favorites: false, | ||
userAgent: 'DESKTOP', | ||
resentFocusTime: '2018-11-25T16:34:17.266Z', | ||
id: 'd5db9663-4879-47ca-ab63-10cf74de2967', | ||
}, | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,8 @@ | ||
import { app, remote } from 'electron'; | ||
import path from 'path'; | ||
|
||
/** | ||
* Path for globally. | ||
*/ | ||
export const CONFIG_PATH = (app || remote.app).getPath('appData'); | ||
export const SETTING_FILE_NAME = '/oh-my-desk/store.json'; | ||
|
||
/** | ||
* Path for main process. | ||
*/ | ||
|
||
function getPagePath(target) { | ||
const rootPath = process.env.NODE_ENV === 'development' ? | ||
path.resolve(__dirname, '../../..') : path.resolve(__dirname, '..'); | ||
const projectPath = process.env.NODE_ENV === 'development' ? `app/renderer/pages/${target}` : 'build'; | ||
const htmlPath = `${target}.html`; | ||
|
||
return path.join(rootPath, projectPath, htmlPath); | ||
} | ||
|
||
export const WIDGET_PATH = getPagePath('widget'); | ||
export const PREFERENCE_PATH = getPagePath('preference'); | ||
export const SEARCH_PATH = getPagePath('search'); | ||
export const UPDATE_WINDOW_PATH = getPagePath('UpdateWindow'); | ||
export const UPDATE_PROGRESS_PATH = getPagePath('UpdateProgress'); | ||
|
||
function getAssetPath(image) { | ||
const rootPath = process.env.NODE_ENV === 'development' ? | ||
path.resolve(__dirname, '../../..') : path.resolve(__dirname, '..'); | ||
const assetPath = 'app/assets'; | ||
|
||
return path.join(rootPath, assetPath, `${image}.png`); | ||
} | ||
|
||
export const TRAY_ICON_PATH = getAssetPath('iconTemplate'); | ||
export const LOGO_ICON_PATH = getAssetPath('oh-my-desk-icon'); | ||
|
||
/** | ||
* Path for renderer process. | ||
*/ | ||
const ROOT_PATH = process.env.NODE_ENV === 'development' ? // TODO find better method to get root path. | ||
path.resolve(__dirname, '../../../..') : path.resolve(__dirname, '..'); | ||
export const PRELOAD_SCRIPT_PATH = path.join(ROOT_PATH, 'build/preloadScript.js'); | ||
export const PRELOAD_SCRIPT_PATH = path.join(ROOT_PATH, 'build/preloadScript.js'); // eslint-disable-line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { ipcMain } from 'electron'; | ||
import TrayMenuBar from 'main/utils/menu/trayMenuBar'; | ||
|
||
function e2eIpcHandler() { | ||
ipcMain.on('search.window.open', () => { | ||
TrayMenuBar.showWindow(); | ||
}); | ||
|
||
ipcMain.on('search.window.close', () => { | ||
TrayMenuBar.hideWindow(); | ||
}); | ||
} | ||
|
||
export default e2eIpcHandler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import fs from 'fs'; | ||
import * as PATH from 'constants/path'; | ||
import { SETTING_FILE_PATH } from 'config'; | ||
import store from 'store/storeMain'; | ||
|
||
const saveData = () => { | ||
const data = store.getState().get('share'); | ||
|
||
fs.writeFileSync(`${PATH.CONFIG_PATH}/${PATH.SETTING_FILE_NAME}`, JSON.stringify(data.toJS())); | ||
fs.writeFileSync(SETTING_FILE_PATH, JSON.stringify(data.toJS())); | ||
}; | ||
|
||
export default saveData; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.