-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Description
We have an intent, LogoutIntent
, when we call it, it prompts the user to confirm:
Are you sure you want to logout?
So it emits type :ask
to the user, expecting a followup confirmation response from them (yes/no). In this followup confirmation yes/no intent, we check the attributes to see which intent is being confirmed by the user. When the audio player is not playing, the attributes are preserved and our followup confirmation intent works as expected. But, when the audio player is playing, the attributes object is empty even though the session with the user has not ended.
When testing with a real Alexa device, it works both when the audio player is playing and not.
Here is the test we are having trouble with:
test('LogoutIntent should log out', async () => {
const deviceId = uuid();
alexa.context().device().setID(deviceId);
expect(alexa.context().device().id()).toEqual(deviceId);
const logoutResponse = await alexa.intend('LogoutIntent');
expect(logoutResponse['response'].outputSpeech.ssml).toBeDefined();
expect(logoutResponse['response'].outputSpeech.ssml).toMatchSnapshot();
// attributes are defined to guide the confirmation intent
const logoutConfirmationResponse = await alexa.utter('yes');
// attributes are defined here, works as intended
expect(logoutConfirmationResponse['response'].outputSpeech.ssml).toBeDefined();
expect(logoutConfirmationResponse['response'].outputSpeech.ssml).toMatchSnapshot();
const launchResponse = await alexa.launch();
expect(launchResponse['response'].outputSpeech.ssml).toBeDefined();
expect(launchResponse['response'].outputSpeech.ssml).toMatchSnapshot();
const loginResponse = await alexa.utter(`My name is ${testConstants.userName}`);
expect(loginResponse['response'].outputSpeech.ssml).toBeDefined();
expect(loginResponse['response'].outputSpeech.ssml).toMatchSnapshot();
const usernameConfirmationResponse = await alexa.utter('yes');
expect(usernameConfirmationResponse['response'].outputSpeech.ssml).toBeDefined();
expect(usernameConfirmationResponse['response'].outputSpeech.ssml).toMatchSnapshot();
const logoutResponse2 = await alexa.intend('LogoutIntent');
expect(logoutResponse2['response'].outputSpeech.ssml).toBeDefined();
expect(logoutResponse2['response'].outputSpeech.ssml).toMatchSnapshot();
const logoutConfirmationResponse1 = await alexa.utter('yes');
// attributes are defined here, works as intended
expect(logoutConfirmationResponse1['response'].outputSpeech.ssml).toBeDefined();
expect(logoutConfirmationResponse1['response'].outputSpeech.ssml).toMatchSnapshot();
const loginResponse1 = await alexa.utter(`My name is ${testConstants.userName}`);
expect(loginResponse1['response'].outputSpeech.ssml).toBeDefined();
expect(loginResponse1['response'].outputSpeech.ssml).toMatchSnapshot();
const usernameConfirmationResponse1 = await alexa.utter('yes');
expect(usernameConfirmationResponse1['response'].outputSpeech.ssml).toBeDefined();
expect(usernameConfirmationResponse1['response'].outputSpeech.ssml).toMatchSnapshot();
const joinIntentResponse = await alexa.intend('JoinIntent', { channelname: testConstants.channelName });
expect(joinIntentResponse['response'].outputSpeech.ssml).toBeDefined();
expect(joinIntentResponse['response'].outputSpeech.ssml).toMatchSnapshot();
const channelConfirmationResponse = await alexa.utter('yes');
// at this point, the audio player starts
expect(channelConfirmationResponse['response'].outputSpeech).toBeUndefined();
expect(channelConfirmationResponse['response'].shouldEndSession).toBeDefined();
expect(channelConfirmationResponse['response'].shouldEndSession).toBeTruthy();
const logoutResponse3 = await alexa.intend('LogoutIntent');
expect(logoutResponse3['response'].outputSpeech.ssml).toBeDefined();
expect(logoutResponse3['response'].outputSpeech.ssml).toMatchSnapshot();
// when testing with alexa device, the attributes are defined here as expected
// but when testing with virtual-alexa, the attributes object is empty (defined, but empty {})
// (even though the session is still open i.e. emit ":ask")
const logoutConfirmationResponse2 = await alexa.intend('SoloSlotIntent', { solo_slot_value: 'yes' });
// we have tried this with both "utter" and "intend", neither works as expected
expect(logoutConfirmationResponse2['response'].outputSpeech.ssml).toBeDefined();
expect(logoutConfirmationResponse2['response'].outputSpeech.ssml).toMatchSnapshot();
}, 15000);
Metadata
Metadata
Assignees
Labels
No labels