Giter Site home page Giter Site logo

vumi-jssandbox-toolkit's People

Contributors

dependabot[bot] avatar erikh360 avatar gsvr avatar hodgestar avatar imsickofmaps avatar jerith avatar justinvdm avatar mrhamdulay avatar rudigiesler avatar sewagodimo avatar smn avatar snyk-bot avatar stevebarnett avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vumi-jssandbox-toolkit's Issues

Allow user applications a chance to decide how to handle errors.

Currently InteractionMachine.err handles errors all by itself. We should allow user applications a chance to do the high-level processing of the error themselves (falling back to the current behaviour if the application error handler throws an exception or indicates that it'd like default error processing to continue).

Add default delay to fixture HTTP calls.

Currently the test framework immediately returns results for http calls, that's not how things will happen in production.

Having a configurable delay in the fixtures would help, a default of 100ms would probably be OK?
It would help indicate where too many http calls are being made for production (even though they're snappy in the tests).

Add a check on the length of replies and outbound SMSes.

The check would be on a configurable maximum message length (set in the config for the JS app) and would log a warning if the content is too long.

The test harness already checks this but a check in production would help pick up odd errors (e.g. where the aggregator ends the USSD session because the reply is too long) more quickly. Sometimes production replies are longer than test replies (e.g. because dynamic content is included in the replies).

Remove unnecessary namespaces in event names

Users emit events like user:new, user:load and States emit events like state:enter. This means attaching listeners looks something like this:

user.on('user:new', function() {
    ...
})

This feels a little redundant, since we already know that the object emitting the event is a user. Event names like session:new make sense, I think, since they happen on the interaction machine.

Add a kv helper

The only helper missing (other than GroupStore). Would be great to have this out when we do a final release for v02.

Split out param part of url encoding and decoding utils

We currently have utils that look something like:

function url_encode(url, params) {
    ...
}

function url_decode(url) {
    ...
}

Url encoding params (without a url) is needed often enough that it probably makes sense to split these out into their own utilities.

Add documented examples for various sandbox features

This should be in the form of mini-applications that exercise a feature. Each should appear in the documentation and be tested. We need:

  • general package and documentation structure to be set up
  • an example of a simple app
  • an example of a slightly more complex app
  • an example of using the HttpApi and JsonApi helpers
  • an example of using a language state
  • an example using contacts

Once those are done, we can add examples as needed.

Allow test checker `response` attribute to be a plain string

Currently all response values are assumed to be strings that represent regex patterns. We should instead allow responses to be either regexes or strings and do a pattern match for regexes and an exact match for strings.

E.g.

// regular expression match
tester.check_state({
  response: /^foo.*$/
})

// exact string match
tester.check_state({
  response: "foo"
})

Allow ChoiceState to take in an array of objects as choices

Currently, we do this:

return new ChoiceState(name, {
    question: "Coffee or tea?",
    choices: [
        new Choice('coffee', "Coffee"),
        new Choice('tea', 'Tea')
    ],
    next: function(choice) {
        return {
            coffee: 'states:coffee',
            tea: 'states:tea',
        }[choice.value];
    }
});

It would be nice if we could do this too:

return new ChoiceState(name, {
    question: "Coffee or tea?",
    choices: [{
        value: 'coffee',
        label "Coffee"
    }, {
        value: 'tea',
        label "Tea"
    })]
    next: function(choice) {
        return {
            coffee: 'states:coffee',
            tea: 'states:tea',
        }[choice.value];
    }
});

Align BookletState and PaginatedChoiceState navigation options

The BookletState and PaginatedChoiceState provide similar navigation options but for historical reasons there constructor arguments are completely different. We should standardize on one set of navigation arguments before doing an official release of version 2.

Add support for helper_metadata to outbound resource.

Once #217 lands we will have support for helper_metadata on replies, but not for setting it on non-reply outbound sends (it would be cool to be able to support triggering a voice call from a USSD menu the way we support triggering an SMS).

Get mocha to display diffs for fixture mismatches

At the moment, it is difficult to tell why a fixture doesn't match a real request, especially for cases where the bodies are non-trivial. It would be great if we could make use of mocha's showDiff error flag to show these diffs in a way that it is easy to figure out the reason for mismatches.

Allow triggering metrics on delegator states.

Currently one can't trigger metrics helper metrics on delegator states because those don't have events fired. This is a thorny problem and I'm not entirely sure what the solution is.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.