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

Release/production #874

Merged
merged 35 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
748c73b
pushName added
enrique-holguin Sep 5, 2023
0a8b527
Merge branch 'dev' of https://github.com/enrique-holguin/bot-whatsapp…
enrique-holguin Sep 5, 2023
ac24227
sticker and video added
enrique-holguin Sep 12, 2023
1af603f
Merge pull request #850 from enrique-holguin/feat/baileys-video-sticker
leifermendez Sep 13, 2023
6493899
Merge pull request #846 from enrique-holguin/feat/pushname-meta
leifermendez Sep 13, 2023
a6ea656
Update index.mdx
Askabel Sep 13, 2023
b7d104c
Update CONTRIBUTING.md
Askabel Sep 13, 2023
3a84069
Merge pull request #854 from Askabel/patch-3
leifermendez Sep 14, 2023
e711358
Merge pull request #853 from Askabel/patch-2
leifermendez Sep 14, 2023
751594f
build: mejorando
leifermendez Sep 21, 2023
7d60d94
Merge branch 'dev' of github.com:codigoencasa/bot-whatsapp into dev
leifermendez Sep 21, 2023
96eeceb
chore: :art: `flowDynamic` delay option
leifermendez Sep 27, 2023
35d1279
fix: :art: more
leifermendez Sep 27, 2023
70d75ed
feat: :art: next-version
leifermendez Sep 28, 2023
dab9e51
fix: queue timer clear
leifermendez Sep 29, 2023
215ccfe
fix: queue timer clear
leifermendez Sep 29, 2023
74b0054
Merge pull request #867 from codigoencasa/dev
leifermendez Sep 29, 2023
e13f912
fix: remove map
leifermendez Sep 30, 2023
07dd0fe
fix: idle
leifermendez Sep 30, 2023
e2a6cbd
feat(bot): :zap: idle feature
leifermendez Sep 30, 2023
71146de
test: :art: more test coverage
leifermendez Sep 30, 2023
1291b63
Merge branch 'release/next' into dev
leifermendez Sep 30, 2023
859d5ab
Merge pull request #868 from codigoencasa/dev
leifermendez Sep 30, 2023
158849f
feat: next release
leifermendez Sep 30, 2023
a39c9d2
feat: idle state
leifermendez Oct 1, 2023
d496259
Merge branch 'release/next' into dev
leifermendez Oct 1, 2023
44307f6
Merge pull request #869 from codigoencasa/dev
leifermendez Oct 1, 2023
7b5f8fd
feat: meta add fileUrl image
leifermendez Oct 1, 2023
98eda95
Merge branch 'dev' of github.com:codigoencasa/bot-whatsapp into dev
leifermendez Oct 1, 2023
26a0b50
Merge branch 'release/next' into dev
leifermendez Oct 1, 2023
843a6c2
next-release
leifermendez Oct 1, 2023
3f50a05
feat: next-release
leifermendez Oct 2, 2023
8cd3abb
Merge branch 'release/next' into dev
leifermendez Oct 2, 2023
0b800a5
Merge pull request #872 from codigoencasa/dev
leifermendez Oct 2, 2023
f72df9e
next-version
leifermendez Oct 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ En la consola encontraras los pasos a seguir -->
![](https://i.imgur.com/dC6lEwy.png)


> __NOTA:__ [Eres libre de aportar informacion a este documento o arreglar ortografia 🤣](
> __NOTA:__ [Eres libre de aportar informacion inexacta a este documento o arreglar horrores de ortografia que dificultan la comprensión. 🤣](
https://github.com/codigoencasa/bot-whatsapp/edit/dev/CONTRIBUTING.md)

------
Expand Down
103 changes: 97 additions & 6 deletions __test__/0.1.7-case.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ suiteCase(`Debe retornar un mensaje resumen`, async ({ database, provider }) =>
capture: true,
},
async (ctx, { flowDynamic, state }) => {
state.update({ name: ctx.body })
flowDynamic('Gracias por tu nombre!')
await state.update({ name: ctx.body })
await flowDynamic('Gracias por tu nombre!')
}
)
.addAnswer(
Expand All @@ -28,14 +28,14 @@ suiteCase(`Debe retornar un mensaje resumen`, async ({ database, provider }) =>
capture: true,
},
async (ctx, { flowDynamic, state }) => {
state.update({ age: ctx.body })
const myState = state.getMyState()
await flowDynamic(`Gracias por tu edad! ${myState.name}`)
await state.update({ age: ctx.body })
const name = state.get('name')
await flowDynamic(`Gracias por tu edad! ${name}`)
}
)
.addAnswer(MOCK_VALUES[2], null, async (_, { flowDynamic, state }) => {
const myState = state.getMyState()
flowDynamic(`Nombre: ${myState.name} Edad: ${myState.age}`)
await flowDynamic(`Nombre: ${myState.name} Edad: ${myState.age}`)
})
.addAnswer('🤖🤖 Gracias por tu participacion')

Expand Down Expand Up @@ -98,4 +98,95 @@ suiteCase(`Debe retornar un mensaje resumen`, async ({ database, provider }) =>
assert.is(undefined, getHistory[18])
})

suiteCase(`Manejando globalState`, async ({ database, provider }) => {
const MOCK_VALUES = ['¿Cual es tu nombre?', '¿Cual es tu edad?', 'Tu datos son:']

const flujoPrincipal = addKeyword(['hola'])
.addAnswer(
MOCK_VALUES[0],
{
capture: true,
},
async (ctx, { flowDynamic, state, globalState }) => {
await state.update({ name: ctx.body })
await globalState.update({ value: 'Soy el valor global' })
await flowDynamic('Gracias por tu nombre!')
}
)
.addAnswer(
MOCK_VALUES[1],
{
capture: true,
},
async (ctx, { flowDynamic, state }) => {
await state.update({ age: ctx.body })
const name = state.get('name')
await flowDynamic(`Gracias por tu edad! ${name}`)
}
)
.addAnswer(MOCK_VALUES[2], null, async (_, { flowDynamic, state, globalState }) => {
const myState = state.getMyState()
const value = globalState.get('value')
await flowDynamic(`Nombre: ${myState.name} Edad: ${myState.age} Valor Global: ${value}`)
})
.addAnswer('🤖🤖 Gracias por tu participacion')

createBot({
database,
flow: createFlow([flujoPrincipal]),
provider,
})

await provider.delaySendMessage(0, 'message', {
from: '000',
body: 'hola',
})

await provider.delaySendMessage(5, 'message', {
from: '001',
body: 'hola',
})

await provider.delaySendMessage(10, 'message', {
from: '000',
body: 'Leifer',
})

await provider.delaySendMessage(15, 'message', {
from: '000',
body: '90',
})

await provider.delaySendMessage(20, 'message', {
from: '001',
body: 'Maria',
})

await provider.delaySendMessage(25, 'message', {
from: '001',
body: '100',
})

await delay(1000)
const getHistory = database.listHistory.map((i) => i.answer)
assert.is(MOCK_VALUES[0], getHistory[0])
assert.is('¿Cual es tu nombre?', getHistory[1])
assert.is('Leifer', getHistory[2])
assert.is('Gracias por tu nombre!', getHistory[3])
assert.is('¿Cual es tu edad?', getHistory[4])
assert.is('90', getHistory[5])
assert.is('Gracias por tu edad! Leifer', getHistory[6])
assert.is('Tu datos son:', getHistory[7])
assert.is('Nombre: Leifer Edad: 90 Valor Global: Soy el valor global', getHistory[8])
assert.is('🤖🤖 Gracias por tu participacion', getHistory[9])
assert.is('Maria', getHistory[10])
assert.is('Gracias por tu nombre!', getHistory[11])
assert.is('¿Cual es tu edad?', getHistory[12])
assert.is('100', getHistory[13])
assert.is('Gracias por tu edad! Maria', getHistory[14])
assert.is('Tu datos son:', getHistory[15])
assert.is('Nombre: Maria Edad: 100 Valor Global: Soy el valor global', getHistory[16])
assert.is('🤖🤖 Gracias por tu participacion', getHistory[17])
assert.is(undefined, getHistory[18])
})
suiteCase.run()
11 changes: 7 additions & 4 deletions __test__/0.1.8-case.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@ suiteCase(`Debe ejecutar accion con captura`, async ({ database, provider }) =>

await delay(1000)
const getHistory = database.listHistory.map((i) => i.answer)
assert.is('Buenas! ¿Cual es tu nombre?', getHistory[0])
assert.is('Gracias por tu nombre!: Leifer', getHistory[3])
assert.is('Chao!', getHistory[4])
assert.is(undefined, getHistory[5])
assert.is('__call_action__', getHistory[0])
assert.is('Buenas! ¿Cual es tu nombre?', getHistory[1])
assert.is('__capture_only_intended__', getHistory[2])
assert.is('Leifer', getHistory[3])
assert.is('Gracias por tu nombre!: Leifer', getHistory[4])
assert.is('Chao!', getHistory[5])
assert.is(undefined, getHistory[6])
})

