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

feat: Add support for config auth type (fetch & submit) #4485

Merged
merged 9 commits into from
Jun 22, 2023

Conversation

corinagum
Copy link
Collaborator

@corinagum corinagum commented Jun 6, 2023

Fixes #4487

Description

Add new Teams invoke types 'config/fetch' and 'config/submit' for supporting Auth & TaskModuleContinue in configuration flow.

Specific Changes

  • Add new teamsActivityHandlers for 'config/fetch' and 'config/submit' invoke requests
  • For config, add ConfigAuthResponse, ConfigResponse, and BotConfigAuthType for parsing config payloads.

Testing

Unit tests added.

=========

Local bot code:

// extending both handlers

    async handleTeamsConfigFetch(_context, configData) {
        let response = {};
        switch (configData.command) {
            case 'card':
                {
                    response.config = {
                        suggestedActions: {
                            actions: [
                                {
                                    type: 'bot config auth',
                                    title: 'bot config title',
                                    image:
                                        'https://static-asm.secure.skypeassets.com/pes/v1/emoticons/win10/views/default_40',
                                    value: 'bot config auth value',
                                },
                            ],
                        },
                        type: 'auth',
                    };
                }
                break;
            case 'message':
                {
                    const cardJson = {
                        type: 'AdaptiveCard',
                        version: '1.4',

                        body: [
                            {
                                type: 'TextBlock',
                                text: 'Bot Config Fetch',
                            },
                        ],
                    };
                    const card = CardFactory.adaptiveCard(cardJson);

                    response = {
                        config: {
                            value: {
                                height: 200,
                                width: 200,
                                title: 'test card fetch',
                                card,
                            },
                            type: 'continue',
                        },
                    };
                }
                break;
            default:
                console.log('no default');
        }

        return response;
    }

    async handleTeamsConfigSubmit(_context, configData) {
        let response = {};
        switch (configData.command) {
            case 'card':
                {
                    const cardJson = {
                        type: 'AdaptiveCard',
                        version: '1.4',

                        body: [
                            {
                                type: 'TextBlock',
                                text: 'Bot Config Submit',
                            },
                        ],
                    };
                    const card = CardFactory.adaptiveCard(cardJson);

                    response = {
                        config: {
                            value: {
                                height: 200,
                                width: 200,
                                title: 'test card submit',
                                card,
                            },
                            type: 'continue',
                        },
                    };
                }
                break;
            case 'message':
                {
                    response = {
                        config: {
                            value: 'config submit text',
                            type: 'message',
                        },
                    };
                }
                break;
            default:
                console.log('no default');
                break;
        }

        return response;
    }

Manual test validation:

'config/fetch' - auth response

image

'config/fetch' - message TaskModuleContinue response

image

'config/submit' card TaskModuleContinue response

image

'config/submit' message TaskModuleContinue response

image

@corinagum corinagum changed the title Add support for config auth type (fetch & submit) feat: Add support for config auth type (fetch & submit) Jun 6, 2023
@yingduyingdu

This comment was marked as outdated.

@coveralls
Copy link

coveralls commented Jun 6, 2023

Pull Request Test Coverage Report for Build 5338185464

  • 5 of 6 (83.33%) changed or added relevant lines in 1 file are covered.
  • 63 unchanged lines in 2 files lost coverage.
  • Overall coverage remained the same at 84.503%

Changes Missing Coverage Covered Lines Changed/Added Lines %
libraries/botbuilder/src/teamsActivityHandler.ts 5 6 83.33%
Files with Coverage Reduction New Missed Lines %
libraries/botbuilder-azure-blobs/src/blobsStorage.ts 27 43.82%
libraries/botbuilder/src/cloudAdapter.ts 36 36.36%
Totals Coverage Status
Change from base Build 5124179949: 0.0%
Covered Lines: 20042
Relevant Lines: 22482

💛 - Coveralls

@corinagum corinagum marked this pull request as ready for review June 12, 2023 22:19
@corinagum corinagum requested a review from a team as a code owner June 12, 2023 22:19
@tracyboehrer tracyboehrer requested review from ceciliaavila and removed request for yingduyingdu June 20, 2023 20:58
Copy link
Collaborator

@ceciliaavila ceciliaavila left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could add unit tests for the new methods using a TestActivityHandler class to implement them and assert the response.

libraries/botbuilder/src/teamsActivityHandler.ts Outdated Show resolved Hide resolved
libraries/botbuilder/src/teamsActivityHandler.ts Outdated Show resolved Hide resolved
libraries/botframework-schema/src/teams/index.ts Outdated Show resolved Hide resolved
@corinagum
Copy link
Collaborator Author

@ceciliaavila could I get a new review please? Addressed your comments. Thanks!

@corinagum
Copy link
Collaborator Author

You could add unit tests for the new methods using a TestActivityHandler class to implement them and assert the response.

Historically, developer implemented methods don't have unit tests in this repo, therefore I'll keep as-is

Copy link
Collaborator

@ceciliaavila ceciliaavila left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. I still believe unit tests are relevant, mainly because in .NET they were added.

@tracyboehrer tracyboehrer merged commit 288cb8f into main Jun 22, 2023
15 checks passed
@tracyboehrer tracyboehrer deleted the corinagum/botAuthConfig branch June 22, 2023 17:06
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

Successfully merging this pull request may close these issues.

Feature: Bot config invoke type
7 participants