SDA-3876 - Remove spectron related code (#1510)

This commit is contained in:
Kiran Niranjan 2022-09-27 07:13:27 +05:30 committed by GitHub
parent 64995f3b1f
commit 526b937193
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 22 additions and 7588 deletions

View File

@ -1,38 +0,0 @@
env:
global:
- ELECTRON_QA="true"
- npm config set package-lock false
os:
- osx
compiler:
- gcc
language: node_js
node_js:
- '12.13.0'
addons:
chrome: stable
apt:
packages:
- xvfb
before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi
install:
- export DISPLAY=':99.0'
- Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
- npm install
script:
- node --version
- npm --version
- npm run test
cache:
directories:
- node_modules

View File

@ -1,24 +0,0 @@
build: off
os: unstable
platform:
- x86
- x64
skip_tags: false
environment:
nodejs_version: "12"
cache:
- node_modules -> package.json
install:
- ps: Install-Product node $env:nodejs_version
- npm install
test_script:
- node --version
- npm --version
- npm run test

View File

@ -56,13 +56,6 @@ npm run test:unit
# Specific Unit tests
npm run test:unit -- --match=spell*
# Spectron tests only
npm run compile:spec
npm run test:spectron
# Specific Spectron tests
npm run test:spectron -- --match=spell*
```
### Code Coverage

6901
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -32,10 +32,6 @@
"start": "run-s compile browserify && cross-env ELECTRON_DEV=true electron .",
"test": "run-s lint test:unit",
"test:unit": "cross-env ELECTRON_QA=true jest --config jest-config.json --runInBand --detectOpenHandles",
"test:spectron": "npm run copy && run-s lint compile browserify && cross-env ELECTRON_QA=true npx ava --verbose --serial",
"copy": "run-os",
"copy:darwin": "ncp config 'node_modules/electron/dist/Electron.app/Contents/config'",
"copy:win32": "ncp config node_modules\\electron\\dist\\config",
"unpacked-mac": "npm run prebuild && npm run test && ./node_modules/.bin/electron-builder build --mac",
"unpacked-win": "npm run prebuild && npm run test && node_modules\\.bin\\electron-builder build --win --x64"
},
@ -171,7 +167,6 @@
"@types/react": "16.8.3",
"@types/react-dom": "16.0.9",
"@types/rimraf": "^3.0.0",
"ava": "2.4.0",
"browserify": "16.5.1",
"builder-util-runtime": "^9.0.3",
"cross-env": "5.2.0",
@ -198,9 +193,7 @@
"npm-run-all": "4.1.5",
"prettier": "2.2.1",
"pretty-quick": "^3.1.0",
"robotjs": "0.6.0",
"run-script-os": "^1.1.6",
"spectron": "^15.0.0",
"ts-jest": "25.3.0",
"tslint": "5.11.0",
"tslint-config-prettier": "^1.18.0",

View File

@ -1,57 +0,0 @@
import test from 'ava';
import * as robot from 'robotjs';
import { Application } from 'spectron';
import { robotActions } from './fixtures/robot-actions';
import {
loadURL,
podUrl,
sleep,
startApplication,
stopApplication,
Timeouts,
} from './fixtures/spectron-setup';
let app;
test.before(async (t) => {
app = (await startApplication()) as Application;
t.true(app.isRunning());
await loadURL(app, podUrl);
await app.client.waitUntilWindowLoaded(Timeouts.fiveSec);
await sleep(Timeouts.fiveSec);
});
test.after.always(async () => {
await stopApplication(app);
});
test('about-app: verify about application feature', async (t) => {
robotActions.clickAppMenu();
robot.keyTap('down');
robot.keyTap('enter');
// wait for about window to load
await sleep(Timeouts.halfSec);
await app.client.windowByIndex(1);
await app.client.waitUntilWindowLoaded(Timeouts.fiveSec);
t.truthy(await app.browserWindow.getTitle(), 'About Symphony');
});
test('about-app: verify copy button with few data validation', async (t) => {
await sleep(Timeouts.oneSec);
await app.client.click('.AboutApp-copy-button');
const clipboard = JSON.parse(
await app.client.electron.remote.clipboard.readText(),
);
t.log(clipboard);
t.true(clipboard.hasOwnProperty('appName'));
t.true(clipboard.hasOwnProperty('clientVersion'));
t.true(clipboard.hasOwnProperty('sfeVersion'));
t.true(clipboard.hasOwnProperty('sfeClientType'));
t.true(clipboard.hasOwnProperty('sdaVersion'));
t.true(clipboard.hasOwnProperty('sdaBuildNumber'));
robotActions.closeWindow();
});

View File

@ -1,74 +0,0 @@
import * as robot from 'robotjs';
import { isMac } from '../../src/common/env';
import { Timeouts } from './spectron-setup';
class RobotActions {
constructor() {
robot.setKeyboardDelay(Timeouts.oneSec);
robot.setMouseDelay(Timeouts.oneSec);
}
/**
* Closes window via keyboard action
*/
public closeWindow(): void {
const modifier = isMac ? ['command'] : ['control'];
robot.keyToggle('w', 'down', modifier);
robot.keyToggle('w', 'up', modifier);
}
/**
* Makes the application fullscreen via keyboard
*/
public toggleFullscreen(): void {
robot.keyToggle('f', 'down', ['command', 'control']);
robot.keyToggle('f', 'up', ['command', 'control']);
}
/**
* Zoom in via keyboard Command/Ctrl +
*/
public zoomIn(): void {
const modifier = isMac ? ['command'] : ['control'];
robot.keyToggle('+', 'down', modifier);
robot.keyToggle('+', 'up', modifier);
}
/**
* Zoom out via keyboard
*/
public zoomOut(): void {
const modifier = isMac ? ['command'] : ['control'];
robot.keyToggle('-', 'down', modifier);
robot.keyToggle('-', 'up', modifier);
}
/**
* Zoom reset via keyboard
*/
public zoomReset(): void {
const modifier = isMac ? ['command'] : ['control'];
robot.keyToggle('0', 'down', modifier);
robot.keyToggle('0', 'up', modifier);
}
/**
* Click the App menu
*/
public clickAppMenu(point?: Electron.Point): void {
if (isMac) {
robot.moveMouse(83, 14);
robot.mouseClick();
} else {
if (!point) {
throw new Error('browser window points are required');
}
robot.moveMouse(point.x + 10, point.y + 14);
robot.mouseClick();
}
}
}
const robotActions = new RobotActions();
export { robotActions };

View File

@ -1,116 +0,0 @@
import * as path from 'path';
import { Application, BasicAppSettings } from 'spectron';
export const podUrl = 'https://corporate.symphony.com';
export enum Timeouts {
halfSec = 500,
oneSec = 1000,
threeSec = 3000,
fiveSec = 5000,
tenSec = 10000,
}
/**
* Returns the electron executable path
*/
export const getElectronPath = (): string => {
let electronPath = path.join(
__dirname,
'..',
'..',
'..',
'node_modules',
'.bin',
'electron',
);
if (process.platform === 'win32') {
electronPath += '.cmd';
}
return electronPath;
};
/**
* Returns the demo application html path
*/
export const getDemoFilePath = (): string => {
return `file://${path.join(
__dirname,
'..',
'..',
'..',
'/src/demo/index.html',
)}`;
};
/**
* Returns app init file
*/
export const getArgs = (): string[] => {
return [path.join(__dirname, '..', '..', '/src/app/init.js')];
};
/**
* Stops the application
* @param application
*/
export const stopApplication = async (
application,
): Promise<Application | undefined> => {
if (!application || !application.isRunning()) {
return;
}
await application.stop();
return;
};
/**
* Starts and returns the application instance
* @param shouldLoadDemoApp {Boolean}
* @param options {BasicAppSettings}
*/
export const startApplication = async (
shouldLoadDemoApp: boolean = false,
options: BasicAppSettings = {
path: getElectronPath(),
args: getArgs(),
},
): Promise<Application> => {
// loads demo page correctly
if (shouldLoadDemoApp && options.args) {
options.args.push(`. --url=file://${getDemoFilePath()}`);
}
const application = new Application(options);
await application.start();
return application;
};
/**
* Sleep function for tests that needs to wait
* @param ms
*/
export const sleep = (ms) => {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
};
/**
* Loads the url with try catch due to an issue in Spectron frame work
* https://github.com/electron-userland/spectron/issues/493
* @param app
* @param url
*/
export const loadURL = async (app: Application, url: string): Promise<void> => {
try {
return await app.browserWindow.loadURL(url);
} catch (error) {
const errorIsNavigatedError: boolean = error.message.includes(
'Inspected target navigated or closed',
);
if (!errorIsNavigatedError) {
throw error;
}
}
};

View File

@ -1,35 +0,0 @@
import test from 'ava';
import * as robot from 'robotjs';
import { Application } from 'spectron';
import { robotActions } from './fixtures/robot-actions';
import {
getDemoFilePath,
loadURL,
sleep,
startApplication,
stopApplication,
Timeouts,
} from './fixtures/spectron-setup';
let app;
test.before(async (t) => {
app = (await startApplication()) as Application;
t.true(app.isRunning());
});
test.after.always(async () => {
await stopApplication(app);
});
test('fullscreen: verify application full screen feature', async (t) => {
await loadURL(app, getDemoFilePath());
await app.client.waitUntilWindowLoaded(Timeouts.fiveSec);
robotActions.toggleFullscreen();
t.true(await app.browserWindow.isFullScreen());
await sleep(Timeouts.halfSec);
robot.keyTap('escape');
t.false(await app.browserWindow.isFullScreen());
});

View File

@ -1,34 +0,0 @@
import test from 'ava';
import { Application } from 'spectron';
import { robotActions } from './fixtures/robot-actions';
import { startApplication, stopApplication } from './fixtures/spectron-setup';
let app;
test.before(async (t) => {
app = (await startApplication()) as Application;
t.true(app.isRunning());
});
test.after.always(async () => {
await stopApplication(app);
});
test('minimize: verify application minimize / maximize feature', async (t) => {
const win = app.browserWindow;
win.minimize();
t.true(await win.isMinimized());
win.restore();
t.true(await win.isVisible());
});
test('minimize: verify application to be minimized with keyboard accelerator', async (t) => {
const win = app.browserWindow;
robotActions.closeWindow();
t.false(await win.isVisible());
win.restore();
t.true(await win.isVisible());
});

