Skip to content

Commit

Permalink
Merge pull request #923 from codigoencasa/dev
Browse files Browse the repository at this point in the history
pre-release
  • Loading branch information
leifermendez authored Nov 17, 2023
2 parents 8c931c4 + 9f586aa commit dfab218
Show file tree
Hide file tree
Showing 62 changed files with 862 additions and 643 deletions.
Empty file modified .husky/commit-msg
100644 → 100755
Empty file.
Empty file modified .husky/pre-commit
100644 → 100755
Empty file.
Empty file modified .husky/pre-push
100644 → 100755
Empty file.
21 changes: 11 additions & 10 deletions __test__/0.0.0-case.test.js → __test__/0.0.0-flow-simple.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ const assert = require('uvu/assert')
const { addKeyword, createBot, createFlow } = require('../packages/bot/index')
const { setup, clear, delay } = require('../__mocks__/env')

const suiteCase = suite('Flujo: Simple')
const testSuite = suite('Flujo: Simple')

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

suiteCase(`Responder a "hola"`, async ({ database, provider }) => {
const flow = addKeyword('hola').addAnswer('Buenas!').addAnswer('Como vamos!')
testSuite(`Responder a "hola"`, async ({ database, provider }) => {
const helloFlow = addKeyword('hola').addAnswer('Buenas!').addAnswer('Como vamos!')

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

await provider.delaySendMessage(0, 'message', {
Expand All @@ -23,18 +23,19 @@ suiteCase(`Responder a "hola"`, async ({ database, provider }) => {
})

await delay(50)

assert.is('Buenas!', database.listHistory[0].answer)
assert.is('Como vamos!', database.listHistory[1].answer)
assert.is(undefined, database.listHistory[2])
})

suiteCase(`NO reponder a "pepe"`, async ({ database, provider }) => {
const flow = addKeyword('hola').addAnswer('Buenas!').addAnswer('Como vamos!')
testSuite(`NO responder a "pepe"`, async ({ database, provider }) => {
const helloFlow = addKeyword('hola').addAnswer('Buenas!').addAnswer('Como vamos!')

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

await provider.delaySendMessage(0, 'message', {
Expand All @@ -48,4 +49,4 @@ suiteCase(`NO reponder a "pepe"`, async ({ database, provider }) => {
assert.is(undefined, database.listHistory[1])
})

suiteCase.run()
testSuite.run()
111 changes: 0 additions & 111 deletions __test__/0.0.1-case.test.js

This file was deleted.

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

const testSuite = suite('Flujo: enviando eventos')

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

testSuite(`Responder a "EVENTS.LOCATION"`, async ({ database, provider }) => {
const locationFlow = addKeyword(EVENTS.LOCATION).addAnswer('Gracias por tu location')

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

await provider.delaySendMessage(0, 'message', {
from: '000',
body: '_event_location__f405d946-cf07-uutt-l7e0-b6d475bc7f81',
})

await delay(200)
const history = database.listHistory.map((item) => item.answer)
assert.is('Gracias por tu location', history[0])
assert.is(undefined, history[1])
})

testSuite(`Responder a "EVENTS.DOCUMENT"`, async ({ database, provider }) => {
const documentFlow = addKeyword(EVENTS.DOCUMENT).addAnswer('Gracias por tu documento')

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

await provider.delaySendMessage(0, 'message', {
from: '000',
body: '_event_document__f405d946-cf07-uutt-l7e0-b6d475bc7f81',
})

await delay(200)
const history = database.listHistory.map((item) => item.answer)
assert.is('Gracias por tu documento', history[0])
assert.is(undefined, history[1])
})

testSuite(`Responder a "EVENTS.WELCOME"`, async ({ database, provider }) => {
const welcomeFlow = addKeyword(EVENTS.WELCOME).addAnswer('Bienvenido!')

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

await provider.delaySendMessage(0, 'message', {
from: '000',
body: '_event_welcome__f405d946-cf07-uutt-l7e0-b6d475bc7f81',
})

await delay(200)
const history = database.listHistory.map((item) => item.answer)
assert.is('Bienvenido!', history[0])
assert.is(undefined, history[1])
})

testSuite(`Responder a "EVENTS.MEDIA"`, async ({ database, provider }) => {
const mediaFlow = addKeyword(EVENTS.MEDIA).addAnswer('gracias por la imagen o video!')

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

await provider.delaySendMessage(0, 'message', {
from: '000',
body: '_event_media__f405d946-cf07-uutt-l7e0-b6d475bc7f81',
})

await delay(200)
const history = database.listHistory.map((item) => item.answer)
assert.is('gracias por la imagen o video!', history[0])
assert.is(undefined, history[1])
})

testSuite(`Responder a "EVENTS.VOICE_NOTE"`, async ({ database, provider }) => {
const voiceNoteFlow = addKeyword(EVENTS.VOICE_NOTE).addAnswer('gracias por la nota de voz!')

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

await provider.delaySendMessage(0, 'message', {
from: '000',
body: '_event_voice_note__f405d946-cf07-uutt-l7e0-b6d475bc7f81',
})

await delay(200)
const history = database.listHistory.map((item) => item.answer)
assert.is('gracias por la nota de voz!', history[0])
assert.is(undefined, history[1])
})

testSuite.run()
119 changes: 0 additions & 119 deletions __test__/0.0.2-case.test.js

This file was deleted.

Loading

0 comments on commit dfab218

Please sign in to comment.