-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(plugin-flow-builder): add test for whatsapp button list message
- Loading branch information
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
packages/botonic-plugin-flow-builder/tests/messages/flow-button-list.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { INPUT } from '@botonic/core' | ||
import { describe, test } from '@jest/globals' | ||
|
||
import { FlowWhatsappButtonList } from '../../src/index' | ||
import { ProcessEnvNodeEnvs } from '../../src/types' | ||
import { basicFlow } from '../helpers/flows/basic' | ||
import { | ||
createFlowBuilderPlugin, | ||
createRequest, | ||
getContentsAfterPreAndBotonicInit, | ||
} from '../helpers/utils' | ||
|
||
describe('Check the contents of a WhatsApp Button List node', () => { | ||
process.env.NODE_ENV = ProcessEnvNodeEnvs.PRODUCTION | ||
const flowBuilderPlugin = createFlowBuilderPlugin(basicFlow) | ||
|
||
test('The contents of the WhatsApp Button List are displayed', async () => { | ||
const request = createRequest({ | ||
input: { data: 'flowButtonList', type: INPUT.TEXT }, | ||
plugins: { | ||
// @ts-ignore | ||
flowBuilderPlugin, | ||
}, | ||
}) | ||
|
||
const { contents } = await getContentsAfterPreAndBotonicInit( | ||
request, | ||
flowBuilderPlugin | ||
) | ||
const buttonListContent = contents[0] as FlowWhatsappButtonList | ||
expect(buttonListContent.text).toBe('WhatsApp button list') | ||
expect(buttonListContent.listButtonText).toBe('Menu') | ||
|
||
const buttonListSections = buttonListContent.sections | ||
expect(buttonListSections.length).toBeGreaterThanOrEqual(1) | ||
|
||
const firstSection = buttonListSections[0] | ||
expect(firstSection.title).toBe('Section 1') | ||
|
||
const rows = firstSection.rows | ||
expect(rows.length).toBeGreaterThan(3) | ||
|
||
const firstRow = rows[0] | ||
expect(firstRow.title).toBe('Row title 1') | ||
expect(firstRow.description).toBe('Row description 1') | ||
expect(firstRow.targetId).toBe('128970b5-3404-472c-a0e7-b6aaa8d38bc9') | ||
}) | ||
}) |