suiteCase.run()
44 changes: 44 additions & 0 deletions __test__/0.1.9-case.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const { suite } = require('uvu')
const assert = require('uvu/assert')
const { addKeyword, createBot, createFlow } = require('../packages/bot/index')
const { setup, clear, delay } = require('../__mocks__/env')

const suiteCase = suite('Flujo: flowDynamic (delay)')

suiteCase.before.each(setup)
suiteCase.after.each(clear)

suiteCase(`Delay en los flowDynamic`, async ({ database, provider }) => {
const flujoPrincipal = addKeyword(['hola'])
.addAction(async (_, { flowDynamic }) => {
await flowDynamic('Buenas! ¿Cual es tu nombre? este mensaje debe tener delay 1000', { delay: 1000 })
await flowDynamic([{ body: 'Todo bien?', delay: 850 }])
})
.addAnswer('Bien!', null, async (_, { flowDynamic }) => {
await flowDynamic('si nada')
})
.addAnswer('Chao!')

await createBot({
database,
flow: createFlow([flujoPrincipal]),
provider,
})

await provider.delaySendMessage(0, 'message', {
from: '000',
body: 'hola',
})

await delay(2000)
const getHistory = database.listHistory.map((i) => i.answer)
assert.is('__call_action__', getHistory[0])
assert.is('Buenas! ¿Cual es tu nombre? este mensaje debe tener delay 1000', getHistory[1])
assert.is('Todo bien?', getHistory[2])
assert.is('Bien!', getHistory[3])
assert.is('si nada', getHistory[4])
assert.is('Chao!', getHistory[5])
assert.is(undefined, getHistory[6])
})

