How to use sendGroupUsersChange method in devicefarmer-stf

Best JavaScript code snippet using devicefarmer-stf

groups.js

Source:groups.js Github

copy

Full Screen

...77 )78 )79 ])80 }81 function sendGroupUsersChange(group, users, devices, isAdded, action) {82 const isDeletedLater = action === 'GroupDeletedLater'83 pushdev.send([84 wireutil.global85 , wireutil.envelope(86 new wire.GroupUserChangeMessage(users, isAdded, group.id, isDeletedLater, devices))87 ])88 }89 function doUpdateDeviceOriginGroup(group) {90 return dbapi.updateDeviceOriginGroup(group.ticket.serial, group).then(function() {91 push.send([92 wireutil.global93 , wireutil.envelope(94 new wire.DeviceOriginGroupMessage(group.ticket.signature)95 )96 ])97 })98 }99 function doUpdateDevicesCurrentGroup(group, devices) {100 return Promise.map(devices, function(serial) {101 return dbapi.updateDeviceCurrentGroup(serial, group)102 })103 }104 function doUpdateDevicesCurrentGroupFromOrigin(devices) {105 return Promise.map(devices, function(serial) {106 return dbapi.updateDeviceCurrentGroupFromOrigin(serial)107 })108 }109 function doUpdateDevicesCurrentGroupDates(group) {110 if (apiutil.isOriginGroup(group.class)) {111 return Promise.map(group.devices, function(serial) {112 return dbapi.loadDeviceBySerial(serial).then(function(device) {113 return device.group.id === group.id ?114 doUpdateDevicesCurrentGroup(group, [serial]) :115 false116 })117 })118 }119 else {120 return Promise.map(group.devices, function(serial) {121 return doUpdateDevicesCurrentGroup(group, [serial])122 })123 }124 }125 function treatGroupUsersChange(group, users, isActive, isAddedUser) {126 if (isActive) {127 return Promise.map(users, function(email) {128 return Promise.map(group.devices, function(serial) {129 return dbapi.loadDeviceBySerial(serial).then(function(device) {130 if (device && device.group.id === group.id) {131 if (!isAddedUser && device.owner && device.owner.email === email) {132 return new Promise(function(resolve) {133 let messageListener134 const responseTimer = setTimeout(function() {135 channelRouter.removeListener(wireutil.global, messageListener)136 resolve(serial)137 }, 5000)138 messageListener = wirerouter()139 .on(wire.LeaveGroupMessage, function(channel, message) {140 if (message.serial === serial &&141 message.owner.email === email) {142 clearTimeout(responseTimer)143 channelRouter.removeListener(wireutil.global, messageListener)144 resolve(serial)145 }146 })147 .handler()148 channelRouter.on(wireutil.global, messageListener)149 sendReleaseDeviceControl(serial, device.channel)150 })151 }152 return serial153 }154 return false155 })156 })157 .then(function(devices) {158 sendGroupUsersChange(159 group, [email], _.without(devices, false), isAddedUser, 'GroupUser(s)Updated')160 })161 })162 }163 else {164 return sendGroupUsersChange(group, users, [], isAddedUser, 'GroupUser(s)Updated')165 }166 }167 function treatGroupDevicesChange(oldGroup, group, devices, isAddedDevice) {168 if (isAddedDevice) {169 return doUpdateDevicesCurrentGroup(group, devices)170 }171 else {172 return doUpdateDevicesCurrentGroupFromOrigin(devices)173 .then(function() {174 if (group === null) {175 sendGroupUsersChange(oldGroup, oldGroup.users, [], false, 'GroupDeletedLater')176 }177 })178 }179 }180 function treatGroupDeletion(group) {181 if (apiutil.isOriginGroup(group.class)) {182 return dbapi.getRootGroup().then(function(rootGroup) {183 return Promise.map(group.devices, function(serial) {184 return dbapi.updateDeviceOriginGroup(serial, rootGroup)185 })186 .then(function() {187 sendGroupUsersChange(group, group.users, [], false, 'GroupDeletedLater')188 })189 })190 }191 else {192 return sendGroupUsersChange(group, group.users, [], false, 'GroupDeleted')193 }194 }195 db.run(r196 .table('groups')197 .pluck(198 'id'199 , 'name'200 , 'class'201 , 'privilege'202 , 'owner'203 , 'dates'204 , 'duration'205 , 'repetitions'206 , 'devices'207 , 'users'208 , 'state'209 , 'isActive'210 , 'ticket'211 )212 .changes(), function(err, cursor) {213 if (err) {214 throw err215 }216 return cursor217 })218 .then(function(cursor) {219 cursor.each(function(err, data) {220 let users, devices, isBecomeActive, isBecomeUnactive, isActive221 , isAddedUser, isAddedDevice, isUpdatedDeviceOriginGroup, isChangedDates222 if (err) {223 throw err224 }225 if (data.old_val === null) {226 sendGroupChange(227 data.new_val228 , data.new_val.users229 , false230 , false231 , false232 , []233 , false234 , []235 , 'created'236 )237 return sendGroupUsersChange(238 data.new_val239 , data.new_val.users240 , data.new_val.devices241 , true242 , 'GroupCreated'243 )244 }245 if (data.new_val === null) {246 sendGroupChange(247 data.old_val248 , data.old_val.users249 , false250 , false251 , false...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var DeviceFarmerClient = require('devicefarmer-stf-client');2var device = client.getDeviceBySerial('0123456789abcdef');3device.sendGroupUsersChange({users: ['user1', 'user2']});4var DeviceFarmerClient = require('devicefarmer-stf-client');5var device = client.getDeviceBySerial('0123456789abcdef');6device.sendGroupUsersChange({users: ['user1', 'user2']});7var DeviceFarmerClient = require('devicefarmer-stf-client');8var device = client.getDeviceBySerial('0123456789abcdef');9device.sendGroupUsersChange({users: ['user1', 'user2']});10var DeviceFarmerClient = require('devicefarmer-stf-client');11var device = client.getDeviceBySerial('0123456789abcdef');12device.sendGroupUsersChange({users: ['user1', 'user2']});13var DeviceFarmerClient = require('devicefarmer-stf-client');14var device = client.getDeviceBySerial('0123456789abcdef');15device.sendGroupUsersChange({users: ['user1', 'user2']});16var DeviceFarmerClient = require('devicefarmer-stf-client');17var device = client.getDeviceBySerial('0123456789abcdef');18device.sendGroupUsersChange({users: ['user1', 'user2']});

Full Screen

Using AI Code Generation

copy

Full Screen

1var devicefarm = require('devicefarmer-stf-client');2var group = 'group1';3var groupUsers = client.sendGroupUsersChange(group,users);4console.log(groupUsers);5{ group: 'group1',6 [ { username: 'user1',

Full Screen

Using AI Code Generation

copy

Full Screen

1var stf = require('stf');2var device = client.getDevice('3c6c2b6f');3var group = client.getGroup('9b6f');4device.sendGroupUsersChange(group, ['user1', 'user2']);5device.sendGroupUsersChange(group, ['user1', 'user2'], true);6device.sendGroupUsersChange(group, ['user1', 'user2'], false);7device.sendGroupUsersChange(group, ['user1', 'user2'], true, true);8device.sendGroupUsersChange(group, ['user1', 'user2'], false, true);9device.sendGroupUsersChange(group, ['user1', 'user2'], true, false);10device.sendGroupUsersChange(group, ['user1', 'user2'], false, false);11device.sendGroupUsersChange(group, ['user1', 'user2'], false, false, true);12device.sendGroupUsersChange(group, ['user1', 'user2'], false, false, false);13device.sendGroupUsersChange(group, ['user1', 'user2'], false, false, false, true);14device.sendGroupUsersChange(group, ['user1', 'user2'], false, false, false, false);15device.sendGroupUsersChange(group, ['user1', 'user2'], false, false, false, false, true);

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 devicefarmer-stf 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