How to use this.getContexts method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

openNLX.js

Source:openNLX.js Github

copy

Full Screen

...21  async resetContext(bot, conversationId, v) {22    this.openNLX.deleteContext(bot.id, v, conversationId);23    // delete in db parameters24    try {25      await this.getContexts().deleteVariables(conversationId);26    } catch (error) {27      // Silent error :28      // the context could be not stored in Parameters as not previously29      // initialized/used by adding a message30    }31  }32  static async updateInputMessage(messenger, message, response, params, debug) {33    const p = { ...params };34    if (response && response.message) {35      p.message = response.message.text;36    } else if (debug) {37      p.message = "[Error] No intent found";38      p.error = "No intent found";39    } else {40      logger.info("error in response", response);41    }42    if (debug) {43      p.debug = response.debug;44      await messenger.updateMessage({45        ...message,46        debug: response.debug,47      });48    }49    return p;50  }51  static intentsToOpenNLX(intents) {52    return intents.map((int) => {53      const toOpenNLXIntent = int;54      if (int.previousId && int.previousId.length > 0) {55        toOpenNLXIntent.previous = int.previousId;56        delete toOpenNLXIntent.previousId;57      }58      toOpenNLXIntent.deactivated = int.state && int.state === "deactivated";59      return toOpenNLXIntent;60    });61  }62  async refreshConversation(messenger, conversation, bot, v) {63    const { conversationId } = conversation;64    logger.info("conversation=", conversation);65    const messages = await messenger.getConversationMessages(conversationId);66    const localContext = await this.getContexts().initLocalContext(67      conversation,68      bot,69      messenger,70    );71    await this.resetContext(bot, conversationId, v);72    if (Array.isArray(messages)) {73      this.openNLX.setContext(74        { agentId: bot.id, version: v, name: conversationId },75        localContext.variables,76        localContext.attributes,77      );78      const fromBot = `bot_${bot.name}_${bot.id}`;79      /* eslint-disable no-restricted-syntax */80      /* eslint-disable no-await-in-loop */81      for (const message of messages) {82        if (message.from !== fromBot && message.debug) {83          const msg = {84            text: message.body,85            from: message.from,86            conversationId: message.conversationId,87            id: message.id,88            created_time: message.created_time,89          };90          const debug = v === "default";91          const response = await this.openNLX.parse(bot.id, v, msg, debug);92          const params = await OpenNLXMiddleware.updateInputMessage(93            messenger,94            message,95            response,96            {97              from: fromBot,98              speaker: "chatbot",99            },100            debug,101          );102          const outputMessage = messages.find((m) => message.id === m.previous);103          if (params.message && outputMessage) {104            await messenger.updateMessage({105              ...outputMessage,106              body: params.message,107              debug: response.debug,108            });109          } else {110            logger.error("No previous output message to refresh");111          }112        }113      }114      /* eslint-disable no-restricted-syntax */115      /* eslint-disable no-await-in-loop */116      // store in Db parameters117      await this.getContexts().setVariables(118        conversationId,119        localContext.variables,120      );121    } else {122      await this.getContexts().setVariables(123        conversationId,124        localContext.variables,125      );126    }127  }128  async handleMessengerActions(data, version = null) {129    const bot = await this.mainControllers130      .getBots()131      .getBot(data.conversationOrigin || data.origin);132    if (!bot) return;133    let v = version;134    let messenger;135    if (!version) {136      v = bot.publishedVersionId;137      messenger = this.mainControllers.getMessenger();138    } else {139      v = "default";140      messenger = this.mainControllers.getSandboxMessenger();141    }142    if (data.action === "newConversation") {143      // create Conversation / Context144      const localContext = await this.getContexts().initLocalContext(145        data,146        bot,147        messenger,148      );149      const { variables, attributes } = localContext;150      this.openNLX.setContext(151        { agentId: bot.id, version: v, name: data.conversationId },152        variables,153        attributes,154      );155      // store in db parameters156      await this.getContexts().setVariables(data.conversationId, variables);157    } else if (data.action === "resetConversation") {158      // reset Conversation / Context159      this.resetContext(bot, data.conversationId, v);160      // logger.info("reset conversationId=", data.conversationId);161    } else if (data.action === "newMessages") {162      const fromBot = `bot_${bot.name}_${bot.id}`;163      /* eslint-disable no-restricted-syntax */164      /* eslint-disable no-await-in-loop */165      // get params from Db parameters166      let variables = await this.getContexts().getVariables(167        data.conversationId,168      );169      for (const message of data.messages) {170        if (message.from !== fromBot && !message.debug) {171          // set context in OpenNLX172          this.openNLX.setContext(173            { agentId: bot.id, version: v, name: data.conversationId },174            variables,175          );176          const msg = {177            text: message.body,178            from: message.from,179            conversationId: message.conversationId,180            id: message.id,181            created_time: message.created_time,182          };183          const debug = v === "default";184          const response = await this.openNLX.parse(bot.id, v, msg, debug);185          const { conversationId } = message;186          const params = await OpenNLXMiddleware.updateInputMessage(187            messenger,188            message,189            response,190            {191              from: fromBot,192              speaker: "chatbot",193              previous: message.id,194            },195            debug,196          );197          if (params.message) {198            await messenger.createMessage(null, conversationId, params);199          }200          // get context from OpenNLX201          const contextParams = this.openNLX.getContextData({202            agentId: bot.id,203            version: v,204            name: data.conversationId,205          });206          ({ variables } = contextParams);207        }208      }209      /* eslint-disable no-restricted-syntax */210      /* eslint-disable no-await-in-loop */211      // logger.info("contextParams=", contextParams);212      // store in Db parameters213      const localContext = await Contexts.resetLocalContext(214        data.conversationId,215        bot,216        messenger,217        variables,218      );219      ({ variables } = localContext);220      await this.getContexts().setVariables(data.conversationId, variables);221    } else if (222      data.action === "updateConversation" ||223      data.action === "createConversation" ||224      data.action === "deleteMessage"225    ) {226      await this.refreshConversation(messenger, data, bot, v);227    }228  }229  async onDispatch(className, data) {230    // logger.info("OpenNLX onDispatch: ", className, data.action);231    if (className === "sandbox") {232      await this.handleMessengerActions(data, "sandbox");233    } else if (className === "bot") {234      // handle intents events...

Full Screen

Full Screen

treeExtender.js

Source:treeExtender.js Github

copy

Full Screen

...31      if (!tree || _.isEmpty(tree)) {32        debug('no tree injected');33        return null;34      }35      var ctxs = this.getContexts();36      var info = {37        contexts: []38      };39      ctxs.forEach(function (ctx) {40        var c = { name: ctx.name, aggregates: [] };41        ctx.aggregates.forEach(function (aggr) {42          var a = { name: aggr.name, version: aggr.version, commands: [], events: [], businessRules: [] };43          aggr.commands.forEach(function (command) {44            var cmd = { name: command.name, version: command.version, preConditions: [], preLoadConditions: [] };45            // if (command.source && command.source.aggregate) {46            //   cmd.source = command.source;47            // }48            command.preConditions.forEach(function (pc) {49              var n = pc.name.join(', ');50              cmd.preConditions.push({ name: n, description: pc.description, priority: pc.priority });51            });52            command.preLoadConditions.forEach(function (pc) {53              var n = pc.name.join(', ');54              cmd.preLoadConditions.push({ name: n, description: pc.description, priority: pc.priority });55            });56            a.commands.push(cmd);57          });58          aggr.events.forEach(function (event) {59            a.events.push({ name: event.name, version: event.version });60          });61          aggr.businessRules.forEach(function (businessRule) {62            a.businessRules.push({ name: businessRule.name, description: businessRule.description, priority: businessRule.priority });63          });64          c.aggregates.push(a);65        });66        info.contexts.push(c);67      });68      return info;69    },70    getContexts: function () {71      if (!tree || _.isEmpty(tree)) {72        debug('no tree injected');73        return null;74      }75      var ctxs = [];76      for (var c in tree) {77        var ctx = tree[c];78        if (ctx instanceof Context) {79          ctxs.push(ctx);80        }81      }82      return ctxs;83    },84    getContext: function (name) {85      if (!tree || _.isEmpty(tree)) {86        debug('no tree injected');87        return null;88      }89      var ctx = tree[name];90      if (ctx instanceof Context) {91        return ctx;92      }93      return null;94    },95    getCommandHandler: function (query) {96      if (!tree || _.isEmpty(tree)) {97        debug('no tree injected');98        return null;99      }100      var ctx;101      if (query.context) {102        ctx = this.getContext(query.context);103        if (!ctx) {104          debug('no context found with name ' + query.context);105          return null;106        }107        return getCommandHandler(ctx, query);108      } else {109        var ctxs = this.getContexts();110        for (var c in ctxs) {111          ctx = ctxs[c];112          var handler = getCommandHandler(ctx, query);113          if (handler) {114            return handler;115          }116        }117      }118      return null;119    },120    // getCommandHandlerByOldTarget: function (query) {121    //   if (!tree || _.isEmpty(tree)) {122    //     debug('no tree injected');123    //     return null;124    //   }125    //126    //   var ctx;127    //   var ctxs = this.getContexts();128    //   for (var c in ctxs) {129    //     ctx = ctxs[c];130    //     var handler = getCommandHandlerByOldTarget(ctx, query);131    //     if (handler) {132    //       return handler;133    //     }134    //   }135    //   return null;136    // },137    defineOptions: function (options) {138      if (!tree || _.isEmpty(tree)) {139        debug('no tree injected');140        return this;141      }142      this.getContexts().forEach(function (ctx) {143        ctx.defineOptions(options);144        ctx.getAggregates().forEach(function (aggr) {145          aggr.defineOptions(options);146          if (aggr.defaultCommandHandler) {147            aggr.defaultCommandHandler.defineOptions(options);148          }149          aggr.getCommands().forEach(function (cmd) {150            cmd.defineOptions(options);151            if (cmd.preCondition) {152              cmd.preCondition.defineOptions(options);153            }154            if (cmd.preLoadCondition) {155              cmd.preLoadCondition.defineOptions(options);156            }157          });158          aggr.getEvents().forEach(function (evt) {159            evt.defineOptions(options);160          });161          aggr.getCommandHandlers().forEach(function (cmdHndl) {162            cmdHndl.defineOptions(options);163          });164          aggr.getBusinessRules().forEach(function (buRu) {165            buRu.defineOptions(options);166          });167        });168      });169      return this;170    },171    defineCommand: function (definition) {172      if (!tree || _.isEmpty(tree)) {173        debug('no tree injected');174        return this;175      }176      this.getContexts().forEach(function (ctx) {177        ctx.defineCommand(definition);178        ctx.getAggregates().forEach(function (aggr) {179          aggr.defineCommand(definition);180          if (aggr.defaultCommandHandler) {181            aggr.defaultCommandHandler.defineCommand(definition);182          }183          aggr.getCommands().forEach(function (cmd) {184            cmd.defineCommand(definition);185          });186          aggr.getEvents().forEach(function (evt) {187            evt.defineCommand(definition);188          });189          aggr.getCommandHandlers().forEach(function (cmdHndl) {190            cmdHndl.defineCommand(definition);191          });192          aggr.getBusinessRules().forEach(function (buRu) {193            buRu.defineCommand(definition);194          });195        });196      });197      return this;198    },199    defineEvent: function (definition) {200      if (!tree || _.isEmpty(tree)) {201        debug('no tree injected');202        return this;203      }204      this.getContexts().forEach(function (ctx) {205        ctx.defineEvent(definition);206        ctx.getAggregates().forEach(function (aggr) {207          aggr.defineEvent(definition);208          if (aggr.defaultCommandHandler) {209            aggr.defaultCommandHandler.defineEvent(definition);210          }211          aggr.getCommands().forEach(function (cmd) {212            cmd.defineEvent(definition);213            if (cmd.preCondition) {214              cmd.preCondition.defineEvent(definition);215            }216            if (cmd.preLoadCondition) {217              cmd.preLoadCondition.defineEvent(definition);218            }219          });220          aggr.getEvents().forEach(function (evt) {221            evt.defineEvent(definition);222          });223          aggr.getCommandHandlers().forEach(function (cmdHndl) {224            cmdHndl.defineEvent(definition);225          });226          aggr.getBusinessRules().forEach(function (buRu) {227            buRu.defineEvent(definition);228          });229        });230      });231      return this;232    },233    useEventStore: function (eventStore) {234      if (!tree || _.isEmpty(tree)) {235        debug('no tree injected');236        return this;237      }238      this.getContexts().forEach(function (ctx) {239        ctx.getAggregates().forEach(function (aggr) {240          if (aggr.defaultCommandHandler) {241            aggr.defaultCommandHandler.useEventStore(eventStore);242          }243          aggr.getCommandHandlers().forEach(function (cmdHndl) {244            cmdHndl.useEventStore(eventStore);245          });246        });247      });248      return this;249    },250    useAggregateLock: function (aggregateLock) {251      if (!tree || _.isEmpty(tree)) {252        debug('no tree injected');253        return this;254      }255      this.getContexts().forEach(function (ctx) {256        ctx.getAggregates().forEach(function (aggr) {257          if (aggr.defaultCommandHandler) {258            aggr.defaultCommandHandler.useAggregateLock(aggregateLock);259          }260          aggr.getCommandHandlers().forEach(function (cmdHndl) {261            cmdHndl.useAggregateLock(aggregateLock);262          });263        });264      });265      return this;266    },267    idGenerator: function (getNewId) {268      if (!getNewId || !_.isFunction(getNewId)) {269        var err = new Error('Please pass a valid function!');270        debug(err);271        throw err;272      }273      if (!tree || _.isEmpty(tree)) {274        debug('no tree injected');275        return this;276      }277      this.getContexts().forEach(function (ctx) {278        ctx.getAggregates().forEach(function (aggr) {279          aggr.idGenerator(getNewId);280        });281      });282      return this;283    },284    aggregateIdGenerator: function (getNewId) {285      if (!getNewId || !_.isFunction(getNewId)) {286        var err = new Error('Please pass a valid function!');287        debug(err);288        throw err;289      }290      if (!tree || _.isEmpty(tree)) {291        debug('no tree injected');292        return this;293      }294      this.getContexts().forEach(function (ctx) {295        ctx.getAggregates().forEach(function (aggr) {296          if (aggr.defaultCommandHandler) {297            aggr.defaultCommandHandler.aggregateIdGenerator(getNewId);298          }299          aggr.getCommandHandlers().forEach(function (cmdHndl) {300            cmdHndl.aggregateIdGenerator(getNewId);301          });302        });303      });304      return this;305    }306  };...

Full Screen

Full Screen

Schema.js

Source:Schema.js Github

copy

Full Screen

...43    // Root paths as we want to validate whole doc44    var paths = [];45    // Custom validator contexts46    try {47      var contexts = this.getContexts(rootSchema, newDoc, paths);48    } catch (err) {49      return done(formatError(this._getError(err)));50    }51    var validateCreate = (err) => {52      // If there was no error from async custom validators,53      //   run sync schema validation and sync custom validators54      done(formatError(err || this.validate(newDoc, rootSchema, paths, contexts)));55    };56    var counter = this._getCounter();57    this.runAsyncs(contexts, counter, validateCreate);58    // There was no countexts or not async fn in any of them59    if (counter.count === 0 && !counter.sent) {60      validateCreate();61    }62  };63  runAsyncs = (contexts, counter, done) => {64    var self = this;65    var error = this._getError();66    const formatError = (err) => {67      if (!err) {68        return;69      }70      err.code = "ERR_VALIDATION_FAILED";71      err.message = JSON.stringify({ errors: err.errors }, null, 2);72      return err;73    };74    for (var k = 0; k < contexts.length; k++) {75      var context = contexts[k];76      var customValidator = context.customValidator;77      if (customValidator.async) {78        counter.count++;79        setTimeout(function () {80          (function () {81            customValidator.async.call(self, context, function (err, data) {82              if (err) {83                err.paths = context.paths;84                error.errors.push(err);85              }86              context.data = data;87              counter.count--;88              if (counter.count === 0 && !counter.sent) {89                counter.sent = true;90                if (error.errors.length) {91                  done(formatError(error));92                } else {93                  done();94                }95              }96            });97          })(context);98        }, 0);99      }100    }101  };102  validate = (doc, rootSchema, paths, contexts) => {103    var error = this._getError();104    // Schema validation is here105    //   everytime we validate the whole doc, because it`s only case106    //   when z-schema returns full paths with errors107    var valid = this.validator.validate(doc, rootSchema);108    // console.log({ valid, doc });109    if (!valid) {110      error.errors = this.validator.getLastErrors();111      // Parse path to array for each error112      for (var i = 0; i < error.errors.length; i++) {113        var parsedError = error.errors[i];114        var path = parsedError.path;115        var paths = [];116        // Avoiding '#/'117        if (path.length > 2) {118          paths = path.split("/").slice(1);119        }120        // Add last part from params.property121        if (parsedError.params && parsedError.params.property) {122          paths.push(parsedError.params.property);123        }124        for (var k = 0; k < paths.length; k++) {125          var part = paths[k];126          if (part[0] === "[") {127            paths[k] = +part.slice(1, part.length - 1);128          }129        }130        error.errors[i].paths = paths;131      }132    }133    // Custom validators134    if (contexts) {135      for (var i = 0; i < contexts.length; i++) {136        var context = contexts[i];137        if (!context.customValidator.sync) continue;138        var value;139        if (context.paths.length) {140          value = dotty.get(doc, context.paths);141        } else {142          value = doc;143        }144        if (!value) continue;145        var err = context.customValidator.sync(value, context);146        if (err) {147          err.paths = context.paths;148          error.errors.push(err);149        }150      }151    }152    if (error.errors.length > 0) {153      // console.log(JSON.stringify(error, null, 2));154      return error;155    }156  };157  getContexts = (schema, value, defaultPaths, paths) => {158    var results = [];159    paths = paths || [];160    if (!schema) {161      return results;162    }163    if (schema.validators) {164      for (var i = 0; i < schema.validators.length; i++) {165        var validatorName = schema.validators[i];166        var customValidator = this.customValidators[validatorName];167        if (!customValidator) throw Error("Unknown validator: " + validatorName);168        results.push({169          name: validatorName,170          customValidator: customValidator,171          paths: defaultPaths.concat(paths),172          schema: schema,173          value: value,174        });175      }176    }177    if (schema.type === "object") {178      if (value) {179        for (var key in value) {180          try {181            results = results.concat(182              this.getContexts(183                this._getSchemaForObjectProperty(schema, key, paths),184                value[key],185                defaultPaths,186                paths.concat([key]),187              ),188            );189          } catch (err) {190            // Prevent overwriting if we catched rethrown error191            if (!err.paths) {192              err.paths = defaultPaths.concat(paths);193            }194            throw err;195          }196        }197      }198    } else if (schema.type === "array") {199      if (value) {200        for (var i = 0; i < value.length; i++) {201          var passValue = value[i];202          results = results.concat(203            this.getContexts(schema.items, passValue, defaultPaths, paths.concat([i])),204          );205        }206      }207    }208    return results;209  };210  _getSchemaForPaths = (schema, paths) => {211    if (!paths.length) return schema;212    var property = paths[0];213    paths = paths.slice(1);214    if (schema.type === "object") {215      try {216        return this._getSchemaForPaths(this._getSchemaForObjectProperty(schema, property), paths);217      } catch (err) {...

Full Screen

Full Screen

App.js

Source:App.js Github

copy

Full Screen

...42        currentUrl.searchParams.set('port', port);43        window.history.pushState({}, '', currentUrl.href);44        try {45            await this.getMeta();46            await this.getContexts();47        } catch (err) {48            console.log(err);49            this.setState({50                apiVersion: null,51                contexts: {},52                supported: false,53            });54        }55    }56    async onSave(type, name) {57        if (type === 'context') {58            await this.api.setContext(name, this.state.contexts[name]);59        }60        this.page.reload();61    }62    async componentDidMount() {63        try {64            await this.getMeta();65            await this.getContexts();66        } catch (err) {67            console.log(err);68        }69        this.page.onChange(async () => {70            try {71                await this.getMeta();72                await this.getContexts();73            } catch (err) {74                console.log(err);75                this.setState({76                    apiVersion: null,77                    contexts: {},78                    supported: false,79                });80            }81        });82    }83    async getMeta() {84        const { version, enabled } = await this.api.getMeta();85        const min = this.state.minApiVersion.replace(/-[(beta)(alpha)].*/, '');86        let curr = version;...

Full Screen

Full Screen

bedrock-app-context-behavior.js

Source:bedrock-app-context-behavior.js Github

copy

Full Screen

...85    /**86      * Content is not appearing - Content development is under progress. 87      */88    getDomainContexts: function () {89        return this.getContexts(this.CONTEXT_TYPE_DOMAIN);90    },91    /**92      * Content is not appearing - Content development is under progress. 93      */94    getDataContexts: function () {95        return this.getContexts(this.CONTEXT_TYPE_DATA);96    },97    /**98      * Content is not appearing - Content development is under progress. 99      */100    getItemContexts: function () {101        return this.getContexts(this.CONTEXT_TYPE_ITEM);102    },103    /**104      * Content is not appearing - Content development is under progress. 105      */106    getValueContexts: function () {107        return this.getContexts(this.CONTEXT_TYPE_VALUE);108    },109    /**110      * Content is not appearing - Content development is under progress. 111      */112    getUserContexts: function () {113        return this.getContexts(this.CONTEXT_TYPE_USER);114    },115    /**116      * Content is not appearing - Content development is under progress. 117      */118    getAppContexts: function () {119        return this.getContexts(this.CONTEXT_TYPE_APP);120    },121    /**122      * Content is not appearing - Content development is under progress. 123      */124    getConfigContexts: function () {125        //enhance this..126        let configContexts = _.createCartesianObjects(this._contextData);127        return configContexts;128    }...

Full Screen

Full Screen

bedrock-component-context-behavior.js

Source:bedrock-component-context-behavior.js Github

copy

Full Screen

...38    /**39     * Content is not appearing - Content development is under progress. 40     */41    getDomainContexts: function () {42        return this.getContexts(ContextHelper.CONTEXT_TYPE_DOMAIN);43    },44    /**45       * Content is not appearing - Content development is under progress. 46       */47    getDataContexts: function () {48        return this.getContexts(ContextHelper.CONTEXT_TYPE_DATA);49    },50    /**51      * Content is not appearing - Content development is under progress. 52      */53    getItemContexts: function () {54        return this.getContexts(ContextHelper.CONTEXT_TYPE_ITEM);55    },56    /**57      * Content is not appearing - Content development is under progress. 58      */59    getValueContexts: function () {60        return this.getContexts(ContextHelper.CONTEXT_TYPE_VALUE);61    },62    /**63      * Content is not appearing - Content development is under progress. 64      */65    getUserContexts: function () {66        return this.getContexts(ContextHelper.CONTEXT_TYPE_USER);67    },68    /**69      * Content is not appearing - Content development is under progress. 70      */71    getAppContexts: function () {72        return this.getContexts(ContextHelper.CONTEXT_TYPE_APP);73    },74    /**75     * Content is not appearing - Content development is under progress. 76    */77    getFirstDomainContext: function () {78        return this.getFirstContext(ContextHelper.CONTEXT_TYPE_DOMAIN);79    },80    /**81      * Content is not appearing - Content development is under progress. 82      */83    getFirstDataContext: function () {84        return this.getFirstContext(ContextHelper.CONTEXT_TYPE_DATA);85    },86    /**...

Full Screen

Full Screen

BlockingContextsModel.js

Source:BlockingContextsModel.js Github

copy

Full Screen

...12  setContexts(contexts) {13    this.contexts = contexts;14  }15  serialize() {16    return this.getContexts();17  }18  getContexts() {19    return this.contexts;20  }21  getBlockingContextById(id) {22    return this.getContexts().find(context => context.id === id)23  }24  removeContext(toRemove) {25    const index = this.contexts.indexOf(toRemove);26    if (index >= 0) {27      this._disableContextForAllDoBlocks(toRemove);28      this.contexts.splice(index, 1);29    }30  }31  addContext(context) {32    this.contexts.push(context);33  }34  mutateToSingleBlockingContextForAllDoBlocks() {35    this.removeAllBlockingContexts();36    const context = BlockingContextsModel.getDefaultContext();37    this.addContext(context);38    this._enableContextForAllDoBlocks(context);39  }40  static getDefaultContext = () => ({41    id: 'default-blocking-context',42    name: 'Default',43    color: '#ffaff3',44    workerBlockedMessage: "<p><h1>Thank you</h1>You've already worked on another job related to this project</p>"45  });46  _enableContextForAllDoBlocks = (context) =>47    this.getBlockingContextModelsOfDoBlocks()48      .forEach(blockingContextModel => blockingContextModel.setBlockingContextId(context.id));49  getBlockingContextModelsOfDoBlocks = () => this.getDoBlockModels()50    .map(block => block.getBlockingContextModelParameter());51  getDoBlockModels() {52    return this.graphModel.getBlocksArray().filter(block => block instanceof DoBlockNodeModel);53  }54  removeAllBlockingContexts() {55    this.contexts.forEach(context => {56      this._disableContextForAllDoBlocks(context);57      this.removeContext(context)58    });59  }60  _disableContextForAllDoBlocks = (context) =>61    this.getBlockingContextModelsOfDoBlocks()62      .filter(blockingContextModel => blockingContextModel.getBlockingContextId() === context.id)63      .forEach(blockingContextModel => blockingContextModel.setBlockingContextId(null));64  isSingleBlockingContextEnabledForAllDoBlocks = () => {65    const onlyOneContext = this.getContexts().length === 1;66    const blocks = this.graphModel.getBlocksArray();67    const blocksWithEnabledBlockingContext = this.getBlockingContextModelsOfDoBlocks()68      .filter(blockingContextModel => !!blockingContextModel.getBlockingContextId());69    return onlyOneContext && blocks.length === blocksWithEnabledBlockingContext.length;70  };71  areSomeBlockingContextsEnabled = () =>72    this.getBlockingContextModelsOfDoBlocks()73      .filter(blockingContextModel => !!blockingContextModel.getBlockingContextId())74      .length > 0;75}76export const isBlockingContextValid = ({name, workerBlockedMessage}) =>77  name && name.length >= 0 && workerBlockedMessage...

Full Screen

Full Screen

Pipeline.Class.js

Source:Pipeline.Class.js Github

copy

Full Screen

...16       Pipeline.prototype.addEvent = function(event) {17        this.events.push(event);18       }19       Pipeline.prototype.updateStats = function() {20            this.stats.total = this.getContexts().length;21            this.stats.errored = this.erroredContexts().length;22            this.stats.failed = this.failedContexts().length;23            this.stats.inProgress = this.inProgressContexts().length24            this.stats.complete = this.completeContexts().length;25            $rootScope.$apply();26       }27       Pipeline.prototype.startContext = function(contextId, startTime) {28            this.contexts[contextId] = new PipelineContext(contextId, startTime);29            this.updateStats();30       }31       Pipeline.prototype.endContext = function(contextId, status, endTime) {32            var c = this.contexts[contextId];33            c.status = status;34            c.endTime = endTime;35            this.updateStats();36       }37       Pipeline.prototype.addContext = function(context) {38            this.contexts[context.id] = context;39            this.updateStats();40       }41       Pipeline.prototype.getContexts = function() {42            return Object.keys(this.contexts).map(key => this.contexts[key]);43       }44       Pipeline.prototype.getContextsWithStatus = function(status) {45            return this.getContexts().filter( context => context.status === status );46       }47       Pipeline.prototype.erroredContexts = function() {48            return this.getContextsWithStatus('ERROR' );49       };50       Pipeline.prototype.failedContexts = function() {51            return this.getContextsWithStatus('FAILURE' );52       };53       Pipeline.prototype.completeContexts = function() {54            return this.getContextsWithStatus('COMPLETE' );55       };56       Pipeline.prototype.inProgressContexts = function() {57            return this.getContextsWithStatus('IN_PROGRESS' );58       };59       Pipeline.apiResponseTransformer = responseData => new Pipeline(responseData.name, responseData.script);...

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 Appium Xcuitest Driver automation tests on LambdaTest cloud grid

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

Sign up Free
_

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful