Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

TypeError: Cannot use 'in' operator to search for 'endConversation' in undefined #6

Open
pglejzer opened this issue Mar 19, 2021 · 7 comments

Comments

@pglejzer
Copy link

Hello,
I made a topic on StackOverflow with my problem but nobody responds about this so I will copy/paste here everything here.

I did everything what is wrote in the setup configuration and when I tried to test my queries I can only send the first started query to start an application and if I try to send a second query with a different phrase there is an error with TypeError: Cannot use 'in' operator to search for 'endConversation' in undefined. I don't know how to resolve it. Any help will be appreciated.

import "mocha";
import { ActionsOnGoogleTestManager } from "@assistant/conversation-testing";

const { expect } = require("chai");
const DEFAULT_LOCALE = "en-GB";
const DEFAULT_SURFACE = "SMART_DISPLAY";

const projectId = "test";
const TRIGGER_PHRASE = "Talk to test";


describe("Test Suite", function () {
  // Set the timeout for each test run to 60s.
  this.timeout(60000);

  let testManager: ActionsOnGoogleTestManager;

  afterEach(function () {
    testManager.cleanUpAfterTest();
  });

  before(async function () {
    testManager = new ActionsOnGoogleTestManager({ projectId });
    await testManager.writePreviewFromDraft();

    testManager.setSuiteLocale(DEFAULT_LOCALE);
    testManager.setSuiteSurface(DEFAULT_SURFACE);
  });

  it("welcome intent", async function () {
    testManager.setTestLocale("en-GB");

    await testManager.sendQuery(TRIGGER_PHRASE);

    testManager.assertSpeech(
      "Welcome Alpha"
    );

    // await testManager.sendQuery("donation");
  });
});

Working ss:

enter image description here

If I tried to uncomment the second query with 'donation' there is an error that I mentioned above.enter image description here

@Fleker
Copy link
Member

Fleker commented Mar 19, 2021

Seems like the getIsConversationEnded is asserting that this.getLatestActionsBuilderEvent is not undefined, which may be a wrong assumption. I'm going to try to replicate this behavior.

@Fleker
Copy link
Member

Fleker commented Mar 19, 2021

Unfortunately I cannot reproduce this error basing my test off samples/skeleton_test.ts:

/* eslint-disable  node/no-unpublished-import */
/* eslint-disable  prefer-arrow-callback */

import 'mocha';
import {ActionsOnGoogleTestManager} from '../src/index';

const PROJECT_ID = '...'; // Replace this with your project id.
const TRIGGER_PHRASE = 'Talk to my test app'; // Replace this with your action trigger phrase.

const DEFAULT_LOCALE = 'en-GB';
const DEFAULT_SURFACE = 'SMART_DISPLAY';

describe('Action project', function () {
  // Set the timeout for each test run to 60s.
  this.timeout(60000);
  let test: ActionsOnGoogleTestManager;

  before('set up test suite', async function () {
    test = new ActionsOnGoogleTestManager({projectId: PROJECT_ID});
    await test.writePreviewFromDraft();
    test.setSuiteLocale(DEFAULT_LOCALE);
    test.setSuiteSurface(DEFAULT_SURFACE);
  });

  afterEach('clean up test', function () {
    test.cleanUpAfterTest();
  });

  // Trigger test
  it('should trigger action', async function () {
    test.setTestLocale('en-GB')
    await test.sendQuery(TRIGGER_PHRASE);
    test.assertSpeech('Welcome speech');

    await test.sendQuery('donation');
  });
});

If you can reproduce in a way that I can reproduce it, that would be very helpful.

@LuizPiresS
Copy link

Were you able to find a solution to this problem?

I have the same problem but I can't find the solution

Thanks

@Fleker
Copy link
Member

Fleker commented Mar 23, 2021

Can you reproduce this bug at HEAD rather than in the library, using samples/skeleton_test.ts?

@vicly
Copy link

vicly commented Jul 16, 2021

I have the same issue found recently, which just happens w/o a code change. It might be related to the "Cancel" query response.

    "@assistant/conversation-testing": {
      "version": "1.0.0",
      "resolved": "https://registry.npmjs.org/@assistant/conversation-testing/-/conversation-testing-1.0.0.tgz",
      "integrity": "sha512-9NZ3q1PI/FXegVaF+Kt2M/z2tWcDSPZ8aQ/UBYqtmYk0xSQX3ZRNhg9FWEGeAGL7+1tV4aRRkBylTvUUOGivrQ==",

From the existing testing code
No code change and no error before 10 July.

    // Sending "Cancel" is OK
    await testManager.sendStop();
    console.log(JSON.stringify(testManager.getLatestResponse(), null, 2));
    // Error here
    testManager.assertConversationEnded();

"Cancel" query response payload
image

Error from action-on-google-test-manager.ts
assertConversationEnded -> getIsConversationEnded -> getLatestActionsBuilderEvent

Given above response payload, getLatestActionsBuilderEvent returns undefined, which causes error.
image

image

Does that mean something changed about the "Cancel" request? Could you advise? Thanks.

@Fleker
Copy link
Member

Fleker commented Jul 16, 2021

I am able to reproduce this, and I'll look into what's changed.

@taycaldwell
Copy link
Contributor

Hello,

It looks like this issue only is reproducible when setting the surface type to 'PHONE'.
We are now currently addressing this issue, and I will re-ping this thread when it has been resolved.

Thank you for your patience.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants