How to use launchapp method in pyatom

Best Python code snippet using pyatom_python

Device.test.js

Source:Device.test.js Github

copy

Full Screen

1const configurationsMock = require('../configurations.mock');2const path = require('path');3const validScheme = configurationsMock.validOneDeviceAndSession;4const invalidDeviceNoBinary = configurationsMock.invalidDeviceNoBinary;5const invalidDeviceNoDeviceName = configurationsMock.invalidDeviceNoDeviceName;6describe('Device', () => {7 let fs;8 let DeviceDriverBase;9 let SimulatorDriver;10 let Device;11 let device;12 let argparse;13 let sh;14 let Client;15 let client;16 let logger;17 let logError;18 beforeEach(async () => {19 jest.mock('fs');20 jest.mock('../utils/logger');21 fs = require('fs');22 logger = require('../utils/logger');23 Device = require('./Device');24 jest.mock('../utils/sh');25 sh = require('../utils/sh');26 sh.cp = jest.fn();27 jest.mock('../client/Client');28 jest.mock('../utils/argparse');29 argparse = require('../utils/argparse');30 jest.mock('./drivers/DeviceDriverBase');31 DeviceDriverBase = require('./drivers/DeviceDriverBase');32 SimulatorDriver = require('./drivers/SimulatorDriver');33 Client = require('../client/Client');34 client = new Client(validScheme.session);35 await client.connect();36 });37 function schemeDevice(scheme, configuration) {38 const device = new Device({39 deviceConfig: scheme.configurations[configuration],40 deviceDriver: new DeviceDriverBase(client),41 sessionConfig: scheme.session,42 });43 fs.existsSync.mockReturnValue(true);44 device.deviceDriver.defaultLaunchArgsPrefix.mockReturnValue('-');45 device.deviceDriver.acquireFreeDevice.mockReturnValue('mockDeviceId');46 return device;47 }48 function validDevice() {49 return schemeDevice(validScheme, 'ios.sim.release')50 }51 it(`valid scheme, no binary, should throw`, async () => {52 device = validDevice();53 fs.existsSync.mockReturnValue(false);54 try {55 await device.prepare();56 fail('should throw')57 } catch (ex) {58 expect(ex.message).toMatch(/app binary not found at/)59 }60 });61 it(`valid scheme, no binary, should not throw`, async () => {62 device = validDevice();63 await device.prepare();64 });65 it(`prepare() with when reuse is enabled should not uninstall and install`, async () => {66 device = validDevice();67 fs.existsSync.mockReturnValue(true);68 argparse.getArgValue.mockReturnValue(true);69 await device.prepare();70 expect(device.deviceDriver.uninstallApp).not.toHaveBeenCalled();71 expect(device.deviceDriver.installApp).not.toHaveBeenCalled();72 });73 it(`launchApp() should launch app with default launch args`, async () => {74 device = validDevice();75 await device.launchApp();76 expect(device.deviceDriver.launchApp).toHaveBeenCalledWith(device._deviceId,77 device._bundleId,78 {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test"}, undefined);79 });80 it('launchApp({languageAndLocale}) should launch app with a specific language/locale', async () => {81 device = validDevice();82 const languageAndLocale = {83 language: 'es-MX',84 locale: 'es-MX'85 };86 await device.launchApp({languageAndLocale});87 expect(device.deviceDriver.launchApp).toHaveBeenCalledWith(device._deviceId,88 device._bundleId,89 {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test"}, languageAndLocale);90 });91 it(`relaunchApp()`, async () => {92 device = validDevice();93 await device.relaunchApp();94 expect(device.deviceDriver.terminate).toHaveBeenCalled();95 expect(device.deviceDriver.launchApp).toHaveBeenCalledWith(device._deviceId,96 device._bundleId,97 {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test"}, undefined);98 });99 it(`relaunchApp({newInstance: false}) should not terminate the app before launch`, async () => {100 device = validDevice();101 await device.relaunchApp({newInstance: false});102 expect(device.deviceDriver.terminate).not.toHaveBeenCalled();103 });104 it(`relaunchApp({newInstance: true}) should terminate the app before launch`, async () => {105 device = validDevice();106 await device.relaunchApp({newInstance: true});107 expect(device.deviceDriver.terminate).toHaveBeenCalled();108 });109 it(`relaunchApp() (no params) should terminate the app before launch - backwards compat`, async () => {110 device = validDevice();111 await device.relaunchApp();112 expect(device.deviceDriver.terminate).toHaveBeenCalled();113 });114 it(`relaunchApp() with delete=true`, async () => {115 device = validDevice();116 fs.existsSync.mockReturnValue(true);117 await device.relaunchApp({delete: true});118 expect(device.deviceDriver.uninstallApp).toHaveBeenCalled();119 expect(device.deviceDriver.installApp).toHaveBeenCalled();120 expect(device.deviceDriver.launchApp).toHaveBeenCalledWith(device._deviceId,121 device._bundleId,122 {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test"}, undefined);123 });124 it(`relaunchApp() without delete when reuse is enabled should not uninstall and install`, async () => {125 device = validDevice();126 argparse.getArgValue.mockReturnValue(true);127 fs.existsSync.mockReturnValue(true);128 await device.relaunchApp();129 expect(device.deviceDriver.uninstallApp).not.toHaveBeenCalled();130 expect(device.deviceDriver.installApp).not.toHaveBeenCalled();131 expect(device.deviceDriver.launchApp).toHaveBeenCalledWith(device._deviceId,132 device._bundleId,133 {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test"}, undefined);134 });135 it(`relaunchApp() with url should send the url as a param in launchParams`, async () => {136 device = await validDevice();137 await device.relaunchApp({url: `scheme://some.url`});138 expect(device.deviceDriver.launchApp).toHaveBeenCalledWith(device._deviceId,139 device._bundleId,140 {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test", "-detoxURLOverride": "scheme://some.url"}, undefined);141 });142 it(`relaunchApp() with url should send the url as a param in launchParams`, async () => {143 device = await validDevice();144 await device.relaunchApp({url: `scheme://some.url`, sourceApp: 'sourceAppBundleId'});145 expect(device.deviceDriver.launchApp).toHaveBeenCalledWith(device._deviceId,146 device._bundleId,147 {148 "-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test", "-detoxURLOverride": "scheme://some.url", "-detoxSourceAppOverride":149 "sourceAppBundleId"150 }, undefined);151 });152 it(`launchApp() with disableTouchIndicators should send a boolean switch as a param in launchParams`, async () => {153 device = await validDevice();154 await device.launchApp({disableTouchIndicators: true});155 expect(device.deviceDriver.launchApp).toHaveBeenCalledWith(device._deviceId,156 device._bundleId,157 {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test", "-detoxDisableTouchIndicators": true}, undefined);158 });159 it(`relaunchApp() with userNofitication should send the userNotification as a param in launchParams`, async () => {160 device = validDevice();161 fs.existsSync.mockReturnValue(true);162 device.deviceDriver.createPayloadFile = jest.fn(() => 'url');163 await device.relaunchApp({userNotification: 'json'});164 expect(device.deviceDriver.launchApp).toHaveBeenCalledWith(device._deviceId,165 device._bundleId,166 {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test", "-detoxUserNotificationDataURL": "url"}, undefined);167 });168 it(`relaunchApp() with url and userNofitication should throw`, async () => {169 device = validDevice();170 try {171 await device.relaunchApp({url: "scheme://some.url", userNotification: 'notif'});172 fail('should fail');173 } catch (ex) {174 expect(ex).toBeDefined();175 }176 });177 it(`relaunchApp() with permissions should send trigger setpermissions before app starts`, async () => {178 device = await validDevice();179 await device.relaunchApp({permissions: {calendar: "YES"}});180 expect(device.deviceDriver.setPermissions).toHaveBeenCalledWith(device._deviceId,181 device._bundleId, {calendar: "YES"});182 });183 it(`launchApp({launchArgs: }) should pass to native as launch args`, async () => {184 device = validDevice();185 await device.launchApp({launchArgs: {arg1: "1", arg2: 2}});186 expect(device.deviceDriver.launchApp).toHaveBeenCalledWith(device._deviceId,187 device._bundleId,188 {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test", "-arg1": "1", "-arg2": 2}, undefined);189 });190 it(`sendToHome() should pass to device driver`, async () => {191 device = validDevice();192 await device.sendToHome();193 expect(device.deviceDriver.sendToHome).toHaveBeenCalledTimes(1);194 });195 it(`shake() should pass to device driver`, async () => {196 device = validDevice();197 await device.shake();198 expect(device.deviceDriver.shake).toHaveBeenCalledTimes(1);199 });200 it(`terminateApp() should pass to device driver`, async () => {201 device = validDevice();202 await device.terminateApp();203 expect(device.deviceDriver.terminate).toHaveBeenCalledTimes(1);204 });205 it(`installApp() with a custom app path should use custom app path`, async () => {206 device = validDevice();207 fs.existsSync.mockReturnValue(true);208 await device.installApp('newAppPath');209 expect(device.deviceDriver.installApp).toHaveBeenCalledWith(device._deviceId, 'newAppPath', undefined);210 });211 it(`installApp() with a custom test app path should use custom test app path`, async () => {212 device = validDevice();213 fs.existsSync.mockReturnValue(true);214 await device.installApp('newAppPath', 'newTestAppPath');215 expect(device.deviceDriver.installApp).toHaveBeenCalledWith(device._deviceId, 'newAppPath', 'newTestAppPath');216 });217 it(`installApp() with no params should use the default path given in configuration`, async () => {218 device = validDevice();219 await device.installApp();220 expect(device.deviceDriver.installApp).toHaveBeenCalledWith(device._deviceId, device._binaryPath, device._testBinaryPath);221 });222 it(`uninstallApp() with a custom app path should use custom app path`, async () => {223 device = validDevice();224 fs.existsSync.mockReturnValue(true);225 await device.uninstallApp('newBundleId');226 expect(device.deviceDriver.uninstallApp).toHaveBeenCalledWith(device._deviceId, 'newBundleId');227 });228 it(`uninstallApp() with no params should use the default path given in configuration`, async () => {229 device = validDevice();230 await device.uninstallApp();231 expect(device.deviceDriver.uninstallApp).toHaveBeenCalledWith(device._deviceId, device._binaryPath);232 });233 it(`shutdown() should pass to device driver`, async () => {234 device = validDevice();235 await device.shutdown();236 expect(device.deviceDriver.shutdown).toHaveBeenCalledTimes(1);237 });238 it(`openURL({url:url}) should pass to device driver`, async () => {239 device = validDevice();240 await device.openURL({url: 'url'});241 expect(device.deviceDriver.deliverPayload).toHaveBeenCalledWith({url: 'url'});242 });243 it(`openURL(notAnObject) should pass to device driver`, async () => {244 device = validDevice();245 try {246 await device.openURL('url');247 fail('should throw');248 } catch (ex) {249 expect(ex).toBeDefined();250 }251 });252 it(`reloadReactNative() should pass to device driver`, async () => {253 device = validDevice();254 await device.reloadReactNative();255 expect(device.deviceDriver.reloadReactNative).toHaveBeenCalledTimes(1);256 });257 it(`setOrientation() should pass to device driver`, async () => {258 device = validDevice();259 await device.setOrientation('param');260 expect(device.deviceDriver.setOrientation).toHaveBeenCalledWith(device._deviceId, 'param');261 });262 it(`sendUserNotification() should pass to device driver`, async () => {263 device = validDevice();264 await device.sendUserNotification('notif');265 expect(device.deviceDriver.createPayloadFile).toHaveBeenCalledTimes(1);266 expect(device.deviceDriver.deliverPayload).toHaveBeenCalledTimes(1);267 });268 it(`sendUserActivity() should pass to device driver`, async () => {269 device = validDevice();270 await device.sendUserActivity('notif');271 expect(device.deviceDriver.createPayloadFile).toHaveBeenCalledTimes(1);272 expect(device.deviceDriver.deliverPayload).toHaveBeenCalledTimes(1);273 });274 it(`setLocation() should pass to device driver`, async () => {275 device = validDevice();276 await device.setLocation(30.1, 30.2);277 expect(device.deviceDriver.setLocation).toHaveBeenCalledWith(device._deviceId, '30.1', '30.2');278 });279 it(`setURLBlacklist() should pass to device driver`, async () => {280 device = validDevice();281 await device.setURLBlacklist();282 expect(device.deviceDriver.setURLBlacklist).toHaveBeenCalledTimes(1);283 });284 it(`enableSynchronization() should pass to device driver`, async () => {285 device = validDevice();286 await device.enableSynchronization();287 expect(device.deviceDriver.enableSynchronization).toHaveBeenCalledTimes(1);288 });289 it(`disableSynchronization() should pass to device driver`, async () => {290 device = validDevice();291 await device.disableSynchronization();292 expect(device.deviceDriver.disableSynchronization).toHaveBeenCalledTimes(1);293 });294 it(`resetContentAndSettings() should pass to device driver`, async () => {295 device = validDevice();296 await device.resetContentAndSettings();297 expect(device.deviceDriver.resetContentAndSettings).toHaveBeenCalledTimes(1);298 });299 it(`getPlatform() should pass to device driver`, async () => {300 device = validDevice();301 device.getPlatform();302 expect(device.deviceDriver.getPlatform).toHaveBeenCalledTimes(1);303 });304 it(`_cleanup() should pass to device driver`, async () => {305 device = validDevice();306 await device._cleanup();307 expect(device.deviceDriver.cleanup).toHaveBeenCalledTimes(1);308 });309 it(`new Device() with invalid device config (no binary) should throw`, () => {310 expect(() => new Device({311 deviceConfig: invalidDeviceNoBinary.configurations['ios.sim.release'],312 deviceDriver: new SimulatorDriver(client),313 sessionConfig: validScheme.session,314 })).toThrowErrorMatchingSnapshot();315 });316 it(`new Device() with invalid device config (no device name) should throw`, () => {317 expect(() => new Device({318 deviceConfig: invalidDeviceNoDeviceName.configurations['ios.sim.release'],319 deviceDriver: new SimulatorDriver(client),320 sessionConfig: validScheme.session,321 })).toThrowErrorMatchingSnapshot();322 });323 it(`launchApp({newInstance: false}) should check if process is in background and reopen it`, async () => {324 const processId = 1;325 device = validDevice();326 device.deviceDriver.getBundleIdFromBinary.mockReturnValue('test.bundle');327 device.deviceDriver.launchApp.mockReturnValue(processId);328 await device.prepare({launchApp: true});329 await device.launchApp({newInstance: false});330 expect(device.deviceDriver.deliverPayload).not.toHaveBeenCalled();331 });332 it(`launchApp({url: url}) should check if process is in background and use openURL() instead of launch args`, async () => {333 const processId = 1;334 device = validDevice();335 device.deviceDriver.getBundleIdFromBinary.mockReturnValue('test.bundle');336 device.deviceDriver.launchApp.mockReturnValue(processId);337 await device.prepare({launchApp: true});338 await device.launchApp({url: 'url://me'});339 expect(device.deviceDriver.deliverPayload).toHaveBeenCalledTimes(1);340 });341 it(`launchApp({url: url}) should check if process is in background and if not use launch args`, async () => {342 const launchParams = {url: 'url://me'};343 const processId = 1;344 const newProcessId = 2;345 device = validDevice();346 device.deviceDriver.getBundleIdFromBinary.mockReturnValue('test.bundle');347 device.deviceDriver.launchApp.mockReturnValueOnce(processId).mockReturnValueOnce(newProcessId);348 await device.prepare();349 await device.launchApp(launchParams);350 expect(device.deviceDriver.deliverPayload).not.toHaveBeenCalled();351 });352 it(`launchApp({url: url}) should check if process is in background and use openURL() instead of launch args`, async () => {353 const launchParams = {url: 'url://me'};354 const processId = 1;355 device = validDevice();356 device.deviceDriver.getBundleIdFromBinary.mockReturnValue('test.bundle');357 device.deviceDriver.launchApp.mockReturnValue(processId);358 await device.prepare({launchApp: true});359 await device.launchApp(launchParams);360 expect(device.deviceDriver.deliverPayload).toHaveBeenCalledWith({delayPayload: true, url: 'url://me'});361 });362 it('launchApp({userActivity: userActivity}) should check if process is in background and if it is use deliverPayload', async () => {363 const launchParams = {userActivity: 'userActivity'};364 const processId = 1;365 device = validDevice();366 device.deviceDriver.getBundleIdFromBinary.mockReturnValue('test.bundle');367 device.deviceDriver.launchApp.mockReturnValueOnce(processId).mockReturnValueOnce(processId);368 device.deviceDriver.createPayloadFile = () => 'url';369 await device.prepare({launchApp: true});370 await device.launchApp(launchParams);371 expect(device.deviceDriver.deliverPayload).toHaveBeenCalledWith({delayPayload: true, detoxUserActivityDataURL: 'url'});372 });373 it('launchApp({userNotification: userNotification}) should check if process is in background and if it is use deliverPayload', async () => {374 const launchParams = {userNotification: 'notification'};375 const processId = 1;376 device = validDevice();377 device.deviceDriver.getBundleIdFromBinary.mockReturnValue('test.bundle');378 device.deviceDriver.launchApp.mockReturnValueOnce(processId).mockReturnValueOnce(processId);379 device.deviceDriver.createPayloadFile = () => 'url';380 await device.prepare({launchApp: true});381 await device.launchApp(launchParams);382 expect(device.deviceDriver.deliverPayload).toHaveBeenCalledTimes(1);383 });384 it(`launchApp({userNotification: userNotification}) should check if process is in background and if not use launch args`, async () => {385 const launchParams = {userNotification: 'notification'};386 const processId = 1;387 const newProcessId = 2;388 device = validDevice();389 device.deviceDriver.getBundleIdFromBinary.mockReturnValue('test.bundle');390 device.deviceDriver.launchApp.mockReturnValueOnce(processId).mockReturnValueOnce(newProcessId);391 await device.prepare();392 await device.launchApp(launchParams);393 expect(device.deviceDriver.deliverPayload).not.toHaveBeenCalled();394 });395 it(`launchApp({userNotification: userNotification, url: url}) should fail`, async () => {396 const launchParams = {userNotification: 'notification', url: 'url://me'};397 const processId = 1;398 device = validDevice();399 device.deviceDriver.getBundleIdFromBinary.mockReturnValue('test.bundle');400 device.deviceDriver.launchApp.mockReturnValueOnce(processId).mockReturnValueOnce(processId);401 await device.prepare();402 try {403 await device.launchApp(launchParams);404 fail('should throw');405 } catch (ex) {406 expect(ex).toBeDefined();407 }408 expect(device.deviceDriver.deliverPayload).not.toHaveBeenCalled();409 });410 async function launchAndTestBinaryPath(configuration) {411 const device = schemeDevice(configurationsMock.pathsTests, configuration);412 await device.prepare();413 await device.launchApp();414 return device.deviceDriver.installApp.mock.calls[0][1];415 }416 it(`should accept absolute path for binary`, async () => {417 const actualPath = await launchAndTestBinaryPath('absolutePath');418 expect(actualPath).toEqual(process.platform === 'win32' ? 'C:\\Temp\\abcdef\\123' : '/tmp/abcdef/123');419 });420 it(`should accept relative path for binary`, async () => {421 const actualPath = await launchAndTestBinaryPath('relativePath');422 expect(actualPath).toEqual(path.join(process.cwd(), 'abcdef/123'));423 });424 it(`pressBack() should be called`, async () => {425 device = validDevice();426 await device.pressBack();427 expect(device.deviceDriver.pressBack).toHaveBeenCalledWith(device._deviceId);428 });...

Full Screen

Full Screen

server.js

Source:server.js Github

copy

Full Screen

1const inquirer = require("inquirer");2const table = require("console.table");3const mysql = require("mysql2");4//Establish connection to database5const db = mysql.createConnection(6 {7 host: "localhost",8 // MySQL username9 user: "root",10 //MySQL password11 password: "password",12 //Database being connected to13 database: "tracker_db",14 },15 console.log(`Connected to the employee tracker database.`)16);17db.connect(function (err) {18 if (err) throw err;19});20//Initialize the app21function launchApp() {22 inquirer23 .prompt([24 {25 type: "list",26 name: "userSelect",27 message:28 "Welcome to your employee database! Please select an option below.",29 choices: [30 "View All Employees",31 "Add an Employee",32 "Update Employee Role",33 "View All Departments",34 "View All Roles",35 "Add a Department",36 "Add a Role",37 "Exit",38 ],39 },40 ])41 .then((answer) => {42 console.log(answer);43 switch (answer.userSelect) {44 case "View All Employees":45 viewEmployee();46 break;47 case "Add an Employee":48 addEmployee();49 break;50 case "Update Employee Role":51 updateRole();52 break;53 case "View All Roles":54 viewRoles();55 break;56 case "View All Departments":57 viewDepartment();58 break;59 case "Add a Department":60 addDepartment();61 break;62 case "Add a Role":63 addRole();64 break;65 case "Exit":66 console.log("Goodbye!");67 db.end();68 break;69 }70 });71 function viewEmployee() {72 let query = "SELECT * FROM employee";73 db.query(query, function (err, res) {74 if (err) throw err;75 console.log(res.length + " employees are currently employed!");76 console.table("Here are all employees:", res);77 launchApp();78 });79 }80 //Enter new employee information and add to employee table81 function addEmployee() {82 db.query("SELECT * FROM role", function (err, res) {83 if (err) throw err;84 inquirer85 .prompt([86 {87 name: "first_name",88 type: "input",89 message: "What is the employee's fist name? ",90 },91 {92 name: "last_name",93 type: "input",94 message: "What is the employee's last name? ",95 },96 {97 name: "manager_id",98 type: "input",99 message: "What is the employee's manager's ID? ",100 },101 {102 name: "role",103 type: "list",104 choices: function () {105 var roleArray = [];106 for (let i = 0; i < res.length; i++) {107 roleArray.push(res[i].title);108 }109 return roleArray;110 },111 message: "What is this employee's role? ",112 },113 ])114 .then(function (answer) {115 let role_id;116 for (let a = 0; a < res.length; a++) {117 if (res[a].title == answer.role) {118 role_id = res[a].id;119 console.log(role_id);120 }121 }122 db.query(123 "INSERT INTO employee SET ?",124 {125 first_name: answer.first_name,126 last_name: answer.last_name,127 manager_id: answer.manager_id,128 role_id: role_id,129 },130 function (err) {131 if (err) throw err;132 console.table(res);133 console.log("Your employee has been added!");134 launchApp();135 }136 );137 });138 });139 }140 //Add a department to department table141 function addDepartment() {142 inquirer143 .prompt([144 {145 name: "newDept",146 type: "input",147 message: "What is the name of the department?",148 },149 ])150 .then(function (answer) {151 db.query("INSERT INTO department SET ?", {152 name: answer.newDept,153 });154 let query = "SELECT * FROM department";155 db.query(query, function (err, res) {156 if (err) throw err;157 console.log("Your new department has been added!");158 console.table("All Departments:", res);159 launchApp();160 });161 });162 }163 //Add a new role to role table164 function addRole() {165 db.query("SELECT * FROM department", function (err, res) {166 if (err) throw err;167 inquirer168 .prompt([169 {170 name: "new_role",171 type: "input",172 message: "What new role would you like to add?",173 },174 {175 name: "salary",176 type: "input",177 message: "What is the salary of this role? (Enter a number)",178 },179 {180 name: "Department",181 type: "list",182 choices: function () {183 let deptArray = [];184 for (let i = 0; i < res.length; i++) {185 deptArray.push(res[i].name);186 }187 return deptArray;188 },189 },190 ])191 .then(function (answer) {192 let department_id;193 for (let a = 0; a < res.length; a++) {194 if (res[a].name == answer.Department) {195 department_id = res[a].id;196 }197 }198 db.query(199 "INSERT INTO role SET ?",200 {201 title: answer.new_role,202 salary: answer.salary,203 department_id: department_id,204 },205 function (err, res) {206 if (err) throw err;207 console.log("Your new role has been added!");208 console.table("All Roles:", res);209 launchApp();210 }211 );212 });213 });214 }215 //View all departments216 function viewDepartment() {217 let query = "SELECT * FROM department";218 db.query(query, function (err, res) {219 if (err) throw err;220 console.table("All Departments:", res);221 launchApp();222 });223 }224 //View all roles225 function viewRoles() {226 let query = "SELECT * FROM role";227 db.query(query, function (err, res) {228 if (err) throw err;229 console.table("All Roles:", res);230 launchApp();231 });232 }233 //Update a current role234 function updateRole() {235 let query = "UPDATE employee SET role_id = ? WHERE id = ?";236 db.query(237 `SELECT CONCAT(first_name," ",last_name) AS nameOfEmployee, id FROM employee;`,238 function (errEmployee, resEmployee) {239 if (errEmployee) throw errEmployee;240 db.query("Select title, id FROM role", function (errRole, resRole) {241 if (errRole) throw errRole;242 inquirer243 .prompt([244 {245 name: "nameOfEmployee",246 type: "list",247 message: "Select employee.",248 choices: resEmployee.map((employee) => {249 return {250 name: employee.nameOfEmployee,251 value: employee.id,252 };253 }),254 },255 {256 name: "employeeRole",257 type: "list",258 message: "Select employee's new role.",259 choices: resRole.map((role) => {260 return {261 name: role.title,262 value: role.id,263 };264 }),265 },266 ])267 .then(function (answer) {268 db.query(269 "UPDATE employee SET role_id = ? WHERE id = ?",270 [answer.employeeRole, answer.nameOfEmployee],271 function (err) {272 if (err) throw err;273 console.log("Employee role has been updated!");274 launchApp();275 }276 );277 });278 });279 }280 );281 }282}...

Full Screen

Full Screen

06.device.test.js

Source:06.device.test.js Github

copy

Full Screen

1describe('Device', () => {2 it('reloadReactNative - should tap successfully', async () => {3 await device.reloadReactNative();4 await element(by.text('Sanity')).tap();5 await element(by.text('Say Hello')).tap();6 await expect(element(by.text('Hello!!!'))).toBeVisible();7 });8 it('relaunchApp - should tap successfully', async () => {9 await device.relaunchApp();10 await element(by.text('Sanity')).tap();11 await element(by.text('Say Hello')).tap();12 await expect(element(by.text('Hello!!!'))).toBeVisible();13 });14 it('relaunchApp({delete: true}) - should tap successfully', async () => {15 await device.relaunchApp({delete: true});16 await element(by.text('Sanity')).tap();17 await element(by.text('Say Hello')).tap();18 await expect(element(by.text('Hello!!!'))).toBeVisible();19 });20 it('uninstall() + install() + relaunch() - should tap successfully', async () => {21 await device.uninstallApp();22 await device.installApp();23 await device.relaunchApp();24 await element(by.text('Sanity')).tap();25 await element(by.text('Say Hello')).tap();26 await expect(element(by.text('Hello!!!'))).toBeVisible();27 });28 it('launchApp({newInstance: true}) + sendToHome() + launchApp() - should bring up previous instance', async () => {29 await device.launchApp({newInstance: true});30 await element(by.text('Sanity')).tap();31 await element(by.text('Say Hello')).tap();32 await device.sendToHome();33 await device.launchApp();34 await expect(element(by.text('Hello!!!'))).toBeVisible();35 });36 // // Passing on iOS, not implemented on Android37 // it('launchApp in a different language', async () => {38 // let languageAndLocale = {39 // language: "es-MX",40 // locale: "es-MX"41 // };42 // await device.launchApp({newInstance: true, languageAndLocale});43 // await element(by.text('Language')).tap();44 // await expect(element(by.text(`Current locale: ${languageAndLocale.locale}`))).toBeVisible();45 // await expect(element(by.text(`Current language: ${languageAndLocale.language}`))).toBeVisible();46 // languageAndLocale = {47 // language: "en-US",48 // locale: "en-US"49 // };50 // await device.launchApp({newInstance: true, languageAndLocale});51 // await element(by.text('Language')).tap();52 // await expect(element(by.text(`Current locale: ${languageAndLocale.locale}`))).toBeVisible();53 // await expect(element(by.text(`Current language: ${languageAndLocale.language}`))).toBeVisible();54 // });55 it('resetContentAndSettings() + install() + relaunch() - should tap successfully', async () => {56 await device.resetContentAndSettings();57 await device.installApp();58 await device.launchApp({ newInstance: true });59 await element(by.text('Sanity')).tap();60 await element(by.text('Say Hello')).tap();61 await expect(element(by.text('Hello!!!'))).toBeVisible();62 });63 it(':ios: shake() should shake screen', async () => {64 await device.reloadReactNative();65 await element(by.text('Shake')).tap();66 await device.shake();67 await expect(element(by.text('Shaken, not stirred'))).toBeVisible();68 });69 it(':android: device back button - should show popup back pressed when back button is pressed', async () => {70 await device.reloadReactNative();71 await element(by.text('Actions')).tap();72 await device.pressBack();73 await expect(element(by.text('Back pressed !'))).toBeVisible();74 });...

Full Screen

Full Screen

11.user-notifications.test.js

Source:11.user-notifications.test.js Github

copy

Full Screen

1describe(':ios: User Notifications', () => {2 it('Init from push notification', async () => {3 await device.launchApp({newInstance: true, userNotification: userNotificationPushTrigger});4 await expect(element(by.text('From push'))).toBeVisible();5 });6 xit('Init from calendar notification', async () => {7 await device.launchApp({newInstance: true, userNotification: userNotificationCalendarTrigger});8 await expect(element(by.text('From calendar'))).toBeVisible();9 });10 it('Background push notification', async () => {11 await device.launchApp({newInstance: true});12 await device.sendToHome();13 await device.launchApp({newInstance: false, userNotification: userNotificationPushTrigger});14 await expect(element(by.text('From push'))).toBeVisible();15 });16 it('Background calendar notification', async () => {17 await device.launchApp({newInstance: true});18 await device.sendToHome();19 await device.launchApp({newInstance: false, userNotification: userNotificationCalendarTrigger});20 await expect(element(by.text('From calendar'))).toBeVisible();21 });22 it('Foreground push notifications', async () => {23 await device.launchApp({newInstance: true});24 await device.sendUserNotification(userNotificationCalendarTrigger);25 await expect(element(by.text('From calendar'))).toBeVisible();26 });27 it('Foreground calendar notifications', async () => {28 await device.launchApp({newInstance: true});29 await device.sendUserNotification(userNotificationCalendarTrigger);30 await expect(element(by.text('From calendar'))).toBeVisible();31 });32});33const userNotificationPushTrigger = {34 "trigger": {35 "type": "push"36 },37 "title": "From push",38 "subtitle": "Subtitle",39 "body": "Body",40 "badge": 1,41 "payload": {42 "key1": "value1",43 "key2": "value2"44 },45 "category": "com.example.category",46 "content-available": 0,47 "action-identifier": "default"48};49const userNotificationCalendarTrigger = {50 "trigger": {51 "type": "calendar",52 "date-components": {53 "era": 1,54 "year": 2017,55 "month": 1,56 "day": 1,57 "hour": 0,58 "minute": 0,59 "second": 0,60 "weekday": 0,61 "weekdayOrdinal": 0,62 "quarter": 1,63 "weekOfMonth": 1,64 "weekOfYear": 1,65 "leapMonth": false66 },67 "repeats": true68 },69 "title": "From calendar",70 "subtitle": "Subtitle",71 "body": "From calendar",72 "badge": 1,73 "payload": {74 "key1": "value1",75 "key2": "value2"76 },77 "category": "com.example.category",78 "user-text": "Hi there!",79 "content-available": 0,80 "action-identifier": "default"...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pyatom automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful