Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support testing APLA directives #20

Open
xavidop opened this issue Nov 8, 2020 · 6 comments
Open

Support testing APLA directives #20

xavidop opened this issue Nov 8, 2020 · 6 comments

Comments

@xavidop
Copy link

xavidop commented Nov 8, 2020

Description

It is important to support APLA Documents. I saw that you are supporting APL documents.

Steps to Reproduce

Test a resquest of an intent with an APLA directive

Expected behavior: work with APLA documents

Actual behavior: It does not work

Environment

NodeJS-Version: Node.js 10.x

OS: Windows 10

@hoegertn
Copy link
Member

hoegertn commented Nov 8, 2020

Can you provide details on the use case or show a piece of sample code? That would make it easier to follow.

@xavidop
Copy link
Author

xavidop commented Nov 8, 2020

You can test it adding this piece of code on the file lambda/test.js in the project https://github.com/xavidop/alexa-skill-pokedex

  describe('LaunchRequest', function() {
    alexaTest.test([
      {
        request: new test.LaunchRequestBuilder(skillSettings).build(),
        saysLike: i18n.t('WELCOME_MSG'), repromptsNothing: false, shouldEndSession: false,
      },
    ]);
  });

@s-maheshbabu
Copy link
Contributor

@hoegertn
APL-A support can be added to the existing APLValidator by adding a check for APL Audio documents.

const renderedDocument = response.response.directives.find((value) => value.type === 'Alexa.Presentation.APL.RenderDocument' || value.type === 'Alexa.Presentation.APLA.RenderDocument');

Or we can create a new validator altogether: APLAValidator.ts

What do you think?

Here is an APL-A snippet in case you want to read through.

@xavidop
Copy link
Author

xavidop commented Nov 27, 2020

Hello team!

any updates of the PR?

Xavi

@s-maheshbabu s-maheshbabu mentioned this issue Nov 29, 2020
Merged
@habuma
Copy link

habuma commented Jan 31, 2023

Was just trying this out and it's a nice start in that it helps me assert that the response includes the expected document and data source. But...and I know that I'm asking for a big thing here...permit me to think aloud...

It would be AMAZING if I could write the test to render the APL-A document into text and then compare that to expected text. Something like this:

renderDocument: {
    token: 'TEST_TOKEN',
    document: (doc) => {

        // render document into string
        // compare rendered document with expected speech

    },
    hasDataSources: {
      ...
    },
},

Of course, the rendered APL-A could include sound files, so...I'd think that the best that could be done is to render the "Speech" elements into flat text...maybe including audio in the resulting text as something like "[audio 'soundbank://soundlibrary/water/nature/nature_08']" so that it can also be checked for from the expected response.

What's missing here is that APL-A renderer. Does such a thing already exist (ideally as a module that can be imported and used easily here)? If not...I wonder how difficult it would be to create such a renderer. (APL-A is relatively simple as compared to APL, but it still could get tricky I suppose.

The ask dialog command kinda does this. It receives the APL-A template and datasource in the response and renders it into text that is emitted in the shell. Maybe that could be reused or duplicated here? (My next step: Go look at the source behind ask dialog to see how it does this.)

@hoegertn
Copy link
Member

Happy to look into this if you can provide a PR. Currently, I don't have the bandwidth to implement this.

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

No branches or pull requests

4 participants