Electron-308 - Fixed and updated the Spectron test cases

This commit is contained in:
Kiran Niranjan 2018-02-19 10:57:15 +05:30 committed by kiranniranjan
parent f23ed615a7
commit de4b00c21f
4 changed files with 42 additions and 16 deletions

View File

@ -136,7 +136,7 @@ describe('Tests for Always on top', () => {
robot.setMouseDelay(200);
robot.moveMouse(190, 0);
robot.mouseClick();
for (let i = 0; i < 8; i++) {
for (let i = 0; i < 10; i++) {
robot.keyTap('down');
}
robot.keyTap('enter');

View File

@ -108,7 +108,7 @@ describe('Tests for Full screen', () => {
robot.moveMouseSmooth(205, 10);
robot.mouseClick();
robot.setKeyboardDelay(100);
for (let i = 0; i < 6; i++) {
for (let i = 0; i < 8; i++) {
robot.keyTap('down');
}
robot.keyTap('enter');

View File

@ -16,6 +16,7 @@ class App {
}
App.copyConfigPath();
App.copyLibraryDir();
this.app = new Application(this.options);
}
@ -40,27 +41,52 @@ class App {
}
static readConfig(configPath) {
return new Promise(function (resolve, reject) {
fs.readFile(configPath, function (err, data) {
if (err) {
reject(err);
}
resolve(JSON.parse(data));
if (!fs.existsSync(configPath)) {
return this.copyConfigPath();
} else {
return new Promise(function (resolve) {
fs.readFile(configPath, 'utf-8', function (err, data) {
if (err) {
throw new Error("Unable to read user config file " + err);
}
resolve(JSON.parse(data));
});
});
});
}
}
static copyConfigPath() {
return new Promise((resolve) => {
if (isMac) {
ncp('config', 'node_modules/electron/dist/Electron.app/Contents/config', function (err) {
if (err) {
throw new Error("Unable to copy config file to Electron dir " + err);
}
resolve();
});
} else {
ncp('config', 'node_modules/electron/dist/config', function (err) {
if (err) {
throw new Error("Unable to copy config file to Electron dir " + err);
}
resolve();
});
}
})
}
static copyLibraryDir() {
if (isMac) {
ncp('config', 'node_modules/electron/dist/Electron.app/Contents/config', function (err) {
ncp('library', 'node_modules/electron/dist/Electron.app/Contents/library', function (err) {
if (err) {
throw(err);
throw new Error("Unable to copy Swift search library dir " + err);
}
});
} else {
ncp('config', 'node_modules/electron/dist/config', function (err) {
ncp('library', 'node_modules/electron/dist/library', function (err) {
if (err) {
throw(err);
throw new Error("Unable to copy Swift search library dir " + err);
}
});
}

View File

@ -79,8 +79,8 @@ describe('Tests for spellChecker', () => {
it('should invoke context menu ', (done) => {
if (isMac) {
app.browserWindow.getBounds().then((bounds) => {
let x = bounds.x + 45;
let y = bounds.y + 398;
let x = bounds.x + 55;
let y = bounds.y + 430;
robot.moveMouseSmooth(x, y);
robot.setMouseDelay(200);
@ -114,7 +114,7 @@ describe('Tests for spellChecker', () => {
return app.client
.windowByIndex(0)
.getValue('#tag').then((value) => {
expect(value).toBe('coming ');
expect(value !== 'comming').toBeTruthy();
});
});