How to use onFinish method in cavy

Best JavaScript code snippet using cavy

Database.ts

Source:Database.ts Github

copy

Full Screen

...19 var Salt = Security.CreateSalt()20 Database.query(`INSERT INTO authusers(ID, HashedPassword, Salt, SessionID, SignupDate)21 VALUES(${Database.escape(ID)}, '${Security.EncryptPassword(Password, Salt)}', '${Salt}', '', NOW());`, (err, rows, fields) => {22 if (!err) { //오류가 없다면23 onFinish(TaskCode.SUCCESS_WORK) //작업 완료24 } else { //오류 발생 시25 console.log(err)26 onFinish(TaskCode.ERR_DATABASE_UNKNOWN) //알 수 없는 오류27 }28 29 })30 } else { onFinish(TaskCode.ERR_SIGNUP_EXISTS_ACCOUNT) } //일치하는 ID가 이미 있다면31 })32 })33 }34 //로그인 쿼리35 static Signin(ID: string, Password: string, onFinish: (code: TaskCode, newSessionID: string) => any) {36 const Pool = getPool()37 Pool.getConnection((poolErr, Database) => {38 Database.query(`SELECT * FROM authusers WHERE ID=${Database.escape(ID)};`, (err, rows, fields) => {39 if (!err && (rows as any).length == 1) {40 console.log(err)41 var FoundUser = (rows as any)[0]42 var LoginResult: boolean = (FoundUser.HashedPassword == Security.EncryptPassword(Password, FoundUser.Salt))43 if (LoginResult) { //로그인 성공 시44 var SessionID: string = Security.CreateSessionID()45 Database.query(`UPDATE authusers SET SessionID='${SessionID}' WHERE ID=${Database.escape(ID)};`, (err, rows, fields) => {46 console.log(err)47 if (!err) { //새로운 세션 ID 발급 시48 onFinish(TaskCode.SUCCESS_WORK, SessionID)49 50 return51 }52 })53 } else if (!LoginResult) { //페스워드가 틀릴 경우(* 경고 : 페스워드 오류와 일치하는 계정 없음 오류는 보안을 위해 클라이언트에서 하나의 오류로 표시할 것!)54 onFinish(TaskCode.ERR_SIGNIN_NOT_EQUAL_PW, "")55 }56 else { onFinish(TaskCode.ERR_DATABASE_UNKNOWN, "") } //알 수 없는 오류57 } else if ((rows as any).length > 1) { onFinish(TaskCode.ERR_SIGNIN_NOT_FOUND, "") } //일치하는 계정이 없음58 else { onFinish(TaskCode.ERR_DATABASE_UNKNOWN, "") } //알수없는 오류59 60 })61 })62 }63 //기타 작업 시 세션ID 인증 함수64 static AuthSession(SessionID: string, onFinish: (code: TaskCode, newSessionID: string) => any) {65 const Pool = getPool()66 Pool.getConnection((poolErr, Database) => {67 Database.query(`SELECT * FROM authusers WHERE SessionID=${Database.escape(SessionID)};`, (err, rows, fields) => {68 if (!err && (rows as any).length == 1) { //DB 오류가 없다면69 var CreatedSessionID = Security.CreateSessionID()70 Database.query(`UPDATE authusers SET SessionID='${CreatedSessionID}' WHERE SessionID=${Database.escape(SessionID)};`, (err, rows, fields) => {71 if (!err) { //새로운 세션 ID 발급 시72 onFinish(TaskCode.SUCCESS_WORK, CreatedSessionID)73 } else { onFinish(TaskCode.ERR_SESSION_REGEN_FAILED, "") }74 75 return76 })77 } else if ((rows as any).length == 0 || (rows as any).length > 1) { onFinish(TaskCode.ERR_SESSION_AUTH_FAILED, "") } //일치하는 계정을 찾을 수 없음78 else { onFinish(TaskCode.ERR_DATABASE_UNKNOWN, "") } //DB 오류가 있다면79 80 })81 })82 }83 //접촉 기록 추가84 static InsertRecord(myStaticID: string, records: Array<string>, onFinish: (code: TaskCode) => any) {85 const Pool = getPool()86 Pool.getConnection((poolErr, Database) => {87 var QueryValues: string[] = records.map((it) =>88 `(${Database.escape(myStaticID)}, ${Database.escape(it)}, ${Database.escape(momentJS(new Date()).tz("Asia/Seoul").format("YYYY-MM-DD"))})` //KST TIMEZONE89 )90 //console.log("디버그" + `INSERT INTO scanchains(ScannerStaticID, ScanedDynamicUUID, ContactDayWithoutTime, Authed) VALUES ${QueryValues.join(",")};` + "ㅇ그리고ㅇ" + "INSERT INTO scanchains(ScannerStaticID, ScanedDynamicUUID, ContactDayWithoutTime, Authed) VALUES " + QueryValues.join(",") + ";")91 Database.query(`INSERT INTO scanchains(ScannerStaticID, ScanedDynamicUUID, ContactDayWithoutTime) VALUES ${QueryValues.join(",")};`, (err, rows, fields) => {92 console.log(err)93 if (!err) {94 onFinish(TaskCode.SUCCESS_WORK) //INSERT 성공95 } else { onFinish(TaskCode.ERR_DATABASE_UNKNOWN) } //INSERT 중 오류 발생 시96 97 })98 })99 }100 //확진자 접촉여부 검색101 static SearchRecord(myStaticID: string, onFinish: (code: TaskCode, found_uuid: Array<string>, found_date: Array<string>) => any) {102 const Pool = getPool()103 Pool.getConnection((poolErr, Database) => {104 Database.query(`SELECT * FROM scanchains WHERE ScannerStaticID=${Database.escape(myStaticID)} AND ContactDayWithoutTime > (NOW() - INTERVAL 1 MONTH);`, (err, rows_my, fields) => {105 if (!err) { //확진자들 리스트에서 유저가 스캔했던 접촉기록들을 전부 불러옴(단 한달 전부터 지금까지 있었던 기록만 가져옴)106 if ((rows_my as any).length == 0) { onFinish(TaskCode.SUCCESS_WORK, [], []) } //스캔 기록 자체가 없을 때107 else {108 var myscanedUUIDlist: Array<string> = (rows_my as any).map((it: any) => { return it.ScanedDynamicUUID })109 Database.query(`SELECT * FROM infectedpersons WHERE Authed=1 AND PersonUUID IN (?)`, myscanedUUIDlist, (err, rows, fields) => {110 if (!err) { //인증된 확진자들 중에서 만난 확진자가 있다면111 var contactedUUID: Array<string> = (rows as any).map((it: any) => { return it.PersonUUID })112 var contactedDate: Array<string> = (rows as any).map((it: any) => { return it.ContactDayWithoutTime })113 onFinish(TaskCode.SUCCESS_WORK, contactedUUID, contactedDate) //값 반환114 } else { onFinish(TaskCode.ERR_DATABASE_UNKNOWN, [], []) }115 116 })117 }118 } else { onFinish(TaskCode.ERR_DATABASE_UNKNOWN, [], []); }119 })120 })121 }122 //확진자 추가123 static InsertInfection(Records: Array<string>, GovermentEmail: string, GovermentID: string, PhoneLastNumber: string, onFinish: (code: TaskCode, AuthID: string) => any) {124 const Pool = getPool()125 Pool.getConnection((poolErr, Database) => {126 var QueryValues: string[] = Records.map((it) =>127 `(${Database.escape(it)}, ${Database.escape(GovermentID)}, ${Database.escape(PhoneLastNumber)}, ${Database.escape(GovermentEmail)})`128 )129 const EmailAuthID = Security.CreateSessionID()130 Database.query(`INSERT INTO infectedpersons(PersonUUID, GovermentID, PhoneLastNumber, GovermentEMAIL) VALUES ${QueryValues.join(",")};`,131 (err, rows, fields) => { //확진자 등록132 console.log("오류 : " + err?.message + "\n" + err?.code + "\n" + err?.stack) //SQL 디버그(작동 확인후 이 주석은 지우기)133 if (!err) {134 Database.query(`INSERT INTO authinfect(EmailAuthID, GovermentID) VALUES('${EmailAuthID}', ${Database.escape(GovermentID)});`,135 (err, rows, fields) => { //이메일 링크 등록136 console.log("오류 : " + err?.message + "\n" + err?.code) //SQL 디버그(작동 확인후 이 주석은 지우기)137 if (!err) {138 onFinish(TaskCode.SUCCESS_WORK, EmailAuthID)139 } else { onFinish(TaskCode.ERR_DATABASE_UNKNOWN, "") }140 141 })142 } else { onFinish(TaskCode.ERR_DATABASE_UNKNOWN, ""); }143 })144 })145 }146 //확진자 인증147 static AuthInfection(AuthID: string, onFinish: (code: TaskCode) => any) {148 const Pool = getPool()149 Pool.getConnection((poolErr, Database) => { 150 Database.query(`SELECT * FROM authinfect WHERE EmailAuthID=${Database.escape(AuthID)}`, (err, rows, fields) => { //인증 ID로 확진자들 ID 가져오기151 if (!err && (rows as any).length > 0) { //오류가 없다면152 Database.query(`UPDATE infectedpersons SET Authed=1 WHERE GovermentID='${(rows as any)[0].GovermentID}'`, (err, rows, fields) => { //확진자들 ID와 일치하는 확진자는 모두 인증 처리153 if (!err) {154 Database.query(`DELETE FROM authinfect WHERE EmailAuthID=${Database.escape(AuthID)}`)155 onFinish(TaskCode.SUCCESS_WORK)156 } else { onFinish(TaskCode.ERR_DATABASE_UNKNOWN) }157 })158 } else { onFinish(TaskCode.ERR_DATABASE_UNKNOWN) }159 })160 })161 }162}163//데이터베이스 관련 작업 결과 코드164enum TaskCode {165 //성공시166 SUCCESS_WORK, //데이터베이스 쿼리가 정상적으로 작동했을 때167 //범용 데이터베이스 오류168 ERR_DATABASE_NOT_CONNECT, //데이터베이스 연결이 안될 때169 ERR_DATABASE_UNKNOWN, //알려지지 않은 오류170 ERR_INVALID_VALUE, //올바르지 않은 입력값171 //회원가입 및 로그인 오류172 ERR_SIGNUP_EXISTS_ACCOUNT, //회원가입 시 계정이 이미 존재할 때...

Full Screen

Full Screen

action.ts

Source:action.ts Github

copy

Full Screen

...50 name,51 },52 });53 if (onFinish) {54 onFinish();55 }56 toast('Department Created Successfully');57 console.log('🚀 ~ file: action.ts ~ line 22 ~ result', res);58 } catch (e) {59 console.log('e', e);60 toast(e);61 dispatch({62 type: 'CREATE_OR_UPDATE',63 payload: false,64 });65 if (onFinish) {66 onFinish();67 }68 }69 };70export const updateDepartment =71 (payload, id, onFinish) => async (dispatch: Dispatch) => {72 try {73 dispatch({74 type: 'CREATE_OR_UPDATE',75 payload: true,76 });77 const {name} = payload;78 await httpClient(`/department/${id}`, {79 method: 'PUT',80 body: {81 name,82 },83 });84 toast('Department Updated Successfully');85 if (onFinish) {86 onFinish();87 }88 } catch (e) {89 console.log('e', e);90 toast(e);91 dispatch({92 type: 'CREATE_OR_UPDATE',93 payload: false,94 });95 if (onFinish) {96 onFinish();97 }98 }99 };100export const deleteDepartment =101 (id, onFinish) => async (dispatch: Dispatch) => {102 try {103 dispatch({104 type: 'CREATE_OR_UPDATE',105 payload: true,106 });107 const res = await httpClient(`/department/${id}`, {108 method: 'DELETE',109 });110 toast('Sucessfully deleted!');111 if (onFinish) {112 onFinish();113 }114 } catch (e) {115 toast('Somthing Went Wrong!', {116 type: 'error',117 });118 dispatch({119 type: 'CREATE_OR_UPDATE',120 payload: false,121 });122 if (onFinish) {123 onFinish();124 }125 }126 };127 // Department Actions128export const getAllEmployee =129(payload = {130 searchQuery:'',131 page:0,132 pageSize:5133}) =>134async (dispatch: Dispatch) => {135 try {136 dispatch({137 type: 'LOADING',...