View File

@ -1,54 +0,0 @@
import test from 'ava';
import { Application } from 'spectron';
import {
getDemoFilePath,
loadURL,
sleep,
startApplication,
stopApplication,
Timeouts,
} from './fixtures/spectron-setup';
let app;
test.before(async (t) => {
app = (await startApplication(true)) as Application;
t.true(app.isRunning());
});
test.after.always(async () => {
await stopApplication(app);
});
test('Verify is the application is running', async (t) => {
t.true(app.isRunning());
});
test('Verify notification window is created', async (t) => {
await loadURL(app, getDemoFilePath());
await app.client.waitUntilWindowLoaded(Timeouts.fiveSec);
await app.client.click('#notf');
await sleep(Timeouts.oneSec);
t.timeout(10000);
t.is(await app.client.getWindowCount(), 2);
await app.client.windowByIndex(1);
await app.client.click('.close');
await sleep(2000);
await app.client.windowByIndex(0);
});
test('Verify notification window is hidden', async (t) => {
await app.client.click('#notf');
await sleep(Timeouts.oneSec);
t.timeout(Timeouts.fiveSec);
await app.client.windowByIndex(1);
await app.client.click('.close');
await sleep(2000);
await app.client.windowByIndex(0);
t.is(await app.client.getWindowCount(), 2);
});

View File

@ -1,57 +0,0 @@
import test from 'ava';
import * as robot from 'robotjs';
import { Application } from 'spectron';
import {
getDemoFilePath,
loadURL,
sleep,
startApplication,
stopApplication,
Timeouts,
} from './fixtures/spectron-setup';
let app;
export const openScreenPicker = async (window) => {
if (!window) {
throw new Error('openScreenPicker: must be called with Application');
}
await window.client.scroll(125, 1000);
await sleep(Timeouts.halfSec);
await window.client.click('#get-sources');
await window.client.waitUntilWindowLoaded(Timeouts.fiveSec);
};
test.before(async (t) => {
app = (await startApplication()) as Application;
t.true(app.isRunning());
});
test.after.always(async () => {
await stopApplication(app);
});
test('screen-picker: verify screen-picker close button', async (t) => {
await loadURL(app, getDemoFilePath());
await app.client.waitUntilWindowLoaded(Timeouts.fiveSec);
await openScreenPicker(app);
await sleep(Timeouts.halfSec);
t.is(await app.client.getWindowCount(), 2);
await app.client.windowByIndex(1);
await app.client.click('.ScreenPicker-x-button');
await sleep(Timeouts.halfSec);
t.is(await app.client.getWindowCount(), 1);
});
test('screen-picker: verify screen-picker escape keyboard actions', async (t) => {
await app.client.windowByIndex(0);
await openScreenPicker(app);
await sleep(Timeouts.halfSec);
t.is(await app.client.getWindowCount(), 2);
robot.keyTap('escape');
await sleep(Timeouts.halfSec);
t.is(await app.client.getWindowCount(), 1);
});

View File

@ -1,69 +0,0 @@
import test from 'ava';
import * as robot from 'robotjs';
import { Application } from 'spectron';
import {
getDemoFilePath,
loadURL,
sleep,
startApplication,
stopApplication,
Timeouts,
} from './fixtures/spectron-setup';
let app;
export const openScreenPicker = async (window) => {
if (!window) {
throw new Error('openScreenPicker: must be called with Application');
}
await window.client.scroll(125, 1000);
await sleep(Timeouts.halfSec);
await window.client.click('#get-sources');
await window.client.waitUntilWindowLoaded(Timeouts.fiveSec);
};
test.before(async (t) => {
app = (await startApplication()) as Application;
t.true(app.isRunning());
});
test.after.always(async () => {
await stopApplication(app);
});
test('screen-sharing-indicator: verify screen sharing indicator with frame is shown', async (t) => {
await loadURL(app, getDemoFilePath());
await app.client.waitUntilWindowLoaded(Timeouts.fiveSec);
await openScreenPicker(app);
robot.setKeyboardDelay(2000);
await sleep(Timeouts.halfSec);
t.is(await app.client.getWindowCount(), 2);
await app.client.windowByIndex(1);
// will select the entire screen option in the picker
robot.keyTap('right');
robot.keyTap('left');
robot.keyTap('enter');
await sleep(2000);
t.is(await app.client.getWindowCount(), 2);
});
test('screen-sharing-indicator: verify screen sharing indicator title', async (t) => {
// including the screen sharing frame
await app.client.windowByIndex(1);
await app.client.waitUntilWindowLoaded(Timeouts.fiveSec);
const indicatorTitle = await app.browserWindow.getTitle();
if (indicatorTitle !== 'Screen Sharing Indicator - Symphony') {
await app.client.windowByIndex(1);
}
await app.client.click('.stop-sharing-button');
await app.client.windowByIndex(0);
await sleep(Timeouts.halfSec);
// verify both frame and indicator are closed
// when stop button is clicked
t.is(await app.client.getWindowCount(), 1);
});

View File

@ -1,43 +0,0 @@
import test from 'ava';
import * as robot from 'robotjs';
import { Application } from 'spectron';
import {
getDemoFilePath,
loadURL,
startApplication,
stopApplication,
Timeouts,
} from './fixtures/spectron-setup';
let app;
test.before(async (t) => {
app = (await startApplication()) as Application;
t.true(app.isRunning());
});
test.after.always(async () => {
await stopApplication(app);
});
test('spell-checker: verify application spell checking feature', async (t) => {
robot.setKeyboardDelay(Timeouts.oneSec);
const missSpelledWord = 'teest ';
await loadURL(app, getDemoFilePath());
await app.client.waitUntilWindowLoaded(Timeouts.fiveSec);
await app.client.electron.remote.clipboard.writeText(missSpelledWord);
await app.client.click('#tag');
await app.client.webContents.paste();
await app.client.waitForValue('#tag', Timeouts.fiveSec);
t.is(await app.client.getValue('#tag'), missSpelledWord);
await app.client.rightClick('#tag', 10, 10);
robot.keyTap('down');
robot.keyTap('enter');
t.not(await app.client.getValue('#tag'), missSpelledWord);
});

View File

@ -1,43 +0,0 @@
import test from 'ava';
import { Application } from 'spectron';
import { robotActions } from './fixtures/robot-actions';
import {
getDemoFilePath,
loadURL,
sleep,
startApplication,
stopApplication,
Timeouts,
} from './fixtures/spectron-setup';
let app;
test.before(async (t) => {
app = (await startApplication()) as Application;
t.true(app.isRunning());
});
test.after.always(async () => {
await stopApplication(app);
});
test('zoom: verify application zoom feature', async (t) => {
await loadURL(app, getDemoFilePath());
await app.client.waitUntilWindowLoaded(Timeouts.fiveSec);
robotActions.zoomIn();
t.is(await app.webContents.getZoomLevel(), 0.5);
await sleep(Timeouts.oneSec);
robotActions.zoomIn();
t.is(await app.webContents.getZoomLevel(), 1);
await sleep(Timeouts.oneSec);
robotActions.zoomOut();
t.is(await app.webContents.getZoomLevel(), 0.5);
await sleep(Timeouts.oneSec);
robotActions.zoomReset();
t.is(await app.webContents.getZoomLevel(), 0);
});

View File

@ -244,9 +244,6 @@ export class AppBridge {
response: mediaPermission,
});
break;
// case apiCmds.autoUpdate:
// ssf.autoUpdate(data.filename);
// break;
}
}

View File

@ -1,38 +0,0 @@
env:
global:
- ELECTRON_QA="true"
- npm config set package-lock false
os:
- osx
compiler:
- gcc
language: node_js
node_js:
- '12.13.0'
addons:
chrome: stable
apt:
packages:
- xvfb
before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi
install:
- export DISPLAY=':99.0'
- Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
- npm install
script:
- node --version
- npm --version
- npm run test:spectron
cache:
directories:
- node_modules

View File

@ -3,12 +3,6 @@
"compilerOptions": {
"outDir": "lib"
},
"include": [
"spectron/**/*"
],
"exclude": [
"node_modules/**",
"src",
"spec"
]
"include": [],
"exclude": ["node_modules/**", "src", "spec"]
}