How to use getTestClient method in wpt

Best JavaScript code snippet using wpt

moderation.js

Source:moderation.js Github

copy

Full Screen

...8 // do nothing9 }10}11async function banUsers() {12 const client = utils.getTestClient(true);13 const user = {14 id: uuidv4(),15 };16 const evilUser = 'evil-user' + uuidv4();17 await utils.createUsers([evilUser, user.id]);18 return await client.banUser(evilUser, {19 banned_by_id: user.id,20 });21}22async function shadowBan() {23 const client = utils.getTestClient(true);24 const user = {25 id: uuidv4(),26 };27 const evilUser = 'evil-shadow-user' + uuidv4();28 await utils.createUsers([evilUser, user.id]);29 return await client.banUser(evilUser, {30 banned_by_id: user.id,31 shadow: true,32 });33}34async function createBlockList() {35 const name = 'FWord';36 const client = utils.getTestClient(true);37 await cleanupBucketList(client, name);38 const returnValue = await client.createBlockList({ name, words: ['F*!k'] });39 await client.deleteBlockList(name);40 return returnValue;41}42async function createPermission() {43 const authClient = await utils.getTestClient(true);44 return await authClient.createPermission({45 id: 'test-create-permission',46 name: 'TestCreatePermission',47 action: 'ReadChannel',48 condition: {49 '$subject.magic_custom_field': {50 $eq: 'magic_custom_value',51 },52 },53 });54}55async function createRole() {56 const authClient = await utils.getTestClient(true);57 return await authClient.createRole(uuidv4());58}59async function deleteBlockList() {60 const name = 'FWord';61 const name2 = 'SWord';62 const client = await utils.getTestClient(true);63 await cleanupBucketList(client, name);64 await cleanupBucketList(client, name2);65 await client.createBlockList({ name, words: ['F*!k'] });66 await client.createBlockList({ name: name2, words: ['S!*t'] });67 const returnValue = await client.deleteBlockList(name);68 await client.deleteBlockList(name2);69 return returnValue;70}71async function deletePermission() {72 const authClient = await utils.getTestClient(true);73 await authClient.createPermission({74 id: 'test-delete-permission',75 name: 'TestDeletePermission',76 action: 'ReadChannel',77 condition: {78 '$subject.magic_custom_field': {79 $eq: 'magic_custom_value',80 },81 },82 });83 await sleep(2500);84 return await authClient.deletePermission('test-delete-permission');85}86async function deleteRole() {87 const name = uuidv4();88 const authClient = await utils.getTestClient(true);89 await authClient.createRole(name);90 await sleep(2500);91 return await authClient.deleteRole(name);92}93async function flagMessage() {94 //flag the user95 const authClient = utils.getTestClient(true);96 const serverAuthClient = utils.getTestClient(true);97 const thierry = {98 id: 'thierry2',99 name: 'Thierry',100 status: 'busy',101 image: 'myimageurl',102 role: 'admin',103 };104 const tommaso = {105 id: 'tommaso',106 name: 'Tommaso',107 image: 'myimageurl',108 role: 'admin',109 };110 await serverAuthClient.upsertUsers([thierry, tommaso, { id: 'thierry' }]);111 // delete thierry.role;112 // await isn't needed but makes testing a bit easier113 await authClient.connectUser(thierry);114 const channel = authClient.channel('livestream', `ninja-${uuidv4()}`, {115 mysearchablefield: 'hi',116 });117 await channel.watch();118 const text = 'Flag me, i dare you mods!';119 const messageResponse = await channel.sendMessage({ text });120 return await authClient.flagMessage(messageResponse.message.id);121}122async function flagUser() {123 //flag the user124 const authClient = utils.getTestClient(true);125 const serverAuthClient = utils.getTestClient(true);126 const thierry = {127 id: 'thierry2',128 name: 'Thierry',129 status: 'busy',130 image: 'myimageurl',131 role: 'admin',132 };133 const tommaso = {134 id: 'tommaso',135 name: 'Tommaso',136 image: 'myimageurl',137 role: 'admin',138 };139 await serverAuthClient.upsertUsers([thierry, tommaso, { id: 'thierry' }]);140 // delete thierry.role;141 // await isn't needed but makes testing a bit easier142 await authClient.connectUser(thierry);143 const evilId = uuidv4();144 const evil = {145 id: evilId,146 name: 'Eviluser',147 status: 'busy',148 image: 'myimageurl',149 role: 'user',150 };151 const modUserID = uuidv4();152 await utils.createUsers([modUserID]);153 await serverAuthClient.upsertUser(evil);154 return await authClient.flagUser(evilId);155}156async function getBlockList() {157 const name = 'FWord';158 const client = await utils.getTestClient(true);159 await cleanupBucketList(client, name);160 await client.createBlockList({ name, words: ['F*!k'] });161 const returnValue = await client.getBlockList(name);162 await client.deleteBlockList(name);163 return returnValue;164}165async function getPermission() {166 const authClient = await utils.getTestClient(true);167 await authClient.createPermission({168 id: 'test-get-permission',169 name: 'TestGetPermission',170 action: 'ReadChannel',171 condition: {172 '$subject.magic_custom_field': {173 $eq: 'magic_custom_value',174 },175 },176 });177 await sleep(2500);178 return await authClient.getPermission('test-get-permission');179}180async function listBlockLists() {181 const name = 'FWord';182 const client = await utils.getTestClient(true);183 await client.createBlockList({ name, words: ['F*!k'] });184 const returnValue = await client.listBlockLists();185 await client.deleteBlockList(name);186 return returnValue;187}188async function listPermissions() {189 const authClient = await utils.getTestClient(true);190 return await authClient.listPermissions();191}192async function listRoles() {193 const authClient = await utils.getTestClient(true);194 await authClient.listRoles();195}196async function muteUser() {197 const user1 = uuidv4();198 const user2 = uuidv4();199 await utils.createUsers([user1, user2]);200 const client1 = await utils.getTestClientForUser(user1);201 return await client1.muteUser(user2);202}203async function unbanUsers() {204 const client = utils.getTestClient(true);205 const user = {206 id: uuidv4(),207 };208 const evilUser = 'evil-user' + uuidv4();209 await utils.createUsers([evilUser, user.id]);210 return await client.unbanUser(evilUser);211}212async function removeShadowBan() {213 const client = utils.getTestClient(true);214 const user = {215 id: uuidv4(),216 };217 const evilUser = 'evil-shadow-user' + uuidv4();218 await utils.createUsers([evilUser, user.id]);219 return await client.unbanUser(evilUser);220}221async function unflagMessage() {222 //flag the user223 const authClient = utils.getTestClient(true);224 const serverAuthClient = utils.getTestClient(true);225 const thierry = {226 id: 'thierry2',227 name: 'Thierry',228 status: 'busy',229 image: 'myimageurl',230 role: 'admin',231 };232 const tommaso = {233 id: 'tommaso',234 name: 'Tommaso',235 image: 'myimageurl',236 role: 'admin',237 };238 await serverAuthClient.upsertUsers([thierry, tommaso, { id: 'thierry' }]);239 // delete thierry.role;240 // await isn't needed but makes testing a bit easier241 await authClient.connectUser(thierry);242 const channel = authClient.channel('livestream', `ninja-${uuidv4()}`, {243 mysearchablefield: 'hi',244 });245 await channel.watch();246 const text = 'Flag me, i dare you mods!';247 const messageResponse = await channel.sendMessage({ text });248 await authClient.flagMessage(messageResponse.message.id);249 return await authClient.unflagMessage(messageResponse.message.id);250}251async function unflagUser() {252 //flag the user253 const authClient = utils.getTestClient(true);254 const serverAuthClient = utils.getTestClient(true);255 const evilId = uuidv4();256 const evil = {257 id: evilId,258 name: 'Eviluser',259 status: 'busy',260 image: 'myimageurl',261 role: 'user',262 };263 const thierry = {264 id: 'thierry2',265 name: 'Thierry',266 status: 'busy',267 image: 'myimageurl',268 role: 'admin',269 };270 const tommaso = {271 id: 'tommaso',272 name: 'Tommaso',273 image: 'myimageurl',274 role: 'admin',275 };276 await serverAuthClient.upsertUsers([thierry, tommaso, { id: 'thierry' }]);277 // delete thierry.role;278 // await isn't needed but makes testing a bit easier279 await authClient.connectUser(thierry);280 const modUserID = uuidv4();281 await utils.createUsers([modUserID]);282 await serverAuthClient.upsertUser(evil);283 await authClient.flagUser(evilId);284 return await authClient.unflagUser(evilId);285}286async function unmuteUser() {287 const user1 = uuidv4();288 const user2 = uuidv4();289 await utils.createUsers([user1, user2]);290 const client1 = await utils.getTestClientForUser(user1);291 await client1.muteUser(user2);292 return await client1.unmuteUser(user2);293}294async function updateBlockList() {295 const name = 'FWord';296 const client = await utils.getTestClient(true);297 await cleanupBucketList(client, name);298 await client.createBlockList({ name, words: ['F*!k'] });299 const returnValue = await client.updateBlockList(name, {300 words: ['S*!t'],301 });302 await client.deleteBlockList(name);303 return returnValue;304}305async function updatePermission() {306 const authClient = await utils.getTestClient(true);307 await authClient.createPermission({308 id: 'test-update-permission',309 name: 'TestUpdatePermission',310 action: 'ReadChannel',311 condition: {312 '$subject.magic_custom_field': {313 $eq: 'magic_custom_value',314 },315 },316 });317 await sleep(2500);318 return await authClient.updatePermission('test-update-permission', {319 name: 'TestUpdatePermissionUpdated',320 action: 'DeleteChannel',...