Full Screen

Full Screen

Manager.js

Source:Manager.js Github

copy

Full Screen

1/**2 * @todo -> irgendwann als package manager3 */4define('classes/plugins/Manager', [5 'qui/QUI',6 'qui/classes/DOM',7 'classes/plugins/Plugin',8 'qui/utils/Object',9 'Ajax',10 'Plugins',11 'Projects'12], function (QUI, DOM, Plugin, ObjectUtils, Ajax, Plugins, Projects) {13 "use strict";14 return new Class({15 Extends: DOM,16 Type : 'classes/plugins/Manager',17 initialize: function (options) {18 this.parent(options);19 this.$plugins = {};20 this.$typesNames = {};21 },22 /**23 * create an Plugin24 *25 * @param plugin - String: Plugin Name26 * @param options - Plugin Params27 * events28 * methods29 */30 create: function (plugin, options) {31 options = options || {};32 options.name = plugin;33 this.$plugins[plugin] = new Plugin(options);34 },35 get: function (plugin, onfinish) {36 if (this.$plugins[plugin]) {37 this.$get(plugin, onfinish);38 return;39 }40 if (typeof QUI.MVC.plugins[plugin] === 'undefined') {41 onfinish(false);42 return;43 }44 QUI.MVC.require([plugin], function (plugin, onfinish) {45 this.$get(plugin, onfinish);46 }.bind(this, [plugin, onfinish]));47 },48 /**49 * Load ausführen50 */51 $get: function (plugin, onfinish) {52 if (this.$plugins[plugin].isLoaded()) {53 onfinish(this.$plugins[plugin]);54 return;55 }56 this.$plugins[plugin].load(function () {57 onfinish(this.$plugins[plugin]);58 }.bind(this, [plugin, onfinish]));59 },60 /**61 * Return the name of a type62 *63 * @param {String} type64 * @param {Function} [onfinish]65 * @param {Object} [params]66 */67 getTypeName: function (type, onfinish, params) {68 if (typeof this.$typesNames[type] !== 'undefined') {69 if (typeof onfinish === 'function') {70 onfinish(this.$typesNames[type]);71 }72 return;73 }74 params = ObjectUtils.combine(params, {75 sitetype: type76 });77 Ajax.get('ajax_project_types_get_title', function (result) {78 if (typeof onfinish === 'function') {79 onfinish(result);80 }81 }, params);82 },83 /**84 * Return all available types of a project85 *86 * @param {String} project - project name87 * @param {Function} [onfinish] - callback88 * @param {Object} [params]89 */90 getTypes: function (project, onfinish, params) {91 var Project = Projects.get();92 if (typeof project !== 'undefined') {93 Project = Projects.get(project);94 }95 params = params || {};96 params.project = Project.encode();97 Ajax.get('ajax_project_types_get_list', function (result, Ajax) {98 if (typeof onfinish === 'function') {99 onfinish(result, Ajax);100 }101 }, params);102 }103 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { afterAll, beforeAll } from 'cavy';2beforeAll(async () => {3 await device.launchApp({ permissions: { notifications: 'YES' } });4});5afterAll(async () => {6 await device.terminateApp();7});8import { spec } from 'cavy';9const testHook = spec(test);10describe('My App', function() {11 testHook('Should do something', async function() {12 await expect(element(by.id('some-id'))).toExist();13 });14});15describe('My App', function() {16 testHook('Should do something', async function() {17 await expect(element(by.id('some-id'))).toExist();18 });19});20it('Should do something', async function() {21 await expect(element(by.id('some-id'))).toExist();22});23#### `expect(element(by.id('some-id'))).toExist()`24#### `expect(element(by.id('some-id'))).toHaveText('Some text')`25#### `expect(element(by.id('some-id'))).toHaveValue('Some value')`26#### `expect(element(by.id('some-id'))).toHaveLabel('Some label')`27#### `expect(element(by.id('some-id'))).toHaveStyle({ width: 100 })`28#### `expect(element(by.id('some-id'))).toBeVisible()`29#### `expect(element(by.id('some-id'))).toBeNotVisible()`30#### `expect(element(by.id('some-id'))).toBeDisabled()`

Full Screen

Using AI Code Generation

copy

Full Screen

1const spec = async (TestComponent) => {2 describe('TestComponent', () => {3 let component;4 let tester;5 beforeEach(async () => {6 component = await loadComponent(7 );8 tester = await createTester(component);9 });10 it('should have a button', async () => {11 await tester.findComponent('button');12 });13 });14};15const spec = async (TestComponent) => {16 describe('TestComponent', () => {17 let component;18 let tester;19 beforeEach(async () => {20 component = await loadComponent(21 );22 tester = await createTester(component);23 });24 it('should have a button', async () => {25 await tester.findComponent('button');26 });27 });28};29const spec = async (TestComponent) => {30 describe('TestComponent', () => {31 let component;32 let tester;33 beforeEach(async () => {34 component = await loadComponent(35 );36 tester = await createTester(component);37 });38 it('should have a button', async () => {39 await tester.findComponent('button');40 });41 });42};43const spec = async (TestComponent) => {44 describe('TestComponent', () => {45 let component;46 let tester;47 beforeEach(async () => {48 component = await loadComponent(49 );50 tester = await createTester(component);51 });52 it('should have a button', async () => {53 await tester.findComponent('button');54 });55 });56};57const spec = async (TestComponent) => {58 describe('TestComponent', () => {59 let component;60 let tester;61 beforeEach(async () => {62 component = await loadComponent(63 );64 tester = await createTester(component);65 });66 it('should have a button', async () => {67 await tester.findComponent('button');68 });69 });70};71const spec = async (TestComponent) => {72 describe('TestComponent', () => {73 let component;74 let tester;75 beforeEach(async () => {

Full Screen

Using AI Code Generation

copy

Full Screen

1const spec = async (test) => {2 await test('should render the correct text', async (t) => {3 await t.expect(element(by.id('text'))).toHaveText('Hello, world!');4 });5};6const specWithFinish = async (test) => {7 await test('should render the correct text', async (t) => {8 await t.expect(element(by.id('text'))).toHaveText('Hello, world!');9 });10};11module.exports = {12};13import { spec, specWithFinish } from './TestComponent';14describe('Example', () => {15 beforeAll(async () => {16 await device.launchApp();17 });18 afterAll(async () => {19 await device.terminateApp();20 });21 describe('Example', () => {22 it('should render the correct text', async () => {23 await spec(test);24 });25 });26});27import { spec, specWithFinish } from './TestComponent';28describe('Example', () => {29 beforeAll(async () => {30 await device.launchApp();31 });32 afterAll(async () => {33 await device.terminateApp();34 });35 describe('Example', () => {36 it('should render the correct text', async () => {37 await spec(test);38 });39 it('should render the correct text', async () => {40 await specWithFinish(test);41 });42 });43});44This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details

Full Screen

Using AI Code Generation

copy

Full Screen

1const { finish, test } = require('cavy');2const spec = require('./spec');3test('My first test spec', async (t) => {4 await spec(t);5 await finish(t);6});7Please see [CONTRIBUTING.md](

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 cavy 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