From 37e6e6d003feb6f5c8e1aef10d686ce1f8fc90bc Mon Sep 17 00:00:00 2001 From: Arne Date: Thu, 28 Sep 2023 15:33:05 +0200 Subject: [PATCH] Latest --- .dist/electron-app/main/components/app.js | 82 +- .dist/electron-app/main/components/window.js | 253 +++--- .../main/components/window.js.map | 2 +- .dist/electron-app/main/index.js | 8 +- .../main/services/abstract-service.js | 20 +- .../main/services/door-service.js | 65 ++ .../main/services/door-service.js.map | 1 + .../main/services/file-list-service.js | 66 +- .../main/services/file-list-service.js.map | 2 +- .../main/services/print-service.js | 22 + .../main/services/print-service.js.map | 1 + .dist/electron-app/main/utils/logger.js | 222 +++--- .dist/electron-app/renderer/index.js | 6 +- .dist/electron-app/renderer/preload.js | 28 +- .dist/electron-e2e/app.spec.js | 70 +- .dist/electron-e2e/multiples.spec.js | 76 +- .../pageobjects/multiples.page.js | 92 +-- .dist/electron-e2e/pageobjects/page.js | 5 +- .dist/electron-e2e/webdriverio.config.js | 740 +++++++++--------- .../main/services/door-service.ts | 38 +- 20 files changed, 901 insertions(+), 898 deletions(-) create mode 100644 .dist/electron-app/main/services/door-service.js create mode 100644 .dist/electron-app/main/services/door-service.js.map create mode 100644 .dist/electron-app/main/services/print-service.js create mode 100644 .dist/electron-app/main/services/print-service.js.map diff --git a/.dist/electron-app/main/components/app.js b/.dist/electron-app/main/components/app.js index 89c8d86..6452ad7 100644 --- a/.dist/electron-app/main/components/app.js +++ b/.dist/electron-app/main/components/app.js @@ -1,48 +1,46 @@ import { app, shell } from 'electron'; import { Window } from './window'; export class App { - static launch() { - app.on('window-all-closed', App.quit); - app.on('activate', App.start); - app.on('ready', App.start); - // Limit navigation and open external links in default browser - app.on('web-contents-created', App.openExternalLinksInDefaultBrowser); - } - static get electronWindow() { - return this._wrapper ? this._wrapper.electronWindow : undefined; - } - static start() { - // On MacOS it is common to re-create a window from app even after all windows have been closed - if (!App.electronWindow) { - App._wrapper = new Window(); - } - } - static quit() { - // On MacOS it is common for applications to stay open until the user explicitly quits - // But WebDriverIO Test Runner does handle that behaviour yet - if ( - process.platform !== 'darwin' || - global.appConfig.configId === 'e2e-test' - ) { - app.quit(); - } - } + static launch() { + app.on('window-all-closed', App.quit); + app.on('activate', App.start); + app.on('ready', App.start); + // Limit navigation and open external links in default browser + app.on('web-contents-created', App.openExternalLinksInDefaultBrowser); + } + static get electronWindow() { + return this._wrapper ? this._wrapper.electronWindow : undefined; + } + static start() { + // On MacOS it is common to re-create a window from app even after all windows have been closed + if (!App.electronWindow) { + App._wrapper = new Window(); + } + } + static quit() { + // On MacOS it is common for applications to stay open until the user explicitly quits + // But WebDriverIO Test Runner does handle that behaviour yet + if (process.platform !== 'darwin' || + global.appConfig.configId === 'e2e-test') { + app.quit(); + } + } } App.openExternalLinksInDefaultBrowser = (event, contents) => { - // Disabling creation of new windows - contents.setWindowOpenHandler((handler) => { - // Telling the user platform to open this event's url in the default browser - shell.openExternal(handler.url); - // Blocking this event from loading in current app - return { action: 'deny' }; - }); - // Limiting navigation - contents.on('will-navigate', (event, navigationUrl) => { - const parsedUrl = new URL(navigationUrl); - // Allowing local navigation only - if (parsedUrl.origin !== 'http://localhost:4200') { - event.preventDefault(); - } - }); + // Disabling creation of new windows + contents.setWindowOpenHandler((handler) => { + // Telling the user platform to open this event's url in the default browser + shell.openExternal(handler.url); + // Blocking this event from loading in current app + return { action: 'deny' }; + }); + // Limiting navigation + contents.on('will-navigate', (event, navigationUrl) => { + const parsedUrl = new URL(navigationUrl); + // Allowing local navigation only + if (parsedUrl.origin !== 'http://localhost:4200') { + event.preventDefault(); + } + }); }; -//# sourceMappingURL=app.js.map +//# sourceMappingURL=app.js.map \ No newline at end of file diff --git a/.dist/electron-app/main/components/window.js b/.dist/electron-app/main/components/window.js index 3b787d0..0a7f88e 100644 --- a/.dist/electron-app/main/components/window.js +++ b/.dist/electron-app/main/components/window.js @@ -1,141 +1,126 @@ -var __awaiter = - (this && this.__awaiter) || - function (thisArg, _arguments, P, generator) { - function adopt(value) { - return value instanceof P - ? value - : new P(function (resolve) { - resolve(value); - }); - } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e) { - reject(e); - } - } - function rejected(value) { - try { - step(generator['throw'](value)); - } catch (e) { - reject(e); - } - } - function step(result) { - result.done - ? resolve(result.value) - : adopt(result.value).then(fulfilled, rejected); - } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); - }; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; import * as remoteMain from '@electron/remote/main'; import { app, BrowserWindow, ipcMain, nativeImage } from 'electron'; import * as path from 'node:path'; import { FileListService } from '../services/file-list-service'; +import { PrintService } from './../services/print-service'; import { Logger } from '../utils/logger'; +import { DoorService } from '../services/door-service'; +import { readFile } from 'node:fs'; export class Window { - constructor() { - this.createWindow(); - this.loadRenderer(); - this.registerService(new FileListService()); - } - createWindow() { - this._electronWindow = new BrowserWindow({ - width: 1280, - height: 720, - backgroundColor: '#FFFFFF', - icon: this.loadIcon(), - webPreferences: { - // Default behavior in Electron since 5, that - // limits the powers granted to remote content - // except in e2e test when those powers are required - nodeIntegration: global.appConfig.isNodeIntegration, - // Isolate window context to protect against prototype pollution - // except in e2e test when that access is required - contextIsolation: global.appConfig.isContextIsolation, - // Introduced in Electron 20 and enabled by default - // Among others security constraints, it prevents from required - // CommonJS modules imports into preload script - // which is not bundled yet in dev mode - sandbox: global.appConfig.isSandbox, - // Use a preload script to enhance security - preload: MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY, - }, - }); - // Disable the remote module to enhance security - // except in e2e test when that access is required - if (global.appConfig.isEnableRemoteModule) { - remoteMain.enable(this._electronWindow.webContents); - } - } - loadIcon() { - let iconObject; - if (global.appConfig.isIconAvailable) { - const iconPath = path.join(__dirname, 'icons/icon.png'); - Logger.debug('Icon Path', iconPath); - iconObject = nativeImage.createFromPath(iconPath); - // Change dock icon on MacOS - if (iconObject && process.platform === 'darwin') { - app.dock.setIcon(iconObject); - } - } - return iconObject; - } - loadRenderer() { - if (global.appConfig.configId === 'development') { - // Dev mode, take advantage of the live reload by loading local URL - this.electronWindow.loadURL(`http://localhost:4200`); - } else { - // Else mode, we simply load angular bundle - const indexPath = path.join( - __dirname, - '../renderer/angular_window/index.html' - ); - this.electronWindow.loadURL(`file://${indexPath}`); - } - if (global.appConfig.isOpenDevTools) { - this.openDevTools(); - } - // When the window is closed` - this._electronWindow.on('closed', () => { - // Remove IPC Main listeners - ipcMain.removeAllListeners(); - // Delete current reference - delete this._electronWindow; - }); - } - openDevTools() { - this._electronWindow.webContents.openDevTools(); - this._electronWindow.webContents.on('devtools-opened', () => { - this._electronWindow.focus(); - setImmediate(() => { - this._electronWindow.focus(); - }); - }); - } - registerService(service) { - ipcMain.on(service.receptionChannel(), (event, ...parameters) => - __awaiter(this, void 0, void 0, function* () { - // Handling input - const input = parameters[0]; - Logger.debug(`[${service.receptionChannel()}] =====> `, input); - const output = service.process(input); - // Handling output - if (service.sendingChannel()) { - Logger.debug(`[${service.sendingChannel()}] =====> `, output); - this._electronWindow.webContents.send( - service.sendingChannel(), - output - ); - } - }) - ); - } - get electronWindow() { - return this._electronWindow; - } + constructor() { + this.createWindow(); + this.loadRenderer(); + const fileListService = new FileListService(); + this.registerService(fileListService); + this.registerService(new DoorService()); + readFile('./config.json', 'utf8', (error, data) => { + if (error) { + console.log(error); + return; + } + const config = JSON.parse(data); + fileListService.setPaths(config.filePaths); + }); + } + createWindow() { + this._electronWindow = new BrowserWindow({ + fullscreen: false, + backgroundColor: '#FFFFFF', + icon: this.loadIcon(), + webPreferences: { + // Default behavior in Electron since 5, that + // limits the powers granted to remote content + // except in e2e test when those powers are required + nodeIntegration: global.appConfig.isNodeIntegration, + // Isolate window context to protect against prototype pollution + // except in e2e test when that access is required + contextIsolation: global.appConfig.isContextIsolation, + // Introduced in Electron 20 and enabled by default + // Among others security constraints, it prevents from required + // CommonJS modules imports into preload script + // which is not bundled yet in dev mode + sandbox: global.appConfig.isSandbox, + // Use a preload script to enhance security + preload: MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY, + }, + }); + this._printService = new PrintService(); + this._printService.setWindow(this._electronWindow); + this.registerService(this._printService); + // Disable the remote module to enhance security + // except in e2e test when that access is required + if (global.appConfig.isEnableRemoteModule) { + remoteMain.enable(this._electronWindow.webContents); + } + } + loadIcon() { + let iconObject; + if (global.appConfig.isIconAvailable) { + const iconPath = path.join(__dirname, 'icons/icon.png'); + Logger.debug('Icon Path', iconPath); + iconObject = nativeImage.createFromPath(iconPath); + // Change dock icon on MacOS + if (iconObject && process.platform === 'darwin') { + app.dock.setIcon(iconObject); + } + } + return iconObject; + } + loadRenderer() { + if (global.appConfig.configId === 'development') { + // Dev mode, take advantage of the live reload by loading local URL + this.electronWindow.loadURL(`http://localhost:4200`); + } + else { + // Else mode, we simply load angular bundle + const indexPath = path.join(__dirname, '../renderer/angular_window/index.html'); + this.electronWindow.loadURL(`file://${indexPath}`); + } + if (global.appConfig.isOpenDevTools) { + this.openDevTools(); + } + // When the window is closed` + this._electronWindow.on('closed', () => { + // Remove IPC Main listeners + ipcMain.removeAllListeners(); + // Delete current reference + delete this._electronWindow; + }); + } + openDevTools() { + this._electronWindow.webContents.openDevTools(); + this._electronWindow.webContents.on('devtools-opened', () => { + this._electronWindow.focus(); + setImmediate(() => { + this._electronWindow.focus(); + }); + }); + } + registerService(service) { + ipcMain.on(service.receptionChannel(), (event, ...parameters) => __awaiter(this, void 0, void 0, function* () { + // Handling input + const input = parameters[0]; + Logger.debug(`[${service.receptionChannel()}] =====> `, input); + service.process(input).then((output) => { + // Handling output + if (service.sendingChannel()) { + Logger.debug(`[${service.sendingChannel()}] =====> `, output); + this._electronWindow.webContents.send(service.sendingChannel(), output); + } + }); + })); + } + get electronWindow() { + return this._electronWindow; + } } -//# sourceMappingURL=window.js.map +//# sourceMappingURL=window.js.map \ No newline at end of file diff --git a/.dist/electron-app/main/components/window.js.map b/.dist/electron-app/main/components/window.js.map index 5d21df8..c9327dc 100644 --- a/.dist/electron-app/main/components/window.js.map +++ b/.dist/electron-app/main/components/window.js.map @@ -1 +1 @@ -{"version":3,"file":"window.js","sourceRoot":"","sources":["../../../../workspaces/electron-app/main/components/window.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACpE,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAKzC,MAAM,OAAO,MAAM;IAGlB;QACC,IAAI,CAAC,YAAY,EAAE,CAAC;QACpB,IAAI,CAAC,YAAY,EAAE,CAAC;QACpB,IAAI,CAAC,eAAe,CAAgC,IAAI,eAAe,EAAE,CAAC,CAAC;IAE5E,CAAC;IAEO,YAAY;QACnB,IAAI,CAAC,eAAe,GAAG,IAAI,aAAa,CAAC;YACxC,KAAK,EAAE,IAAI;YACX,MAAM,EAAE,GAAG;YACX,eAAe,EAAE,SAAS;YAC1B,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE;YACrB,cAAc,EAAE;gBACf,6CAA6C;gBAC7C,8CAA8C;gBAC9C,oDAAoD;gBACpD,eAAe,EAAE,MAAM,CAAC,SAAS,CAAC,iBAAiB;gBACnD,gEAAgE;gBAChE,kDAAkD;gBAClD,gBAAgB,EAAE,MAAM,CAAC,SAAS,CAAC,k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A,CACD,CAAC;IACH,CAAC;IAED,IAAW,cAAc;QACxB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC7B,CAAC;CACD"} \ No newline at end of file +{"version":3,"file":"window.js","sourceRoot":"","sources":["../../../../workspaces/electron-app/main/components/window.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACpE,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAKnC,MAAM,OAAO,MAAM;IAIlB;QACC,IAAI,CAAC,YAAY,EAAE,CAAC;QACpB,IAAI,CAAC,YAAY,EAAE,CAAC;QAElB,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;QAChD,IAAI,CAAC,eAAe,CAAc,eAAe,CAAC,CAAC;QACnD,IAAI,CAAC,eAAe,CAAc,IAAI,WAAW,EAAE,CAAC,CAAC;QAErD,QAAQ,CAAC,eAAe,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YACjD,IAAG,KAAK,EAAC;gBACN,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBACnB,OAAO;aACT;YACD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAChC,eAAe,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAE1C,CAAC,CAAC,CAAC;IACN,CAAC;IAEO,YAAY;QACnB,IAAI,C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,EAAE;YAC5D,iBAAiB;YACjB,MAAM,KAAK,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;YAC5B,MAAM,CAAC,KAAK,CAAC,IAAI,OAAO,CAAC,gBAAgB,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;YAChE,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,MAAW,EAAE,EAAE;gBAC3C,kBAAkB;gBAClB,IAAI,OAAO,CAAC,cAAc,EAAE,EAAE;oBAC7B,MAAM,CAAC,KAAK,CAAC,IAAI,OAAO,CAAC,cAAc,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;oBAC9D,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,IAAI,CACpC,OAAO,CAAC,cAAc,EAAE,EACxB,MAAM,CACN,CAAC;iBACF;YACF,CAAC,CAAC,CAAC;QACJ,CAAC,CAAA,CACD,CAAC;IACH,CAAC;IAED,IAAW,cAAc;QACxB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC7B,CAAC;CACD"} \ No newline at end of file diff --git a/.dist/electron-app/main/index.js b/.dist/electron-app/main/index.js index dd9e4c9..507b590 100644 --- a/.dist/electron-app/main/index.js +++ b/.dist/electron-app/main/index.js @@ -8,9 +8,9 @@ const appConfigs = fs.readJsonSync(path.join(__dirname, 'config.json')); const defaultConfig = appConfigs.development; const currentConfig = appConfigs[currentEnvironment]; global.appConfig = - currentEnvironment === 'development' - ? defaultConfig - : _.merge(defaultConfig, currentConfig); + currentEnvironment === 'development' + ? defaultConfig + : _.merge(defaultConfig, currentConfig); // Launch app App.launch(); -//# sourceMappingURL=index.js.map +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/.dist/electron-app/main/services/abstract-service.js b/.dist/electron-app/main/services/abstract-service.js index 3bb2803..31b5e39 100644 --- a/.dist/electron-app/main/services/abstract-service.js +++ b/.dist/electron-app/main/services/abstract-service.js @@ -1,13 +1,13 @@ const NOT_IMPEMENTED_YET = 'Method not implemented yet.'; export class AbstractService { - receptionChannel() { - throw new Error(NOT_IMPEMENTED_YET); - } - sendingChannel() { - throw new Error(NOT_IMPEMENTED_YET); - } - process(_input) { - throw new Error(NOT_IMPEMENTED_YET); - } + receptionChannel() { + throw new Error(NOT_IMPEMENTED_YET); + } + sendingChannel() { + throw new Error(NOT_IMPEMENTED_YET); + } + process(_input) { + throw new Error(NOT_IMPEMENTED_YET); + } } -//# sourceMappingURL=abstract-service.js.map +//# sourceMappingURL=abstract-service.js.map \ No newline at end of file diff --git a/.dist/electron-app/main/services/door-service.js b/.dist/electron-app/main/services/door-service.js new file mode 100644 index 0000000..43955e8 --- /dev/null +++ b/.dist/electron-app/main/services/door-service.js @@ -0,0 +1,65 @@ +import { WindowApiConst } from 'shared-lib'; +import { AbstractService } from './abstract-service'; +import { readFile, set_fs } from 'xlsx'; +import * as fs from 'node:fs'; +set_fs(fs); +export class DoorService extends AbstractService { + receptionChannel() { + return WindowApiConst.PROJECT_INPUT; + } + sendingChannel() { + return WindowApiConst.PROJECT_OUTPUT; + } + process(input) { + return new Promise((resolve) => { + var _a, _b, _c, _d, _e, _f, _g, _h; + const workbook = readFile(`${input.path}/${input.name}`); + const workingSheet = workbook.Sheets['DEURLIJST']; + const doorList = []; + // remove 2 top rows + const headers = {}; + // get header values + for (let index = 65; index <= 90; index++) { + const currentValue = (_a = workingSheet[`${index}3`]) === null || _a === void 0 ? void 0 : _a.v; + switch (currentValue) { + case 'L/R': + headers['lr'] = index; + break; + case 'KRUK/SLOT': + headers['krukSlot'] = index; + break; + case 'SCHARNIER': + headers['pivot'] = index; + break; + case 'SOORT DEUR': + headers['type'] = index; + break; + case 'MODEL KRUK': + headers['modelKruk'] = index; + break; + case 'OPMERKING': + headers['remark'] = index; + break; + default: break; + } + } + console.log(headers); + // stop at 19 + for (let index = 4; index < 19; index++) { + const door = {}; + door.nr = (_b = workingSheet[`A${index}`]) === null || _b === void 0 ? void 0 : _b.v; + if (door.nr) { + door.lr = (_c = workingSheet[`${headers['lr']}${index}`]) === null || _c === void 0 ? void 0 : _c.v; + door.krukSlot = (_d = workingSheet[`${headers['krukSlot']}${index}`]) === null || _d === void 0 ? void 0 : _d.v; + door.pivot = (_e = workingSheet[`${headers['pivot']}${index}`]) === null || _e === void 0 ? void 0 : _e.v; + door.type = (_f = workingSheet[`${headers['type']}${index}`]) === null || _f === void 0 ? void 0 : _f.v; + door.modelKruk = (_g = workingSheet[`${headers['modelKruk']}${index}`]) === null || _g === void 0 ? void 0 : _g.v; + door.remark = (_h = workingSheet[`${headers['remark']}${index}`]) === null || _h === void 0 ? void 0 : _h.v; + doorList.push(door); + } + } + resolve(doorList); + }); + } +} +//# sourceMappingURL=door-service.js.map \ No newline at end of file diff --git a/.dist/electron-app/main/services/door-service.js.map b/.dist/electron-app/main/services/door-service.js.map new file mode 100644 index 0000000..1d114c3 --- /dev/null +++ b/.dist/electron-app/main/services/door-service.js.map @@ -0,0 +1 @@ +{"version":3,"file":"door-service.js","sourceRoot":"","sources":["../../../../workspaces/electron-app/main/services/door-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAQ,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACxC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,MAAM,CAAC,EAAE,CAAC,CAAC;AAEX,MAAM,OAAO,WAAY,SAAQ,eAA4B;IAC5D,gBAAgB;QACf,OAAO,cAAc,CAAC,aAAa,CAAC;IACrC,CAAC;IAED,cAAc;QACb,OAAO,cAAc,CAAC,cAAc,CAAC;IACtC,CAAC;IAED,OAAO,CAAC,KAAmC;QAC1C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;;YAC9B,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAA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AE;oBACZ,IAAI,CAAC,EAAE,GAAG,MAAA,YAAY,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,0CAAE,CAAC,CAAC;oBACtD,IAAI,CAAC,QAAQ,GAAG,MAAA,YAAY,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG,KAAK,EAAE,CAAC,0CAAE,CAAC,CAAC;oBAClE,IAAI,CAAC,KAAK,GAAG,MAAA,YAAY,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,KAAK,EAAE,CAAC,0CAAE,CAAC,CAAC;oBAC5D,IAAI,CAAC,IAAI,GAAG,MAAA,YAAY,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,KAAK,EAAE,CAAC,0CAAE,CAAC,CAAC;oBAC1D,IAAI,CAAC,SAAS,GAAG,MAAA,YAAY,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,KAAK,EAAE,CAAC,0CAAE,CAAC,CAAC;oBACpE,IAAI,CAAC,MAAM,GAAG,MAAA,YAAY,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,KAAK,EAAE,CAAC,0CAAE,CAAC,CAAC;oBAE9D,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;iBACpB;aACD;YAED,OAAO,CAAC,QAAQ,CAAC,CAAC;QACnB,CAAC,CAAC,CAAC;IACJ,CAAC;CACD"} \ No newline at end of file diff --git a/.dist/electron-app/main/services/file-list-service.js b/.dist/electron-app/main/services/file-list-service.js index 8def827..b4b24ae 100644 --- a/.dist/electron-app/main/services/file-list-service.js +++ b/.dist/electron-app/main/services/file-list-service.js @@ -2,23 +2,51 @@ import { readdir } from 'node:fs'; import { WindowApiConst } from 'shared-lib'; import { AbstractService } from './abstract-service'; export class FileListService extends AbstractService { - receptionChannel() { - return WindowApiConst.FILELIST_INPUT; - } - sendingChannel() { - return WindowApiConst.FILELIST_OUTPUT; - } - process() { - readdir('./', (error, fileList) => { - if (!error) { - const newList = {}; - for (const file in fileList) { - newList[file] = []; - } - return newList; - } - return {}; - }); - } + constructor() { + super(...arguments); + this._paths = ['./assets']; + } + receptionChannel() { + return WindowApiConst.FILELIST_INPUT; + } + sendingChannel() { + return WindowApiConst.FILELIST_OUTPUT; + } + process() { + return new Promise((resolve) => { + const projects = []; + Promise.all(this._paths.map((path) => this.readPath(path))).then((result) => { + for (const entry of result.entries()) { + for (const file of entry[1].result) { + projects.push({ + path: entry[1].path, + name: file, + }); + } + } + resolve(projects); + }); + }); + } + readPath(path) { + return new Promise((resolve) => { + readdir(path, (error, fileList) => { + if (!error) { + const newList = []; + for (const file of fileList) { + newList.push(file); + } + return resolve({ + path, + result: newList, + }); + } + return {}; + }); + }); + } + setPaths(inputPaths) { + this._paths = inputPaths; + } } -//# sourceMappingURL=file-list-service.js.map +//# sourceMappingURL=file-list-service.js.map \ No newline at end of file diff --git a/.dist/electron-app/main/services/file-list-service.js.map b/.dist/electron-app/main/services/file-list-service.js.map index deeb630..adc34be 100644 --- a/.dist/electron-app/main/services/file-list-service.js.map +++ b/.dist/electron-app/main/services/file-list-service.js.map @@ -1 +1 @@ -{"version":3,"file":"file-list-service.js","sourceRoot":"","sources":["../../../../workspaces/electron-app/main/services/file-list-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,cAAc,EAAQ,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,MAAM,OAAO,eAAgB,SAAQ,eAA8C;IAClF,gBAAgB;QACf,OAAO,cAAc,CAAC,cAAc,CAAC;IACtC,CAAC;IAED,cAAc;QACb,OAAO,cAAc,CAAC,eAAe,CAAC;IACvC,CAAC;IAED,OAAO;QACA,QAAQ,CAAC;QACT,OAAO,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,QAAkB,EAAE,EAAE;YACxC,IAAI,CAAC,KAAK,EAAE;gBACR,MAAO,OAAO,GAA4B,EAAE,CAAC;gBAC7C,KAAI,MAAM,IAAI,IAAI,QAAQ,EAAE;oBACxB,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;iBACtB;gBACD,OAAO,OAAO,CAAC;aAClB;YAED,OAAO,EAAE,CAAC;QACd,CAAC,CAAC,CAAC;QAEH,OAAO,EAAE,CAAC;IACjB,CAAC;CACD"} \ No newline at end of file +{"version":3,"file":"file-list-service.js","sourceRoot":"","sources":["../../../../workspaces/electron-app/main/services/file-list-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,MAAM,OAAO,eAAgB,SAAQ,eAA4B;IAAjE;;QACS,WAAM,GAAa,CAAC,UAAU,CAAC,CAAC;IAiDzC,CAAC;IA/CA,gBAAgB;QACf,OAAO,cAAc,CAAC,cAAc,CAAC;IACtC,CAAC;IAED,cAAc;QACb,OAAO,cAAc,CAAC,eAAe,CAAC;IACvC,CAAC;IAED,OAAO;QACN,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC9B,MAAM,QAAQ,GAAU,EAAE,CAAC;YAC3B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,MAAW,EAAE,EAAE;gBAChF,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,OAAO,EAAE,EAAE;oBACrC,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE;wBACnC,QAAQ,CAAC,IAAI,CAAC;4BACb,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI;4BACnB,IAAI,EAAE,IAAI;yBACV,CAAC,CAAC;qBACH;iBACD;gBACD,OAAO,CAAC,QAAQ,CAAC,CAAC;YACnB,CAAC,CAAC,CAAA;QACH,CAAC,CAAC,CAAC;IACJ,CAAC;IAEO,QAAQ,CAAC,IAAY;QAC5B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC9B,OAAO,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,QAAkB,EAAE,EAAE;gBAC3C,IAAI,CAAC,KAAK,EAAE;oBACX,MAAM,OAAO,GAAa,EAAE,CAAC;oBAC7B,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE;wBAC5B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;qBACnB;oBACD,OAAO,OAAO,CAAC;wBACd,IAAI;wBACJ,MAAM,EAAE,OAAO;qBACf,CAAC,CAAC;iBACH;gBAED,OAAO,EAAE,CAAC;YACX,CAAC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACJ,CAAC;IAEM,QAAQ,CAAC,UAAoB;QACnC,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC;IAC1B,CAAC;CACD"} \ No newline at end of file diff --git a/.dist/electron-app/main/services/print-service.js b/.dist/electron-app/main/services/print-service.js new file mode 100644 index 0000000..c380121 --- /dev/null +++ b/.dist/electron-app/main/services/print-service.js @@ -0,0 +1,22 @@ +import { WindowApiConst } from 'shared-lib'; +import { AbstractService } from './abstract-service'; +export class PrintService extends AbstractService { + sendingChannel() { + return WindowApiConst.PRINT_OUTPUT; + } + receptionChannel() { + return WindowApiConst.PRINT_INPUT; + } + process() { + return new Promise((resolve) => { + if (this._browserWindow) { + this._browserWindow.webContents.print({ silent: true }); + } + resolve(); + }); + } + setWindow(window) { + this._browserWindow = window; + } +} +//# sourceMappingURL=print-service.js.map \ No newline at end of file diff --git a/.dist/electron-app/main/services/print-service.js.map b/.dist/electron-app/main/services/print-service.js.map new file mode 100644 index 0000000..7aaa052 --- /dev/null +++ b/.dist/electron-app/main/services/print-service.js.map @@ -0,0 +1 @@ +{"version":3,"file":"print-service.js","sourceRoot":"","sources":["../../../../workspaces/electron-app/main/services/print-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,MAAM,OAAO,YAAa,SAAQ,eAA6B;IAE9D,cAAc;QACb,OAAO,cAAc,CAAC,YAAY,CAAC;IACpC,CAAC;IAED,gBAAgB;QACf,OAAO,cAAc,CAAC,WAAW,CAAC;IACnC,CAAC;IAED,OAAO;QACN,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC9B,IAAI,IAAI,CAAC,cAAc,EAAE;gBACxB,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;aACxD;YACD,OAAO,EAAE,CAAC;QACX,CAAC,CAAC,CAAC;IACJ,CAAC;IAEM,SAAS,CAAC,MAAqB;QACrC,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC;IAC9B,CAAC;CACD"} \ No newline at end of file diff --git a/.dist/electron-app/main/utils/logger.js b/.dist/electron-app/main/utils/logger.js index a3a7afb..7899c54 100644 --- a/.dist/electron-app/main/utils/logger.js +++ b/.dist/electron-app/main/utils/logger.js @@ -3,119 +3,111 @@ import * as os from 'node:os'; import * as path from 'node:path'; import * as winston from 'winston'; export class Logger { - constructor() { - /** - * Custom winston file format - * Write JSON logs with given format : - * `${timestamp} ${level} : ${info.message} : ${meta})` - */ - this.fileFormat = winston.format.printf((data) => { - return JSON.stringify(this.prepareLogData(data)); - }); - /** - * Custom winston console format - * Write logs with given format : - * `${timestamp} ${level} : ${info.message} : JSON.stringify({ ...meta }) ` - */ - this.consoleFormat = winston.format.printf((data) => { - const preparedData = this.prepareLogData(data); - return ( - `${preparedData.timestamp} ${preparedData.level} : ` + - `${preparedData.message} : ${JSON.stringify(preparedData.meta)}` - ); - }); - this.prepareLogData = (data) => { - const additionalData = Object.assign({}, data); - delete additionalData.timestamp; - delete additionalData.level; - delete additionalData.message; - delete additionalData.service; - return { - timestamp: data.timestamp, - level: data.level, - message: data.message, - meta: additionalData, - }; - }; - this._logger = winston.createLogger({ - level: 'debug', - format: winston.format.json(), - defaultMeta: { service: 'user-service' }, - transports: [ - new winston.transports.File({ - filename: this.getLogFilename(), - level: global.appConfig.mainLogLevel, - format: winston.format.combine( - winston.format.timestamp(), - this.fileFormat - ), - }), - ], - }); - // If we're not in production then log also to the `console` with the format: - // `${info.timestamp} ${info.level}: ${info.message} JSON.stringify({ ...rest }) ` - if (global.appConfig.configId === 'development') { - this._logger.add( - new winston.transports.Console({ - stderrLevels: ['error', 'warn'], - format: winston.format.combine( - winston.format.timestamp(), - this.consoleFormat - ), - }) - ); - } - } - static error(message, ...meta) { - Logger.initSingleton(); - Logger.singleton._logger.error(message, meta); - } - static warn(message, ...meta) { - Logger.initSingleton(); - Logger.singleton._logger.warn(message, meta); - } - static info(message, ...meta) { - Logger.initSingleton(); - Logger.singleton._logger.info(message, meta); - } - static http(message, ...meta) { - Logger.initSingleton(); - Logger.singleton._logger.http(message, meta); - } - static verbose(message, ...meta) { - Logger.initSingleton(); - Logger.singleton._logger.verbose(message, meta); - } - static debug(message, ...meta) { - Logger.initSingleton(); - Logger.singleton._logger.debug(message, meta); - } - static silly(message, ...meta) { - Logger.initSingleton(); - Logger.singleton._logger.silly(message, meta); - } - static initSingleton() { - if (!Logger.singleton) { - Logger.singleton = new Logger(); - } - } - /** - * Returns log filename with standard path - * In production, returns absolute standard path depending on platform - */ - getLogFilename() { - let filename = global.appConfig.mainLogFile; - if (global.appConfig.configId === 'production') { - const appName = app.getName(); - if (process.platform == 'linux') { - filename = `.config/${appName}/${filename}`; - } else if (process.platform == 'darwin') { - filename = `Library/Logs/${appName}/${filename}`; - } else if (process.platform == 'win32') { - filename = `AppData\\Roaming\\${appName}\\${filename}`; - } - } - return path.join(os.homedir(), filename); - } + constructor() { + /** + * Custom winston file format + * Write JSON logs with given format : + * `${timestamp} ${level} : ${info.message} : ${meta})` + */ + this.fileFormat = winston.format.printf((data) => { + return JSON.stringify(this.prepareLogData(data)); + }); + /** + * Custom winston console format + * Write logs with given format : + * `${timestamp} ${level} : ${info.message} : JSON.stringify({ ...meta }) ` + */ + this.consoleFormat = winston.format.printf((data) => { + const preparedData = this.prepareLogData(data); + return (`${preparedData.timestamp} ${preparedData.level} : ` + + `${preparedData.message} : ${JSON.stringify(preparedData.meta)}`); + }); + this.prepareLogData = (data) => { + const additionalData = Object.assign({}, data); + delete additionalData.timestamp; + delete additionalData.level; + delete additionalData.message; + delete additionalData.service; + return { + timestamp: data.timestamp, + level: data.level, + message: data.message, + meta: additionalData, + }; + }; + this._logger = winston.createLogger({ + level: 'debug', + format: winston.format.json(), + defaultMeta: { service: 'user-service' }, + transports: [ + new winston.transports.File({ + filename: this.getLogFilename(), + level: global.appConfig.mainLogLevel, + format: winston.format.combine(winston.format.timestamp(), this.fileFormat), + }), + ], + }); + // If we're not in production then log also to the `console` with the format: + // `${info.timestamp} ${info.level}: ${info.message} JSON.stringify({ ...rest }) ` + if (global.appConfig.configId === 'development') { + this._logger.add(new winston.transports.Console({ + stderrLevels: ['error', 'warn'], + format: winston.format.combine(winston.format.timestamp(), this.consoleFormat), + })); + } + } + static error(message, ...meta) { + Logger.initSingleton(); + Logger.singleton._logger.error(message, meta); + } + static warn(message, ...meta) { + Logger.initSingleton(); + Logger.singleton._logger.warn(message, meta); + } + static info(message, ...meta) { + Logger.initSingleton(); + Logger.singleton._logger.info(message, meta); + } + static http(message, ...meta) { + Logger.initSingleton(); + Logger.singleton._logger.http(message, meta); + } + static verbose(message, ...meta) { + Logger.initSingleton(); + Logger.singleton._logger.verbose(message, meta); + } + static debug(message, ...meta) { + Logger.initSingleton(); + Logger.singleton._logger.debug(message, meta); + } + static silly(message, ...meta) { + Logger.initSingleton(); + Logger.singleton._logger.silly(message, meta); + } + static initSingleton() { + if (!Logger.singleton) { + Logger.singleton = new Logger(); + } + } + /** + * Returns log filename with standard path + * In production, returns absolute standard path depending on platform + */ + getLogFilename() { + let filename = global.appConfig.mainLogFile; + if (global.appConfig.configId === 'production') { + const appName = app.getName(); + if (process.platform == 'linux') { + filename = `.config/${appName}/${filename}`; + } + else if (process.platform == 'darwin') { + filename = `Library/Logs/${appName}/${filename}`; + } + else if (process.platform == 'win32') { + filename = `AppData\\Roaming\\${appName}\\${filename}`; + } + } + return path.join(os.homedir(), filename); + } } -//# sourceMappingURL=logger.js.map +//# sourceMappingURL=logger.js.map \ No newline at end of file diff --git a/.dist/electron-app/renderer/index.js b/.dist/electron-app/renderer/index.js index f92cdbb..18909fd 100644 --- a/.dist/electron-app/renderer/index.js +++ b/.dist/electron-app/renderer/index.js @@ -26,7 +26,5 @@ * ``` */ import './index.css'; -console.log( - '👋 This message is being logged by "renderer.js", included via webpack' -); -//# sourceMappingURL=index.js.map +console.log('👋 This message is being logged by "renderer.js", included via webpack'); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/.dist/electron-app/renderer/preload.js b/.dist/electron-app/renderer/preload.js index e155121..711272c 100644 --- a/.dist/electron-app/renderer/preload.js +++ b/.dist/electron-app/renderer/preload.js @@ -35,19 +35,19 @@ if (process.env.X_NODE_ENV === 'e2e-test') { import { contextBridge, ipcRenderer } from 'electron'; import { WindowApiConst } from 'shared-lib'; contextBridge.exposeInMainWorld('api', { - node: () => process.versions.node, - chrome: () => process.versions.chrome, - electron: () => process.versions.electron, - send: (channel, input) => { - if (WindowApiConst.SENDING_SAFE_CHANNELS.includes(channel)) { - ipcRenderer.send(channel, input); - } - }, - receive: (channel, callback) => { - // Deliberately strip event as it includes `sender` - ipcRenderer.on(channel, (_event, ...parameters) => callback(parameters[0])); - }, - // we can also expose variables, not just functions + node: () => process.versions.node, + chrome: () => process.versions.chrome, + electron: () => process.versions.electron, + send: (channel, input) => { + if (WindowApiConst.SENDING_SAFE_CHANNELS.includes(channel)) { + ipcRenderer.send(channel, input); + } + }, + receive: (channel, callback) => { + // Deliberately strip event as it includes `sender` + ipcRenderer.on(channel, (_event, ...parameters) => callback(parameters[0])); + }, + // we can also expose variables, not just functions }); console.log('The preload script has been injected successfully.'); -//# sourceMappingURL=preload.js.map +//# sourceMappingURL=preload.js.map \ No newline at end of file diff --git a/.dist/electron-e2e/app.spec.js b/.dist/electron-e2e/app.spec.js index 3a1199b..175dc17 100644 --- a/.dist/electron-e2e/app.spec.js +++ b/.dist/electron-e2e/app.spec.js @@ -28,53 +28,27 @@ describe('application loading', () => { // }); }); }); */ -var __awaiter = - (this && this.__awaiter) || - function (thisArg, _arguments, P, generator) { - function adopt(value) { - return value instanceof P - ? value - : new P(function (resolve) { - resolve(value); - }); - } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e) { - reject(e); - } - } - function rejected(value) { - try { - step(generator['throw'](value)); - } catch (e) { - reject(e); - } - } - function step(result) { - result.done - ? resolve(result.value) - : adopt(result.value).then(fulfilled, rejected); - } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); - }; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; describe('A simple test to check if app window is opened, visible and with expected title', () => { - describe('App should', () => { - it('show an initial window', () => - __awaiter(this, void 0, void 0, function* () { - // Checking there is one visible window - // expect(await browser.).toEqual(true); - // Please note that getWindowHandles() will return 2 if `dev tools` is opened. - const { length } = yield browser.getWindowHandles(); - expect(length).toEqual(1); - })); - it('have expected title', () => - __awaiter(this, void 0, void 0, function* () { - expect(yield browser.getTitle()).toEqual('ElectronAngularQuickStart'); - })); - }); + describe('App should', () => { + it('show an initial window', () => __awaiter(this, void 0, void 0, function* () { + // Checking there is one visible window + // expect(await browser.).toEqual(true); + // Please note that getWindowHandles() will return 2 if `dev tools` is opened. + const { length } = yield browser.getWindowHandles(); + expect(length).toEqual(1); + })); + it('have expected title', () => __awaiter(this, void 0, void 0, function* () { + expect(yield browser.getTitle()).toEqual('ElectronAngularQuickStart'); + })); + }); }); -//# sourceMappingURL=app.spec.js.map +//# sourceMappingURL=app.spec.js.map \ No newline at end of file diff --git a/.dist/electron-e2e/multiples.spec.js b/.dist/electron-e2e/multiples.spec.js index ef3f896..fc2c125 100644 --- a/.dist/electron-e2e/multiples.spec.js +++ b/.dist/electron-e2e/multiples.spec.js @@ -1,54 +1,28 @@ -var __awaiter = - (this && this.__awaiter) || - function (thisArg, _arguments, P, generator) { - function adopt(value) { - return value instanceof P - ? value - : new P(function (resolve) { - resolve(value); - }); - } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e) { - reject(e); - } - } - function rejected(value) { - try { - step(generator['throw'](value)); - } catch (e) { - reject(e); - } - } - function step(result) { - result.done - ? resolve(result.value) - : adopt(result.value).then(fulfilled, rejected); - } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); - }; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; import MultiplesPage from './pageobjects/multiples.page'; describe('A simple test to check if a given input matches with computed multiples', () => { - describe('Multiples component should', () => { - it('show up on startup', () => - __awaiter(void 0, void 0, void 0, function* () { - yield expect(MultiplesPage.root).toBeDisplayed(); - })); - const number = Math.floor(Math.random() * 100) % 10; - it(`display expected results on input (${number})`, () => - __awaiter(void 0, void 0, void 0, function* () { - yield MultiplesPage.enterInput(number); - const results = yield MultiplesPage.results; - for (const index of results.keys()) { - const ntimes = 1 + index; - const expected = `${number} * ${ntimes} = ${number * ntimes}`; - expect(yield results[index].getText()).toEqual(expected); - } - })); - }); + describe('Multiples component should', () => { + it('show up on startup', () => __awaiter(void 0, void 0, void 0, function* () { + yield expect(MultiplesPage.root).toBeDisplayed(); + })); + const number = Math.floor(Math.random() * 100) % 10; + it(`display expected results on input (${number})`, () => __awaiter(void 0, void 0, void 0, function* () { + yield MultiplesPage.enterInput(number); + const results = yield MultiplesPage.results; + for (const index of results.keys()) { + const ntimes = 1 + index; + const expected = `${number} * ${ntimes} = ${number * ntimes}`; + expect(yield results[index].getText()).toEqual(expected); + } + })); + }); }); -//# sourceMappingURL=multiples.spec.js.map +//# sourceMappingURL=multiples.spec.js.map \ No newline at end of file diff --git a/.dist/electron-e2e/pageobjects/multiples.page.js b/.dist/electron-e2e/pageobjects/multiples.page.js index 700f56d..015204c 100644 --- a/.dist/electron-e2e/pageobjects/multiples.page.js +++ b/.dist/electron-e2e/pageobjects/multiples.page.js @@ -1,62 +1,38 @@ -var __awaiter = - (this && this.__awaiter) || - function (thisArg, _arguments, P, generator) { - function adopt(value) { - return value instanceof P - ? value - : new P(function (resolve) { - resolve(value); - }); - } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e) { - reject(e); - } - } - function rejected(value) { - try { - step(generator['throw'](value)); - } catch (e) { - reject(e); - } - } - function step(result) { - result.done - ? resolve(result.value) - : adopt(result.value).then(fulfilled, rejected); - } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); - }; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; import AbstractPage from './page'; class MultiplesPage extends AbstractPage { - /** - * Selectors using getter methods - */ - get root() { - return $('#multiples'); - } - get input() { - return $('#input'); - } - get results() { - return $$('.results'); - } - get buttonSubmit() { - return $('button[type="submit"]'); - } - /** - * Wrapper method to interact with the page - */ - enterInput(number) { - return __awaiter(this, void 0, void 0, function* () { - yield this.input.setValue(number); - yield this.buttonSubmit.click(); - }); - } + /** + * Selectors using getter methods + */ + get root() { + return $('#multiples'); + } + get input() { + return $('#input'); + } + get results() { + return $$('.results'); + } + get buttonSubmit() { + return $('button[type="submit"]'); + } + /** + * Wrapper method to interact with the page + */ + enterInput(number) { + return __awaiter(this, void 0, void 0, function* () { + yield this.input.setValue(number); + yield this.buttonSubmit.click(); + }); + } } export default new MultiplesPage(); -//# sourceMappingURL=multiples.page.js.map +//# sourceMappingURL=multiples.page.js.map \ No newline at end of file diff --git a/.dist/electron-e2e/pageobjects/page.js b/.dist/electron-e2e/pageobjects/page.js index e3d6044..54eaad2 100644 --- a/.dist/electron-e2e/pageobjects/page.js +++ b/.dist/electron-e2e/pageobjects/page.js @@ -2,5 +2,6 @@ * Abstract page object containing all methods, selectors and functionality * that is shared across all page objects */ -export default class AbstractPage {} -//# sourceMappingURL=page.js.map +export default class AbstractPage { +} +//# sourceMappingURL=page.js.map \ No newline at end of file diff --git a/.dist/electron-e2e/webdriverio.config.js b/.dist/electron-e2e/webdriverio.config.js index 26a0407..91cabc9 100644 --- a/.dist/electron-e2e/webdriverio.config.js +++ b/.dist/electron-e2e/webdriverio.config.js @@ -1,396 +1,362 @@ -var __awaiter = - (this && this.__awaiter) || - function (thisArg, _arguments, P, generator) { - function adopt(value) { - return value instanceof P - ? value - : new P(function (resolve) { - resolve(value); - }); - } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e) { - reject(e); - } - } - function rejected(value) { - try { - step(generator['throw'](value)); - } catch (e) { - reject(e); - } - } - function step(result) { - result.done - ? resolve(result.value) - : adopt(result.value).then(fulfilled, rejected); - } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); - }; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; import path from 'node:path'; // Path to local electron binary let electronPath = path.join(__dirname, '../../node_modules/.bin/electron'); if (process.platform === 'win32') { - electronPath += '.cmd'; + electronPath += '.cmd'; } // Starting hook -const waitUntilWindowLoaded = () => - __awaiter(void 0, void 0, void 0, function* () { - const timeout = 10000; - yield browser.waitUntil( - () => - __awaiter(void 0, void 0, void 0, function* () { - return (yield browser.isLoading()) === false; - }), - { - timeout: timeout, - timeoutMsg: `Expected app to be loaded in less than ${timeout}ms`, - } - ); - }); +const waitUntilWindowLoaded = () => __awaiter(void 0, void 0, void 0, function* () { + const timeout = 10000; + yield browser.waitUntil(() => __awaiter(void 0, void 0, void 0, function* () { return (yield browser.isLoading()) === false; }), { + timeout: timeout, + timeoutMsg: `Expected app to be loaded in less than ${timeout}ms`, + }); +}); // Closing hook -const closeApplication = () => - __awaiter(void 0, void 0, void 0, function* () { - if (browser) { - // Wait 1 second and close window - yield new Promise((resolve) => setTimeout(resolve, 1000)); - yield browser.closeWindow(); - } - }); +const closeApplication = () => __awaiter(void 0, void 0, void 0, function* () { + if (browser) { + // Wait 1 second and close window + yield new Promise((resolve) => setTimeout(resolve, 1000)); + yield browser.closeWindow(); + } +}); export const config = { - // - // ==================== - // Runner Configuration - // ==================== - // - // - // ===================== - // ts-node Configurations - // ===================== - // - // You can write tests using TypeScript to get autocompletion and type safety. - // You will need typescript and ts-node installed as devDependencies. - // WebdriverIO will automatically detect if these dependencies are installed - // and will compile your config and tests for you. - // If you need to configure how ts-node runs please use the - // environment variables for ts-node or use wdio config's autoCompileOpts section. - // - autoCompileOpts: { - autoCompile: true, - // see https://github.com/TypeStrong/ts-node#cli-and-programmatic-options - // for all available options - tsNodeOpts: { - transpileOnly: true, - project: 'workspaces/electron-e2e/tsconfig.json', - }, - // tsconfig-paths is only used if "tsConfigPathsOpts" are provided, if you - // do please make sure "tsconfig-paths" is installed as dependency - // tsConfigPathsOpts: { - // baseUrl: './' - // } - }, - // - // ================== - // Specify Test Files - // ================== - // Define which test specs should run. The pattern is relative to the directory - // from which `wdio` was called. - // - // The specs are defined as an array of spec files (optionally using wildcards - // that will be expanded). The test for each spec file will be run in a separate - // worker process. In order to have a group of spec files run in the same worker - // process simply enclose them in an array within the specs array. - // - // If you are calling `wdio` from an NPM script (see https://docs.npmjs.com/cli/run-script), - // then the current working directory is where your `package.json` resides, so `wdio` - // will be called from there. - // - specs: ['./workspaces/electron-e2e/**/*.spec.ts'], - // Patterns to exclude. - exclude: [ - // 'path/to/excluded/files' - ], - // - // ============ - // Capabilities - // ============ - // Define your capabilities here. WebdriverIO can run multiple capabilities at the same - // time. Depending on the number of capabilities, WebdriverIO launches several test - // sessions. Within your capabilities you can overwrite the spec and exclude options in - // order to group specific specs to a specific capability. - // - // First, you can define how many instances should be started at the same time. Let's - // say you have 3 different capabilities (Chrome, Firefox, and Safari) and you have - // set maxInstances to 1; wdio will spawn 3 processes. Therefore, if you have 10 spec - // files and you set maxInstances to 10, all spec files will get tested at the same time - // and 30 processes will get spawned. The property handles how many capabilities - // from the same test should run tests. - // - maxInstances: 10, - // - // If you have trouble getting all important capabilities together, check out the - // Sauce Labs platform configurator - a great tool to configure your capabilities: - // https://saucelabs.com/platform/platform-configurator - // - capabilities: [ - { - // maxInstances can get overwritten per capability. So if you have an in-house Selenium - // grid with only 5 firefox instances available you can make sure that not more than - // 5 instances get started at a time. - maxInstances: 5, - // - browserName: 'chrome', - acceptInsecureCerts: true, - 'goog:chromeOptions': { - binary: electronPath, - args: ['app=' + '.webpack/main/index.js'], - }, - // If outputDir is provided WebdriverIO can capture driver session logs - // it is possible to configure which logTypes to include/exclude. - // excludeDriverLogs: ['*'], // pass '*' to exclude all driver session logs - // excludeDriverLogs: ['bugreport', 'server'], - }, - ], - // - // =================== - // Test Configurations - // =================== - // Define all options that are relevant for the WebdriverIO instance here - // - // Level of logging verbosity: trace | debug | info | warn | error | silent - logLevel: 'info', - // - // Set specific log levels per logger - // loggers: - // - webdriver, webdriverio - // - @wdio/browserstack-service, @wdio/devtools-service, @wdio/sauce-service - // - @wdio/mocha-framework, @wdio/jasmine-framework - // - @wdio/local-runner - // - @wdio/sumologic-reporter - // - @wdio/cli, @wdio/config, @wdio/utils - // Level of logging verbosity: trace | debug | info | warn | error | silent - // logLevels: { - // webdriver: 'info', - // '@wdio/appium-service': 'info' - // }, - // - // If you only want to run your tests until a specific amount of tests have failed use - // bail (default is 0 - don't bail, run all tests). - bail: 0, - // - // Set a base URL in order to shorten url command calls. If your `url` parameter starts - // with `/`, the base url gets prepended, not including the path portion of your baseUrl. - // If your `url` parameter starts without a scheme or `/` (like `some/path`), the base url - // gets prepended directly. - baseUrl: 'http://localhost', - // - // Default timeout for all waitFor* commands. - waitforTimeout: 10000, - // - // Default timeout in milliseconds for request - // if browser driver or grid doesn't send response - connectionRetryTimeout: 120000, - // - // Default request retries count - connectionRetryCount: 3, - // - // Test runner services - // Services take over a specific job you don't want to take care of. They enhance - // your test setup with almost no effort. Unlike plugins, they don't add new - // commands. Instead, they hook themselves up into the test process. - services: ['chromedriver'], - // Framework you want to run your specs with. - // The following are supported: Mocha, Jasmine, and Cucumber - // see also: https://webdriver.io/docs/frameworks - // - // Make sure you have the wdio adapter package for the specific framework installed - // before running any tests. - framework: 'jasmine', - // - // The number of times to retry the entire specfile when it fails as a whole - // specFileRetries: 1, - // - // Delay in seconds between the spec file retry attempts - // specFileRetriesDelay: 0, - // - // Whether or not retried specfiles should be retried immediately or deferred to the end of the queue - // specFileRetriesDeferred: false, - // - // Test reporter for stdout. - // The only one supported by default is 'dot' - // see also: https://webdriver.io/docs/dot-reporter - reporters: ['spec', ['allure', { outputDir: 'allure-results' }]], - // - // Options to be passed to Jasmine. - jasmineOpts: { - // Jasmine default timeout - defaultTimeoutInterval: 60000, - // - // The Jasmine framework allows interception of each assertion in order to log the state of the application - // or website depending on the result. For example, it is pretty handy to take a screenshot every time - // an assertion fails. - expectationResultHandler: function (_passed, _assertion) { - // do something - }, - }, - // - // ===== - // Hooks - // ===== - // WebdriverIO provides several hooks you can use to interfere with the test process in order to enhance - // it and to build services around it. You can either apply a single function or an array of - // methods to it. If one of them returns with a promise, WebdriverIO will wait until that promise got - // resolved to continue. - /** - * Gets executed once before all workers get launched. - * @param {Object} config wdio configuration object - * @param {Array.} capabilities list of capabilities details - */ - // onPrepare: function (config, capabilities) { - // }, - /** - * Gets executed before a worker process is spawned and can be used to initialise specific service - * for that worker as well as modify runtime environments in an async fashion. - * @param {String} cid capability id (e.g 0-0) - * @param {[type]} caps object containing capabilities for session that will be spawn in the worker - * @param {[type]} specs specs to be run in the worker process - * @param {[type]} args object that will be merged with the main configuration once worker is initialized - * @param {[type]} execArgv list of string arguments passed to the worker process - */ - // onWorkerStart: function (cid, caps, specs, args, execArgv) { - // }, - /** - * Gets executed just after a worker process has exited. - * @param {String} cid capability id (e.g 0-0) - * @param {Number} exitCode 0 - success, 1 - fail - * @param {[type]} specs specs to be run in the worker process - * @param {Number} retries number of retries used - */ - // onWorkerEnd: function (cid, exitCode, specs, retries) { - // }, - /** - * Gets executed just before initialising the webdriver session and test framework. It allows you - * to manipulate configurations depending on the capability or spec. - * @param {Object} config wdio configuration object - * @param {Array.} capabilities list of capabilities details - * @param {Array.} specs List of spec file paths that are to be run - * @param {String} cid worker id (e.g. 0-0) - */ - // beforeSession: function (config, capabilities, specs, cid) { - // }, - /** - * Gets executed before test execution begins. At this point you can access to all global - * variables like `browser`. It is the perfect place to define custom commands. - * @param {Array.} capabilities list of capabilities details - * @param {Array.} specs List of spec file paths that are to be run - * @param {Object} browser instance of created browser/device session - */ - // before: function (capabilities, specs) { - // }, - /** - * Runs before a WebdriverIO command gets executed. - * @param {String} commandName hook command name - * @param {Array} args arguments that command would receive - */ - // beforeCommand: function (commandName, args) { - // }, - /** - * Hook that gets executed before the suite starts - * @param {Object} suite suite details - */ - beforeSuite: (_suite) => - __awaiter(void 0, void 0, void 0, function* () { - yield waitUntilWindowLoaded(); - }), - /** - * Function to be executed before a test (in Mocha/Jasmine) starts. - */ - // beforeTest: function (test, context) { - // }, - /** - * Hook that gets executed _before_ a hook within the suite starts (e.g. runs before calling - * beforeEach in Mocha) - */ - // beforeHook: function (test, context) { - // }, - /** - * Hook that gets executed _after_ a hook within the suite starts (e.g. runs after calling - * afterEach in Mocha) - */ - // afterHook: function (test, context, { error, result, duration, passed, retries }) { - // }, - /** - * Function to be executed after a test (in Mocha/Jasmine only) - * @param {Object} test test object - * @param {Object} context scope object the test was executed with - * @param {Error} result.error error object in case the test fails, otherwise `undefined` - * @param {Any} result.result return object of test function - * @param {Number} result.duration duration of test - * @param {Boolean} result.passed true if test has passed, otherwise false - * @param {Object} result.retries informations to spec related retries, e.g. `{ attempts: 0, limit: 0 }` - */ - afterTest: function (_test, _context, result) { - return __awaiter(this, void 0, void 0, function* () { - // result = { _error, _result, _duration, passed, _retries } - if (!result.passed) { - yield browser.takeScreenshot(); - } - }); - }, - /** - * Hook that gets executed after the suite has ended - * @param {Object} suite suite details - */ - // afterSuite: async function (_suite) { - // }, - /** - * Runs after a WebdriverIO command gets executed - * @param {String} commandName hook command name - * @param {Array} args arguments that command would receive - * @param {Number} result 0 - command success, 1 - command error - * @param {Object} error error object if any - */ - // afterCommand: function (commandName, args, result, error) { - // }, - /** - * Gets executed after all tests are done. You still have access to all global variables from - * the test. - * @param {Number} result 0 - test pass, 1 - test fail - * @param {Array.} capabilities list of capabilities details - * @param {Array.} specs List of spec file paths that ran - */ - after: (_result, _capabilities, _specs) => - __awaiter(void 0, void 0, void 0, function* () { - yield closeApplication(); - }), - /** - * Gets executed right after terminating the webdriver session. - * @param {Object} config wdio configuration object - * @param {Array.} capabilities list of capabilities details - * @param {Array.} specs List of spec file paths that ran - */ - // afterSession: function (config, capabilities, specs) { - // }, - /** - * Gets executed after all workers got shut down and the process is about to exit. An error - * thrown in the onComplete hook will result in the test run failing. - * @param {Object} exitCode 0 - success, 1 - fail - * @param {Object} config wdio configuration object - * @param {Array.} capabilities list of capabilities details - * @param {} results object containing test results - */ - // onComplete: function(_exitCode, _config, _capabilities, _results) { - // }, - /** - * Gets executed when a refresh happens. - * @param {String} oldSessionId session ID of the old session - * @param {String} newSessionId session ID of the new session - */ - // onReload: function(oldSessionId, newSessionId) { - // } + // + // ==================== + // Runner Configuration + // ==================== + // + // + // ===================== + // ts-node Configurations + // ===================== + // + // You can write tests using TypeScript to get autocompletion and type safety. + // You will need typescript and ts-node installed as devDependencies. + // WebdriverIO will automatically detect if these dependencies are installed + // and will compile your config and tests for you. + // If you need to configure how ts-node runs please use the + // environment variables for ts-node or use wdio config's autoCompileOpts section. + // + autoCompileOpts: { + autoCompile: true, + // see https://github.com/TypeStrong/ts-node#cli-and-programmatic-options + // for all available options + tsNodeOpts: { + transpileOnly: true, + project: 'workspaces/electron-e2e/tsconfig.json', + }, + // tsconfig-paths is only used if "tsConfigPathsOpts" are provided, if you + // do please make sure "tsconfig-paths" is installed as dependency + // tsConfigPathsOpts: { + // baseUrl: './' + // } + }, + // + // ================== + // Specify Test Files + // ================== + // Define which test specs should run. The pattern is relative to the directory + // from which `wdio` was called. + // + // The specs are defined as an array of spec files (optionally using wildcards + // that will be expanded). The test for each spec file will be run in a separate + // worker process. In order to have a group of spec files run in the same worker + // process simply enclose them in an array within the specs array. + // + // If you are calling `wdio` from an NPM script (see https://docs.npmjs.com/cli/run-script), + // then the current working directory is where your `package.json` resides, so `wdio` + // will be called from there. + // + specs: ['./workspaces/electron-e2e/**/*.spec.ts'], + // Patterns to exclude. + exclude: [ + // 'path/to/excluded/files' + ], + // + // ============ + // Capabilities + // ============ + // Define your capabilities here. WebdriverIO can run multiple capabilities at the same + // time. Depending on the number of capabilities, WebdriverIO launches several test + // sessions. Within your capabilities you can overwrite the spec and exclude options in + // order to group specific specs to a specific capability. + // + // First, you can define how many instances should be started at the same time. Let's + // say you have 3 different capabilities (Chrome, Firefox, and Safari) and you have + // set maxInstances to 1; wdio will spawn 3 processes. Therefore, if you have 10 spec + // files and you set maxInstances to 10, all spec files will get tested at the same time + // and 30 processes will get spawned. The property handles how many capabilities + // from the same test should run tests. + // + maxInstances: 10, + // + // If you have trouble getting all important capabilities together, check out the + // Sauce Labs platform configurator - a great tool to configure your capabilities: + // https://saucelabs.com/platform/platform-configurator + // + capabilities: [ + { + // maxInstances can get overwritten per capability. So if you have an in-house Selenium + // grid with only 5 firefox instances available you can make sure that not more than + // 5 instances get started at a time. + maxInstances: 5, + // + browserName: 'chrome', + acceptInsecureCerts: true, + 'goog:chromeOptions': { + binary: electronPath, + args: ['app=' + '.webpack/main/index.js'], + }, + // If outputDir is provided WebdriverIO can capture driver session logs + // it is possible to configure which logTypes to include/exclude. + // excludeDriverLogs: ['*'], // pass '*' to exclude all driver session logs + // excludeDriverLogs: ['bugreport', 'server'], + }, + ], + // + // =================== + // Test Configurations + // =================== + // Define all options that are relevant for the WebdriverIO instance here + // + // Level of logging verbosity: trace | debug | info | warn | error | silent + logLevel: 'info', + // + // Set specific log levels per logger + // loggers: + // - webdriver, webdriverio + // - @wdio/browserstack-service, @wdio/devtools-service, @wdio/sauce-service + // - @wdio/mocha-framework, @wdio/jasmine-framework + // - @wdio/local-runner + // - @wdio/sumologic-reporter + // - @wdio/cli, @wdio/config, @wdio/utils + // Level of logging verbosity: trace | debug | info | warn | error | silent + // logLevels: { + // webdriver: 'info', + // '@wdio/appium-service': 'info' + // }, + // + // If you only want to run your tests until a specific amount of tests have failed use + // bail (default is 0 - don't bail, run all tests). + bail: 0, + // + // Set a base URL in order to shorten url command calls. If your `url` parameter starts + // with `/`, the base url gets prepended, not including the path portion of your baseUrl. + // If your `url` parameter starts without a scheme or `/` (like `some/path`), the base url + // gets prepended directly. + baseUrl: 'http://localhost', + // + // Default timeout for all waitFor* commands. + waitforTimeout: 10000, + // + // Default timeout in milliseconds for request + // if browser driver or grid doesn't send response + connectionRetryTimeout: 120000, + // + // Default request retries count + connectionRetryCount: 3, + // + // Test runner services + // Services take over a specific job you don't want to take care of. They enhance + // your test setup with almost no effort. Unlike plugins, they don't add new + // commands. Instead, they hook themselves up into the test process. + services: ['chromedriver'], + // Framework you want to run your specs with. + // The following are supported: Mocha, Jasmine, and Cucumber + // see also: https://webdriver.io/docs/frameworks + // + // Make sure you have the wdio adapter package for the specific framework installed + // before running any tests. + framework: 'jasmine', + // + // The number of times to retry the entire specfile when it fails as a whole + // specFileRetries: 1, + // + // Delay in seconds between the spec file retry attempts + // specFileRetriesDelay: 0, + // + // Whether or not retried specfiles should be retried immediately or deferred to the end of the queue + // specFileRetriesDeferred: false, + // + // Test reporter for stdout. + // The only one supported by default is 'dot' + // see also: https://webdriver.io/docs/dot-reporter + reporters: ['spec', ['allure', { outputDir: 'allure-results' }]], + // + // Options to be passed to Jasmine. + jasmineOpts: { + // Jasmine default timeout + defaultTimeoutInterval: 60000, + // + // The Jasmine framework allows interception of each assertion in order to log the state of the application + // or website depending on the result. For example, it is pretty handy to take a screenshot every time + // an assertion fails. + expectationResultHandler: function (_passed, _assertion) { + // do something + }, + }, + // + // ===== + // Hooks + // ===== + // WebdriverIO provides several hooks you can use to interfere with the test process in order to enhance + // it and to build services around it. You can either apply a single function or an array of + // methods to it. If one of them returns with a promise, WebdriverIO will wait until that promise got + // resolved to continue. + /** + * Gets executed once before all workers get launched. + * @param {Object} config wdio configuration object + * @param {Array.} capabilities list of capabilities details + */ + // onPrepare: function (config, capabilities) { + // }, + /** + * Gets executed before a worker process is spawned and can be used to initialise specific service + * for that worker as well as modify runtime environments in an async fashion. + * @param {String} cid capability id (e.g 0-0) + * @param {[type]} caps object containing capabilities for session that will be spawn in the worker + * @param {[type]} specs specs to be run in the worker process + * @param {[type]} args object that will be merged with the main configuration once worker is initialized + * @param {[type]} execArgv list of string arguments passed to the worker process + */ + // onWorkerStart: function (cid, caps, specs, args, execArgv) { + // }, + /** + * Gets executed just after a worker process has exited. + * @param {String} cid capability id (e.g 0-0) + * @param {Number} exitCode 0 - success, 1 - fail + * @param {[type]} specs specs to be run in the worker process + * @param {Number} retries number of retries used + */ + // onWorkerEnd: function (cid, exitCode, specs, retries) { + // }, + /** + * Gets executed just before initialising the webdriver session and test framework. It allows you + * to manipulate configurations depending on the capability or spec. + * @param {Object} config wdio configuration object + * @param {Array.} capabilities list of capabilities details + * @param {Array.} specs List of spec file paths that are to be run + * @param {String} cid worker id (e.g. 0-0) + */ + // beforeSession: function (config, capabilities, specs, cid) { + // }, + /** + * Gets executed before test execution begins. At this point you can access to all global + * variables like `browser`. It is the perfect place to define custom commands. + * @param {Array.} capabilities list of capabilities details + * @param {Array.} specs List of spec file paths that are to be run + * @param {Object} browser instance of created browser/device session + */ + // before: function (capabilities, specs) { + // }, + /** + * Runs before a WebdriverIO command gets executed. + * @param {String} commandName hook command name + * @param {Array} args arguments that command would receive + */ + // beforeCommand: function (commandName, args) { + // }, + /** + * Hook that gets executed before the suite starts + * @param {Object} suite suite details + */ + beforeSuite: (_suite) => __awaiter(void 0, void 0, void 0, function* () { + yield waitUntilWindowLoaded(); + }), + /** + * Function to be executed before a test (in Mocha/Jasmine) starts. + */ + // beforeTest: function (test, context) { + // }, + /** + * Hook that gets executed _before_ a hook within the suite starts (e.g. runs before calling + * beforeEach in Mocha) + */ + // beforeHook: function (test, context) { + // }, + /** + * Hook that gets executed _after_ a hook within the suite starts (e.g. runs after calling + * afterEach in Mocha) + */ + // afterHook: function (test, context, { error, result, duration, passed, retries }) { + // }, + /** + * Function to be executed after a test (in Mocha/Jasmine only) + * @param {Object} test test object + * @param {Object} context scope object the test was executed with + * @param {Error} result.error error object in case the test fails, otherwise `undefined` + * @param {Any} result.result return object of test function + * @param {Number} result.duration duration of test + * @param {Boolean} result.passed true if test has passed, otherwise false + * @param {Object} result.retries informations to spec related retries, e.g. `{ attempts: 0, limit: 0 }` + */ + afterTest: function (_test, _context, result) { + return __awaiter(this, void 0, void 0, function* () { + // result = { _error, _result, _duration, passed, _retries } + if (!result.passed) { + yield browser.takeScreenshot(); + } + }); + }, + /** + * Hook that gets executed after the suite has ended + * @param {Object} suite suite details + */ + // afterSuite: async function (_suite) { + // }, + /** + * Runs after a WebdriverIO command gets executed + * @param {String} commandName hook command name + * @param {Array} args arguments that command would receive + * @param {Number} result 0 - command success, 1 - command error + * @param {Object} error error object if any + */ + // afterCommand: function (commandName, args, result, error) { + // }, + /** + * Gets executed after all tests are done. You still have access to all global variables from + * the test. + * @param {Number} result 0 - test pass, 1 - test fail + * @param {Array.} capabilities list of capabilities details + * @param {Array.} specs List of spec file paths that ran + */ + after: (_result, _capabilities, _specs) => __awaiter(void 0, void 0, void 0, function* () { + yield closeApplication(); + }), + /** + * Gets executed right after terminating the webdriver session. + * @param {Object} config wdio configuration object + * @param {Array.} capabilities list of capabilities details + * @param {Array.} specs List of spec file paths that ran + */ + // afterSession: function (config, capabilities, specs) { + // }, + /** + * Gets executed after all workers got shut down and the process is about to exit. An error + * thrown in the onComplete hook will result in the test run failing. + * @param {Object} exitCode 0 - success, 1 - fail + * @param {Object} config wdio configuration object + * @param {Array.} capabilities list of capabilities details + * @param {} results object containing test results + */ + // onComplete: function(_exitCode, _config, _capabilities, _results) { + // }, + /** + * Gets executed when a refresh happens. + * @param {String} oldSessionId session ID of the old session + * @param {String} newSessionId session ID of the new session + */ + // onReload: function(oldSessionId, newSessionId) { + // } }; -//# sourceMappingURL=webdriverio.config.js.map +//# sourceMappingURL=webdriverio.config.js.map \ No newline at end of file diff --git a/workspaces/electron-app/main/services/door-service.ts b/workspaces/electron-app/main/services/door-service.ts index fd1215a..a71b0c0 100644 --- a/workspaces/electron-app/main/services/door-service.ts +++ b/workspaces/electron-app/main/services/door-service.ts @@ -19,19 +19,37 @@ export class DoorService extends AbstractService { const workingSheet = workbook.Sheets['DEURLIJST']; const doorList: Door[] = []; - // remove 2 top rows + + const headers: any = {}; + // get header values + for (let index = 65; index <= 90; index++) { + const currentValue = workingSheet[`${String.fromCodePoint(index)}3`]?.v; + switch(currentValue) { + case 'L/R': this.setObjectWithChar(headers, 'lr', index); break; + case 'KRUK/\r\nSLOT': this.setObjectWithChar(headers, 'krukSlot', index); break; + case 'SCHARNIER': this.setObjectWithChar(headers, 'pivot', index); break; + case 'SOORT DEUR': this.setObjectWithChar(headers, 'type', index); break; + case 'MODEL\r\nKRUK': this.setObjectWithChar(headers, 'modelKruk', index); break; + case 'OPMERKING': this.setObjectWithChar(headers, 'remark', index); break; + default: break; + } + } + + // get max records + const maxRecords = Number.parseInt(workingSheet['!ref'].split(':')[1].replace(/[A-Z]*/g, '')); + // stop at 19 - for (let index = 4; index < 19; index++) { + for (let index = 4; index < maxRecords; index++) { const door: Door = {}; door.nr = workingSheet[`A${index}`]?.v; if (door.nr) { - door.lr = workingSheet[`H${index}`]?.v; - door.krukSlot = workingSheet[`K${index}`]?.v; - door.pivot = workingSheet[`Q${index}`]?.v; - door.type = workingSheet[`S${index}`]?.v; - door.modelKruk = workingSheet[`T${index}`]?.v; - door.remark = workingSheet[`U${index}`]?.v; + door.lr = workingSheet[`${headers['lr']}${index}`]?.v; + door.krukSlot = workingSheet[`${headers['krukSlot']}${index}`]?.v; + door.pivot = workingSheet[`${headers['pivot']}${index}`]?.v; + door.type = workingSheet[`${headers['type']}${index}`]?.v; + door.modelKruk = workingSheet[`${headers['modelKruk']}${index}`]?.v; + door.remark = workingSheet[`${headers['remark']}${index}`]?.v; doorList.push(door); } @@ -40,4 +58,8 @@ export class DoorService extends AbstractService { resolve(doorList); }); } + + private setObjectWithChar(object: any, key: string, value: number) { + object[key] = String.fromCodePoint(value); + } }