Full Screen

Full Screen

client.js

Source:client.js Github

copy

Full Screen

...6 const client = await utils.getTestClientForUser(user1);7 return await client.addDevice(uuidv4(), 'firebase', user1);8}9async function connect() {10 const authClient = await utils.getTestClient(true);11 await authClient.connectAnonymousUser();12 return await authClient.connect();13}14async function createCommand() {15 const authClient = await utils.getTestClient(true);16 try {17 await authClient.deleteCommand('testCreateCommand');18 } catch {19 // No command to delete20 }21 const result = await authClient.createCommand({22 description: 'testCreateCommand',23 name: 'testCreateCommand',24 set: 'testCreateCommand_set',25 });26 await authClient.deleteCommand('testCreateCommand');27 return result;28}29async function deleteCommand() {30 const authClient = await utils.getTestClient(true);31 try {32 await authClient.deleteCommand('testDeleteCommand');33 } catch {34 // No command to delete35 }36 await authClient.createCommand({37 description: 'testDeleteCommand',38 name: 'testDeleteCommand',39 set: 'testDeleteCommand_set',40 });41 return await authClient.deleteCommand('testDeleteCommand');42}43async function disconnect() {44 const authClient = await utils.getTestClient(true);45 await authClient.connectAnonymousUser();46 await authClient.connect();47 return await authClient.disconnectUser();48}49async function getAppSettings() {50 const authClient = await utils.getServerTestClient();51 return await authClient.getAppSettings();52}53async function getCommand() {54 const authClient = await utils.getTestClient(true);55 try {56 await authClient.deleteCommand('testGetCommand');57 } catch {58 // No command to delete59 }60 await authClient.createCommand({61 description: 'testGetCommand',62 name: 'testGetCommand',63 set: 'testGetCommand_set',64 });65 const result = await authClient.getCommand('testGetCommand');66 await authClient.deleteCommand('testGetCommand');67 return result;68}69async function getDevices() {70 const user1 = uuidv4();71 await utils.createUsers([user1]);72 const client = await utils.getTestClientForUser(user1);73 await client.addDevice(uuidv4(), 'firebase', user1);74 return await client.getDevices(user1);75}76async function listCommands() {77 const authClient = await utils.getTestClient(true);78 try {79 await authClient.deleteCommand('testListCommand');80 } catch {81 // No command to delete82 }83 await authClient.createCommand({84 description: 'testListCommand',85 name: 'testListCommand',86 set: 'testListCommand_set',87 });88 const result = await authClient.listCommands();89 await authClient.deleteCommand('testListCommand');90 return result;91}92async function markAllRead() {93 const user1 = uuidv4();94 await utils.createUsers([user1]);95 const client = await utils.getTestClientForUser(user1);96 return await client.markAllRead({ user_id: user1 });97}98async function queryUsers() {99 const user1 = uuidv4();100 const user2 = uuidv4();101 await utils.createUsers([user1, user2], { nickname: user2 });102 const client = await utils.getTestClientForUser(user1);103 return await client.queryUsers({ nickname: { $eq: user2 } });104}105async function queryBannedUsers() {106 const authClient = await utils.getTestClient(true);107 const user = {108 id: uuidv4(),109 };110 const evilUser = 'evil-user' + uuidv4();111 await utils.createUsers([evilUser, user.id]);112 await authClient.banUser(evilUser, {113 banned_by_id: user.id,114 reason: 'because',115 });116 return await authClient.queryBannedUsers({ reason: 'because' }, { created_at: 1 });117}118async function connectAnonymousUser() {119 const authClient = await utils.getTestClient(true);120 return await authClient.connectAnonymousUser();121}122async function setGuestUser() {123 const authClient = await utils.getTestClient(true);124 return await authClient.setGuestUser({ id: 'steven' });125}126async function connectUser() {127 const user1 = uuidv4();128 const user2 = uuidv4();129 await utils.createUsers([user1, user2]);130 const client1 = await utils.getTestClientForUser(user1);131 await client1.muteUser(user2);132 const authClient = await utils.getTestClient(false);133 return authClient.connectUser({ id: user1 }, utils.createUserToken(user1));134}135async function sync() {136 const user1 = uuidv4();137 await utils.createUsers([user1]);138 const client = await utils.getTestClientForUser(user1);139 const channelId = uuidv4();140 const channel = await utils.createTestChannelForUser(channelId, user1);141 await channel.sendMessage({142 text: 'New Event?',143 user: { id: user1 },144 });145 return await client.sync(146 [channel.cid],147 new Date(Date.now() - 1000 * 60).toISOString(),148 );149}150async function syncTeam() {151 const team = 'TestTeam';152 const user1 = uuidv4();153 await utils.createMultiTenancyUsers([user1], [team]);154 const client = await utils.getMultiTenancyTestClientForUser(user1);155 const channelId = uuidv4();156 const channel = await utils.createTestMultiTenancyChannelForUser(157 channelId,158 user1,159 team,160 );161 await channel.sendMessage({162 text: 'New Event?',163 user: { id: user1 },164 });165 return await client.sync(166 [channel.cid],167 new Date(Date.now() - 1000 * 60).toISOString(),168 );169}170async function updateAppSettings() {171 const authClient = await utils.getTestClient(true);172 return await authClient.updateAppSettings({173 custom_action_handler_url:174 'https://example.com/webhooks/stream/custom-commands?type={type}',175 enforce_unique_usernames: 'no',176 });177}178async function updateCommand() {179 const authClient = await utils.getTestClient(true);180 try {181 await authClient.createCommand({182 description: 'testUpdateCommand',183 name: 'testUpdateCommand',184 set: 'testUpdateCommand_set',185 });186 } catch {187 // Command exists188 }189 const result = await authClient.updateCommand('testUpdateCommand', {190 set: 'testUpdateCommand_set_two',191 description: 'testUpdateCommand',192 });193 await authClient.deleteCommand('testUpdateCommand');...

Full Screen

Full Screen

channel-type.js

Source:channel-type.js Github

copy

Full Screen

1const { v4: uuidv4 } = require('uuid');2const utils = require('../utils');3async function createChannelType() {4 const client = utils.getTestClient(true);5 const newType = uuidv4();6 return await client.createChannelType({7 name: newType,8 commands: ['all'],9 });10}11async function deleteChannelType() {12 const client = utils.getTestClient(true);13 const newType = uuidv4();14 await client.createChannelType({15 name: newType,16 commands: ['all'],17 });18 return await client.deleteChannelType(newType);19}20async function getChannelType() {21 const client = utils.getTestClient(true);22 return await client.getChannelType('messaging');23}24async function listChannelTypes() {25 const client = utils.getTestClient(true);26 return await client.listChannelTypes();27}28module.exports = {29 createChannelType,30 deleteChannelType,31 getChannelType,32 listChannelTypes,...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wp = require('./wptest.js');2var client = wp.getTestClient();3client.getPosts(function(err, data) {4 if (err) {5 console.log(err);6 } else {7 console.log(data);8 }9});

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