Skip to content

Commit a5c9b45

Browse files
vanbasten17Iru89
andauthored
botonic-react & plugin-flow-builder: allow creating test cases #BLT-1491 (#2992)
## Description Remove code to not create cases from provider accounts flagged as test --------- Co-authored-by: Oriol Raventos <o.raventos.89@gmail.com>
1 parent 748229d commit a5c9b45

File tree

14 files changed

+128
-154
lines changed

14 files changed

+128
-154
lines changed

package-lock.json

Lines changed: 104 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/botonic-core/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ All notable changes to Botonic will be documented in this file.
2020

2121
</details>
2222

23+
## [0.34.0] - 2025-04-01
24+
25+
### Added
26+
27+
- [PR-2292](https://github.com/hubtype/botonic/pull/2992): Allow create handoff test cases
28+
2329
## [0.33.2] - 2025-04-01
2430

2531
### Added

packages/botonic-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@botonic/core",
3-
"version": "0.33.2",
3+
"version": "0.34.0-alpha.0",
44
"license": "MIT",
55
"description": "Build Chatbots using React",
66
"main": "./lib/cjs/index.js",

packages/botonic-core/src/core-bot.ts

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,6 @@ export class CoreBot {
101101
})
102102
}
103103

104-
if (session._botonic_action?.startsWith(BotonicAction.CreateTestCase)) {
105-
return await this.runFollowUpTestIntegrationInput(output, {
106-
input,
107-
session,
108-
lastRoutePath,
109-
})
110-
}
111-
112104
return output
113105
}
114106

@@ -242,37 +234,6 @@ export class CoreBot {
242234
}
243235
}
244236

245-
private async runFollowUpTestIntegrationInput(
246-
previousResponse: BotResponse,
247-
{ input, session, lastRoutePath }: BotRequest
248-
) {
249-
const [_, onFinishPayloadId] = session._botonic_action!.split(
250-
'create_test_integration_case:'
251-
)
252-
const inputWithOnFinishPayload: Input = {
253-
...input,
254-
payload: onFinishPayloadId,
255-
type: INPUT.POSTBACK,
256-
data: undefined,
257-
text: undefined,
258-
}
259-
260-
session._botonic_action = undefined
261-
262-
const followUp = await this.runInput({
263-
input: inputWithOnFinishPayload,
264-
session,
265-
lastRoutePath,
266-
})
267-
268-
return {
269-
input: followUp.input,
270-
response: previousResponse.response.concat(followUp.response),
271-
session,
272-
lastRoutePath: followUp.lastRoutePath,
273-
}
274-
}
275-
276237
private async runRedirectAction(
277238
previousResponse: BotResponse,
278239
{ input, session, lastRoutePath }: BotRequest,
@@ -322,16 +283,6 @@ export class CoreBot {
322283
)
323284
}
324285

325-
if (
326-
response.session._botonic_action?.startsWith(BotonicAction.CreateTestCase)
327-
) {
328-
return await this.runFollowUpTestIntegrationInput(response, {
329-
input,
330-
session,
331-
lastRoutePath,
332-
})
333-
}
334-
335286
return response
336287
}
337288
}

packages/botonic-core/src/handoff.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,11 +267,7 @@ async function _humanHandOff(
267267
if (subscribeHelpdeskEvents.length > 0) {
268268
params.subscribe_helpdesk_events = subscribeHelpdeskEvents
269269
}
270-
if (!session.is_test_integration) {
271-
session._botonic_action = `${BotonicAction.CreateCase}:${JSON.stringify(params)}`
272-
} else {
273-
session._botonic_action = `${BotonicAction.CreateTestCase}:${params.on_finish || ''}`
274-
}
270+
session._botonic_action = `${BotonicAction.CreateCase}:${JSON.stringify(params)}`
275271
}
276272

