Simulating local serverless app getting product OnCreate/OnUpdate events in end-to-end testing

I notice when run my custom serverless app in local dev env that it appears in the custom app gallery. When I enable it, the settings button only shows option to uninstall.

Question

Is there any documentation on how a servless app will behave when run in this way and app is enabled thru portal? I’m curious to know if this is a way to make testing easier.

I love the fact that today I can write a custom GUI app and test it thru the portal. It makes testing really easy. But for a serverless app nothing seems to happen as result of enabling the app in the custom app gallery.

Here is what I’d like to do:

About the app:

Custom training serverless app that processes changes made to the training module and updates contact record (also gets external event form our online training service and updates contact’s progress in the training module. It also updates account when contacts are certified to show account also has that certification. In dev environment, when i test, each app performs read/write REST API calls to the corresponding contact record.

The problem:

To test the app, I need to generate appropriate JSON structure to add to teh test page (http://localhost:10001/web/test#) in order to simulate a change and test it. This JSon structure is very large - especially for Custom Module changes. This can take quite a while to modify the necessary JSON to test each app permutation.

What I’d like:

Any product events such as OnContactCreate, OnCustomModuleUpdate, etc are sent to my local dev environment

It would be really nice if there was a way for the serverless app to get its changes from the live service. That’s because it can be hard to create the appropriate JSON in the simulation test page. It would be a LOT easier if I can use the GUI to make needed changes.

My Workaround

To get the needed JSON for simulating, I write a custom app that just logs the desired product event ( onChange, OnCreate) and capture the JSON from that in order to facilitate testing. I wrote the following to allow me to get the needed JSON because the object has too many levels of nesting to log correctly with simple console.log and the logs.

  let args = Array.prototype.slice.call(arguments);
  let logval=""
  for(const arg of args) {
    logval+=util.inspect(arg, false, null, true) + ""
  }
  console.log(logval)

The above prints the full JSON object (all nested levels) to console which I can run in Freshsales and copy to run in my local server env.

BUT, this only works local. The logs in portal are limited to 2000 characters. So then I need to split up the log as follows:

JSON.stringify(payload).match(/.{1,2000}/g).forEach( (x) => log.logV(x));

This gets REALLY cumbersome because a custom app JSON may be about 8000 or more characters so I have to then copy the JSON part of each message and paste them to new document, then validate the JSON and finally paste it into the http://localhost:10001/web/test# page to test.

@stevemc ,
Good Day!
Unfortunately, the product events are not able to simulate directly from the gallery for the development app and only app setup events can be tested.

to test the other events you should use http://localhost:10001/web/test this way or put it as a custom app, these are the only two ways to test.

Hope it helps :slight_smile:

Thanks for clarifying. At least its good to know the answer but it is too bad this is not possible. Because my implementation (and I’m sure many others) needs to make API calls to read or update CRM records, setting up for a single test is VERY time consuming as noted below. Offering ability to submit product events from CRM in dev environment (local) mode would be extremely helpful.

This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.