Skip to content

Commit

Permalink
fix(webhook): update snapshot of context output
Browse files Browse the repository at this point in the history
  • Loading branch information
MrOrz committed Dec 19, 2023
1 parent f8ebe6c commit c814fad
Show file tree
Hide file tree
Showing 5 changed files with 180 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,14 @@ Array [

exports[`should submit article if user agrees to submit: has AI reply 1`] = `
Object {
"data": Object {
"searchedText": "Some text forwarded by the user",
"context": Object {
"msgs": Array [
Object {
"id": "foo",
"text": "Some text forwarded by the user",
"type": "text",
},
],
"sessionId": 1577923200000,
},
"replies": Array [
Expand Down Expand Up @@ -325,8 +331,14 @@ Object {

exports[`should submit article if user agrees to submit: has no AI reply 1`] = `
Object {
"data": Object {
"searchedText": "Some text forwarded by the user",
"context": Object {
"msgs": Array [
Object {
"id": "foo",
"text": "Some text forwarded by the user",
"type": "text",
},
],
"sessionId": 1577923200000,
},
"replies": Array [
Expand Down Expand Up @@ -475,10 +487,13 @@ Object {

exports[`should submit image article if user agrees to submit 1`] = `
Object {
"data": Object {
"messageId": "6530038889933",
"messageType": "image",
"searchedText": "",
"context": Object {
"msgs": Array [
Object {
"id": "6530038889933",
"type": "image",
},
],
"sessionId": 1577923200000,
},
"replies": Array [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@

exports[`should ask users if they want to submit article when user say not found 1`] = `
Object {
"data": Object {
"searchedText": "這一篇文章確實是一個轉傳文章,他夠長,看起來很轉傳,但是使用者覺得資料庫裡沒有。",
"context": Object {
"msgs": Array [
Object {
"id": "foo",
"text": "這一篇文章確實是一個轉傳文章,他夠長,看起來很轉傳,但是使用者覺得資料庫裡沒有。",
"type": "text",
},
],
"sessionId": 0,
},
"replies": Array [
Expand Down Expand Up @@ -85,9 +91,13 @@ May I ask you a quick question?",

exports[`should ask users if they want to submit image article when user say not found 1`] = `
Object {
"data": Object {
"messageId": "6530038889933",
"messageType": "image",
"context": Object {
"msgs": Array [
Object {
"id": "6530038889933",
"type": "image",
},
],
"sessionId": 0,
},
"replies": Array [
Expand Down Expand Up @@ -198,8 +208,14 @@ Array [

exports[`should select article and choose the only one reply for user 1`] = `
Object {
"data": Object {
"searchedText": "Just One Reply Just One Reply Just One Reply Just One Reply Just One Reply",
"context": Object {
"msgs": Array [
Object {
"id": "foo",
"text": "Just One Reply Just One Reply Just One Reply Just One Reply Just One Reply",
"type": "text",
},
],
"sessionId": 0,
},
"replies": Array [
Expand Down Expand Up @@ -325,8 +341,14 @@ https://dev.cofacts.tw/article/article-id",

exports[`should select article and have OPINIONATED and NOT_ARTICLE replies 1`] = `
Object {
"data": Object {
"searchedText": "老榮民九成存款全部捐給慈濟,如今窮了卻得不到慈濟醫院社工的幫忙,竟翻臉不認人",
"context": Object {
"msgs": Array [
Object {
"id": "foo",
"text": "老榮民九成存款全部捐給慈濟,如今窮了卻得不到慈濟醫院社工的幫忙,竟翻臉不認人",
"type": "text",
},
],
"sessionId": 1497994017447,
},
"replies": Array [
Expand Down Expand Up @@ -671,8 +693,14 @@ Object {

exports[`should select article and slice replies when over 10 1`] = `
Object {
"data": Object {
"searchedText": "老榮民九成存款全部捐給慈濟,如今窮了卻得不到慈濟醫院社工的幫忙,竟翻臉不認人",
"context": Object {
"msgs": Array [
Object {
"id": "foo",
"text": "老榮民九成存款全部捐給慈濟,如今窮了卻得不到慈濟醫院社工的幫忙,竟翻臉不認人",
"type": "text",
},
],
"sessionId": 0,
},
"replies": Array [
Expand Down Expand Up @@ -1490,13 +1518,19 @@ Object {

exports[`should select article by articleId 1`] = `
Object {
"data": Object {
"searchedText": "《緊急通知
"context": Object {
"msgs": Array [
Object {
"id": "foo",
"text": "《緊急通知
台北馬偕醫院傳來訊息:
資深醫生(林清風)傳來:「請大家以後千萬不要再吃生魚片了!」
因為最近已經發現- 好多病人因為吃了生魚片,胃壁附著《海獸胃腺蟲》,大小隻不一定,有的病人甚至胃壁上滿滿都是無法夾出來,驅蟲藥也很難根治,罹患機率每個國家的人都一樣。
尤其;鮭魚的含蟲量最高、最可怕!
請傳給朋友,讓他們有所警惕!",
"type": "text",
},
],
"sessionId": 0,
},
"replies": Array [
Expand Down Expand Up @@ -1683,8 +1717,14 @@ Object {

exports[`should select article with no replies: has AI reply 1`] = `
Object {
"data": Object {
"searchedText": "老司機車裡總備一塊香皂,知道內情的新手默默也準備了一塊",
"context": Object {
"msgs": Array [
Object {
"id": "foo",
"text": "老司機車裡總備一塊香皂,知道內情的新手默默也準備了一塊",
"type": "text",
},
],
"sessionId": 0,
},
"replies": Array [
Expand Down Expand Up @@ -1862,8 +1902,14 @@ Don’t trust the message just yet!",

exports[`should select article with no replies: has no AI reply 1`] = `
Object {
"data": Object {
"searchedText": "老司機車裡總備一塊香皂,知道內情的新手默默也準備了一塊",
"context": Object {
"msgs": Array [
Object {
"id": "foo",
"text": "老司機車裡總備一塊香皂,知道內情的新手默默也準備了一塊",
"type": "text",
},
],
"sessionId": 0,
},
"replies": Array [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,14 @@ Array [

exports[`should select reply by replyId should handle the case with just one reply 1`] = `
Object {
"data": Object {
"searchedText": "貼圖",
"context": Object {
"msgs": Array [
Object {
"id": "foo",
"text": "貼圖",
"type": "text",
},
],
"sessionId": 0,
},
"replies": Array [
Expand Down Expand Up @@ -370,8 +376,14 @@ https://dev.cofacts.tw/article/AWDZYXxAyCdS-nWhumlz",

exports[`should select reply by replyId should handle the case with multiple replies 1`] = `
Object {
"data": Object {
"searchedText": "貼圖",
"context": Object {
"msgs": Array [
Object {
"id": "foo",
"text": "貼圖",
"type": "text",
},
],
"sessionId": 0,
},
"replies": Array [
Expand Down
80 changes: 64 additions & 16 deletions src/webhook/handlers/__tests__/__snapshots__/initState.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@

exports[`article found 1`] = `
Object {
"data": Object {
"searchedText": "計程車上有裝悠遊卡感應器,老人悠悠卡可以享受優惠部分由政府補助,不影響司機收入",
"context": Object {
"msgs": Array [
Object {
"id": "abc",
"text": "計程車上有裝悠遊卡感應器,老人悠悠卡可以享受優惠部分由政府補助,不影響司機收入",
"type": "text",
},
],
"sessionId": 1497994017447,
},
"replies": Array [
Expand Down Expand Up @@ -161,8 +167,14 @@ Please choose the version that looks the most similar👇",

exports[`articles found with high similarity 1`] = `
Object {
"data": Object {
"searchedText": "YouTube · 寻找健康人生",
"context": Object {
"msgs": Array [
Object {
"id": "abc",
"text": "YouTube · 寻找健康人生",
"type": "text",
},
],
"sessionId": 1497994017447,
},
"replies": Array [
Expand Down Expand Up @@ -348,8 +360,14 @@ Please choose the version that looks the most similar👇",

exports[`input matches dialogflow intent search article when input length > 10 and intentDetectionConfidence != 1 1`] = `
Object {
"data": Object {
"searchedText": "零一二三四五六七八九十",
"context": Object {
"msgs": Array [
Object {
"id": "abc",
"text": "零一二三四五六七八九十",
"type": "text",
},
],
"sessionId": 1497994017447,
},
"replies": Array [
Expand Down Expand Up @@ -431,8 +449,14 @@ May I ask you a quick question?",

exports[`input matches dialogflow intent uses dialogflow response when input length < 10 1`] = `
Object {
"data": Object {
"searchedText": "你好",
"context": Object {
"msgs": Array [
Object {
"id": "abc",
"text": "你好",
"type": "text",
},
],
"sessionId": 1497994017447,
},
"replies": Array [
Expand All @@ -446,8 +470,14 @@ Object {

exports[`input matches dialogflow intent uses dialogflow response when input length > 10 and intentDetectionConfidence = 1 1`] = `
Object {
"data": Object {
"searchedText": "零一二三四五六七八九十",
"context": Object {
"msgs": Array [
Object {
"id": "abc",
"text": "零一二三四五六七八九十",
"type": "text",
},
],
"sessionId": 1497994017447,
},
"replies": Array [
Expand All @@ -461,8 +491,14 @@ Object {

exports[`only one article found with high similarity and choose for user 1`] = `
Object {
"data": Object {
"searchedText": "YouTube · 寻找健康人生",
"context": Object {
"msgs": Array [
Object {
"id": "abc",
"text": "YouTube · 寻找健康人生",
"type": "text",
},
],
"sessionId": 1497994017447,
},
"replies": Array [
Expand Down Expand Up @@ -613,8 +649,14 @@ Don’t trust the message just yet!",

exports[`should handle message matches only hyperlinks 1`] = `
Object {
"data": Object {
"searchedText": "YouTube · 寻找健康人生",
"context": Object {
"msgs": Array [
Object {
"id": "abc",
"text": "YouTube · 寻找健康人生",
"type": "text",
},
],
"sessionId": 1497994017447,
},
"replies": Array [
Expand Down Expand Up @@ -920,8 +962,14 @@ title2 title2 title2 ",

exports[`should handle text not found 1`] = `
Object {
"data": Object {
"searchedText": "YouTube · 寻找健康人生 驚!大批香蕉受到愛滋血污染!這種香蕉千萬不要吃!吃到可能會被 ...",
"context": Object {
"msgs": Array [
Object {
"id": "abc",
"text": "YouTube · 寻找健康人生 驚!大批香蕉受到愛滋血污染!這種香蕉千萬不要吃!吃到可能會被 ...",
"type": "text",
},
],
"sessionId": 1497994017447,
},
"replies": Array [
Expand Down
Loading

0 comments on commit c814fad

Please sign in to comment.