Closed dnotes closed 2 years ago
Hey, I actually figured out shortly after posting this that you can just take the request object from the testSuite.requestBuilder.intent()
and change the properties before you pass it to conversation.send()
. So this should be a simple thing.
I'm reopening this, because this isn't working as I thought. When I run the tests, my Jovo handlers do receive the inputs with the key fields, but it seems that $inputs[name].key
is just copied over from $inputs[name].value
.
In the image below, you'll see my helper function, on the right, which uses testSuite.requestBuilder()
then sets the "key" and "value" for each of the slots. After that the request gets passed to conversation.send()
. Somewhere in the process of initiating the $inputs, I think the key
is getting changed to whatever is in value
; as you can see from the watch panel, the $request still has the proper values for the slot, but this.$inputs has been changed, even though the values in this.$inputs[name].alexaSkill are still correct.
I tried for a few minutes to trace this through the code, but my test debugger got cranky and died, and I wonder if someone on here could help me figure out where the test runner converts Alexa slot values to this.$inputs.
Thank you. We've updated the Jovo Test Suite since then to include more powerful ways to test user input: https://www.jovo.tech/docs/unit-testing#input (please note that $input
is now the abstracted user input, $entities
are what we used to call inputs)
Something like this could work:
const { output, response } = await testSuite.run({
intent: 'MyNameIsIntent',
entities: {
bookPartNamed: {
value: 'the beginning',
resolved: 'beginning',
},
},
});
I'm submitting a...
Expected Behavior
When my handler gets requests from Amazon, the input slots have a value and, if a match was found to my custom inputType, a key. For example (it's a library) it might be something like
{ value: "moby dick", key: "moby_dick_melville_en"}
. It would be helpful to have a way to test having a key and value, as my application branches based on whether an exact match was found, what the key is, etc.I had a look in at the AlexaRequestBuilder and it seems like something could be created to allow devs to set the
resolutions
property of the input slot, for example.Current Behavior
Currently,
testSuite.intent('IntentName', args)
sets only the value for each input. I timed out trying to learn how to send a full JSON request with the testSuite, but if that's not too difficult then a documentation example would be helpful.Your Environment