277273
export async function storeCaseRating(

packages/botonic-core/src/models/legacy-types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,6 @@ export type Matcher = string | RegExp | ((args) => boolean)
389389

390390
export type BotonicActionType =
391391
| `${BotonicAction.CreateCase}${BotonicActionSeparator}${string}`
392-
| `${BotonicAction.CreateTestCase}${BotonicActionSeparator}${string}`
393392
| `${BotonicAction.Redirect}${BotonicActionSeparator}${string}`
394393
| `${BotonicAction.DiscardCase}${BotonicActionSeparator}${string}`
395394
| `${BotonicAction.DiscardCase}`
@@ -400,7 +399,6 @@ type BotonicActionSeparator = ':'
400399
export enum BotonicAction {
401400
Redirect = 'redirect_action',
402401
CreateCase = 'create_case',
403-
CreateTestCase = 'create_test_integration_case',
404402
DeleteUser = 'delete_user',
405403
DiscardCase = 'discard_case',
406404
}

packages/botonic-core/tests/core-bot/core-bot.test.ts

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -218,58 +218,6 @@ describe('CoreBot', () => {
218218
})
219219
})
220220

221-
it('input returns the follow up when a handoff is done in a test integration', async () => {
222-
// Arrange
223-
const session = {
224-
is_test_integration: true,
225-
_botonic_action: `${BotonicAction.CreateTestCase}:payload1`,
226-
}
227-
228-
const coreBot = initCoreBotWithDeveloperConfig({
229-
routes: [
230-
{
231-
path: '',
232-
text: 'hello',
233-
action: 'Hi user!',
234-
},
235-
{
236-
path: 'follow-up',
237-
payload: 'payload1',
238-
action: 'Follow up action',
239-
},
240-
],
241-
})
242-
243-
// Act
244-
const botResponse = await coreBot.input({
245-
input: { type: 'text', data: 'hello' },
246-
session,
247-
lastRoutePath: '',
248-
})
249-
250-
// Assert
251-
expect(botResponse.input).toEqual({
252-
type: 'postback',
253-
data: undefined,
254-
payload: 'payload1',
255-
text: undefined,
256-
})
257-
expect(botResponse.session).toEqual({
258-
is_test_integration: true,
259-
_botonic_action: undefined,
260-
__locale: 'en',
261-
__retries: 0,
262-
is_first_interaction: false,
263-
})
264-
expect(botResponse.lastRoutePath).toEqual('follow-up')
265-
expect(botResponse.response[0].actions).toEqual([null, 'Hi user!', null])
266-
expect(botResponse.response[1].actions).toEqual([
267-
null,
268-
'Follow up action',
269-
null,
270-
])
271-
})
272-
273221
it('input returns two actions when first returen a _botonic_action redirect', async () => {
274222
// Arrange
275223
const session = {

packages/botonic-core/tests/handoff.test.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,6 @@ describe('Handoff', () => {
129129
expect(builder._session._botonic_action).toEqual(expectedBotonicAction)
130130
})
131131

132-
test('defines create_test_integration_case_with_payload for test integrations', () => {
133-
const builder = new HandOffBuilder({
134-
is_test_integration: true,
135-
}).withOnFinishPayload('payload1')
136-
builder.handOff()
137-
const expectedBotonicAction = `${BotonicAction.CreateTestCase}:payload1`
138-
expect(builder._session._botonic_action).toEqual(expectedBotonicAction)
139-
})
140-
141132
test('Create a handoff and subscribe to agent_messsage_created', () => {
142133
const builder = new HandOffBuilder({})
143134
.withSubscribeHelpdeskEvents([HelpdeskEvent.AgentMessageCreated])

packages/botonic-plugin-flow-builder/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ All notable changes to Botonic will be documented in this file.
2020

2121
</details>
2222

23+
## [0.34.0] - 2025-04-01
24+
25+
### Added
26+
27+
- [PR-2292](https://github.com/hubtype/botonic/pull/2992): Allow create handoff test cases
28+
2329
## [0.33.1] - 2025-04-01
2430

2531
### Added

0 commit comments

Comments
 (0)