suiteCase.run()
61 changes: 61 additions & 0 deletions __test__/0.2.0-case.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
const { suite } = require('uvu')
const assert = require('uvu/assert')
const { addKeyword, createBot, createFlow } = require('../packages/bot/index')
const { setup, clear, delay } = require('../__mocks__/env')

const suiteCase = suite('Flujo: addAction (capture) encadenados')

suiteCase.before.each(setup)
suiteCase.after.each(clear)

suiteCase(`Encadenanos addAction con captures`, async ({ database, provider }) => {
const flujoPrincipal = addKeyword(['hola'])
.addAction(async (ctx, { flowDynamic }) => {
await flowDynamic(`Hola! primer flow dynamic. respondeme algo`)
})
.addAction({ capture: true }, async (ctx, { flowDynamic, state }) => {
const reply = ctx.body
await state.update({ reply })
await flowDynamic(`Esto me respondieste ${reply}`)
})
.addAction(async (ctx, { flowDynamic }) => {
await flowDynamic(`Hola! segundo flow dynamic. respondeme algo`)
})
.addAction({ capture: true }, async (ctx, { flowDynamic, state }) => {
const currentState = state.getMyState()?.reply
const reply = ctx.body
await state.update({ reply: currentState + ' ' + reply })
await flowDynamic(`Esto me respondieste ${reply}`)
})
.addAnswer('Chao')

await createBot({
database,
flow: createFlow([flujoPrincipal]),
provider,
})

await provider.delaySendMessage(0, 'message', {
from: '000',
body: 'hola',
})

await provider.delaySendMessage(10, 'message', {
from: '000',
body: 'ping',
})

await delay(2000)
const getHistory = database.listHistory.map((i) => i.answer)
assert.is('__call_action__', getHistory[0])
assert.is('Hola! primer flow dynamic. respondeme algo', getHistory[1])
assert.is('__capture_only_intended__', getHistory[2])
assert.is('ping', getHistory[3])
assert.is('Esto me respondieste ping', getHistory[4])
assert.is('__call_action__', getHistory[5])
assert.is('Hola! segundo flow dynamic. respondeme algo', getHistory[6])
assert.is('__capture_only_intended__', getHistory[7])
assert.is(undefined, getHistory[8])
})

suiteCase.run()
Loading