NoIntent return nothing

unit-testing

#1

Hi
I wish to test index value, and dont get why receive undefined …

describe('no intent must suggest change category', function () {

  it('should return 0', async () => {
    let initTest = {
      'events': events,
      'index': 0
    };
    const ni = await testSuite.requestBuilder.intent('NoIntent');
    ni.setState('eventState');
    ni.setSessionAttributes(initTest)
    const r = await conversation.send(ni);

    expect(r.getSessionData().index).toEqual(0);
  });

});

and receive

expect(received).toEqual(expected) // deep equality

Expected: 0
Received: undefined

I try to send confirmationStatus without success

  it('return object from call', async () => {
    let initTest = {
      'events': null,
      'index': 0,
    };
    const request = await testSuite.requestBuilder.intent('NoIntent', {
      'confirmationStatus': 'CONFIRMED'
    });
    request.setState('eventState');
    request.setSessionAttributes(initTest)
    const response = await conversation.send(request);
    expect(response.getSessionData()).toEqual("quelquechose")
  });

#2

Could you provide the request and response json?


#3

response

 AlexaResponse {
        version: '1.0',
        response: { shouldEndSession: true },
        sessionAttributes: {}
      }

Request :

 AlexaRequest {
        version: '1.0',
        session: {
          new: false,
          sessionId: 'amzn1.echo-api.session.0000000-0000-0000-0000-00000000000',
          application: {
            applicationId: 'amzn1.echo-sdk-ams.app.000000-d0ed-0000-ad00-000000d00ebe'
          },
          attributes: { events: null, index: 0, confirmationStatus: 'CONFIRMED' },
          user: { userId: 'amzn1.account.AM3B00000000000000000000000' }
        },
        context: {
          System: { application: [Object], user: [Object], device: [Object] },
          AudioPlayer: { offsetInMilliseconds: 0, playerActivity: 'IDLE' }
        },
        request: {
          type: 'IntentRequest',
          requestId: 'amzn1.echo-api.request.0000000-0000-0000-0000-00000000000',
          timestamp: '2020-08-30T17:08:53.455Z',
          dialogState: 'COMPLETED',
          locale: 'en-US',
          intent: { name: 'NoIntent', confirmationStatus: 'NONE', slots: {} }
        }
      }

#4

I find, but have issue with session limit

  it('return from call', async () => {
    const request = await testSuite.requestBuilder.intent('NoIntent');
    request.addSessionData("events",events.data.data);
    request.setState('eventState');
    const response = await conversation.send(request);
  });

for test, i send session attribute, but it have issue with limit of session.

how to send data from test without reach limit of session ?


#5

What do you mean by session limit?


#6

this 24kb
https://forums.developer.amazon.com/questions/31377/how-much-data-can-i-put-into-sessionattributes.html

I fetch API result and insert all events in session for test.
When I use in live server, session is full from data.


#7

I would store this kind of data in the database. (this.$user.$data)


#8

but how to send this when, make a unit test ?
i think request builder not have function to send data when instantiate conversation.

issue is not create the this.$use.$data but how to mock or send this data


#9
// set value to db before the request
conversation.$user.$data.varABC = 'foobar';
const intentRequest = await testSuite.requestBuilder.intent('IntentA');
// check value after request
expect(conversation.$user.$data.varABC).toEqual('foobar');
// delete db file for this test
await conversation.clearDb();