From d3acc717276e211a16de1900649c44e2c75dbe38 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Wed, 20 Sep 2023 21:55:52 +0800 Subject: [PATCH 01/12] implement userhandler idempotency --- functions/src/definitions/common/utils.ts | 8 ++ functions/src/definitions/userHandlers.ts | 106 ++++++++++++++++---- functions/src/definitions/webhookHandler.ts | 13 +++ integration-tests/env.json | 7 +- 4 files changed, 112 insertions(+), 22 deletions(-) diff --git a/functions/src/definitions/common/utils.ts b/functions/src/definitions/common/utils.ts index 3aa3778e..a200af74 100644 --- a/functions/src/definitions/common/utils.ts +++ b/functions/src/definitions/common/utils.ts @@ -33,6 +33,13 @@ const checkUrl = function (urlString: string) { return url.protocol === "http:" || url.protocol === "https:" } +async function checkMessageId(messageId: string) { + const db = admin.firestore() + const messageRef = db.doc(`messagesIds/${messageId}`) + const messageSnap = await messageRef.get() + return messageSnap.exists +} + function stripPhone(originalStr: string, includePlaceholder = false) { const phoneNumbers = findPhoneNumbersInText(originalStr) let newStr = originalStr @@ -91,4 +98,5 @@ export { getThresholds, checkUrl, normalizeSpaces, + checkMessageId, } diff --git a/functions/src/definitions/userHandlers.ts b/functions/src/definitions/userHandlers.ts index 8d877ea2..71b9fac2 100644 --- a/functions/src/definitions/userHandlers.ts +++ b/functions/src/definitions/userHandlers.ts @@ -9,7 +9,12 @@ import { sendWhatsappContactMessage, } from "./common/sendWhatsappMessage" import { sendDisputeNotification } from "./common/sendMessage" -import { sleep, hashMessage, normalizeSpaces } from "./common/utils" +import { + sleep, + hashMessage, + normalizeSpaces, + checkMessageId, +} from "./common/utils" import { getResponsesObj, sendMenuMessage, @@ -44,6 +49,15 @@ const hashids = new Hashids(salt) const db = admin.firestore() const userHandlerWhatsapp = async function (message: Message) { + if (!message?.id) { + functions.logger.error("No message id") + return + } + if (await checkMessageId(message.id)) { + functions.logger.warn(`Message ${message.id} already exists`) + return + } + let from = message.from // extract the phone number from the webhook payload let type = message.type const responses = await getResponsesObj("user") @@ -161,7 +175,7 @@ const userHandlerWhatsapp = async function (message: Message) { step = await newTextInstanceHandler({ text: message.text.body, timestamp: messageTimestamp, - id: message.id || null, + id: message.id, from: from || null, isForwarded: message?.context?.forwarded || null, isFrequentlyForwarded: message?.context?.frequently_forwarded || null, @@ -173,7 +187,7 @@ const userHandlerWhatsapp = async function (message: Message) { step = await newImageInstanceHandler({ caption: message?.image?.caption || null, timestamp: messageTimestamp, - id: message.id || null, + id: message.id, mediaId: message?.image?.id || null, mimeType: message?.image?.mime_type || null, from: from || null, @@ -253,14 +267,15 @@ async function newTextInstanceHandler({ }: { text: string timestamp: Timestamp - id: string | null + id: string from: string | null isForwarded: boolean | null isFrequentlyForwarded: boolean | null isFirstTimeUser: boolean }) { let hasMatch = false - let messageRef + let messageRef: FirebaseFirestore.DocumentReference | null = null + let messageUpdateObj: Object | null = null const machineCategory = (await classifyText(text)) ?? "error" if (from && isFirstTimeUser && machineCategory.includes("irrelevant")) { await db.collection("users").doc(from).update({ @@ -286,7 +301,7 @@ async function newTextInstanceHandler({ let bestMatchingDocumentRef let bestMatchingText let similarityScore = 0 - let matchedParentMessageRef + let matchedParentMessageRef = null if ( similarity.ref && @@ -306,7 +321,8 @@ async function newTextInstanceHandler({ } if (!hasMatch) { - let writeResult = await db.collection("messages").add({ + messageRef = db.collection("messages").doc() + messageUpdateObj = { machineCategory: machineCategory, //Can be "fake news" or "scam" isMachineCategorised: !!( machineCategory && @@ -349,17 +365,18 @@ async function newTextInstanceHandler({ : null, customReply: null, //string instanceCount: 0, - }) - messageRef = writeResult + } } else { messageRef = matchedParentMessageRef } if (!messageRef) { - throw new Error( + functions.logger.error( `No messageRef created or matched for whatsapp message with id ${id}` ) + return } - const _ = await messageRef.collection("instances").add({ + const instanceRef = messageRef.collection("instances").doc() + const instanceUpdateObj = { source: "whatsapp", id: id || null, //taken from webhook object, needed to reply timestamp: timestamp, //timestamp, taken from webhook object (firestore timestamp data type) @@ -394,7 +411,29 @@ async function newTextInstanceHandler({ }, isSatisfactionSurveySent: null, satisfactionScore: null, - }) + } + const messageIdRef = db.collection("messageIds").doc(id) + try { + await db.runTransaction(async (t) => { + const doc = await t.get(messageIdRef) + if (doc.exists) { + return + } + if (!hasMatch && !!messageRef && !!messageUpdateObj) { + t.set(messageRef, messageUpdateObj) + } + t.set(instanceRef, instanceUpdateObj) + t.set(messageIdRef, { instanceRef: instanceRef }) + }) + functions.logger.log( + `Transaction success for messageId ${id} from ${from}!` + ) + } catch (e) { + functions.logger.error( + `Transaction failure for messageId ${id} from ${from}!`, + e + ) + } return Promise.resolve(`text_machine_${machineCategory}`) } @@ -413,14 +452,15 @@ async function newImageInstanceHandler({ mediaId: string | null mimeType: string | null timestamp: Timestamp - id: string | null + id: string from: string | null isForwarded: boolean | null isFrequentlyForwarded: boolean | null isFirstTimeUser: boolean }) { let filename - let messageRef + let messageRef: FirebaseFirestore.DocumentReference | null = null + let messageUpdateObj: Object | null = null let hasMatch = false let matchType = "none" // will be set to either "similarity" or "image" or "none" let matchedInstanceSnap @@ -512,7 +552,7 @@ async function newImageInstanceHandler({ let bestMatchingDocumentRef let bestMatchingText let similarityScore = 0 - let matchedParentMessageRef + let matchedParentMessageRef = null let textHash = null if (ocrSuccess && isConvo && !!extractedMessage && !hasMatch) { @@ -547,7 +587,8 @@ async function newImageInstanceHandler({ } if (!hasMatch || (!matchedInstanceSnap && !matchedParentMessageRef)) { - let writeResult = await db.collection("messages").add({ + messageRef = db.collection("messages").doc() + messageUpdateObj = { machineCategory: machineCategory, //Can be "fake news" or "scam" isMachineCategorised: !!( machineCategory && @@ -587,8 +628,7 @@ async function newImageInstanceHandler({ : null, customReply: null, //string instanceCount: 0, - }) - messageRef = writeResult + } } else { if (matchType === "image" && matchedInstanceSnap) { messageRef = matchedInstanceSnap.ref.parent.parent @@ -600,11 +640,13 @@ async function newImageInstanceHandler({ } } if (!messageRef) { - throw new Error( + functions.logger.error( `No messageRef created or matched for whatsapp message with id ${id}` ) + return } - const _ = await messageRef.collection("instances").add({ + const instanceRef = messageRef.collection("instances").doc() + const instanceUpdateObj = { source: "whatsapp", id: id || null, //taken from webhook object, needed to reply timestamp: timestamp, //timestamp, taken from webhook object (firestore timestamp data type) @@ -644,7 +686,29 @@ async function newImageInstanceHandler({ }, isSatisfactionSurveySent: null, satisfactionScore: null, - }) + } + const messageIdRef = db.collection("messageIds").doc(id) + try { + await db.runTransaction(async (t) => { + const doc = await t.get(messageIdRef) + if (doc.exists) { + return + } + if (!hasMatch && !!messageRef && !!messageUpdateObj) { + t.set(messageRef, messageUpdateObj) + } + t.set(instanceRef, instanceUpdateObj) + t.set(messageIdRef, { instanceRef: instanceRef }) + }) + functions.logger.log( + `Transaction success for messageId ${id} from ${from}!` + ) + } catch (e) { + functions.logger.error( + `Transaction failure for messageId ${id} from ${from}!`, + e + ) + } return Promise.resolve("image") } diff --git a/functions/src/definitions/webhookHandler.ts b/functions/src/definitions/webhookHandler.ts index 5b8c8751..2b598c96 100644 --- a/functions/src/definitions/webhookHandler.ts +++ b/functions/src/definitions/webhookHandler.ts @@ -5,6 +5,7 @@ import { defineString } from "firebase-functions/params" import { handleSpecialCommands } from "./specialCommands" import { publishToTopic } from "./common/pubsub" import { onRequest } from "firebase-functions/v2/https" +import { checkMessageId } from "./common/utils" const runtimeEnvironment = defineString("ENVIRONMENT") const testUserPhoneNumberId = defineString( @@ -57,6 +58,18 @@ app.post("/whatsapp", async (req, res) => { //handle db commands await handleSpecialCommands(message) } else { + if (message?.id) { + //if message has been processed before, don't even put it in queue. + if (await checkMessageId(message.id)) { + functions.logger.warn(`message ${message.id} already processed`) + res.sendStatus(200) + return + } + } else { + functions.logger.error(`message ${message.id} has no id`) + res.sendStatus(200) + return + } if ( (type == "button" || type == "interactive" || type == "text") && phoneNumberId === checkerPhoneNumberId diff --git a/integration-tests/env.json b/integration-tests/env.json index 587eb4fe..40ae6c11 100644 --- a/integration-tests/env.json +++ b/integration-tests/env.json @@ -8,6 +8,11 @@ "type": "default", "enabled": true }, + { + "key": "MOCK_WHATSAPP_MSG_ID", + "value": "wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==", + "enabled": true + }, { "key": "FIRESTORE_URL", "value": "http://localhost:18080", @@ -377,4 +382,4 @@ "_postman_variable_scope": "environment", "_postman_exported_at": "2023-04-30T14:17:56.196Z", "_postman_exported_using": "Postman/10.13.0" -} \ No newline at end of file +} From e6711ac48ccf7d78a619a8a08d563f8d01301b88 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Wed, 20 Sep 2023 21:59:42 +0800 Subject: [PATCH 02/12] removed v1 webhookHandler --- functions/src/definitions/webhookHandler.ts | 17 +---------------- functions/src/index.ts | 1 - 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/functions/src/definitions/webhookHandler.ts b/functions/src/definitions/webhookHandler.ts index 2b598c96..95caf7b0 100644 --- a/functions/src/definitions/webhookHandler.ts +++ b/functions/src/definitions/webhookHandler.ts @@ -135,21 +135,6 @@ app.get("/whatsapp", (req, res) => { } }) -const webhookHandler = functions - .region("asia-southeast1") - .runWith({ - secrets: [ - "WHATSAPP_USER_BOT_PHONE_NUMBER_ID", - "WHATSAPP_CHECKERS_BOT_PHONE_NUMBER_ID", - "WHATSAPP_TOKEN", - "VERIFY_TOKEN", - "TYPESENSE_TOKEN", - "ML_SERVER_TOKEN", - "TELEGRAM_REPORT_BOT_TOKEN", - ], - }) - .https.onRequest(app) - const webhookHandlerV2 = onRequest( { secrets: [ @@ -161,4 +146,4 @@ const webhookHandlerV2 = onRequest( app ) -export { app, webhookHandlerV2, webhookHandler } +export { app, webhookHandlerV2 } diff --git a/functions/src/index.ts b/functions/src/index.ts index 7aa9888c..34ec40ec 100644 --- a/functions/src/index.ts +++ b/functions/src/index.ts @@ -7,7 +7,6 @@ export { onInstanceCreate } from "./definitions/onInstanceCreate" export { onInstanceDelete } from "./definitions/onInstanceDelete" export { onInstanceUpdate } from "./definitions/onInstanceUpdate" export { onMessageUpdate } from "./definitions/onMessageUpdate" -export { webhookHandler } from "./definitions/webhookHandler" export { webhookHandlerV2 } from "./definitions/webhookHandler" export { onVoteRequestUpdate } from "./definitions/onVoteRequestUpdate" export { healthcheck } from "./definitions/healthcheck" From dcf48c978989e7b6f14e79769900aecd0bd5a07b Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Wed, 20 Sep 2023 22:40:23 +0800 Subject: [PATCH 03/12] refactored out db update --- functions/src/definitions/userHandlers.ts | 87 +++++++++++------------ 1 file changed, 43 insertions(+), 44 deletions(-) diff --git a/functions/src/definitions/userHandlers.ts b/functions/src/definitions/userHandlers.ts index 71b9fac2..5bc77614 100644 --- a/functions/src/definitions/userHandlers.ts +++ b/functions/src/definitions/userHandlers.ts @@ -412,28 +412,14 @@ async function newTextInstanceHandler({ isSatisfactionSurveySent: null, satisfactionScore: null, } - const messageIdRef = db.collection("messageIds").doc(id) - try { - await db.runTransaction(async (t) => { - const doc = await t.get(messageIdRef) - if (doc.exists) { - return - } - if (!hasMatch && !!messageRef && !!messageUpdateObj) { - t.set(messageRef, messageUpdateObj) - } - t.set(instanceRef, instanceUpdateObj) - t.set(messageIdRef, { instanceRef: instanceRef }) - }) - functions.logger.log( - `Transaction success for messageId ${id} from ${from}!` - ) - } catch (e) { - functions.logger.error( - `Transaction failure for messageId ${id} from ${from}!`, - e - ) - } + await addInstanceToDb( + id, + hasMatch, + messageRef, + messageUpdateObj, + instanceRef, + instanceUpdateObj + ) return Promise.resolve(`text_machine_${machineCategory}`) } @@ -687,28 +673,14 @@ async function newImageInstanceHandler({ isSatisfactionSurveySent: null, satisfactionScore: null, } - const messageIdRef = db.collection("messageIds").doc(id) - try { - await db.runTransaction(async (t) => { - const doc = await t.get(messageIdRef) - if (doc.exists) { - return - } - if (!hasMatch && !!messageRef && !!messageUpdateObj) { - t.set(messageRef, messageUpdateObj) - } - t.set(instanceRef, instanceUpdateObj) - t.set(messageIdRef, { instanceRef: instanceRef }) - }) - functions.logger.log( - `Transaction success for messageId ${id} from ${from}!` - ) - } catch (e) { - functions.logger.error( - `Transaction failure for messageId ${id} from ${from}!`, - e - ) - } + await addInstanceToDb( + id, + hasMatch, + messageRef, + messageUpdateObj, + instanceRef, + instanceUpdateObj + ) return Promise.resolve("image") } @@ -856,6 +828,33 @@ async function onTextListReceipt(messageObj: Message, platform = "whatsapp") { return Promise.resolve(step) } +async function addInstanceToDb( + id: string, + hasMatch: boolean, + messageRef: FirebaseFirestore.DocumentReference | null, + messageUpdateObj: Object | null = null, + instanceRef: FirebaseFirestore.DocumentReference, + instanceUpdateObj: Object +) { + const messageIdRef = db.collection("messageIds").doc(id) + try { + await db.runTransaction(async (t) => { + const doc = await t.get(messageIdRef) + if (doc.exists) { + return + } + if (!hasMatch && !!messageRef && !!messageUpdateObj) { + t.set(messageRef, messageUpdateObj) + } + t.set(instanceRef, instanceUpdateObj) + t.set(messageIdRef, { instanceRef: instanceRef }) + }) + functions.logger.log(`Transaction success for messageId ${id}!`) + } catch (e) { + functions.logger.error(`Transaction failure for messageId ${id}!`, e) + } +} + async function createNewUser( userRef: admin.firestore.DocumentReference, messageTimestamp: Timestamp From 558fd73b6855dc1031b9794b56ff33509a97848d Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Thu, 21 Sep 2023 22:52:50 +0800 Subject: [PATCH 04/12] edited tests so mock user msgs have unique IDs --- .../checkmate.postman_collection.json | 24101 +++++++++------- 1 file changed, 12916 insertions(+), 11185 deletions(-) diff --git a/integration-tests/checkmate.postman_collection.json b/integration-tests/checkmate.postman_collection.json index 97c164ec..1fca9b6d 100644 --- a/integration-tests/checkmate.postman_collection.json +++ b/integration-tests/checkmate.postman_collection.json @@ -1,11186 +1,12917 @@ { - "info": { - "_postman_id": "103b9282-6f00-47a0-8170-35734cf20265", - "name": "checkmate", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", - "_exporter_id": "25230076" - }, - "item": [ - { - "name": "000_Healthcheck", - "item": [ - { - "name": "Healthcheck", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/healthcheck", - "host": ["{{FUNCTIONS_URL}}"], - "path": ["checkmate-373101", "asia-southeast1", "healthcheck"] - } - }, - "response": [] - } - ] - }, - { - "name": "001_Mock_Db", - "item": [ - { - "name": "Create mock firestore DB", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"Test User\"\r\n },\r\n \"wa_id\": \"88888888\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"88888888\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIDFCMDlDNjhFRDgzMEJCQjA0M0FBM0NEQTc5MEYzRkE4AA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"/mockdb\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ],\r\n \"severity\": \"INFO\",\r\n \"message\": \"\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get mock db collection IDs", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check number of collections /mockdb command creates in Firestore\", function () {\r", - " const jsonData = pm.response.json();\r", - " \r", - " pm.expect(jsonData?.collectionIds?.length).to.eql(2);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "default" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents:listCollectionIds", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "checkmate-373101", - "databases", - "(default)", - "documents:listCollectionIds" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "002_Add_Checkers", - "item": [ - { - "name": "Checker 2 Onboarding", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"I'd like to join as a CheckMate to help counter misinformation and scams! 💪🏻\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Check Onboarding_1 Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const CHECKER_2_NUMBER = pm.variables.get(\"CHECKER_2_NUMBER\");\r", - " const ONBOARDING_1 = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_1\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": ONBOARDING_1,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_2_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"whatsapp\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Checker 2 input name", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Check Onboarding_2 Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const CHECKER_2_NUMBER = pm.variables.get(\"CHECKER_2_NUMBER\");\r", - " const CHECKER_2_NAME = pm.variables.get(\"CHECKER_2_NAME\");\r", - " const ONBOARDING_2 = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_2\").replace(\"{{name}}\", CHECKER_2_NAME);\r", - "\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_2_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": ONBOARDING_2\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": \"privacyOk\",\r", - " \"title\": \"Got it!\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Checker 2 press \"Got it!\" button", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"privacyOk\",\r\n \"title\": \"Got it!\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Check Onboarding_3 Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const CHECKER_2_NUMBER = pm.variables.get(\"CHECKER_2_NUMBER\");\r", - " const ONBOARDING_3 = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_3\")\r", - "\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_2_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": ONBOARDING_3\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": \"typeformDone\",\r", - " \"title\": \"I've done the quiz!\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Checker 2 press \"Ive done the quiz!\" button", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"typeformDone\",\r\n \"title\": \"I've done the quiz!\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Check Onboarding_4 Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const CHECKER_2_NUMBER = pm.variables.get(\"CHECKER_2_NUMBER\");\r", - " const ONBOARDING_4 = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_4\")\r", - "\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": ONBOARDING_4,\r", - " \"preview_url\": true\r", - " },\r", - " \"to\": CHECKER_2_NUMBER,\r", - " \"messaging_product\": \"whatsapp\"\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Checker 3 Onboarding", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"I'd like to join as a CheckMate to help counter misinformation and scams! 💪🏻\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Check Onboarding_1 Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const CHECKER_3_NUMBER = pm.variables.get(\"CHECKER_3_NUMBER\");\r", - " const ONBOARDING_1 = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_1\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": ONBOARDING_1,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_3_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"whatsapp\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Checker 3 input name", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Check Onboarding_2 Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const CHECKER_3_NUMBER = pm.variables.get(\"CHECKER_3_NUMBER\");\r", - " const CHECKER_3_NAME = pm.variables.get(\"CHECKER_3_NAME\");\r", - " const ONBOARDING_2 = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_2\").replace(\"{{name}}\", CHECKER_3_NAME);\r", - "\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_3_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": ONBOARDING_2\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": \"privacyOk\",\r", - " \"title\": \"Got it!\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "003_New_User", - "item": [ - { - "name": "Send WhatsApp message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"F\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (NEW_USER_MENU)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const MENU = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU\");\r", - " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_MENU_PREFIX\");\r", - " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX)\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": MENU_TEXT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"View Menu\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": \"menu_check\",\r", - " \"title\": \"Check/Report\",\r", - " \"description\": \"Send in messages, images, or screenshots for checking!\"\r", - " },\r", - " {\r", - " \"id\": \"menu_referral\",\r", - " \"title\": \"Get Referral Link\",\r", - " \"description\": \"Get referral link to forward to others\"\r", - " },\r", - " {\r", - " \"id\": \"menu_help\",\r", - " \"title\": \"Get Help\",\r", - " \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r", - " },\r", - " {\r", - " \"id\": \"menu_about\",\r", - " \"title\": \"About CheckMate\",\r", - " \"description\": \"Learn more about CheckMate and the team behind it\"\r", - " },\r", - " {\r", - " \"id\": \"menu_feedback\",\r", - " \"title\": \"Send Feedback\",\r", - " \"description\": \"Send us feedback on anything to do with CheckMate\"\r", - " },\r", - " {\r", - " \"id\": \"menu_contact\",\r", - " \"title\": \"Get Contact\",\r", - " \"description\": \"Get CheckMate's contact to add to your contact list\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Check referral count Copy", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that has is created\", function () {\r", - "\r", - " var jsonData = pm.response.json();\r", - " const referralId = jsonData.fields.referralId.stringValue\r", - " pm.collectionVariables.set(\"referralId_USER1\", referralId);\r", - " pm.collectionVariables.set(\"referralLink_USER1\", `https://ref.checkmate.sg/${referralId}`);\r", - " pm.expect(referralId.length).to.be.above(0);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/users/{{USER_1_NUMBER}}", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "checkmate-373101", - "databases", - "(default)", - "documents", - "users", - "{{USER_1_NUMBER}}" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "004_Irrelevant_Message", - "item": [ - { - "name": "Send WhatsApp message (7 Chars)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"1234567\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (IRRELEVANT_MENU)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Message auto-categorised as irrelevant returns correct menu\", function () {\r", - " const MENU = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU\");\r", - " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.IRRELEVANT_AUTO_MENU_PREFIX\");\r", - " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX)\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": MENU_TEXT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"View Menu\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": \"menu_check\",\r", - " \"title\": \"Check/Report\",\r", - " \"description\": \"Send in messages, images, or screenshots for checking!\"\r", - " },\r", - " {\r", - " \"id\": \"menu_referral\",\r", - " \"title\": \"Get Referral Link\",\r", - " \"description\": \"Get referral link to forward to others\",\r", - " },\r", - " {\r", - " \"id\": \"menu_help\",\r", - " \"title\": \"Get Help\",\r", - " \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r", - " },\r", - " {\r", - " \"id\": \"menu_about\",\r", - " \"title\": \"About CheckMate\",\r", - " \"description\": \"Learn more about CheckMate and the team behind it\"\r", - " },\r", - " {\r", - " \"id\": \"menu_feedback\",\r", - " \"title\": \"Send Feedback\",\r", - " \"description\": \"Send us feedback on anything to do with CheckMate\"\r", - " },\r", - " {\r", - " \"id\": \"menu_dispute_messages/*/instances/*\",\r", - " \"title\": \"Dispute Assessment\",\r", - " \"description\": \"Dispute CheckMate's assesment of this message\"\r", - " },\r", - " {\r", - " \"id\": \"menu_contact\",\r", - " \"title\": \"Get Contact\",\r", - " \"description\": \"Get CheckMate's contact to add to your contact list\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " \r", - " // get the id of \"Dispute Assessment\" for validation\r", - " let disputeAssessmentId = jsonData.body.interactive.action.sections[0].rows.find(row => row.title === \"Dispute Assessment\").id;\r", - " let [, , disputedInstancePath] = disputeAssessmentId.split(\"_\")\r", - " \r", - " // check if the id matches the pattern \"menu_dispute_messages/*/instances/*\"\r", - " pm.expect(disputeAssessmentId).to.match(/menu_dispute_messages\\/[^\\/]+\\/instances\\/[^\\/]+/);\r", - " pm.collectionVariables.set(\"disputedInstancePath\", disputedInstancePath);\r", - "\r", - " // remove the id of \"Dispute Assessment\" for comparison\r", - " jsonData.body.interactive.action.sections[0].rows = jsonData.body.interactive.action.sections[0].rows.map(row => {\r", - " if (row.title === \"Dispute Assessment\") {\r", - " return {...row, id: \"menu_dispute_messages/*/instances/*\"};\r", - " } else {\r", - " return row;\r", - " }\r", - " });\r", - "\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 5000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Make Menu Selection (\"Dispute Categorisation\")", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_dispute_{{disputedInstancePath}}\",\r\n \"title\": \"Dispute Assessment\",\r\n \"description\": \"Dispute CheckMate's assesment of this message\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (telegram blast)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"On dispute, message is sent out to Telegram group chat\", function () {\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const DISPUTED_INSTANCE_PATH = pm.collectionVariables.get(\"disputedInstancePath\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/botTELEGRAM_REPORT_BOT_TOKEN/sendMessage\",\r", - " \"body\": {\r", - " \"chat_id\": \"111111111\",\r", - " \"text\": `${USER_1_NUMBER} has disputed the assessment of a message sent by them.\\n \\nmessage/instance path: ${DISPUTED_INSTANCE_PATH}\\n\\ntype: text\\n\\ntext: 1234567\\n\\ncategory: irrelevant`\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - "\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Get last message (DISPUTE)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.DISPUTE\");\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": BODY_TEXT,\r", - " \"preview_url\": true\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "005_Spam_Human", - "item": [ - { - "name": "005a_User_Send_First_Vote", - "item": [ - { - "name": "Send WhatsApp message (15 Chars)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is a sp-am message that will be voted on\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (MESSAGE_NOT_YET_ASSESSED)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const MESSAGE_NOT_YET_ASSESSED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MESSAGE_NOT_YET_ASSESSED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": MESSAGE_NOT_YET_ASSESSED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Get first checker message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", - " const CHECKER_NAME = \"CHECKER_NAME\"\r", - " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBER,\r", - " \"type\": \"template\",\r", - " \"template\": {\r", - " \"name\": \"new_message_received\",\r", - " \"language\": {\r", - " \"policy\": \"deterministic\",\r", - " \"code\": \"en\"\r", - " },\r", - " \"components\": [\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 0,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 1,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"body\",\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"text\",\r", - " \"text\": CHECKER_NAME\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"factChecker\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " //check name in list\r", - " const name = jsonData.body.template.components[2].parameters[0].text\r", - " pm.expect(CHECKER_NAMES).to.include(name);\r", - " //check number in list\r", - " const number = jsonData.body.to\r", - " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", - " const spamVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", - " const [, messageId, , voteRequestId] = spamVoteRequestPath.split(\"/\")\r", - " pm.collectionVariables.set(`spamVoteRequestPath_${name}`, spamVoteRequestPath);\r", - " pm.collectionVariables.set(`spamMessageId`, messageId);\r", - " pm.collectionVariables.set(`spamVoteRequestId_${name}`, voteRequestId);\r", - " // Replace dynamically created IDs\r", - " jsonData.body.to = CHECKER_PHONE_NUMBER\r", - " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Get second checker message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", - " const CHECKER_NAME = \"CHECKER_NAME\"\r", - " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBER,\r", - " \"type\": \"template\",\r", - " \"template\": {\r", - " \"name\": \"new_message_received\",\r", - " \"language\": {\r", - " \"policy\": \"deterministic\",\r", - " \"code\": \"en\"\r", - " },\r", - " \"components\": [\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 0,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 1,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"body\",\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"text\",\r", - " \"text\": CHECKER_NAME\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"factChecker\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " //check name in list\r", - " const name = jsonData.body.template.components[2].parameters[0].text\r", - " pm.expect(CHECKER_NAMES).to.include(name);\r", - " //check number in list\r", - " const number = jsonData.body.to\r", - " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", - " const spamVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", - " const [, messageId, , voteRequestId] = spamVoteRequestPath.split(\"/\")\r", - " pm.collectionVariables.set(`spamVoteRequestPath_${name}`, spamVoteRequestPath);\r", - " pm.collectionVariables.set(`spamMessageId`, messageId);\r", - " pm.collectionVariables.set(`spamVoteRequestId_${name}`, voteRequestId);\r", - " // Replace dynamically created IDs\r", - " jsonData.body.to = CHECKER_PHONE_NUMBER\r", - " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Get third checker message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", - " const CHECKER_NAME = \"CHECKER_NAME\"\r", - " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBER,\r", - " \"type\": \"template\",\r", - " \"template\": {\r", - " \"name\": \"new_message_received\",\r", - " \"language\": {\r", - " \"policy\": \"deterministic\",\r", - " \"code\": \"en\"\r", - " },\r", - " \"components\": [\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 0,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 1,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"body\",\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"text\",\r", - " \"text\": CHECKER_NAME\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"factChecker\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " //check name in list\r", - " const name = jsonData.body.template.components[2].parameters[0].text\r", - " pm.expect(CHECKER_NAMES).to.include(name);\r", - " //check number in list\r", - " const number = jsonData.body.to\r", - " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", - " const spamVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", - " const [, messageId, , voteRequestId] = spamVoteRequestPath.split(\"/\")\r", - " pm.collectionVariables.set(`spamVoteRequestPath_${name}`, spamVoteRequestPath);\r", - " pm.collectionVariables.set(`spamMessageId`, messageId);\r", - " pm.collectionVariables.set(`spamVoteRequestId_${name}`, voteRequestId);\r", - " // Replace dynamically created IDs\r", - " jsonData.body.to = CHECKER_PHONE_NUMBER\r", - " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "First checker clicks yes", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{spamVoteRequestPath_CHECKER1}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Message to Check Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Message to check sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": \"This is a sp-am message that will be voted on\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\"\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "L1_ASSESSMENT_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const L1_ASSESSMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L1_ASSESSMENT_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": L1_ASSESSMENT_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Make Selection\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_scam`,\r", - " \"title\": \"Scam\",\r", - " \"description\": \"Intended to obtain money/personal information via deception\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_illicit`,\r", - " \"title\": \"Illicit\",\r", - " \"description\": \"Other potential illicit activity, e.g. moneylending/prostitution\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_info`,\r", - " \"title\": \"News/Information/Opinion\",\r", - " \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_others`,\r", - " \"title\": \"It's something else\",\r", - " \"description\": \"Messages that don't fall into the other categories\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - "\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "First checker selects \"It's something else\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"categorize_{{spamMessageId}}_{{spamVoteRequestId_CHECKER1}}_others\",\r\n \"title\": \"It's something else\",\r\n \"description\": \"Messages that don't fall into the other categories\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "HOLD_FOR_L2_CATEGORISATION", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"HOLD_FOR_L2_CATEGORISATION message sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const HOLD_FOR_L2_CATEGORISATION = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_L2_CATEGORISATION\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": HOLD_FOR_L2_CATEGORISATION,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "L2_CATEGORISATION_MENU", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L2_OTHERS_ASSESSEMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const L2_OTHERS_ASSESSEMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L2_OTHERS_ASSESSEMENT_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": L2_OTHERS_ASSESSEMENT_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Make Selection\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_spam`,\r", - " \"title\": \"Spam\",\r", - " \"description\": \"Unsolicited spam, such as marketing messages\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_legitimate`,\r", - " \"title\": \"Legitimate\",\r", - " \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_irrelevant`,\r", - " \"title\": \"Trivial\",\r", - " \"description\": \"Trivial/banal messages with nothing to assess\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_unsure`,\r", - " \"title\": \"I'm Unsure\",\r", - " \"description\": \"Do try your best to categorize! But if really unsure, select this\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "First checker selects \"spam\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"others_{{spamMessageId}}_{{spamVoteRequestId_CHECKER1}}_spam\",\r\n \"title\": \"Spam\",\r\n \"description\": \"Unsolicited spam, such as marketing messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "RESPONSE_RECORDED", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": RESPONSE_RECORDED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "NO_OUTSTANDING", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": NO_OUTSTANDING,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "005b_Interim_Message", - "item": [ - { - "name": "Send /interim command", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIDFCMDlDNjhFRDgzMEJCQjA0M0FBM0NEQTc5MEYzRkE4AA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"/interim\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ],\r\n \"severity\": \"INFO\",\r\n \"message\": \"\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Get Instance ID", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that there is 1 instance\", function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData?.documents?.length).to.eql(1);\r", - " var fullName = jsonData.documents[0].name;\r", - " var splitName = fullName.split(\"/\");\r", - " var docId = splitName[splitName.length - 1];\r", - " pm.collectionVariables.set(\"spamInstanceId\", docId);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{spamMessageId}}/instances", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "checkmate-373101", - "databases", - "(default)", - "documents", - "messages", - "{{spamMessageId}}", - "instances" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const instanceId = pm.variables.get(\"spamInstanceId\")\r", - " const INTERIM_PROMPT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": INTERIM_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get interim update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Press button to get interim update", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_TEMPLATE_WITH_FEEDBACK", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_TEMPLATE sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const INTERIM_TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE\");\r", - " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK\")\r", - " const instanceId = pm.variables.get(\"spamInstanceId\")\r", - " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"is spam🚧\").replace(\"{{info_placeholder}}\",\"\").replace(\"{{get_feedback}}\",INTERIM_FEEDBACK)\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": interimResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_yes`,\r", - " \"title\": \"Yes, it's useful\"\r", - " }\r", - " },\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_no`,\r", - " \"title\": \"No, it's not\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " \r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Press button \"Yes it's useful\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"feedbackInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}_yes\",\r\n \"title\": \"Yes, it's useful\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_USEFUL", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_USEFUL sent to user\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const INTERIM_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_USEFUL\");\r", - " const instanceId = pm.variables.get(\"spamInstanceId\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": INTERIM_USEFUL\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get another update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Press button \"No it's not\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"feedbackInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}_no\",\r\n \"title\": \"No, it's not\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_NOT_USEFUL", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_NOT_USEFUL sent to user\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const INTERIM_NOT_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_NOT_USEFUL\");\r", - " const instanceId = pm.variables.get(\"spamInstanceId\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": INTERIM_NOT_USEFUL\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get another update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Press button to get interim update again", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_TEMPLATE", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_TEMPLATE with feedback sent to user\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const INTERIM_TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE\");\r", - " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK\")\r", - " const instanceId = pm.variables.get(\"spamInstanceId\")\r", - " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"is spam🚧\").replace(\"{{info_placeholder}}\",\"\").replace(\"{{get_feedback}}\",\"\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": interimResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get another update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "005c_2nd Voter Legitimate", - "item": [ - { - "name": "Second checker clicks yes", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{spamVoteRequestPath_CHECKER2}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Message to Check Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Message to check sent to checker 2\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": \"This is a sp-am message that will be voted on\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"messaging_product\": \"whatsapp\"\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "L1_ASSESSMENT_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER2\").split(\"/\")\r", - " const L1_ASSESSMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L1_ASSESSMENT_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": L1_ASSESSMENT_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Make Selection\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_scam`,\r", - " \"title\": \"Scam\",\r", - " \"description\": \"Intended to obtain money/personal information via deception\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_illicit`,\r", - " \"title\": \"Illicit\",\r", - " \"description\": \"Other potential illicit activity, e.g. moneylending/prostitution\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_info`,\r", - " \"title\": \"News/Information/Opinion\",\r", - " \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_others`,\r", - " \"title\": \"It's something else\",\r", - " \"description\": \"Messages that don't fall into the other categories\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - "\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Second checker selects \"It's something else\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"categorize_{{spamMessageId}}_{{spamVoteRequestId_CHECKER2}}_others\",\r\n \"title\": \"It's something else\",\r\n \"description\": \"Messages that don't fall into the other categories\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "HOLD_FOR_L2_CATEGORISATION", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"HOLD_FOR_L2_CATEGORISATION message sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER2\").split(\"/\")\r", - " const HOLD_FOR_L2_CATEGORISATION = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_L2_CATEGORISATION\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": HOLD_FOR_L2_CATEGORISATION,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "L2_CATEGORISATION_MENU", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L2_OTHERS_ASSESSEMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER2\").split(\"/\")\r", - " const L2_OTHERS_ASSESSEMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L2_OTHERS_ASSESSEMENT_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": L2_OTHERS_ASSESSEMENT_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Make Selection\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_spam`,\r", - " \"title\": \"Spam\",\r", - " \"description\": \"Unsolicited spam, such as marketing messages\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_legitimate`,\r", - " \"title\": \"Legitimate\",\r", - " \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_irrelevant`,\r", - " \"title\": \"Trivial\",\r", - " \"description\": \"Trivial/banal messages with nothing to assess\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_unsure`,\r", - " \"title\": \"I'm Unsure\",\r", - " \"description\": \"Do try your best to categorize! But if really unsure, select this\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Second checker selects \"legitimate\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"others_{{spamMessageId}}_{{spamVoteRequestId_CHECKER2}}_legitimate\",\r\n \"title\": \"Legitimate\",\r\n \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "RESPONSE_RECORDED", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER2\").split(\"/\")\r", - " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": RESPONSE_RECORDED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "NO_OUTSTANDING", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER2\").split(\"/\")\r", - " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": NO_OUTSTANDING,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Press button to get interim update", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_TEMPLATE_UNSURE", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_TEMPLATE sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const INTERIM_TEMPLATE_UNSURE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE_UNSURE\");\r", - " const instanceId = pm.variables.get(\"spamInstanceId\")\r", - " const interimResponse = INTERIM_TEMPLATE_UNSURE.replace(\"{{%voted}}\", \"66.67\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": interimResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get another update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "005d_3rd Voter Spam", - "item": [ - { - "name": "Third checker clicks yes", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{spamVoteRequestPath_CHECKER3}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Message to Check Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Message to check sent to checker 2\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": \"This is a sp-am message that will be voted on\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"messaging_product\": \"whatsapp\"\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "L1_ASSESSMENT_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", - " const L1_ASSESSMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L1_ASSESSMENT_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": L1_ASSESSMENT_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Make Selection\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_scam`,\r", - " \"title\": \"Scam\",\r", - " \"description\": \"Intended to obtain money/personal information via deception\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_illicit`,\r", - " \"title\": \"Illicit\",\r", - " \"description\": \"Other potential illicit activity, e.g. moneylending/prostitution\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_info`,\r", - " \"title\": \"News/Information/Opinion\",\r", - " \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_others`,\r", - " \"title\": \"It's something else\",\r", - " \"description\": \"Messages that don't fall into the other categories\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - "\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Third checker selects \"It's something else\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"categorize_{{spamMessageId}}_{{spamVoteRequestId_CHECKER3}}_others\",\r\n \"title\": \"It's something else\",\r\n \"description\": \"Messages that don't fall into the other categories\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "HOLD_FOR_L2_CATEGORISATION", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"HOLD_FOR_L2_CATEGORISATION message sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", - " const HOLD_FOR_L2_CATEGORISATION = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_L2_CATEGORISATION\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": HOLD_FOR_L2_CATEGORISATION,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "L2_CATEGORISATION_MENU", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L2_OTHERS_ASSESSEMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", - " const L2_OTHERS_ASSESSEMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L2_OTHERS_ASSESSEMENT_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": L2_OTHERS_ASSESSEMENT_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Make Selection\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_spam`,\r", - " \"title\": \"Spam\",\r", - " \"description\": \"Unsolicited spam, such as marketing messages\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_legitimate`,\r", - " \"title\": \"Legitimate\",\r", - " \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_irrelevant`,\r", - " \"title\": \"Trivial\",\r", - " \"description\": \"Trivial/banal messages with nothing to assess\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_unsure`,\r", - " \"title\": \"I'm Unsure\",\r", - " \"description\": \"Do try your best to categorize! But if really unsure, select this\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Third checker selects \"spam\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"others_{{spamMessageId}}_{{spamVoteRequestId_CHECKER3}}_spam\",\r\n \"title\": \"Spam\",\r\n \"description\": \"Unsolicited spam, such as marketing messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "RESPONSE_RECORDED", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", - " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": RESPONSE_RECORDED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "NO_OUTSTANDING", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", - " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": NO_OUTSTANDING,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "SPAM", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"SPAM final reply sent to checker 1\", function () {\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", - " const instanceId = pm.variables.get(\"spamInstanceId\")\r", - " const SPAM = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.SPAM\");\r", - " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\");\r", - " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\");\r", - " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\");\r", - " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\");\r", - " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\");\r", - " const isMachineCategorised = false\r", - " const instanceCount = 1\r", - " const isImmediate = false\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " function getFinalResponseText(responseText) {\r", - " return responseText\r", - " .replace(\r", - " \"{{thanks}}\",\r", - " isImmediate ? THANKS_IMMEDIATE : THANKS_DELAYED\r", - " )\r", - " .replace(\r", - " \"{{matched}}\",\r", - " instanceCount >= 5\r", - " ? `In fact, others have already sent this message in ${instanceCount} times. `\r", - " : \"\"\r", - " )\r", - " .replace(\r", - " \"{{methodology}}\",\r", - " isMachineCategorised\r", - " ? METHODOLOGY_AUTO\r", - " : METHODOLOGY_HUMAN\r", - " )\r", - " .replace(\"{{results}}\", isImmediate ? \"\" : VOTE_RESULTS_SUFFIX)\r", - " }\r", - " const spamResponse = getFinalResponseText(SPAM)\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": spamResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `votingResults_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"See voting results\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "SATISFACTION_SURVEY", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"SATISFACTION_SURVEY sent to user1\", function () {\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", - " const instanceId = pm.variables.get(\"spamInstanceId\")\r", - " const SATISFACTION_SURVEY = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.SATISFACTION_SURVEY\");\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": SATISFACTION_SURVEY\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Tap to respond\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `satisfactionSurvey_10_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"10\",\r", - " \"description\": \"Extremely likely 🤩\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_9_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"9\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_8_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"8\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_7_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"7\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_6_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"6\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_5_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"5\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_4_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"4\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_3_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"3\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_2_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"2\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_1_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"1\",\r", - " \"description\": \"Not at all likely 😥\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - "\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Votes 10", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"satisfactionSurvey_10_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"10\",\r\n \"description\": \"Unsolicited spam, such as marketing messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "SATISFACTION_SURVEY_THANKS", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"ALREADY_REPLIED sent to user 1\", function () {\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const SATISFACTION_SURVEY_THANKS = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.SATISFACTION_SURVEY_THANKS\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": SATISFACTION_SURVEY_THANKS,\r", - " \"preview_url\": true\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Check instance updated", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that instance data updated correctly\", function () {\r", - "\r", - " var jsonData = pm.response.json();\r", - " const isSatisfactionSurveySent = jsonData.fields.isSatisfactionSurveySent.booleanValue\r", - " const satisfactionScore = parseInt(jsonData.fields.satisfactionScore.integerValue) //for some reason integerValue returns string\r", - "\r", - " pm.expect(isSatisfactionSurveySent).to.be.true;\r", - " pm.expect(satisfactionScore).to.equal(10);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{spamMessageId}}/instances/{{spamInstanceId}}", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "checkmate-373101", - "databases", - "(default)", - "documents", - "messages", - "{{spamMessageId}}", - "instances", - "{{spamInstanceId}}" - ] - } - }, - "response": [] - }, - { - "name": "Press button to get interim update", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "ALREADY_REPLIED", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"ALREADY_REPLIED sent to user 1\", function () {\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const ALREADY_REPLIED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.ALREADY_REPLIED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": ALREADY_REPLIED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "005e_Stats_Message", - "item": [ - { - "name": "Press button to see stats", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"votingResults_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"See voting results\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "STATS_TEMPLATE", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"STATS_TEMPLATE sent to user 1\", function () {\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " //we not using the template for this, its hardcoded.\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": \"66.67% of our CheckMates thought this was *spam*. 33.33% thought this was *legitimate*.\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - } - ] - }, - { - "name": "006_Info_Machine_Human", - "item": [ - { - "name": "006a_User_Send_First_Vote", - "item": [ - { - "name": "Send WhatsApp message (15 Chars)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is an info message that will be voted on\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (MESSAGE_NOT_YET_ASSESSED)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const MESSAGE_NOT_YET_ASSESSED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MESSAGE_NOT_YET_ASSESSED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": MESSAGE_NOT_YET_ASSESSED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Get first checker message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", - " const CHECKER_NAME = \"CHECKER_NAME\"\r", - " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBER,\r", - " \"type\": \"template\",\r", - " \"template\": {\r", - " \"name\": \"new_message_received\",\r", - " \"language\": {\r", - " \"policy\": \"deterministic\",\r", - " \"code\": \"en\"\r", - " },\r", - " \"components\": [\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 0,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 1,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"body\",\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"text\",\r", - " \"text\": CHECKER_NAME\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"factChecker\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " //check name in list\r", - " const name = jsonData.body.template.components[2].parameters[0].text\r", - " pm.expect(CHECKER_NAMES).to.include(name);\r", - " //check number in list\r", - " const number = jsonData.body.to\r", - " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", - " const infoVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", - " const [, messageId, , voteRequestId] = infoVoteRequestPath.split(\"/\")\r", - " pm.collectionVariables.set(`infoVoteRequestPath_${name}`, infoVoteRequestPath);\r", - " pm.collectionVariables.set(`infoMessageId`, messageId);\r", - " pm.collectionVariables.set(`infoVoteRequestId_${name}`, voteRequestId);\r", - " // Replace dynamically created IDs\r", - " jsonData.body.to = CHECKER_PHONE_NUMBER\r", - " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Get second checker message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", - " const CHECKER_NAME = \"CHECKER_NAME\"\r", - " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBER,\r", - " \"type\": \"template\",\r", - " \"template\": {\r", - " \"name\": \"new_message_received\",\r", - " \"language\": {\r", - " \"policy\": \"deterministic\",\r", - " \"code\": \"en\"\r", - " },\r", - " \"components\": [\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 0,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 1,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"body\",\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"text\",\r", - " \"text\": CHECKER_NAME\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"factChecker\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " //check name in list\r", - " const name = jsonData.body.template.components[2].parameters[0].text\r", - " pm.expect(CHECKER_NAMES).to.include(name);\r", - " //check number in list\r", - " const number = jsonData.body.to\r", - " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", - " const infoVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", - " const [, messageId, , voteRequestId] = infoVoteRequestPath.split(\"/\")\r", - " pm.collectionVariables.set(`infoVoteRequestPath_${name}`, infoVoteRequestPath);\r", - " pm.collectionVariables.set(`infoVoteRequestId_${name}`, voteRequestId);\r", - " // Replace dynamically created IDs\r", - " jsonData.body.to = CHECKER_PHONE_NUMBER\r", - " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Get third checker message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", - " const CHECKER_NAME = \"CHECKER_NAME\"\r", - " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBER,\r", - " \"type\": \"template\",\r", - " \"template\": {\r", - " \"name\": \"new_message_received\",\r", - " \"language\": {\r", - " \"policy\": \"deterministic\",\r", - " \"code\": \"en\"\r", - " },\r", - " \"components\": [\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 0,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 1,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"body\",\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"text\",\r", - " \"text\": CHECKER_NAME\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"factChecker\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " //check name in list\r", - " const name = jsonData.body.template.components[2].parameters[0].text\r", - " pm.expect(CHECKER_NAMES).to.include(name);\r", - " //check number in list\r", - " const number = jsonData.body.to\r", - " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", - " const infoVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", - " const [, messageId, , voteRequestId] = infoVoteRequestPath.split(\"/\")\r", - " pm.collectionVariables.set(`infoVoteRequestPath_${name}`, infoVoteRequestPath);\r", - " pm.collectionVariables.set(`infoVoteRequestId_${name}`, voteRequestId);\r", - " // Replace dynamically created IDs\r", - " jsonData.body.to = CHECKER_PHONE_NUMBER\r", - " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "First checker clicks yes", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{infoVoteRequestPath_CHECKER1}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Message to Check Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Message to check sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": \"This is an info message that will be voted on\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\"\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "FACTCHECK_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const FACTCHECK_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.FACTCHECK_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": FACTCHECK_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Vote here\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_0`,\r", - " \"title\": \"0\",\r", - " \"description\": \"Totally false\"\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_1`,\r", - " \"title\": \"1\",\r", - " }, \r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_2`,\r", - " \"title\": \"2\",\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_3`,\r", - " \"title\": \"3\",\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_4`,\r", - " \"title\": \"4\",\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_5`,\r", - " \"title\": \"5\",\r", - " \"description\": \"Totally true\"\r", - " },\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "First checker selects \"1\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"vote_{{infoMessageId}}_{{infoVoteRequestId_CHECKER1}}_1\",\r\n \"title\": \"1\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "RESPONSE_RECORDED", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": RESPONSE_RECORDED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "NO_OUTSTANDING", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": NO_OUTSTANDING,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Get Instance ID", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that there is 1 instance\", function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData?.documents?.length).to.eql(1);\r", - " var fullName = jsonData.documents[0].name;\r", - " var splitName = fullName.split(\"/\");\r", - " var docId = splitName[splitName.length - 1];\r", - " pm.collectionVariables.set(\"infoInstanceId\", docId);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{infoMessageId}}/instances", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "checkmate-373101", - "databases", - "(default)", - "documents", - "messages", - "{{infoMessageId}}", - "instances" - ] - } - }, - "response": [] - }, - { - "name": "Send /interim command", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIDFCMDlDNjhFRDgzMEJCQjA0M0FBM0NEQTc5MEYzRkE4AA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"/interim\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ],\r\n \"severity\": \"INFO\",\r\n \"message\": \"\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const instanceId = pm.variables.get(\"infoInstanceId\")\r", - " const INTERIM_PROMPT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": INTERIM_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get interim update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Press button to get interim update", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{infoMessageId}}/instances/{{infoInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_TEMPLATE_WITH_FEEDBACK", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_TEMPLATE sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const INTERIM_TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE\");\r", - " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK\")\r", - " const instanceId = pm.variables.get(\"infoInstanceId\")\r", - " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"is untrue❌\").replace(\"{{info_placeholder}}\",\", with an average score of 1.00 on a scale of 0-5 (5 = completely true)\").replace(\"{{get_feedback}}\",INTERIM_FEEDBACK)\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": interimResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_yes`,\r", - " \"title\": \"Yes, it's useful\"\r", - " }\r", - " },\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_no`,\r", - " \"title\": \"No, it's not\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " \r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Check interim values", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData?.fields?.isMeaningfulInterimReplySent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimReplySent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimPromptSent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimUseful?.nullValue).to.equal(null);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{infoMessageId}}/instances/{{infoInstanceId}}", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "checkmate-373101", - "databases", - "(default)", - "documents", - "messages", - "{{infoMessageId}}", - "instances", - "{{infoInstanceId}}" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "006b_2nd_Voter_1", - "item": [ - { - "name": "Second checker clicks yes", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{infoVoteRequestPath_CHECKER2}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Message to Check Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Message to check sent to checker 2\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": \"This is an info message that will be voted on\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"messaging_product\": \"whatsapp\"\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "FACTCHECK_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER2\").split(\"/\")\r", - " const FACTCHECK_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.FACTCHECK_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": FACTCHECK_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Vote here\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_0`,\r", - " \"title\": \"0\",\r", - " \"description\": \"Totally false\"\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_1`,\r", - " \"title\": \"1\",\r", - " }, \r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_2`,\r", - " \"title\": \"2\",\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_3`,\r", - " \"title\": \"3\",\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_4`,\r", - " \"title\": \"4\",\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_5`,\r", - " \"title\": \"5\",\r", - " \"description\": \"Totally true\"\r", - " },\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Second checker selects \"1\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"vote_{{infoMessageId}}_{{infoVoteRequestId_CHECKER2}}_1\",\r\n \"title\": \"1\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "RESPONSE_RECORDED", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": RESPONSE_RECORDED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "NO_OUTSTANDING", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": NO_OUTSTANDING,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "UNTRUE", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"UNTRUE final reply sent to checker 1\", function () {\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER3\").split(\"/\")\r", - " const instanceId = pm.variables.get(\"infoInstanceId\")\r", - " const UNTRUE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.UNTRUE\");\r", - " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\");\r", - " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\");\r", - " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\");\r", - " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\");\r", - " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\");\r", - " const isMachineCategorised = false\r", - " const instanceCount = 1\r", - " const isImmediate = false\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " function getFinalResponseText(responseText) {\r", - " return responseText\r", - " .replace(\r", - " \"{{thanks}}\",\r", - " isImmediate ? THANKS_IMMEDIATE : THANKS_DELAYED\r", - " )\r", - " .replace(\r", - " \"{{matched}}\",\r", - " instanceCount >= 5\r", - " ? `In fact, others have already sent this message in ${instanceCount} times. `\r", - " : \"\"\r", - " )\r", - " .replace(\r", - " \"{{methodology}}\",\r", - " isMachineCategorised\r", - " ? METHODOLOGY_AUTO\r", - " : METHODOLOGY_HUMAN\r", - " )\r", - " .replace(\"{{results}}\", isImmediate ? \"\" : VOTE_RESULTS_SUFFIX)\r", - " }\r", - " const response = getFinalResponseText(UNTRUE)\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": response\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `votingResults_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"See voting results\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "006c_3rd_Voter_5", - "item": [ - { - "name": "Third checker clicks yes", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{infoVoteRequestPath_CHECKER3}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Message to Check Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Message to check sent to checker 3\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": \"This is an info message that will be voted on\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"messaging_product\": \"whatsapp\"\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "FACTCHECK_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER3\").split(\"/\")\r", - " const FACTCHECK_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.FACTCHECK_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": FACTCHECK_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Vote here\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_0`,\r", - " \"title\": \"0\",\r", - " \"description\": \"Totally false\"\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_1`,\r", - " \"title\": \"1\",\r", - " }, \r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_2`,\r", - " \"title\": \"2\",\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_3`,\r", - " \"title\": \"3\",\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_4`,\r", - " \"title\": \"4\",\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_5`,\r", - " \"title\": \"5\",\r", - " \"description\": \"Totally true\"\r", - " },\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Third checker selects \"5\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"vote_{{infoMessageId}}_{{infoVoteRequestId_CHECKER3}}_5\",\r\n \"title\": \"5\",\r\n \"description\": \"Totally true\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "RESPONSE_RECORDED", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": RESPONSE_RECORDED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "NO_OUTSTANDING", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": NO_OUTSTANDING,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "006d_Stats_Message", - "item": [ - { - "name": "Press button to see stats", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"votingResults_messages/{{infoMessageId}}/instances/{{infoInstanceId}}\",\r\n \"title\": \"See voting results\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "STATS_TEMPLATE", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"STATS_TEMPLATE sent to user 1\", function () {\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " //we not using the template for this, its hardcoded.\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": \"100.00% of our CheckMates collectively thought this was *misleading*, with an average score of 2.33 on a scale of 0-5 (5 = completely true).\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - } - ] - }, - { - "name": "007_Unsure_Human", - "item": [ - { - "name": "007a_User_Send_First_Vote", - "item": [ - { - "name": "Send WhatsApp message (15 Chars)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is an unsure message that will be voted on\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (MESSAGE_NOT_YET_ASSESSED)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const MESSAGE_NOT_YET_ASSESSED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MESSAGE_NOT_YET_ASSESSED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": MESSAGE_NOT_YET_ASSESSED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Get first checker message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", - " const CHECKER_NAME = \"CHECKER_NAME\"\r", - " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBER,\r", - " \"type\": \"template\",\r", - " \"template\": {\r", - " \"name\": \"new_message_received\",\r", - " \"language\": {\r", - " \"policy\": \"deterministic\",\r", - " \"code\": \"en\"\r", - " },\r", - " \"components\": [\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 0,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 1,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"body\",\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"text\",\r", - " \"text\": CHECKER_NAME\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"factChecker\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " //check name in list\r", - " const name = jsonData.body.template.components[2].parameters[0].text\r", - " pm.expect(CHECKER_NAMES).to.include(name);\r", - " //check number in list\r", - " const number = jsonData.body.to\r", - " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", - " const unsureVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", - " const [, messageId, , voteRequestId] = unsureVoteRequestPath.split(\"/\")\r", - " pm.collectionVariables.set(`unsureVoteRequestPath_${name}`, unsureVoteRequestPath);\r", - " pm.collectionVariables.set(`unsureMessageId`, messageId);\r", - " pm.collectionVariables.set(`unsureVoteRequestId_${name}`, voteRequestId);\r", - " // Replace dynamically created IDs\r", - " jsonData.body.to = CHECKER_PHONE_NUMBER\r", - " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Get second checker message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", - " const CHECKER_NAME = \"CHECKER_NAME\"\r", - " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBER,\r", - " \"type\": \"template\",\r", - " \"template\": {\r", - " \"name\": \"new_message_received\",\r", - " \"language\": {\r", - " \"policy\": \"deterministic\",\r", - " \"code\": \"en\"\r", - " },\r", - " \"components\": [\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 0,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 1,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"body\",\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"text\",\r", - " \"text\": CHECKER_NAME\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"factChecker\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " //check name in list\r", - " const name = jsonData.body.template.components[2].parameters[0].text\r", - " pm.expect(CHECKER_NAMES).to.include(name);\r", - " //check number in list\r", - " const number = jsonData.body.to\r", - " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", - " const unsureVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", - " const [, messageId, , voteRequestId] = unsureVoteRequestPath.split(\"/\")\r", - " pm.collectionVariables.set(`unsureVoteRequestPath_${name}`, unsureVoteRequestPath);\r", - " pm.collectionVariables.set(`unsureVoteRequestId_${name}`, voteRequestId);\r", - " // Replace dynamically created IDs\r", - " jsonData.body.to = CHECKER_PHONE_NUMBER\r", - " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Get third checker message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", - " const CHECKER_NAME = \"CHECKER_NAME\"\r", - " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBER,\r", - " \"type\": \"template\",\r", - " \"template\": {\r", - " \"name\": \"new_message_received\",\r", - " \"language\": {\r", - " \"policy\": \"deterministic\",\r", - " \"code\": \"en\"\r", - " },\r", - " \"components\": [\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 0,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 1,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"body\",\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"text\",\r", - " \"text\": CHECKER_NAME\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"factChecker\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " //check name in list\r", - " const name = jsonData.body.template.components[2].parameters[0].text\r", - " pm.expect(CHECKER_NAMES).to.include(name);\r", - " //check number in list\r", - " const number = jsonData.body.to\r", - " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", - " const unsureVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", - " const [, messageId, , voteRequestId] = unsureVoteRequestPath.split(\"/\")\r", - " pm.collectionVariables.set(`unsureVoteRequestPath_${name}`, unsureVoteRequestPath);\r", - " pm.collectionVariables.set(`unsureVoteRequestId_${name}`, voteRequestId);\r", - " // Replace dynamically created IDs\r", - " jsonData.body.to = CHECKER_PHONE_NUMBER\r", - " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "First checker clicks yes", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{unsureVoteRequestPath_CHECKER1}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Message to Check Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Message to check sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": \"This is an unsure message that will be voted on\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\"\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "L1_ASSESSMENT_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const L1_ASSESSMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L1_ASSESSMENT_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": L1_ASSESSMENT_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Make Selection\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_scam`,\r", - " \"title\": \"Scam\",\r", - " \"description\": \"Intended to obtain money/personal information via deception\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_illicit`,\r", - " \"title\": \"Illicit\",\r", - " \"description\": \"Other potential illicit activity, e.g. moneylending/prostitution\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_info`,\r", - " \"title\": \"News/Information/Opinion\",\r", - " \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_others`,\r", - " \"title\": \"It's something else\",\r", - " \"description\": \"Messages that don't fall into the other categories\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - "\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "First checker selects \"It's something else\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"categorize_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER1}}_others\",\r\n \"title\": \"It's something else\",\r\n \"description\": \"Messages that don't fall into the other categories\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "HOLD_FOR_L2_CATEGORISATION", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"HOLD_FOR_L2_CATEGORISATION message sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const HOLD_FOR_L2_CATEGORISATION = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_L2_CATEGORISATION\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": HOLD_FOR_L2_CATEGORISATION,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "L2_CATEGORISATION_MENU", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L2_OTHERS_ASSESSEMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const L2_OTHERS_ASSESSEMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L2_OTHERS_ASSESSEMENT_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": L2_OTHERS_ASSESSEMENT_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Make Selection\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_spam`,\r", - " \"title\": \"Spam\",\r", - " \"description\": \"Unsolicited spam, such as marketing messages\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_legitimate`,\r", - " \"title\": \"Legitimate\",\r", - " \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_irrelevant`,\r", - " \"title\": \"Trivial\",\r", - " \"description\": \"Trivial/banal messages with nothing to assess\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_unsure`,\r", - " \"title\": \"I'm Unsure\",\r", - " \"description\": \"Do try your best to categorize! But if really unsure, select this\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "First checker selects \"unsure\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"others_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER1}}_unsure\",\r\n \"title\": \"I'm Unsure\",\r\n \"description\": \"Do try your best to categorize! But if really unsure, select this\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "RESPONSE_RECORDED", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": RESPONSE_RECORDED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "NO_OUTSTANDING", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": NO_OUTSTANDING,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "007b_Interim_Message", - "item": [ - { - "name": "Send /interim command", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIDFCMDlDNjhFRDgzMEJCQjA0M0FBM0NEQTc5MEYzRkE4AA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"/interim\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ],\r\n \"severity\": \"INFO\",\r\n \"message\": \"\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Get Instance ID", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that there is 1 instance\", function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData?.documents?.length).to.eql(1);\r", - " var fullName = jsonData.documents[0].name;\r", - " var splitName = fullName.split(\"/\");\r", - " var docId = splitName[splitName.length - 1];\r", - " pm.collectionVariables.set(\"unsureInstanceId\", docId);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{unsureMessageId}}/instances", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "checkmate-373101", - "databases", - "(default)", - "documents", - "messages", - "{{unsureMessageId}}", - "instances" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", - " const INTERIM_PROMPT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": INTERIM_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get interim update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Press button to get interim update", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_TEMPLATE_UNSURE", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_TEMPLATE_UNSURE sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const INTERIM_TEMPLATE_UNSURE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE_UNSURE\");\r", - " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", - " const interimResponse = INTERIM_TEMPLATE_UNSURE.replace(\"{{%voted}}\", \"33.33\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": interimResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get another update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " \r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Check interim values", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData?.fields?.isMeaningfulInterimReplySent?.booleanValue).to.equal(false);\r", - " pm.expect(jsonData?.fields?.isInterimReplySent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimPromptSent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimUseful?.booleanValue).to.equal(false);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "checkmate-373101", - "databases", - "(default)", - "documents", - "messages", - "{{unsureMessageId}}", - "instances", - "{{unsureInstanceId}}" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "007c_1st Voter Change To Legitimate", - "item": [ - { - "name": "First checker selects \"legitimate\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"others_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER1}}_legitimate\",\r\n \"title\": \"Legitimate\",\r\n \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "RESPONSE_RECORDED", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": RESPONSE_RECORDED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "NO_OUTSTANDING", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": NO_OUTSTANDING,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Press button to get interim update", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_TEMPLATE_WITH_FEEDBACK", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_TEMPLATE sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const INTERIM_TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE\");\r", - " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK\")\r", - " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", - " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"is legitimate✅\").replace(\"{{info_placeholder}}\",\"\").replace(\"{{get_feedback}}\",INTERIM_FEEDBACK)\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": interimResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_yes`,\r", - " \"title\": \"Yes, it's useful\"\r", - " }\r", - " },\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_no`,\r", - " \"title\": \"No, it's not\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " \r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Check interim values", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData?.fields?.isMeaningfulInterimReplySent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimReplySent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimPromptSent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimUseful?.booleanValue).to.equal(false);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "checkmate-373101", - "databases", - "(default)", - "documents", - "messages", - "{{unsureMessageId}}", - "instances", - "{{unsureInstanceId}}" - ] - } - }, - "response": [] - }, - { - "name": "Press button \"Yes it's useful\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"feedbackInterim_messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}_yes\",\r\n \"title\": \"Yes, it's useful\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_USEFUL", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_USEFUL sent to user\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const INTERIM_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_USEFUL\");\r", - " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": INTERIM_USEFUL\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get another update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Check interim values", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData?.fields?.isMeaningfulInterimReplySent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimReplySent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimPromptSent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimUseful?.booleanValue).to.equal(true);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "checkmate-373101", - "databases", - "(default)", - "documents", - "messages", - "{{unsureMessageId}}", - "instances", - "{{unsureInstanceId}}" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "007d_2nd Voter Info \"3\"", - "item": [ - { - "name": "Second checker clicks yes", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{unsureVoteRequestPath_CHECKER2}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Message to Check Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Message to check sent to checker 2\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": \"This is an unsure message that will be voted on\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"messaging_product\": \"whatsapp\"\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "L1_ASSESSMENT_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER2\").split(\"/\")\r", - " const L1_ASSESSMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L1_ASSESSMENT_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": L1_ASSESSMENT_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Make Selection\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_scam`,\r", - " \"title\": \"Scam\",\r", - " \"description\": \"Intended to obtain money/personal information via deception\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_illicit`,\r", - " \"title\": \"Illicit\",\r", - " \"description\": \"Other potential illicit activity, e.g. moneylending/prostitution\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_info`,\r", - " \"title\": \"News/Information/Opinion\",\r", - " \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_others`,\r", - " \"title\": \"It's something else\",\r", - " \"description\": \"Messages that don't fall into the other categories\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - "\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Second checker selects \"info\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"categorize_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER2}}_info\",\r\n \"title\": \"News/Information/Opinion\",\r\n \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "HOLD_FOR_NEXT_POLL", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"HOLD_FOR_NEXT_POLL message sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const HOLD_FOR_NEXT_POLL = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_NEXT_POLL\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": HOLD_FOR_NEXT_POLL,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "FACTCHECK_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER2\").split(\"/\")\r", - " const FACTCHECK_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.FACTCHECK_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": FACTCHECK_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Vote here\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_0`,\r", - " \"title\": \"0\",\r", - " \"description\": \"Totally false\"\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_1`,\r", - " \"title\": \"1\",\r", - " }, \r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_2`,\r", - " \"title\": \"2\",\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_3`,\r", - " \"title\": \"3\",\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_4`,\r", - " \"title\": \"4\",\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_5`,\r", - " \"title\": \"5\",\r", - " \"description\": \"Totally true\"\r", - " },\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Second checker selects \"3\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"vote_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER2}}_3\",\r\n \"title\": \"3\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "RESPONSE_RECORDED", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": RESPONSE_RECORDED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "NO_OUTSTANDING", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": NO_OUTSTANDING,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Press button to get interim update", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_TEMPLATE_UNSURE", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_TEMPLATE_UNSURE sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const INTERIM_TEMPLATE_UNSURE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE_UNSURE\");\r", - " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", - " const interimResponse = INTERIM_TEMPLATE_UNSURE.replace(\"{{%voted}}\", \"66.67\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": interimResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get another update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " \r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "007e_3rd Voter Spam", - "item": [ - { - "name": "Third checker clicks yes", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{unsureVoteRequestPath_CHECKER3}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Message to Check Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Message to check sent to checker 2\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": \"This is an unsure message that will be voted on\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"messaging_product\": \"whatsapp\"\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "L1_ASSESSMENT_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER3\").split(\"/\")\r", - " const L1_ASSESSMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L1_ASSESSMENT_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": L1_ASSESSMENT_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Make Selection\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_scam`,\r", - " \"title\": \"Scam\",\r", - " \"description\": \"Intended to obtain money/personal information via deception\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_illicit`,\r", - " \"title\": \"Illicit\",\r", - " \"description\": \"Other potential illicit activity, e.g. moneylending/prostitution\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_info`,\r", - " \"title\": \"News/Information/Opinion\",\r", - " \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_others`,\r", - " \"title\": \"It's something else\",\r", - " \"description\": \"Messages that don't fall into the other categories\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " //console.log(JSON.stringify(expected,null,2))\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Third checker selects \"It's something else\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"categorize_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER3}}_others\",\r\n \"title\": \"It's something else\",\r\n \"description\": \"Messages that don't fall into the other categories\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "HOLD_FOR_L2_CATEGORISATION", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"HOLD_FOR_L2_CATEGORISATION message sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const HOLD_FOR_L2_CATEGORISATION = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_L2_CATEGORISATION\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": HOLD_FOR_L2_CATEGORISATION,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "L2_CATEGORISATION_MENU", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L2_OTHERS_ASSESSEMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER3\").split(\"/\")\r", - " const L2_OTHERS_ASSESSEMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L2_OTHERS_ASSESSEMENT_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": L2_OTHERS_ASSESSEMENT_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Make Selection\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_spam`,\r", - " \"title\": \"Spam\",\r", - " \"description\": \"Unsolicited spam, such as marketing messages\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_legitimate`,\r", - " \"title\": \"Legitimate\",\r", - " \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_irrelevant`,\r", - " \"title\": \"Trivial\",\r", - " \"description\": \"Trivial/banal messages with nothing to assess\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_unsure`,\r", - " \"title\": \"I'm Unsure\",\r", - " \"description\": \"Do try your best to categorize! But if really unsure, select this\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Third checker selects \"spam\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"others_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER3}}_spam\",\r\n \"title\": \"Spam\",\r\n \"description\": \"Unsolicited spam, such as marketing messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "RESPONSE_RECORDED", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RESPONSE_RECORDED sent to checker 3\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": RESPONSE_RECORDED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "NO_OUTSTANDING", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"NO_OUTSTANDING sent to checker 3\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": NO_OUTSTANDING,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "UNSURE", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"UNSURE final reply sent to user 1\", function () {\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER3\").split(\"/\")\r", - " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", - " const UNSURE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.UNSURE\");\r", - " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\");\r", - " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\");\r", - " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\");\r", - " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\");\r", - " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\");\r", - " const isMachineCategorised = false\r", - " const instanceCount = 1\r", - " const isImmediate = false\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " function getFinalResponseText(responseText) {\r", - " return responseText\r", - " .replace(\r", - " \"{{thanks}}\",\r", - " isImmediate ? THANKS_IMMEDIATE : THANKS_DELAYED\r", - " )\r", - " .replace(\r", - " \"{{matched}}\",\r", - " instanceCount >= 5\r", - " ? `In fact, others have already sent this message in ${instanceCount} times. `\r", - " : \"\"\r", - " )\r", - " .replace(\r", - " \"{{methodology}}\",\r", - " isMachineCategorised\r", - " ? METHODOLOGY_AUTO\r", - " : METHODOLOGY_HUMAN\r", - " )\r", - " .replace(\"{{results}}\", isImmediate ? \"\" : VOTE_RESULTS_SUFFIX)\r", - " }\r", - " const response = getFinalResponseText(UNSURE)\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": response\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `votingResults_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"See voting results\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "007f_Stats_Message", - "item": [ - { - "name": "Press button to see stats", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"votingResults_messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}\",\r\n \"title\": \"See voting results\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "STATS_TEMPLATE", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"STATS_TEMPLATE sent to user 1\", function () {\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " //we not using the template for this, its hardcoded.\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": \"33.33% of our CheckMates thought this was *spam*. 33.33% collectively thought this was *misleading*, with an average score of 3.00 on a scale of 0-5 (5 = completely true).\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - } - ] - }, - { - "name": "008_Menu_Message", - "item": [ - { - "name": "Send WhatApp message (\"Menu\")", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"Menu\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (GENERIC_MENU)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const MENU = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU\");\r", - " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_PREFIX\");\r", - " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX)\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": MENU_TEXT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"View Menu\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": \"menu_check\",\r", - " \"title\": \"Check/Report\",\r", - " \"description\": \"Send in messages, images, or screenshots for checking!\"\r", - " },\r", - " {\r", - " \"id\": \"menu_referral\",\r", - " \"title\": \"Get Referral Link\",\r", - " \"description\": \"Get referral link to forward to others\"\r", - " },\r", - " {\r", - " \"id\": \"menu_help\",\r", - " \"title\": \"Get Help\",\r", - " \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r", - " },\r", - " {\r", - " \"id\": \"menu_about\",\r", - " \"title\": \"About CheckMate\",\r", - " \"description\": \"Learn more about CheckMate and the team behind it\"\r", - " },\r", - " {\r", - " \"id\": \"menu_feedback\",\r", - " \"title\": \"Send Feedback\",\r", - " \"description\": \"Send us feedback on anything to do with CheckMate\"\r", - " },\r", - " {\r", - " \"id\": \"menu_contact\",\r", - " \"title\": \"Get Contact\",\r", - " \"description\": \"Get CheckMate's contact to add to your contact list\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Make Menu Selection (\"Check/Report\")", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_check\",\r\n \"title\": \"Check/Report\",\r\n \"description\": \"Send in messages, images, or screenshots for checking!\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (PROCEED_TO_SEND)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.PROCEED_TO_SEND\");\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": BODY_TEXT,\r", - " \"preview_url\": true\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Make Menu Selection (\"Get Help\")", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_help\",\r\n \"title\": \"Get Help\",\r\n \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (HOW_TO)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.HOW_TO\");\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": BODY_TEXT,\r", - " \"preview_url\": true\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Make Menu Selection (\"About CheckMate\")", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_about\",\r\n \"title\": \"About CheckMate\",\r\n \"description\": \"Learn more about CheckMate and the team behind it\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (LEARN_MORE)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.LEARN_MORE\");\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": BODY_TEXT,\r", - " \"preview_url\": true\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Make Menu Selection (\"Send Feedback\")", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_feedback\",\r\n \"title\": \"Send Feedback\",\r\n \"description\": \"Send us feedback on anything to do with CheckMate\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (FEEDBACK)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.FEEDBACK\");\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": BODY_TEXT,\r", - " \"preview_url\": true\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Make Menu Selection (\"Get Contact\")", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_contact\",\r\n \"title\": \"Get Contact\",\r\n \"description\": \"Get CheckMates contact to add to your contact list\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (contact type)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"contacts\",\r", - " \"contacts\": [\r", - " {\r", - " \"name\": {\r", - " \"formatted_name\": \"CheckMate\",\r", - " \"suffix\": \"CheckMate\"\r", - " },\r", - " \"urls\": [\r", - " {\r", - " \"url\": \"https://checkmate.sg\"\r", - " }\r", - " ],\r", - " \"phones\": [\r", - " {\r", - " \"phone\": \"+1 555-093-3685\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Get last message (CONTACT)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.CONTACT\");\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": BODY_TEXT,\r", - " \"preview_url\": true\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Make Menu Selection (\"Referral\")", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_referral\",\r\n \"title\": \"Get Referral Link\",\r\n \"description\": \"Get referral link to forward to others\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (REFERRAL)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL\");\r", - " const link = pm.variables.get(\"referralLink_USER1\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const referralMessage = BODY_TEXT.replace(\"{{link}}\", link)\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": referralMessage,\r", - " \"preview_url\": true\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "009_Scam_Autocategorise", - "item": [ - { - "name": "User sends scam message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is a scam message\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (SCAM, IMMEDIATE, NOT MATCHED, AUTO)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"scam immediate autocategorised no matched response\", function () {\r", - " const TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.SCAM\");\r", - " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\")\r", - " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\")\r", - " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\")\r", - " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\")\r", - " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\")\r", - " const BODY_TEXT = TEMPLATE.replace(\"{{thanks}}\",THANKS_IMMEDIATE).replace(\"{{methodology}}\",METHODOLOGY_AUTO).replace(\"{{matched}}\",\"\").replace(\"{{results}}\",\"\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": BODY_TEXT\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": \"ID\",\r", - " \"title\": \"Yes\"\r", - " }\r", - " },\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": \"ID\",\r", - " \"title\": \"No\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - "\r", - " var jsonData = pm.response.json();\r", - "\r", - " let reply_id_yes = jsonData.body.interactive.action.buttons[0].reply.id;\r", - " let reply_id_no = jsonData.body.interactive.action.buttons[1].reply.id;\r", - " let [, scamInstancePath , ] = reply_id_yes.split(\"_\")\r", - " \r", - " // check if the id matches the pattern \"menu_dispute_messages/*/instances/*\"\r", - " pm.expect(reply_id_yes).to.match(/scamshieldConsent_messages\\/\\w+\\/instances\\/\\w+_consent/);\r", - " pm.expect(reply_id_no).to.match(/scamshieldConsent_messages\\/\\w+\\/instances\\/\\w+_decline/);\r", - " pm.collectionVariables.set(\"scamInstancePath\", scamInstancePath);\r", - "\r", - " jsonData.body.interactive.action.buttons[0].reply.id = \"ID\"\r", - " jsonData.body.interactive.action.buttons[1].reply.id = \"ID\"\r", - "\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": ["setTimeout(() => {}, 2000);"], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "010_Spam_Autocategorise", - "item": [ - { - "name": "User sends spam message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is a spam message\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (SPAM, IMMEDIATE, NOT MATCHED, AUTO)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"spam immediate autocategorised no matched response\", function () {\r", - " const TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.SPAM\");\r", - " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\")\r", - " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\")\r", - " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\")\r", - " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\")\r", - " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\")\r", - " const BODY_TEXT = TEMPLATE.replace(\"{{thanks}}\",THANKS_IMMEDIATE).replace(\"{{methodology}}\",METHODOLOGY_AUTO).replace(\"{{matched}}\",\"\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": BODY_TEXT,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": ["setTimeout(() => {}, 2000);"], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "011_Check_Steps_logging", - "item": [ - { - "name": "[DB CALL] Check steps", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that instance data updated correctly\", function () {\r", - "\r", - " var jsonData = pm.response.json();\r", - " const initialJourney = jsonData.fields.initialJourney.mapValue.fields\r", - " const actions = Object.values(initialJourney).map((obj) => obj.stringValue)\r", - " const expected = [\r", - " \"text_machine_irrelevant_length\",\r", - " \"text_machine_irrelevant_length\",\r", - " \"menu_dispute\",\r", - " \"text_machine_unsure\",\r", - " \"sendInterim\",\r", - " \"feedbackInterim_yes\",\r", - " \"feedbackInterim_no\",\r", - " \"sendInterim\",\r", - " \"sendInterim\",\r", - " \"satisfactionSurvey_10\",\r", - " \"sendInterim\",\r", - " \"votingResults\",\r", - " \"text_machine_info\",\r", - " \"sendInterim\",\r", - " \"votingResults\",\r", - " \"text_machine_unsure\",\r", - " \"sendInterim\",\r", - " \"sendInterim\",\r", - " \"feedbackInterim_yes\",\r", - " \"sendInterim\",\r", - " \"votingResults\",\r", - " \"text_menu\",\r", - " \"menu_check\",\r", - " \"menu_help\",\r", - " \"menu_about\",\r", - " \"menu_feedback\",\r", - " \"menu_contact\",\r", - " \"menu_referral\",\r", - " \"text_machine_scam\",\r", - " \"text_machine_spam\",\r", - " ]\r", - " pm.expect(actions).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/users/{{USER_1_NUMBER}}", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "checkmate-373101", - "databases", - "(default)", - "documents", - "users", - "{{USER_1_NUMBER}}" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "012_New_User_Referral", - "item": [ - { - "name": "Send WhatsApp message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_2_NAME}}\" }, \"wa_id\": \"{{USER_2_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"{{__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL_PREPOPULATED_PREFIX}} {{referralId_USER1}}\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (NEW_USER_MENU)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const MENU = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU\");\r", - " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_MENU_PREFIX\");\r", - " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX)\r", - " const USER_2_NUMBER = pm.variables.get(\"USER_2_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_2_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": MENU_TEXT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"View Menu\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": \"menu_check\",\r", - " \"title\": \"Check/Report\",\r", - " \"description\": \"Send in messages, images, or screenshots for checking!\"\r", - " },\r", - " {\r", - " \"id\": \"menu_referral\",\r", - " \"title\": \"Get Referral Link\",\r", - " \"description\": \"Get referral link to forward to others\"\r", - " },\r", - " {\r", - " \"id\": \"menu_help\",\r", - " \"title\": \"Get Help\",\r", - " \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r", - " },\r", - " {\r", - " \"id\": \"menu_about\",\r", - " \"title\": \"About CheckMate\",\r", - " \"description\": \"Learn more about CheckMate and the team behind it\"\r", - " },\r", - " {\r", - " \"id\": \"menu_feedback\",\r", - " \"title\": \"Send Feedback\",\r", - " \"description\": \"Send us feedback on anything to do with CheckMate\"\r", - " },\r", - " {\r", - " \"id\": \"menu_contact\",\r", - " \"title\": \"Get Contact\",\r", - " \"description\": \"Get CheckMate's contact to add to your contact list\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Check referral count", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that referral count is incremented to 1\", function () {\r", - "\r", - " var jsonData = pm.response.json();\r", - " const referralCount = jsonData.fields.referralCount.integerValue\r", - " pm.expect(parseInt(referralCount)).to.eql(1);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/users/{{USER_1_NUMBER}}", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "checkmate-373101", - "databases", - "(default)", - "documents", - "users", - "{{USER_1_NUMBER}}" - ] - } - }, - "response": [] - }, - { - "name": "Send 2nd referral message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_2_NAME}}\" }, \"wa_id\": \"{{USER_2_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"{{__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL_PREPOPULATED_PREFIX}} {{referralId_USER1}}\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (REFERRAL_INVALID)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"REFERRAL_INVALID response received\", function () {\r", - " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL_INVALID\");\r", - " const USER_2_NUMBER = pm.variables.get(\"USER_2_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": BODY_TEXT,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": USER_2_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " },\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - } - ], - "event": [ - { - "listen": "prerequest", - "script": { - "type": "text/javascript", - "exec": [""] - } - }, - { - "listen": "test", - "script": { - "type": "text/javascript", - "exec": [""] - } - } - ], - "variable": [ - { - "key": "disputedMessagePath", - "value": "" - }, - { - "key": "disputedMessageTextListId", - "value": "" - }, - { - "key": "disputedInstancePath", - "value": "" - }, - { - "key": "scamInstancePath", - "value": "" - }, - { - "key": "spamVoteRequestPath", - "value": "" - }, - { - "key": "spamVoteRequestPath_CHECKER3", - "value": "" - }, - { - "key": "spamVoteRequestPath_CHECKER2", - "value": "" - }, - { - "key": "spamVoteRequestPath_CHECKER1", - "value": "" - }, - { - "key": "spamMessageId_CHECKER3", - "value": "" - }, - { - "key": "spamVoteRequestId_CHECKER3", - "value": "" - }, - { - "key": "spamMessageId_CHECKER2", - "value": "" - }, - { - "key": "spamVoteRequestId_CHECKER2", - "value": "" - }, - { - "key": "spamMessageId_CHECKER1", - "value": "" - }, - { - "key": "spamVoteRequestId_CHECKER1", - "value": "" - }, - { - "key": "spamMessageId", - "value": "" - }, - { - "key": "spamInstanceId", - "value": "" - }, - { - "key": "infoVoteRequestPath_CHECKER1", - "value": "" - }, - { - "key": "infoMessageId", - "value": "" - }, - { - "key": "infoVoteRequestId_CHECKER1", - "value": "" - }, - { - "key": "infoVoteRequestPath_CHECKER2", - "value": "" - }, - { - "key": "infoVoteRequestId_CHECKER2", - "value": "" - }, - { - "key": "infoVoteRequestPath_CHECKER3", - "value": "" - }, - { - "key": "infoVoteRequestId_CHECKER3", - "value": "" - }, - { - "key": "infoInstanceId", - "value": "" - }, - { - "key": "unsureVoteRequestPath_CHECKER3", - "value": "" - }, - { - "key": "unsureVoteRequestId_CHECKER3", - "value": "" - }, - { - "key": "unsureVoteRequestPath_CHECKER2", - "value": "" - }, - { - "key": "unsureVoteRequestId_CHECKER2", - "value": "" - }, - { - "key": "unsureInstanceId", - "value": "" - }, - { - "key": "unsureVoteRequestPath_CHECKER1", - "value": "" - }, - { - "key": "unsureMessageId", - "value": "" - }, - { - "key": "unsureVoteRequestId_CHECKER1", - "value": "" - }, - { - "key": "user_1_referralId", - "value": "" - }, - { - "key": "referralLink_USER1", - "value": "" - }, - { - "key": "referralId_USER1", - "value": "" - } - ] -} + "info": { + "_postman_id": "035f0de1-363b-4ee6-ae39-fa8d662c7e11", + "name": "checkmate", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "25230076" + }, + "item": [ + { + "name": "000_Healthcheck", + "item": [ + { + "name": "Healthcheck", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.collectionVariables.set(\"messageCounter\", 0);\r", + "\r", + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/healthcheck", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "healthcheck" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "001_Mock_Db", + "item": [ + { + "name": "Create mock firestore DB", + "event": [ + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 1\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)" + ], + "type": "text/javascript" + } + }, + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"Test User\"\r\n },\r\n \"wa_id\": \"88888888\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"88888888\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIDFCMDlDNjhFRDgzMEJCQjA0M0FBM0NEQTc5MEYzRkE4AA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"/mockdb\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ],\r\n \"severity\": \"INFO\",\r\n \"message\": \"\"\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get mock db collection IDs", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check number of collections /mockdb command creates in Firestore\", function () {\r", + " const jsonData = pm.response.json();\r", + " \r", + " pm.expect(jsonData?.collectionIds?.length).to.eql(2);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "default" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents:listCollectionIds", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents:listCollectionIds" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "002_Add_Checkers", + "item": [ + { + "name": "Checker 2 Onboarding", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 2\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_2}}\",\r\n \"timestamp\": \"{{$timestamp}}\",\r\n \"text\": {\r\n \"body\": \"I'd like to join as a CheckMate to help counter misinformation and scams! 💪🏻\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Check Onboarding_1 Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const CHECKER_2_NUMBER = pm.variables.get(\"CHECKER_2_NUMBER\");\r", + " const ONBOARDING_1 = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_1\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": ONBOARDING_1,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_2_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"whatsapp\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Checker 2 input name", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 3\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"{{MOCK_WHATSAPP_MSG_ID}}\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_3}}\",\r\n \"timestamp\": \"{{$timestamp}}\",\r\n \"text\": {\r\n \"body\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Check Onboarding_2 Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const CHECKER_2_NUMBER = pm.variables.get(\"CHECKER_2_NUMBER\");\r", + " const CHECKER_2_NAME = pm.variables.get(\"CHECKER_2_NAME\");\r", + " const ONBOARDING_2 = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_2\").replace(\"{{name}}\", CHECKER_2_NAME);\r", + "\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_2_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": ONBOARDING_2\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": \"privacyOk\",\r", + " \"title\": \"Got it!\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Checker 2 press \"Got it!\" button", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 4\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"{{MOCK_WHATSAPP_MSG_ID}}\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_4}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"privacyOk\",\r\n \"title\": \"Got it!\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Check Onboarding_3 Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const CHECKER_2_NUMBER = pm.variables.get(\"CHECKER_2_NUMBER\");\r", + " const ONBOARDING_3 = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_3\")\r", + "\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_2_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": ONBOARDING_3\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": \"typeformDone\",\r", + " \"title\": \"I've done the quiz!\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Checker 2 press \"Ive done the quiz!\" button", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 5\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_5}}\",\r\n \"timestamp\": \"{{$timestamp}}\",\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"typeformDone\",\r\n \"title\": \"I've done the quiz!\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Check Onboarding_4 Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const CHECKER_2_NUMBER = pm.variables.get(\"CHECKER_2_NUMBER\");\r", + " const ONBOARDING_4 = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_4\")\r", + "\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": ONBOARDING_4,\r", + " \"preview_url\": true\r", + " },\r", + " \"to\": CHECKER_2_NUMBER,\r", + " \"messaging_product\": \"whatsapp\"\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Checker 3 Onboarding", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 6\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_6}}\",\r\n \"timestamp\": \"{{$timestamp}}\",\r\n \"text\": {\r\n \"body\": \"I'd like to join as a CheckMate to help counter misinformation and scams! 💪🏻\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Check Onboarding_1 Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const CHECKER_3_NUMBER = pm.variables.get(\"CHECKER_3_NUMBER\");\r", + " const ONBOARDING_1 = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_1\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": ONBOARDING_1,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_3_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"whatsapp\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Checker 3 input name", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 7\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_7}}\",\r\n \"timestamp\": \"{{$timestamp}}\",\r\n \"text\": {\r\n \"body\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Check Onboarding_2 Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const CHECKER_3_NUMBER = pm.variables.get(\"CHECKER_3_NUMBER\");\r", + " const CHECKER_3_NAME = pm.variables.get(\"CHECKER_3_NAME\");\r", + " const ONBOARDING_2 = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_2\").replace(\"{{name}}\", CHECKER_3_NAME);\r", + "\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_3_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": ONBOARDING_2\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": \"privacyOk\",\r", + " \"title\": \"Got it!\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "003_New_User", + "item": [ + { + "name": "Send WhatsApp message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 8\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_8}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"F\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (NEW_USER_MENU)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const MENU = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU\");\r", + " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_MENU_PREFIX\");\r", + " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX)\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": MENU_TEXT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"View Menu\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": \"menu_check\",\r", + " \"title\": \"Check/Report\",\r", + " \"description\": \"Send in messages, images, or screenshots for checking!\"\r", + " },\r", + " {\r", + " \"id\": \"menu_referral\",\r", + " \"title\": \"Get Referral Link\",\r", + " \"description\": \"Get referral link to forward to others\"\r", + " },\r", + " {\r", + " \"id\": \"menu_help\",\r", + " \"title\": \"Get Help\",\r", + " \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r", + " },\r", + " {\r", + " \"id\": \"menu_about\",\r", + " \"title\": \"About CheckMate\",\r", + " \"description\": \"Learn more about CheckMate and the team behind it\"\r", + " },\r", + " {\r", + " \"id\": \"menu_feedback\",\r", + " \"title\": \"Send Feedback\",\r", + " \"description\": \"Send us feedback on anything to do with CheckMate\"\r", + " },\r", + " {\r", + " \"id\": \"menu_contact\",\r", + " \"title\": \"Get Contact\",\r", + " \"description\": \"Get CheckMate's contact to add to your contact list\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Check referral count", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that has is created\", function () {\r", + "\r", + " var jsonData = pm.response.json();\r", + " const referralId = jsonData.fields.referralId.stringValue\r", + " pm.collectionVariables.set(\"referralId_USER1\", referralId);\r", + " pm.collectionVariables.set(\"referralLink_USER1\", `https://ref.checkmate.sg/${referralId}`);\r", + " pm.expect(referralId.length).to.be.above(0);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/users/{{USER_1_NUMBER}}", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "users", + "{{USER_1_NUMBER}}" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "004_Irrelevant_Message", + "item": [ + { + "name": "Send WhatsApp message (7 Chars)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 9\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_9}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"1234567\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (IRRELEVANT_MENU)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Message auto-categorised as irrelevant returns correct menu\", function () {\r", + " const MENU = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU\");\r", + " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.IRRELEVANT_AUTO_MENU_PREFIX\");\r", + " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX)\r", + " const wamid = pm.variables.get(\"whatsapp_id_9\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": MENU_TEXT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"View Menu\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": \"menu_check\",\r", + " \"title\": \"Check/Report\",\r", + " \"description\": \"Send in messages, images, or screenshots for checking!\"\r", + " },\r", + " {\r", + " \"id\": \"menu_referral\",\r", + " \"title\": \"Get Referral Link\",\r", + " \"description\": \"Get referral link to forward to others\",\r", + " },\r", + " {\r", + " \"id\": \"menu_help\",\r", + " \"title\": \"Get Help\",\r", + " \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r", + " },\r", + " {\r", + " \"id\": \"menu_about\",\r", + " \"title\": \"About CheckMate\",\r", + " \"description\": \"Learn more about CheckMate and the team behind it\"\r", + " },\r", + " {\r", + " \"id\": \"menu_feedback\",\r", + " \"title\": \"Send Feedback\",\r", + " \"description\": \"Send us feedback on anything to do with CheckMate\"\r", + " },\r", + " {\r", + " \"id\": \"menu_dispute_messages/*/instances/*\",\r", + " \"title\": \"Dispute Assessment\",\r", + " \"description\": \"Dispute CheckMate's assesment of this message\"\r", + " },\r", + " {\r", + " \"id\": \"menu_contact\",\r", + " \"title\": \"Get Contact\",\r", + " \"description\": \"Get CheckMate's contact to add to your contact list\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " \r", + " // get the id of \"Dispute Assessment\" for validation\r", + " let disputeAssessmentId = jsonData.body.interactive.action.sections[0].rows.find(row => row.title === \"Dispute Assessment\").id;\r", + " let [, , disputedInstancePath] = disputeAssessmentId.split(\"_\")\r", + " \r", + " // check if the id matches the pattern \"menu_dispute_messages/*/instances/*\"\r", + " pm.expect(disputeAssessmentId).to.match(/menu_dispute_messages\\/[^\\/]+\\/instances\\/[^\\/]+/);\r", + " pm.collectionVariables.set(\"disputedInstancePath\", disputedInstancePath);\r", + "\r", + " // remove the id of \"Dispute Assessment\" for comparison\r", + " jsonData.body.interactive.action.sections[0].rows = jsonData.body.interactive.action.sections[0].rows.map(row => {\r", + " if (row.title === \"Dispute Assessment\") {\r", + " return {...row, id: \"menu_dispute_messages/*/instances/*\"};\r", + " } else {\r", + " return row;\r", + " }\r", + " });\r", + "\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 2000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Make Menu Selection (\"Dispute Categorisation\")", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 10\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_10}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_dispute_{{disputedInstancePath}}\",\r\n \"title\": \"Dispute Assessment\",\r\n \"description\": \"Dispute CheckMate's assesment of this message\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (telegram blast)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"On dispute, message is sent out to Telegram group chat\", function () {\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const DISPUTED_INSTANCE_PATH = pm.collectionVariables.get(\"disputedInstancePath\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/botTELEGRAM_REPORT_BOT_TOKEN/sendMessage\",\r", + " \"body\": {\r", + " \"chat_id\": \"111111111\",\r", + " \"text\": `${USER_1_NUMBER} has disputed the assessment of a message sent by them.\\n \\nmessage/instance path: ${DISPUTED_INSTANCE_PATH}\\n\\ntype: text\\n\\ntext: 1234567\\n\\ncategory: irrelevant`\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + "\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (DISPUTE)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.DISPUTE\");\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": BODY_TEXT,\r", + " \"preview_url\": true\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "005_Spam_Human", + "item": [ + { + "name": "005a_User_Send_First_Vote", + "item": [ + { + "name": "Send WhatsApp message (15 Chars)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 11\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "\r", + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_11}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is a sp-am message that will be voted on\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (MESSAGE_NOT_YET_ASSESSED)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", + " const MESSAGE_NOT_YET_ASSESSED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MESSAGE_NOT_YET_ASSESSED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": MESSAGE_NOT_YET_ASSESSED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Get first checker message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", + " const CHECKER_NAME = \"CHECKER_NAME\"\r", + " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBER,\r", + " \"type\": \"template\",\r", + " \"template\": {\r", + " \"name\": \"new_message_received\",\r", + " \"language\": {\r", + " \"policy\": \"deterministic\",\r", + " \"code\": \"en\"\r", + " },\r", + " \"components\": [\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 0,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 1,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"body\",\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"text\",\r", + " \"text\": CHECKER_NAME\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"factChecker\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " //check name in list\r", + " const name = jsonData.body.template.components[2].parameters[0].text\r", + " pm.expect(CHECKER_NAMES).to.include(name);\r", + " //check number in list\r", + " const number = jsonData.body.to\r", + " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", + " const spamVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", + " const [, messageId, , voteRequestId] = spamVoteRequestPath.split(\"/\")\r", + " pm.collectionVariables.set(`spamVoteRequestPath_${name}`, spamVoteRequestPath);\r", + " pm.collectionVariables.set(`spamMessageId`, messageId);\r", + " pm.collectionVariables.set(`spamVoteRequestId_${name}`, voteRequestId);\r", + " // Replace dynamically created IDs\r", + " jsonData.body.to = CHECKER_PHONE_NUMBER\r", + " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Get second checker message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", + " const CHECKER_NAME = \"CHECKER_NAME\"\r", + " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBER,\r", + " \"type\": \"template\",\r", + " \"template\": {\r", + " \"name\": \"new_message_received\",\r", + " \"language\": {\r", + " \"policy\": \"deterministic\",\r", + " \"code\": \"en\"\r", + " },\r", + " \"components\": [\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 0,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 1,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"body\",\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"text\",\r", + " \"text\": CHECKER_NAME\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"factChecker\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " //check name in list\r", + " const name = jsonData.body.template.components[2].parameters[0].text\r", + " pm.expect(CHECKER_NAMES).to.include(name);\r", + " //check number in list\r", + " const number = jsonData.body.to\r", + " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", + " const spamVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", + " const [, messageId, , voteRequestId] = spamVoteRequestPath.split(\"/\")\r", + " pm.collectionVariables.set(`spamVoteRequestPath_${name}`, spamVoteRequestPath);\r", + " pm.collectionVariables.set(`spamMessageId`, messageId);\r", + " pm.collectionVariables.set(`spamVoteRequestId_${name}`, voteRequestId);\r", + " // Replace dynamically created IDs\r", + " jsonData.body.to = CHECKER_PHONE_NUMBER\r", + " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Get third checker message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", + " const CHECKER_NAME = \"CHECKER_NAME\"\r", + " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBER,\r", + " \"type\": \"template\",\r", + " \"template\": {\r", + " \"name\": \"new_message_received\",\r", + " \"language\": {\r", + " \"policy\": \"deterministic\",\r", + " \"code\": \"en\"\r", + " },\r", + " \"components\": [\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 0,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 1,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"body\",\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"text\",\r", + " \"text\": CHECKER_NAME\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"factChecker\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " //check name in list\r", + " const name = jsonData.body.template.components[2].parameters[0].text\r", + " pm.expect(CHECKER_NAMES).to.include(name);\r", + " //check number in list\r", + " const number = jsonData.body.to\r", + " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", + " const spamVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", + " const [, messageId, , voteRequestId] = spamVoteRequestPath.split(\"/\")\r", + " pm.collectionVariables.set(`spamVoteRequestPath_${name}`, spamVoteRequestPath);\r", + " pm.collectionVariables.set(`spamMessageId`, messageId);\r", + " pm.collectionVariables.set(`spamVoteRequestId_${name}`, voteRequestId);\r", + " // Replace dynamically created IDs\r", + " jsonData.body.to = CHECKER_PHONE_NUMBER\r", + " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "First checker clicks yes", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{spamVoteRequestPath_CHECKER1}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Message to Check Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Message to check sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": \"This is a sp-am message that will be voted on\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\"\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "L1_ASSESSMENT_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const L1_ASSESSMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L1_ASSESSMENT_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": L1_ASSESSMENT_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Make Selection\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_scam`,\r", + " \"title\": \"Scam\",\r", + " \"description\": \"Intended to obtain money/personal information via deception\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_illicit`,\r", + " \"title\": \"Illicit\",\r", + " \"description\": \"Other potential illicit activity, e.g. moneylending/prostitution\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_info`,\r", + " \"title\": \"News/Information/Opinion\",\r", + " \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_others`,\r", + " \"title\": \"It's something else\",\r", + " \"description\": \"Messages that don't fall into the other categories\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + "\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "First checker selects \"It's something else\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"categorize_{{spamMessageId}}_{{spamVoteRequestId_CHECKER1}}_others\",\r\n \"title\": \"It's something else\",\r\n \"description\": \"Messages that don't fall into the other categories\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "HOLD_FOR_L2_CATEGORISATION", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"HOLD_FOR_L2_CATEGORISATION message sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const HOLD_FOR_L2_CATEGORISATION = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_L2_CATEGORISATION\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": HOLD_FOR_L2_CATEGORISATION,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 2000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "L2_CATEGORISATION_MENU", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L2_OTHERS_ASSESSEMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const L2_OTHERS_ASSESSEMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L2_OTHERS_ASSESSEMENT_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": L2_OTHERS_ASSESSEMENT_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Make Selection\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_spam`,\r", + " \"title\": \"Spam\",\r", + " \"description\": \"Unsolicited spam, such as marketing messages\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_legitimate`,\r", + " \"title\": \"Legitimate\",\r", + " \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_irrelevant`,\r", + " \"title\": \"Trivial\",\r", + " \"description\": \"Trivial/banal messages with nothing to assess\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_unsure`,\r", + " \"title\": \"I'm Unsure\",\r", + " \"description\": \"Do try your best to categorize! But if really unsure, select this\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "First checker selects \"spam\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"others_{{spamMessageId}}_{{spamVoteRequestId_CHECKER1}}_spam\",\r\n \"title\": \"Spam\",\r\n \"description\": \"Unsolicited spam, such as marketing messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "RESPONSE_RECORDED", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": RESPONSE_RECORDED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 2000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "NO_OUTSTANDING", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": NO_OUTSTANDING,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "005b_Interim_Message", + "item": [ + { + "name": "Send /interim command", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 12\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_12}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"/interim\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ],\r\n \"severity\": \"INFO\",\r\n \"message\": \"\"\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Get Instance ID", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that there is 1 instance\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData?.documents?.length).to.eql(1);\r", + " var fullName = jsonData.documents[0].name;\r", + " var splitName = fullName.split(\"/\");\r", + " var docId = splitName[splitName.length - 1];\r", + " pm.collectionVariables.set(\"spamInstanceId\", docId);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{spamMessageId}}/instances", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "messages", + "{{spamMessageId}}", + "instances" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const instanceId = pm.variables.get(\"spamInstanceId\")\r", + " const INTERIM_PROMPT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": INTERIM_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get interim update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Press button to get interim update", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 13\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "\r", + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_13}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_TEMPLATE_WITH_FEEDBACK", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_TEMPLATE sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const INTERIM_TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE\");\r", + " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", + " const instanceId = pm.variables.get(\"spamInstanceId\")\r", + " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"is spam🚧\").replace(\"{{info_placeholder}}\",\"\").replace(\"{{get_feedback}}\",INTERIM_FEEDBACK)\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": interimResponse\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_yes`,\r", + " \"title\": \"Yes, it's useful\"\r", + " }\r", + " },\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_no`,\r", + " \"title\": \"No, it's not\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " \r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Press button \"Yes it's useful\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 14\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "\r", + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_14}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"feedbackInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}_yes\",\r\n \"title\": \"Yes, it's useful\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_USEFUL", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_USEFUL sent to user\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const INTERIM_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_USEFUL\");\r", + " const instanceId = pm.variables.get(\"spamInstanceId\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": INTERIM_USEFUL\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get another update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Press button \"No it's not\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"feedbackInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}_no\",\r\n \"title\": \"No, it's not\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_NOT_USEFUL", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_NOT_USEFUL sent to user\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const INTERIM_NOT_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_NOT_USEFUL\");\r", + " const instanceId = pm.variables.get(\"spamInstanceId\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": INTERIM_NOT_USEFUL\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get another update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Press button to get interim update again", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 15\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "\r", + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_15}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_TEMPLATE", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_TEMPLATE with feedback sent to user\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const INTERIM_TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE\");\r", + " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK\")\r", + " const instanceId = pm.variables.get(\"spamInstanceId\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", + " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"is spam🚧\").replace(\"{{info_placeholder}}\",\"\").replace(\"{{get_feedback}}\",\"\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": interimResponse\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get another update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "005c_2nd Voter Legitimate", + "item": [ + { + "name": "Second checker clicks yes", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{spamVoteRequestPath_CHECKER2}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Message to Check Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Message to check sent to checker 2\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": \"This is a sp-am message that will be voted on\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"messaging_product\": \"whatsapp\"\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "L1_ASSESSMENT_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER2\").split(\"/\")\r", + " const L1_ASSESSMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L1_ASSESSMENT_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": L1_ASSESSMENT_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Make Selection\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_scam`,\r", + " \"title\": \"Scam\",\r", + " \"description\": \"Intended to obtain money/personal information via deception\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_illicit`,\r", + " \"title\": \"Illicit\",\r", + " \"description\": \"Other potential illicit activity, e.g. moneylending/prostitution\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_info`,\r", + " \"title\": \"News/Information/Opinion\",\r", + " \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_others`,\r", + " \"title\": \"It's something else\",\r", + " \"description\": \"Messages that don't fall into the other categories\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + "\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Second checker selects \"It's something else\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"categorize_{{spamMessageId}}_{{spamVoteRequestId_CHECKER2}}_others\",\r\n \"title\": \"It's something else\",\r\n \"description\": \"Messages that don't fall into the other categories\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "HOLD_FOR_L2_CATEGORISATION", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"HOLD_FOR_L2_CATEGORISATION message sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER2\").split(\"/\")\r", + " const HOLD_FOR_L2_CATEGORISATION = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_L2_CATEGORISATION\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": HOLD_FOR_L2_CATEGORISATION,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 2000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "L2_CATEGORISATION_MENU", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L2_OTHERS_ASSESSEMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER2\").split(\"/\")\r", + " const L2_OTHERS_ASSESSEMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L2_OTHERS_ASSESSEMENT_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": L2_OTHERS_ASSESSEMENT_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Make Selection\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_spam`,\r", + " \"title\": \"Spam\",\r", + " \"description\": \"Unsolicited spam, such as marketing messages\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_legitimate`,\r", + " \"title\": \"Legitimate\",\r", + " \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_irrelevant`,\r", + " \"title\": \"Trivial\",\r", + " \"description\": \"Trivial/banal messages with nothing to assess\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_unsure`,\r", + " \"title\": \"I'm Unsure\",\r", + " \"description\": \"Do try your best to categorize! But if really unsure, select this\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Second checker selects \"legitimate\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"others_{{spamMessageId}}_{{spamVoteRequestId_CHECKER2}}_legitimate\",\r\n \"title\": \"Legitimate\",\r\n \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "RESPONSE_RECORDED", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER2\").split(\"/\")\r", + " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": RESPONSE_RECORDED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 2000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "NO_OUTSTANDING", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER2\").split(\"/\")\r", + " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": NO_OUTSTANDING,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Press button to get interim update", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 16\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "\r", + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_16}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_TEMPLATE_UNSURE", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_TEMPLATE sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const INTERIM_TEMPLATE_UNSURE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE_UNSURE\");\r", + " const instanceId = pm.variables.get(\"spamInstanceId\")\r", + " const interimResponse = INTERIM_TEMPLATE_UNSURE.replace(\"{{%voted}}\", \"66.67\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": interimResponse\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get another update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "005d_3rd Voter Spam", + "item": [ + { + "name": "Third checker clicks yes", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{spamVoteRequestPath_CHECKER3}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Message to Check Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Message to check sent to checker 2\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": \"This is a sp-am message that will be voted on\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"messaging_product\": \"whatsapp\"\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "L1_ASSESSMENT_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", + " const L1_ASSESSMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L1_ASSESSMENT_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": L1_ASSESSMENT_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Make Selection\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_scam`,\r", + " \"title\": \"Scam\",\r", + " \"description\": \"Intended to obtain money/personal information via deception\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_illicit`,\r", + " \"title\": \"Illicit\",\r", + " \"description\": \"Other potential illicit activity, e.g. moneylending/prostitution\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_info`,\r", + " \"title\": \"News/Information/Opinion\",\r", + " \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_others`,\r", + " \"title\": \"It's something else\",\r", + " \"description\": \"Messages that don't fall into the other categories\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + "\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Third checker selects \"It's something else\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"categorize_{{spamMessageId}}_{{spamVoteRequestId_CHECKER3}}_others\",\r\n \"title\": \"It's something else\",\r\n \"description\": \"Messages that don't fall into the other categories\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "HOLD_FOR_L2_CATEGORISATION", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"HOLD_FOR_L2_CATEGORISATION message sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", + " const HOLD_FOR_L2_CATEGORISATION = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_L2_CATEGORISATION\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": HOLD_FOR_L2_CATEGORISATION,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 2000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "L2_CATEGORISATION_MENU", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L2_OTHERS_ASSESSEMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", + " const L2_OTHERS_ASSESSEMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L2_OTHERS_ASSESSEMENT_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": L2_OTHERS_ASSESSEMENT_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Make Selection\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_spam`,\r", + " \"title\": \"Spam\",\r", + " \"description\": \"Unsolicited spam, such as marketing messages\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_legitimate`,\r", + " \"title\": \"Legitimate\",\r", + " \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_irrelevant`,\r", + " \"title\": \"Trivial\",\r", + " \"description\": \"Trivial/banal messages with nothing to assess\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_unsure`,\r", + " \"title\": \"I'm Unsure\",\r", + " \"description\": \"Do try your best to categorize! But if really unsure, select this\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Third checker selects \"spam\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"others_{{spamMessageId}}_{{spamVoteRequestId_CHECKER3}}_spam\",\r\n \"title\": \"Spam\",\r\n \"description\": \"Unsolicited spam, such as marketing messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "RESPONSE_RECORDED", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", + " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": RESPONSE_RECORDED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 2000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "NO_OUTSTANDING", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", + " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": NO_OUTSTANDING,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "SPAM", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"SPAM final reply sent to checker 1\", function () {\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", + " const instanceId = pm.variables.get(\"spamInstanceId\")\r", + " const SPAM = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.SPAM\");\r", + " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\");\r", + " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\");\r", + " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\");\r", + " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\");\r", + " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\");\r", + " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", + " const isMachineCategorised = false\r", + " const instanceCount = 1\r", + " const isImmediate = false\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " function getFinalResponseText(responseText) {\r", + " return responseText\r", + " .replace(\r", + " \"{{thanks}}\",\r", + " isImmediate ? THANKS_IMMEDIATE : THANKS_DELAYED\r", + " )\r", + " .replace(\r", + " \"{{matched}}\",\r", + " instanceCount >= 5\r", + " ? `In fact, others have already sent this message in ${instanceCount} times. `\r", + " : \"\"\r", + " )\r", + " .replace(\r", + " \"{{methodology}}\",\r", + " isMachineCategorised\r", + " ? METHODOLOGY_AUTO\r", + " : METHODOLOGY_HUMAN\r", + " )\r", + " .replace(\"{{results}}\", isImmediate ? \"\" : VOTE_RESULTS_SUFFIX)\r", + " }\r", + " const spamResponse = getFinalResponseText(SPAM)\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": spamResponse\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `votingResults_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"See voting results\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "SATISFACTION_SURVEY", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"SATISFACTION_SURVEY sent to user1\", function () {\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", + " const instanceId = pm.variables.get(\"spamInstanceId\")\r", + " const SATISFACTION_SURVEY = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.SATISFACTION_SURVEY\");\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": SATISFACTION_SURVEY\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Tap to respond\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `satisfactionSurvey_10_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"10\",\r", + " \"description\": \"Extremely likely 🤩\"\r", + " },\r", + " {\r", + " \"id\": `satisfactionSurvey_9_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"9\"\r", + " },\r", + " {\r", + " \"id\": `satisfactionSurvey_8_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"8\"\r", + " },\r", + " {\r", + " \"id\": `satisfactionSurvey_7_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"7\"\r", + " },\r", + " {\r", + " \"id\": `satisfactionSurvey_6_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"6\"\r", + " },\r", + " {\r", + " \"id\": `satisfactionSurvey_5_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"5\"\r", + " },\r", + " {\r", + " \"id\": `satisfactionSurvey_4_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"4\"\r", + " },\r", + " {\r", + " \"id\": `satisfactionSurvey_3_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"3\"\r", + " },\r", + " {\r", + " \"id\": `satisfactionSurvey_2_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"2\"\r", + " },\r", + " {\r", + " \"id\": `satisfactionSurvey_1_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"1\",\r", + " \"description\": \"Not at all likely 😥\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + "\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Votes 10", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"satisfactionSurvey_10_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"10\",\r\n \"description\": \"Unsolicited spam, such as marketing messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "SATISFACTION_SURVEY_THANKS", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"ALREADY_REPLIED sent to user 1\", function () {\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const SATISFACTION_SURVEY_THANKS = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.SATISFACTION_SURVEY_THANKS\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": SATISFACTION_SURVEY_THANKS,\r", + " \"preview_url\": true\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Check instance updated", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that instance data updated correctly\", function () {\r", + "\r", + " var jsonData = pm.response.json();\r", + " const isSatisfactionSurveySent = jsonData.fields.isSatisfactionSurveySent.booleanValue\r", + " const satisfactionScore = parseInt(jsonData.fields.satisfactionScore.integerValue) //for some reason integerValue returns string\r", + "\r", + " pm.expect(isSatisfactionSurveySent).to.be.true;\r", + " pm.expect(satisfactionScore).to.equal(10);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{spamMessageId}}/instances/{{spamInstanceId}}", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "messages", + "{{spamMessageId}}", + "instances", + "{{spamInstanceId}}" + ] + } + }, + "response": [] + }, + { + "name": "Press button to get interim update", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 17\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "\r", + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{{{whatsapp_id_17}}}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "ALREADY_REPLIED", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"ALREADY_REPLIED sent to user 1\", function () {\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const ALREADY_REPLIED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.ALREADY_REPLIED\");\r", + " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": ALREADY_REPLIED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "005e_Stats_Message", + "item": [ + { + "name": "Press button to see stats", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 18\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "\r", + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_18}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"votingResults_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"See voting results\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "STATS_TEMPLATE", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"STATS_TEMPLATE sent to user 1\", function () {\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", + " //we not using the template for this, its hardcoded.\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": \"66.67% of our CheckMates thought this was *spam*. 33.33% thought this was *legitimate*.\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + } + ] + }, + { + "name": "006_Info_Machine_Human", + "item": [ + { + "name": "006a_User_Send_First_Vote", + "item": [ + { + "name": "Send WhatsApp message (15 Chars)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 19\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "\r", + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_19}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is an info message that will be voted on\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (MESSAGE_NOT_YET_ASSESSED)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_19\")\r", + " const MESSAGE_NOT_YET_ASSESSED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MESSAGE_NOT_YET_ASSESSED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": MESSAGE_NOT_YET_ASSESSED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 2000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Get first checker message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", + " const CHECKER_NAME = \"CHECKER_NAME\"\r", + " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBER,\r", + " \"type\": \"template\",\r", + " \"template\": {\r", + " \"name\": \"new_message_received\",\r", + " \"language\": {\r", + " \"policy\": \"deterministic\",\r", + " \"code\": \"en\"\r", + " },\r", + " \"components\": [\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 0,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 1,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"body\",\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"text\",\r", + " \"text\": CHECKER_NAME\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"factChecker\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " //check name in list\r", + " const name = jsonData.body.template.components[2].parameters[0].text\r", + " pm.expect(CHECKER_NAMES).to.include(name);\r", + " //check number in list\r", + " const number = jsonData.body.to\r", + " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", + " const infoVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", + " const [, messageId, , voteRequestId] = infoVoteRequestPath.split(\"/\")\r", + " pm.collectionVariables.set(`infoVoteRequestPath_${name}`, infoVoteRequestPath);\r", + " pm.collectionVariables.set(`infoMessageId`, messageId);\r", + " pm.collectionVariables.set(`infoVoteRequestId_${name}`, voteRequestId);\r", + " // Replace dynamically created IDs\r", + " jsonData.body.to = CHECKER_PHONE_NUMBER\r", + " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Get second checker message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", + " const CHECKER_NAME = \"CHECKER_NAME\"\r", + " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBER,\r", + " \"type\": \"template\",\r", + " \"template\": {\r", + " \"name\": \"new_message_received\",\r", + " \"language\": {\r", + " \"policy\": \"deterministic\",\r", + " \"code\": \"en\"\r", + " },\r", + " \"components\": [\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 0,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 1,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"body\",\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"text\",\r", + " \"text\": CHECKER_NAME\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"factChecker\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " //check name in list\r", + " const name = jsonData.body.template.components[2].parameters[0].text\r", + " pm.expect(CHECKER_NAMES).to.include(name);\r", + " //check number in list\r", + " const number = jsonData.body.to\r", + " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", + " const infoVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", + " const [, messageId, , voteRequestId] = infoVoteRequestPath.split(\"/\")\r", + " pm.collectionVariables.set(`infoVoteRequestPath_${name}`, infoVoteRequestPath);\r", + " pm.collectionVariables.set(`infoVoteRequestId_${name}`, voteRequestId);\r", + " // Replace dynamically created IDs\r", + " jsonData.body.to = CHECKER_PHONE_NUMBER\r", + " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Get third checker message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", + " const CHECKER_NAME = \"CHECKER_NAME\"\r", + " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBER,\r", + " \"type\": \"template\",\r", + " \"template\": {\r", + " \"name\": \"new_message_received\",\r", + " \"language\": {\r", + " \"policy\": \"deterministic\",\r", + " \"code\": \"en\"\r", + " },\r", + " \"components\": [\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 0,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 1,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"body\",\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"text\",\r", + " \"text\": CHECKER_NAME\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"factChecker\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " //check name in list\r", + " const name = jsonData.body.template.components[2].parameters[0].text\r", + " pm.expect(CHECKER_NAMES).to.include(name);\r", + " //check number in list\r", + " const number = jsonData.body.to\r", + " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", + " const infoVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", + " const [, messageId, , voteRequestId] = infoVoteRequestPath.split(\"/\")\r", + " pm.collectionVariables.set(`infoVoteRequestPath_${name}`, infoVoteRequestPath);\r", + " pm.collectionVariables.set(`infoVoteRequestId_${name}`, voteRequestId);\r", + " // Replace dynamically created IDs\r", + " jsonData.body.to = CHECKER_PHONE_NUMBER\r", + " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "First checker clicks yes", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{infoVoteRequestPath_CHECKER1}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Message to Check Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Message to check sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": \"This is an info message that will be voted on\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\"\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "FACTCHECK_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const FACTCHECK_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.FACTCHECK_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": FACTCHECK_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Vote here\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_0`,\r", + " \"title\": \"0\",\r", + " \"description\": \"Totally false\"\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_1`,\r", + " \"title\": \"1\",\r", + " }, \r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_2`,\r", + " \"title\": \"2\",\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_3`,\r", + " \"title\": \"3\",\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_4`,\r", + " \"title\": \"4\",\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_5`,\r", + " \"title\": \"5\",\r", + " \"description\": \"Totally true\"\r", + " },\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "First checker selects \"1\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"vote_{{infoMessageId}}_{{infoVoteRequestId_CHECKER1}}_1\",\r\n \"title\": \"1\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "RESPONSE_RECORDED", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": RESPONSE_RECORDED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 2000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "NO_OUTSTANDING", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": NO_OUTSTANDING,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Get Instance ID", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that there is 1 instance\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData?.documents?.length).to.eql(1);\r", + " var fullName = jsonData.documents[0].name;\r", + " var splitName = fullName.split(\"/\");\r", + " var docId = splitName[splitName.length - 1];\r", + " pm.collectionVariables.set(\"infoInstanceId\", docId);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{infoMessageId}}/instances", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "messages", + "{{infoMessageId}}", + "instances" + ] + } + }, + "response": [] + }, + { + "name": "Send /interim command", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 20\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_20}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"/interim\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ],\r\n \"severity\": \"INFO\",\r\n \"message\": \"\"\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_19\")\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const instanceId = pm.variables.get(\"infoInstanceId\")\r", + " const INTERIM_PROMPT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": INTERIM_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get interim update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Press button to get interim update", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 21\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_21}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{infoMessageId}}/instances/{{infoInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_TEMPLATE_WITH_FEEDBACK", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_TEMPLATE sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const INTERIM_TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE\");\r", + " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK\")\r", + " const instanceId = pm.variables.get(\"infoInstanceId\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_19\")\r", + " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"is untrue❌\").replace(\"{{info_placeholder}}\",\", with an average score of 1.00 on a scale of 0-5 (5 = completely true)\").replace(\"{{get_feedback}}\",INTERIM_FEEDBACK)\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": interimResponse\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_yes`,\r", + " \"title\": \"Yes, it's useful\"\r", + " }\r", + " },\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_no`,\r", + " \"title\": \"No, it's not\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " \r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Check interim values", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData?.fields?.isMeaningfulInterimReplySent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimReplySent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimPromptSent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimUseful?.nullValue).to.equal(null);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{infoMessageId}}/instances/{{infoInstanceId}}", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "messages", + "{{infoMessageId}}", + "instances", + "{{infoInstanceId}}" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "006b_2nd_Voter_1", + "item": [ + { + "name": "Second checker clicks yes", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{infoVoteRequestPath_CHECKER2}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Message to Check Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Message to check sent to checker 2\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": \"This is an info message that will be voted on\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"messaging_product\": \"whatsapp\"\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "FACTCHECK_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER2\").split(\"/\")\r", + " const FACTCHECK_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.FACTCHECK_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": FACTCHECK_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Vote here\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_0`,\r", + " \"title\": \"0\",\r", + " \"description\": \"Totally false\"\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_1`,\r", + " \"title\": \"1\",\r", + " }, \r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_2`,\r", + " \"title\": \"2\",\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_3`,\r", + " \"title\": \"3\",\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_4`,\r", + " \"title\": \"4\",\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_5`,\r", + " \"title\": \"5\",\r", + " \"description\": \"Totally true\"\r", + " },\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Second checker selects \"1\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"vote_{{infoMessageId}}_{{infoVoteRequestId_CHECKER2}}_1\",\r\n \"title\": \"1\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "RESPONSE_RECORDED", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": RESPONSE_RECORDED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 2000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "NO_OUTSTANDING", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": NO_OUTSTANDING,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "UNTRUE", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"UNTRUE final reply sent to checker 1\", function () {\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER3\").split(\"/\")\r", + " const instanceId = pm.variables.get(\"infoInstanceId\")\r", + " const UNTRUE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.UNTRUE\");\r", + " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\");\r", + " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\");\r", + " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\");\r", + " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\");\r", + " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\");\r", + " const wamid = pm.variables.get(\"whatsapp_id_19\")\r", + " const isMachineCategorised = false\r", + " const instanceCount = 1\r", + " const isImmediate = false\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " function getFinalResponseText(responseText) {\r", + " return responseText\r", + " .replace(\r", + " \"{{thanks}}\",\r", + " isImmediate ? THANKS_IMMEDIATE : THANKS_DELAYED\r", + " )\r", + " .replace(\r", + " \"{{matched}}\",\r", + " instanceCount >= 5\r", + " ? `In fact, others have already sent this message in ${instanceCount} times. `\r", + " : \"\"\r", + " )\r", + " .replace(\r", + " \"{{methodology}}\",\r", + " isMachineCategorised\r", + " ? METHODOLOGY_AUTO\r", + " : METHODOLOGY_HUMAN\r", + " )\r", + " .replace(\"{{results}}\", isImmediate ? \"\" : VOTE_RESULTS_SUFFIX)\r", + " }\r", + " const response = getFinalResponseText(UNTRUE)\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": response\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `votingResults_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"See voting results\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "006c_3rd_Voter_5", + "item": [ + { + "name": "Third checker clicks yes", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{infoVoteRequestPath_CHECKER3}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Message to Check Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Message to check sent to checker 3\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": \"This is an info message that will be voted on\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"messaging_product\": \"whatsapp\"\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "FACTCHECK_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER3\").split(\"/\")\r", + " const FACTCHECK_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.FACTCHECK_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": FACTCHECK_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Vote here\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_0`,\r", + " \"title\": \"0\",\r", + " \"description\": \"Totally false\"\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_1`,\r", + " \"title\": \"1\",\r", + " }, \r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_2`,\r", + " \"title\": \"2\",\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_3`,\r", + " \"title\": \"3\",\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_4`,\r", + " \"title\": \"4\",\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_5`,\r", + " \"title\": \"5\",\r", + " \"description\": \"Totally true\"\r", + " },\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Third checker selects \"5\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"vote_{{infoMessageId}}_{{infoVoteRequestId_CHECKER3}}_5\",\r\n \"title\": \"5\",\r\n \"description\": \"Totally true\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "RESPONSE_RECORDED", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": RESPONSE_RECORDED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 2000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "NO_OUTSTANDING", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": NO_OUTSTANDING,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "006d_Stats_Message", + "item": [ + { + "name": "Press button to see stats", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 22\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_22}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"votingResults_messages/{{infoMessageId}}/instances/{{infoInstanceId}}\",\r\n \"title\": \"See voting results\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "STATS_TEMPLATE", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"STATS_TEMPLATE sent to user 1\", function () {\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_19\")\r", + " //we not using the template for this, its hardcoded.\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": \"100.00% of our CheckMates collectively thought this was *misleading*, with an average score of 2.33 on a scale of 0-5 (5 = completely true).\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + } + ] + }, + { + "name": "007_Unsure_Human", + "item": [ + { + "name": "007a_User_Send_First_Vote", + "item": [ + { + "name": "Send WhatsApp message (15 Chars)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 23\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_23}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is an unsure message that will be voted on\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (MESSAGE_NOT_YET_ASSESSED)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_23\")\r", + " const MESSAGE_NOT_YET_ASSESSED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MESSAGE_NOT_YET_ASSESSED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": MESSAGE_NOT_YET_ASSESSED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 2000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Get first checker message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", + " const CHECKER_NAME = \"CHECKER_NAME\"\r", + " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBER,\r", + " \"type\": \"template\",\r", + " \"template\": {\r", + " \"name\": \"new_message_received\",\r", + " \"language\": {\r", + " \"policy\": \"deterministic\",\r", + " \"code\": \"en\"\r", + " },\r", + " \"components\": [\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 0,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 1,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"body\",\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"text\",\r", + " \"text\": CHECKER_NAME\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"factChecker\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " //check name in list\r", + " const name = jsonData.body.template.components[2].parameters[0].text\r", + " pm.expect(CHECKER_NAMES).to.include(name);\r", + " //check number in list\r", + " const number = jsonData.body.to\r", + " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", + " const unsureVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", + " const [, messageId, , voteRequestId] = unsureVoteRequestPath.split(\"/\")\r", + " pm.collectionVariables.set(`unsureVoteRequestPath_${name}`, unsureVoteRequestPath);\r", + " pm.collectionVariables.set(`unsureMessageId`, messageId);\r", + " pm.collectionVariables.set(`unsureVoteRequestId_${name}`, voteRequestId);\r", + " // Replace dynamically created IDs\r", + " jsonData.body.to = CHECKER_PHONE_NUMBER\r", + " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Get second checker message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", + " const CHECKER_NAME = \"CHECKER_NAME\"\r", + " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBER,\r", + " \"type\": \"template\",\r", + " \"template\": {\r", + " \"name\": \"new_message_received\",\r", + " \"language\": {\r", + " \"policy\": \"deterministic\",\r", + " \"code\": \"en\"\r", + " },\r", + " \"components\": [\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 0,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 1,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"body\",\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"text\",\r", + " \"text\": CHECKER_NAME\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"factChecker\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " //check name in list\r", + " const name = jsonData.body.template.components[2].parameters[0].text\r", + " pm.expect(CHECKER_NAMES).to.include(name);\r", + " //check number in list\r", + " const number = jsonData.body.to\r", + " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", + " const unsureVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", + " const [, messageId, , voteRequestId] = unsureVoteRequestPath.split(\"/\")\r", + " pm.collectionVariables.set(`unsureVoteRequestPath_${name}`, unsureVoteRequestPath);\r", + " pm.collectionVariables.set(`unsureVoteRequestId_${name}`, voteRequestId);\r", + " // Replace dynamically created IDs\r", + " jsonData.body.to = CHECKER_PHONE_NUMBER\r", + " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Get third checker message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", + " const CHECKER_NAME = \"CHECKER_NAME\"\r", + " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBER,\r", + " \"type\": \"template\",\r", + " \"template\": {\r", + " \"name\": \"new_message_received\",\r", + " \"language\": {\r", + " \"policy\": \"deterministic\",\r", + " \"code\": \"en\"\r", + " },\r", + " \"components\": [\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 0,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 1,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"body\",\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"text\",\r", + " \"text\": CHECKER_NAME\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"factChecker\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " //check name in list\r", + " const name = jsonData.body.template.components[2].parameters[0].text\r", + " pm.expect(CHECKER_NAMES).to.include(name);\r", + " //check number in list\r", + " const number = jsonData.body.to\r", + " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", + " const unsureVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", + " const [, messageId, , voteRequestId] = unsureVoteRequestPath.split(\"/\")\r", + " pm.collectionVariables.set(`unsureVoteRequestPath_${name}`, unsureVoteRequestPath);\r", + " pm.collectionVariables.set(`unsureVoteRequestId_${name}`, voteRequestId);\r", + " // Replace dynamically created IDs\r", + " jsonData.body.to = CHECKER_PHONE_NUMBER\r", + " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "First checker clicks yes", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{unsureVoteRequestPath_CHECKER1}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Message to Check Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Message to check sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": \"This is an unsure message that will be voted on\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\"\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "L1_ASSESSMENT_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const L1_ASSESSMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L1_ASSESSMENT_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": L1_ASSESSMENT_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Make Selection\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_scam`,\r", + " \"title\": \"Scam\",\r", + " \"description\": \"Intended to obtain money/personal information via deception\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_illicit`,\r", + " \"title\": \"Illicit\",\r", + " \"description\": \"Other potential illicit activity, e.g. moneylending/prostitution\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_info`,\r", + " \"title\": \"News/Information/Opinion\",\r", + " \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_others`,\r", + " \"title\": \"It's something else\",\r", + " \"description\": \"Messages that don't fall into the other categories\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + "\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "First checker selects \"It's something else\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"categorize_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER1}}_others\",\r\n \"title\": \"It's something else\",\r\n \"description\": \"Messages that don't fall into the other categories\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "HOLD_FOR_L2_CATEGORISATION", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"HOLD_FOR_L2_CATEGORISATION message sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const HOLD_FOR_L2_CATEGORISATION = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_L2_CATEGORISATION\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": HOLD_FOR_L2_CATEGORISATION,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 2000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "L2_CATEGORISATION_MENU", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L2_OTHERS_ASSESSEMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const L2_OTHERS_ASSESSEMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L2_OTHERS_ASSESSEMENT_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": L2_OTHERS_ASSESSEMENT_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Make Selection\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_spam`,\r", + " \"title\": \"Spam\",\r", + " \"description\": \"Unsolicited spam, such as marketing messages\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_legitimate`,\r", + " \"title\": \"Legitimate\",\r", + " \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_irrelevant`,\r", + " \"title\": \"Trivial\",\r", + " \"description\": \"Trivial/banal messages with nothing to assess\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_unsure`,\r", + " \"title\": \"I'm Unsure\",\r", + " \"description\": \"Do try your best to categorize! But if really unsure, select this\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "First checker selects \"unsure\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"others_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER1}}_unsure\",\r\n \"title\": \"I'm Unsure\",\r\n \"description\": \"Do try your best to categorize! But if really unsure, select this\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "RESPONSE_RECORDED", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": RESPONSE_RECORDED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 2000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "NO_OUTSTANDING", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": NO_OUTSTANDING,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "007b_Interim_Message", + "item": [ + { + "name": "Send /interim command", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 24\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_24}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"/interim\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ],\r\n \"severity\": \"INFO\",\r\n \"message\": \"\"\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Get Instance ID", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that there is 1 instance\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData?.documents?.length).to.eql(1);\r", + " var fullName = jsonData.documents[0].name;\r", + " var splitName = fullName.split(\"/\");\r", + " var docId = splitName[splitName.length - 1];\r", + " pm.collectionVariables.set(\"unsureInstanceId\", docId);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{unsureMessageId}}/instances", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "messages", + "{{unsureMessageId}}", + "instances" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_23\")\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", + " const INTERIM_PROMPT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": INTERIM_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get interim update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Press button to get interim update", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 25\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_25}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_TEMPLATE_UNSURE", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_TEMPLATE_UNSURE sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const wamid = pm.variables.get(\"whatsapp_id_23\")\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const INTERIM_TEMPLATE_UNSURE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE_UNSURE\");\r", + " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", + " const interimResponse = INTERIM_TEMPLATE_UNSURE.replace(\"{{%voted}}\", \"33.33\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": interimResponse\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get another update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " \r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Check interim values", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData?.fields?.isMeaningfulInterimReplySent?.booleanValue).to.equal(false);\r", + " pm.expect(jsonData?.fields?.isInterimReplySent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimPromptSent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimUseful?.booleanValue).to.equal(false);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "messages", + "{{unsureMessageId}}", + "instances", + "{{unsureInstanceId}}" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "007c_1st Voter Change To Legitimate", + "item": [ + { + "name": "First checker selects \"legitimate\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"others_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER1}}_legitimate\",\r\n \"title\": \"Legitimate\",\r\n \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "RESPONSE_RECORDED", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": RESPONSE_RECORDED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 2000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "NO_OUTSTANDING", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": NO_OUTSTANDING,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Press button to get interim update", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 26\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_26}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_TEMPLATE_WITH_FEEDBACK", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_TEMPLATE sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_23\")\r", + " const INTERIM_TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE\");\r", + " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK\")\r", + " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", + " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"is legitimate✅\").replace(\"{{info_placeholder}}\",\"\").replace(\"{{get_feedback}}\",INTERIM_FEEDBACK)\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": interimResponse\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_yes`,\r", + " \"title\": \"Yes, it's useful\"\r", + " }\r", + " },\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_no`,\r", + " \"title\": \"No, it's not\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " \r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Check interim values", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData?.fields?.isMeaningfulInterimReplySent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimReplySent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimPromptSent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimUseful?.booleanValue).to.equal(false);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "messages", + "{{unsureMessageId}}", + "instances", + "{{unsureInstanceId}}" + ] + } + }, + "response": [] + }, + { + "name": "Press button \"Yes it's useful\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 27\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_27}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"feedbackInterim_messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}_yes\",\r\n \"title\": \"Yes, it's useful\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_USEFUL", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_USEFUL sent to user\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_23\")\r", + " const INTERIM_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_USEFUL\");\r", + " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": INTERIM_USEFUL\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get another update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Check interim values", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData?.fields?.isMeaningfulInterimReplySent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimReplySent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimPromptSent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimUseful?.booleanValue).to.equal(true);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "messages", + "{{unsureMessageId}}", + "instances", + "{{unsureInstanceId}}" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "007d_2nd Voter Info \"3\"", + "item": [ + { + "name": "Second checker clicks yes", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{unsureVoteRequestPath_CHECKER2}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Message to Check Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Message to check sent to checker 2\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": \"This is an unsure message that will be voted on\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"messaging_product\": \"whatsapp\"\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "L1_ASSESSMENT_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER2\").split(\"/\")\r", + " const L1_ASSESSMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L1_ASSESSMENT_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": L1_ASSESSMENT_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Make Selection\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_scam`,\r", + " \"title\": \"Scam\",\r", + " \"description\": \"Intended to obtain money/personal information via deception\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_illicit`,\r", + " \"title\": \"Illicit\",\r", + " \"description\": \"Other potential illicit activity, e.g. moneylending/prostitution\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_info`,\r", + " \"title\": \"News/Information/Opinion\",\r", + " \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_others`,\r", + " \"title\": \"It's something else\",\r", + " \"description\": \"Messages that don't fall into the other categories\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + "\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Second checker selects \"info\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"categorize_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER2}}_info\",\r\n \"title\": \"News/Information/Opinion\",\r\n \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "HOLD_FOR_NEXT_POLL", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"HOLD_FOR_NEXT_POLL message sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const HOLD_FOR_NEXT_POLL = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_NEXT_POLL\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": HOLD_FOR_NEXT_POLL,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 2000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "FACTCHECK_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER2\").split(\"/\")\r", + " const FACTCHECK_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.FACTCHECK_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": FACTCHECK_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Vote here\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_0`,\r", + " \"title\": \"0\",\r", + " \"description\": \"Totally false\"\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_1`,\r", + " \"title\": \"1\",\r", + " }, \r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_2`,\r", + " \"title\": \"2\",\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_3`,\r", + " \"title\": \"3\",\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_4`,\r", + " \"title\": \"4\",\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_5`,\r", + " \"title\": \"5\",\r", + " \"description\": \"Totally true\"\r", + " },\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Second checker selects \"3\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"vote_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER2}}_3\",\r\n \"title\": \"3\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "RESPONSE_RECORDED", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": RESPONSE_RECORDED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 2000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "NO_OUTSTANDING", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": NO_OUTSTANDING,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Press button to get interim update", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 28\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_28}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_TEMPLATE_UNSURE", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_TEMPLATE_UNSURE sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_23\")\r", + " const INTERIM_TEMPLATE_UNSURE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE_UNSURE\");\r", + " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", + " const interimResponse = INTERIM_TEMPLATE_UNSURE.replace(\"{{%voted}}\", \"66.67\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": interimResponse\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get another update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " \r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "007e_3rd Voter Spam", + "item": [ + { + "name": "Third checker clicks yes", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{unsureVoteRequestPath_CHECKER3}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Message to Check Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Message to check sent to checker 2\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": \"This is an unsure message that will be voted on\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"messaging_product\": \"whatsapp\"\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "L1_ASSESSMENT_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER3\").split(\"/\")\r", + " const L1_ASSESSMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L1_ASSESSMENT_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": L1_ASSESSMENT_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Make Selection\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_scam`,\r", + " \"title\": \"Scam\",\r", + " \"description\": \"Intended to obtain money/personal information via deception\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_illicit`,\r", + " \"title\": \"Illicit\",\r", + " \"description\": \"Other potential illicit activity, e.g. moneylending/prostitution\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_info`,\r", + " \"title\": \"News/Information/Opinion\",\r", + " \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_others`,\r", + " \"title\": \"It's something else\",\r", + " \"description\": \"Messages that don't fall into the other categories\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " //console.log(JSON.stringify(expected,null,2))\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Third checker selects \"It's something else\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"categorize_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER3}}_others\",\r\n \"title\": \"It's something else\",\r\n \"description\": \"Messages that don't fall into the other categories\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "HOLD_FOR_L2_CATEGORISATION", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"HOLD_FOR_L2_CATEGORISATION message sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const HOLD_FOR_L2_CATEGORISATION = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_L2_CATEGORISATION\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": HOLD_FOR_L2_CATEGORISATION,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 2000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "L2_CATEGORISATION_MENU", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L2_OTHERS_ASSESSEMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER3\").split(\"/\")\r", + " const L2_OTHERS_ASSESSEMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L2_OTHERS_ASSESSEMENT_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": L2_OTHERS_ASSESSEMENT_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Make Selection\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_spam`,\r", + " \"title\": \"Spam\",\r", + " \"description\": \"Unsolicited spam, such as marketing messages\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_legitimate`,\r", + " \"title\": \"Legitimate\",\r", + " \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_irrelevant`,\r", + " \"title\": \"Trivial\",\r", + " \"description\": \"Trivial/banal messages with nothing to assess\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_unsure`,\r", + " \"title\": \"I'm Unsure\",\r", + " \"description\": \"Do try your best to categorize! But if really unsure, select this\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Third checker selects \"spam\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"others_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER3}}_spam\",\r\n \"title\": \"Spam\",\r\n \"description\": \"Unsolicited spam, such as marketing messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "RESPONSE_RECORDED", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"RESPONSE_RECORDED sent to checker 3\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": RESPONSE_RECORDED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 2000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "NO_OUTSTANDING", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"NO_OUTSTANDING sent to checker 3\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": NO_OUTSTANDING,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "UNSURE", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"UNSURE final reply sent to user 1\", function () {\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER3\").split(\"/\")\r", + " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", + " const UNSURE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.UNSURE\");\r", + " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\");\r", + " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\");\r", + " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\");\r", + " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\");\r", + " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\");\r", + " const wamid = pm.variables.get(\"whatsapp_id_23\")\r", + " const isMachineCategorised = false\r", + " const instanceCount = 1\r", + " const isImmediate = false\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " function getFinalResponseText(responseText) {\r", + " return responseText\r", + " .replace(\r", + " \"{{thanks}}\",\r", + " isImmediate ? THANKS_IMMEDIATE : THANKS_DELAYED\r", + " )\r", + " .replace(\r", + " \"{{matched}}\",\r", + " instanceCount >= 5\r", + " ? `In fact, others have already sent this message in ${instanceCount} times. `\r", + " : \"\"\r", + " )\r", + " .replace(\r", + " \"{{methodology}}\",\r", + " isMachineCategorised\r", + " ? METHODOLOGY_AUTO\r", + " : METHODOLOGY_HUMAN\r", + " )\r", + " .replace(\"{{results}}\", isImmediate ? \"\" : VOTE_RESULTS_SUFFIX)\r", + " }\r", + " const response = getFinalResponseText(UNSURE)\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": response\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `votingResults_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"See voting results\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "007f_Stats_Message", + "item": [ + { + "name": "Press button to see stats", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 29\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_29}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"votingResults_messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}\",\r\n \"title\": \"See voting results\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "STATS_TEMPLATE", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"STATS_TEMPLATE sent to user 1\", function () {\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_23\")\r", + " //we not using the template for this, its hardcoded.\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": \"33.33% of our CheckMates thought this was *spam*. 33.33% collectively thought this was *misleading*, with an average score of 3.00 on a scale of 0-5 (5 = completely true).\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + } + ] + }, + { + "name": "008_Menu_Message", + "item": [ + { + "name": "Send WhatApp message (\"Menu\")", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 30\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_30}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"Menu\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (GENERIC_MENU)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const MENU = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU\");\r", + " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_PREFIX\");\r", + " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX)\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": MENU_TEXT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"View Menu\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": \"menu_check\",\r", + " \"title\": \"Check/Report\",\r", + " \"description\": \"Send in messages, images, or screenshots for checking!\"\r", + " },\r", + " {\r", + " \"id\": \"menu_referral\",\r", + " \"title\": \"Get Referral Link\",\r", + " \"description\": \"Get referral link to forward to others\"\r", + " },\r", + " {\r", + " \"id\": \"menu_help\",\r", + " \"title\": \"Get Help\",\r", + " \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r", + " },\r", + " {\r", + " \"id\": \"menu_about\",\r", + " \"title\": \"About CheckMate\",\r", + " \"description\": \"Learn more about CheckMate and the team behind it\"\r", + " },\r", + " {\r", + " \"id\": \"menu_feedback\",\r", + " \"title\": \"Send Feedback\",\r", + " \"description\": \"Send us feedback on anything to do with CheckMate\"\r", + " },\r", + " {\r", + " \"id\": \"menu_contact\",\r", + " \"title\": \"Get Contact\",\r", + " \"description\": \"Get CheckMate's contact to add to your contact list\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Make Menu Selection (\"Check/Report\")", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 31\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_31}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_check\",\r\n \"title\": \"Check/Report\",\r\n \"description\": \"Send in messages, images, or screenshots for checking!\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (PROCEED_TO_SEND)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.PROCEED_TO_SEND\");\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": BODY_TEXT,\r", + " \"preview_url\": true\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Make Menu Selection (\"Get Help\")", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 32\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_32}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_help\",\r\n \"title\": \"Get Help\",\r\n \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (HOW_TO)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.HOW_TO\");\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": BODY_TEXT,\r", + " \"preview_url\": true\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Make Menu Selection (\"About CheckMate\")", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 33\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_33}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_about\",\r\n \"title\": \"About CheckMate\",\r\n \"description\": \"Learn more about CheckMate and the team behind it\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (LEARN_MORE)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.LEARN_MORE\");\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": BODY_TEXT,\r", + " \"preview_url\": true\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Make Menu Selection (\"Send Feedback\")", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 34\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_34}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_feedback\",\r\n \"title\": \"Send Feedback\",\r\n \"description\": \"Send us feedback on anything to do with CheckMate\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (FEEDBACK)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.FEEDBACK\");\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": BODY_TEXT,\r", + " \"preview_url\": true\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Make Menu Selection (\"Get Contact\")", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 35\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_35}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_contact\",\r\n \"title\": \"Get Contact\",\r\n \"description\": \"Get CheckMates contact to add to your contact list\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (contact type)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"contacts\",\r", + " \"contacts\": [\r", + " {\r", + " \"name\": {\r", + " \"formatted_name\": \"CheckMate\",\r", + " \"suffix\": \"CheckMate\"\r", + " },\r", + " \"urls\": [\r", + " {\r", + " \"url\": \"https://checkmate.sg\"\r", + " }\r", + " ],\r", + " \"phones\": [\r", + " {\r", + " \"phone\": \"+1 555-093-3685\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (CONTACT)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.CONTACT\");\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": BODY_TEXT,\r", + " \"preview_url\": true\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Make Menu Selection (\"Referral\")", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 36\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_36}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_referral\",\r\n \"title\": \"Get Referral Link\",\r\n \"description\": \"Get referral link to forward to others\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (REFERRAL)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL\");\r", + " const link = pm.variables.get(\"referralLink_USER1\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const referralMessage = BODY_TEXT.replace(\"{{link}}\", link)\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": referralMessage,\r", + " \"preview_url\": true\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "009_Scam_Autocategorise", + "item": [ + { + "name": "User sends scam message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 37\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_37}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is a scam message\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (SCAM, IMMEDIATE, NOT MATCHED, AUTO)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"scam immediate autocategorised no matched response\", function () {\r", + " const TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.SCAM\");\r", + " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\")\r", + " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\")\r", + " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\")\r", + " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\")\r", + " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_37\")\r", + " const BODY_TEXT = TEMPLATE.replace(\"{{thanks}}\",THANKS_IMMEDIATE).replace(\"{{methodology}}\",METHODOLOGY_AUTO).replace(\"{{matched}}\",\"\").replace(\"{{results}}\",\"\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": BODY_TEXT\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": \"ID\",\r", + " \"title\": \"Yes\"\r", + " }\r", + " },\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": \"ID\",\r", + " \"title\": \"No\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + "\r", + " var jsonData = pm.response.json();\r", + "\r", + " let reply_id_yes = jsonData.body.interactive.action.buttons[0].reply.id;\r", + " let reply_id_no = jsonData.body.interactive.action.buttons[1].reply.id;\r", + " let [, scamInstancePath , ] = reply_id_yes.split(\"_\")\r", + " \r", + " // check if the id matches the pattern \"menu_dispute_messages/*/instances/*\"\r", + " pm.expect(reply_id_yes).to.match(/scamshieldConsent_messages\\/\\w+\\/instances\\/\\w+_consent/);\r", + " pm.expect(reply_id_no).to.match(/scamshieldConsent_messages\\/\\w+\\/instances\\/\\w+_decline/);\r", + " pm.collectionVariables.set(\"scamInstancePath\", scamInstancePath);\r", + "\r", + " jsonData.body.interactive.action.buttons[0].reply.id = \"ID\"\r", + " jsonData.body.interactive.action.buttons[1].reply.id = \"ID\"\r", + "\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "010_Spam_Autocategorise", + "item": [ + { + "name": "User sends spam message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 38\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_38}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is a spam message\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (SPAM, IMMEDIATE, NOT MATCHED, AUTO)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"spam immediate autocategorised no matched response\", function () {\r", + " const TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.SPAM\");\r", + " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\")\r", + " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\")\r", + " const BODY_TEXT = TEMPLATE.replace(\"{{thanks}}\",THANKS_IMMEDIATE).replace(\"{{methodology}}\",METHODOLOGY_AUTO).replace(\"{{matched}}\",\"\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_38\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": BODY_TEXT,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "011_Check_Steps_logging", + "item": [ + { + "name": "[DB CALL] Check steps", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that instance data updated correctly\", function () {\r", + "\r", + " var jsonData = pm.response.json();\r", + " const initialJourney = jsonData.fields.initialJourney.mapValue.fields\r", + " const actions = Object.values(initialJourney).map((obj) => obj.stringValue)\r", + " const expected = [\r", + " \"text_machine_irrelevant_length\",\r", + " \"text_machine_irrelevant_length\",\r", + " \"menu_dispute\",\r", + " \"text_machine_unsure\",\r", + " \"sendInterim\",\r", + " \"feedbackInterim_yes\",\r", + " \"feedbackInterim_no\",\r", + " \"sendInterim\",\r", + " \"sendInterim\",\r", + " \"satisfactionSurvey_10\",\r", + " \"sendInterim\",\r", + " \"votingResults\",\r", + " \"text_machine_info\",\r", + " \"sendInterim\",\r", + " \"votingResults\",\r", + " \"text_machine_unsure\",\r", + " \"sendInterim\",\r", + " \"sendInterim\",\r", + " \"feedbackInterim_yes\",\r", + " \"sendInterim\",\r", + " \"votingResults\",\r", + " \"text_menu\",\r", + " \"menu_check\",\r", + " \"menu_help\",\r", + " \"menu_about\",\r", + " \"menu_feedback\",\r", + " \"menu_contact\",\r", + " \"menu_referral\",\r", + " \"text_machine_scam\",\r", + " \"text_machine_spam\",\r", + " ]\r", + " pm.expect(actions).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/users/{{USER_1_NUMBER}}", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "users", + "{{USER_1_NUMBER}}" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "012_New_User_Referral", + "item": [ + { + "name": "Send WhatsApp message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 39\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_2_NAME}}\" }, \"wa_id\": \"{{USER_2_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_2_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_39}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"{{__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL_PREPOPULATED_PREFIX}} {{referralId_USER1}}\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (NEW_USER_MENU)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const MENU = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU\");\r", + " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_MENU_PREFIX\");\r", + " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX)\r", + " const USER_2_NUMBER = pm.variables.get(\"USER_2_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_2_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": MENU_TEXT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"View Menu\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": \"menu_check\",\r", + " \"title\": \"Check/Report\",\r", + " \"description\": \"Send in messages, images, or screenshots for checking!\"\r", + " },\r", + " {\r", + " \"id\": \"menu_referral\",\r", + " \"title\": \"Get Referral Link\",\r", + " \"description\": \"Get referral link to forward to others\"\r", + " },\r", + " {\r", + " \"id\": \"menu_help\",\r", + " \"title\": \"Get Help\",\r", + " \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r", + " },\r", + " {\r", + " \"id\": \"menu_about\",\r", + " \"title\": \"About CheckMate\",\r", + " \"description\": \"Learn more about CheckMate and the team behind it\"\r", + " },\r", + " {\r", + " \"id\": \"menu_feedback\",\r", + " \"title\": \"Send Feedback\",\r", + " \"description\": \"Send us feedback on anything to do with CheckMate\"\r", + " },\r", + " {\r", + " \"id\": \"menu_contact\",\r", + " \"title\": \"Get Contact\",\r", + " \"description\": \"Get CheckMate's contact to add to your contact list\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Check referral count", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that referral count is incremented to 1\", function () {\r", + "\r", + " var jsonData = pm.response.json();\r", + " const referralCount = jsonData.fields.referralCount.integerValue\r", + " pm.expect(parseInt(referralCount)).to.eql(1);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/users/{{USER_1_NUMBER}}", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "users", + "{{USER_1_NUMBER}}" + ] + } + }, + "response": [] + }, + { + "name": "Send 2nd referral message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 40\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_2_NAME}}\" }, \"wa_id\": \"{{USER_2_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_2_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_40}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"{{__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL_PREPOPULATED_PREFIX}} {{referralId_USER1}}\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (REFERRAL_INVALID)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"REFERRAL_INVALID response received\", function () {\r", + " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL_INVALID\");\r", + " const USER_2_NUMBER = pm.variables.get(\"USER_2_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_40\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": BODY_TEXT,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": USER_2_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " },\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "013_Duplicate_wamid", + "item": [ + { + "name": "[DB CALL] Get Count of Messages", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.collectionVariables.set(\"messageCount\", jsonData.documents.length)\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "messages" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Get Count of Info Instances", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData.documents.length).to.eql(1);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{infoMessageId}}/instances", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "messages", + "{{infoMessageId}}", + "instances" + ] + } + }, + "response": [] + }, + { + "name": "Send WhatsApp message (15 Chars)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 19\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "\r", + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_19}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is an info message that will be voted on\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Get Count of Messages", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", + " var jsonData = pm.response.json();\r", + " const count = pm.variables.get(\"messageCount\")\r", + " pm.expect(jsonData.documents.length).to.eql(count);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 2000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "messages" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Get Count of Info Instances", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.collectionVariables.set(\"messageCount\", jsonData.documents.length)\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "messages" + ] + } + }, + "response": [] + } + ] + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "type": "text/javascript", + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "type": "text/javascript", + "exec": [ + "" + ] + } + } + ], + "variable": [ + { + "key": "disputedMessagePath", + "value": "" + }, + { + "key": "disputedMessageTextListId", + "value": "" + }, + { + "key": "disputedInstancePath", + "value": "" + }, + { + "key": "scamInstancePath", + "value": "" + }, + { + "key": "spamVoteRequestPath", + "value": "" + }, + { + "key": "spamVoteRequestPath_CHECKER3", + "value": "" + }, + { + "key": "spamVoteRequestPath_CHECKER2", + "value": "" + }, + { + "key": "spamVoteRequestPath_CHECKER1", + "value": "" + }, + { + "key": "spamMessageId_CHECKER3", + "value": "" + }, + { + "key": "spamVoteRequestId_CHECKER3", + "value": "" + }, + { + "key": "spamMessageId_CHECKER2", + "value": "" + }, + { + "key": "spamVoteRequestId_CHECKER2", + "value": "" + }, + { + "key": "spamMessageId_CHECKER1", + "value": "" + }, + { + "key": "spamVoteRequestId_CHECKER1", + "value": "" + }, + { + "key": "spamMessageId", + "value": "" + }, + { + "key": "spamInstanceId", + "value": "" + }, + { + "key": "infoVoteRequestPath_CHECKER1", + "value": "" + }, + { + "key": "infoMessageId", + "value": "" + }, + { + "key": "infoVoteRequestId_CHECKER1", + "value": "" + }, + { + "key": "infoVoteRequestPath_CHECKER2", + "value": "" + }, + { + "key": "infoVoteRequestId_CHECKER2", + "value": "" + }, + { + "key": "infoVoteRequestPath_CHECKER3", + "value": "" + }, + { + "key": "infoVoteRequestId_CHECKER3", + "value": "" + }, + { + "key": "infoInstanceId", + "value": "" + }, + { + "key": "unsureVoteRequestPath_CHECKER3", + "value": "" + }, + { + "key": "unsureVoteRequestId_CHECKER3", + "value": "" + }, + { + "key": "unsureVoteRequestPath_CHECKER2", + "value": "" + }, + { + "key": "unsureVoteRequestId_CHECKER2", + "value": "" + }, + { + "key": "unsureInstanceId", + "value": "" + }, + { + "key": "unsureVoteRequestPath_CHECKER1", + "value": "" + }, + { + "key": "unsureMessageId", + "value": "" + }, + { + "key": "unsureVoteRequestId_CHECKER1", + "value": "" + }, + { + "key": "user_1_referralId", + "value": "" + }, + { + "key": "referralLink_USER1", + "value": "" + }, + { + "key": "referralId_USER1", + "value": "" + }, + { + "key": "messageCounter", + "value": "" + }, + { + "key": "whatsapp_id_1", + "value": "" + }, + { + "key": "whatsapp_id_2", + "value": "" + }, + { + "key": "whatsapp_id_3", + "value": "" + }, + { + "key": "whatsapp_id_4", + "value": "" + }, + { + "key": "whatsapp_id_5", + "value": "" + }, + { + "key": "whatsapp_id_6", + "value": "" + }, + { + "key": "whatsapp_id_7", + "value": "" + }, + { + "key": "whatsapp_id_8", + "value": "" + }, + { + "key": "whatsapp_id_9", + "value": "" + }, + { + "key": "whatsapp_id_10", + "value": "" + }, + { + "key": "whatsapp_id_11", + "value": "" + }, + { + "key": "whatsapp_id_12", + "value": "" + }, + { + "key": "whatsapp_id_13", + "value": "" + }, + { + "key": "whatsapp_id_14", + "value": "" + }, + { + "key": "whatsapp_id_15", + "value": "" + }, + { + "key": "whatsapp_id_39", + "value": "" + }, + { + "key": "whatsapp_id_40", + "value": "" + }, + { + "key": "whatsapp_id_16", + "value": "" + }, + { + "key": "whatsapp_id_17", + "value": "" + }, + { + "key": "whatsapp_id_18", + "value": "" + }, + { + "key": "whatsapp_id_19", + "value": "" + }, + { + "key": "whatsapp_id_20", + "value": "" + }, + { + "key": "whatsapp_id_21", + "value": "" + }, + { + "key": "whatsapp_id_22", + "value": "" + }, + { + "key": "whatsapp_id_23", + "value": "" + }, + { + "key": "whatsapp_id_24", + "value": "" + }, + { + "key": "whatsapp_id_25", + "value": "" + }, + { + "key": "whatsapp_id_26", + "value": "" + }, + { + "key": "whatsapp_id_27", + "value": "" + }, + { + "key": "whatsapp_id_28", + "value": "" + }, + { + "key": "whatsapp_id_29", + "value": "" + }, + { + "key": "whatsapp_id_30", + "value": "" + }, + { + "key": "whatsapp_id_31", + "value": "" + }, + { + "key": "whatsapp_id_32", + "value": "" + }, + { + "key": "whatsapp_id_33", + "value": "" + }, + { + "key": "whatsapp_id_34", + "value": "" + }, + { + "key": "whatsapp_id_35", + "value": "" + }, + { + "key": "whatsapp_id_36", + "value": "" + }, + { + "key": "whatsapp_id_37", + "value": "" + }, + { + "key": "whatsapp_id_38", + "value": "" + }, + { + "key": "messageCount", + "value": "" + } + ] +} \ No newline at end of file From 2ce3e4e12de9d32c943e99a125650914ff4b7172 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Fri, 22 Sep 2023 19:15:55 +0800 Subject: [PATCH 05/12] moved db connection initialisation out --- functions/src/definitions/checkerHandlers.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/functions/src/definitions/checkerHandlers.ts b/functions/src/definitions/checkerHandlers.ts index 82138576..c02d5412 100644 --- a/functions/src/definitions/checkerHandlers.ts +++ b/functions/src/definitions/checkerHandlers.ts @@ -22,10 +22,11 @@ if (!admin.apps.length) { admin.initializeApp() } +const db = admin.firestore() + const checkerHandlerWhatsapp = async function (message: Message) { const from = message.from // extract the phone number from the webhook payload const type = message.type - const db = admin.firestore() let responses switch (type) { @@ -99,7 +100,6 @@ const checkerHandlerWhatsapp = async function (message: Message) { async function onSignUp(from: string, platform = "whatsapp") { const responses = await getResponsesObj("factChecker") - const db = admin.firestore() let res = await sendTextMessage( "factChecker", from, @@ -135,7 +135,6 @@ async function onMsgReplyReceipt( platform = "whatsapp" ) { const responses = await getResponsesObj("factChecker") - const db = admin.firestore() const factCheckerSnap = await db.collection("factCheckers").doc(from).get() if (factCheckerSnap.get("getNameMessageId") === messageId) { await factCheckerSnap.ref.update({ @@ -164,7 +163,6 @@ async function onFactCheckerYes( from: string, platform = "whatsapp" ) { - const db = admin.firestore() if (!voteRequestPath.includes("/")) { throw new Error("The voteRequestPath does not contain a forward slash (/).") } @@ -430,7 +428,6 @@ async function onTextListReceipt( } async function onContinue(factCheckerId: string) { - const db = admin.firestore() await db.collection("factCheckers").doc(factCheckerId).update({ isActive: true, }) From 7c37e91b594ed047ea798158313d838120d4f796 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Fri, 22 Sep 2023 19:21:48 +0800 Subject: [PATCH 06/12] increase wait duration --- integration-tests/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/package.json b/integration-tests/package.json index 40c5552a..bfe8f565 100644 --- a/integration-tests/package.json +++ b/integration-tests/package.json @@ -4,7 +4,7 @@ "description": "", "main": "index.js", "scripts": { - "test": "newman run checkmate.postman_collection.json -g ./env.json --delay-request 2000", + "test": "newman run checkmate.postman_collection.json -g ./env.json --delay-request 3000", "update-env": "ts-node ./update-env.ts" }, "author": "", From 826d2065d49ded06c7d334bd0d79c81e1b1a5a93 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Fri, 22 Sep 2023 20:18:11 +0800 Subject: [PATCH 07/12] streamline test waits --- .../checkmate.postman_collection.json | 255 ++++++++++++++---- integration-tests/package.json | 2 +- 2 files changed, 205 insertions(+), 52 deletions(-) diff --git a/integration-tests/checkmate.postman_collection.json b/integration-tests/checkmate.postman_collection.json index 1fca9b6d..3c522b18 100644 --- a/integration-tests/checkmate.postman_collection.json +++ b/integration-tests/checkmate.postman_collection.json @@ -1,6 +1,6 @@ { "info": { - "_postman_id": "035f0de1-363b-4ee6-ae39-fa8d662c7e11", + "_postman_id": "5218f5ab-c512-43d1-b8a3-0831e12514c1", "name": "checkmate", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", "_exporter_id": "25230076" @@ -126,6 +126,15 @@ ], "type": "text/javascript" } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 2000);" + ], + "type": "text/javascript" + } } ], "request": { @@ -252,6 +261,15 @@ ], "type": "text/javascript" } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } } ], "request": { @@ -376,6 +394,15 @@ ], "type": "text/javascript" } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } } ], "request": { @@ -499,6 +526,15 @@ ], "type": "text/javascript" } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } } ], "request": { @@ -607,6 +643,15 @@ ], "type": "text/javascript" } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } } ], "request": { @@ -717,6 +762,15 @@ ], "type": "text/javascript" } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } } ], "request": { @@ -841,6 +895,15 @@ ], "type": "text/javascript" } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } } ], "request": { @@ -999,6 +1062,15 @@ ], "type": "text/javascript" } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } } ], "request": { @@ -1239,7 +1311,7 @@ "script": { "exec": [ "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 2000);" + "setTimeout(() => {}, 5000);" ], "type": "text/javascript" } @@ -1349,6 +1421,15 @@ ], "type": "text/javascript" } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } } ], "request": { @@ -1523,7 +1604,7 @@ "listen": "prerequest", "script": { "exec": [ - "// Allow time for firestore onUpdate event to complete\r" + "setTimeout(() => {}, 5000);" ], "type": "text/javascript" } @@ -1964,7 +2045,7 @@ "listen": "prerequest", "script": { "exec": [ - "" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } @@ -2161,7 +2242,7 @@ "script": { "exec": [ "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 2000);" + "setTimeout(() => {}, 5000);" ], "type": "text/javascript" } @@ -2366,7 +2447,7 @@ "script": { "exec": [ "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 2000);" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } @@ -2529,6 +2610,15 @@ ], "type": "text/javascript" } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } } ], "request": { @@ -2770,7 +2860,7 @@ "listen": "prerequest", "script": { "exec": [ - "" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } @@ -2912,7 +3002,7 @@ "listen": "prerequest", "script": { "exec": [ - "" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } @@ -3042,7 +3132,7 @@ "listen": "prerequest", "script": { "exec": [ - "" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } @@ -3186,7 +3276,7 @@ "listen": "prerequest", "script": { "exec": [ - "" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } @@ -3287,7 +3377,7 @@ "listen": "prerequest", "script": { "exec": [ - "" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } @@ -3484,7 +3574,7 @@ "script": { "exec": [ "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 2000);" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } @@ -3689,7 +3779,7 @@ "script": { "exec": [ "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 2000);" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } @@ -3889,7 +3979,7 @@ "listen": "prerequest", "script": { "exec": [ - "" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } @@ -3990,7 +4080,7 @@ "listen": "prerequest", "script": { "exec": [ - "" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } @@ -4187,7 +4277,7 @@ "script": { "exec": [ "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 2000);" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } @@ -4392,7 +4482,7 @@ "script": { "exec": [ "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 2000);" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } @@ -4773,7 +4863,7 @@ "listen": "prerequest", "script": { "exec": [ - "" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } @@ -4941,6 +5031,15 @@ ], "type": "text/javascript" } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } } ], "request": { @@ -5059,6 +5158,15 @@ ], "type": "text/javascript" } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } } ], "request": { @@ -5189,7 +5297,7 @@ "script": { "exec": [ "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 2000);" + "setTimeout(() => {}, 5000);" ], "type": "text/javascript" } @@ -5628,7 +5736,7 @@ "listen": "prerequest", "script": { "exec": [ - "" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } @@ -5830,7 +5938,7 @@ "script": { "exec": [ "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 2000);" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } @@ -6077,7 +6185,7 @@ "listen": "prerequest", "script": { "exec": [ - "" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } @@ -6228,7 +6336,7 @@ "listen": "prerequest", "script": { "exec": [ - "" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } @@ -6378,7 +6486,7 @@ "listen": "prerequest", "script": { "exec": [ - "" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } @@ -6579,7 +6687,7 @@ "script": { "exec": [ "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 2000);" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } @@ -6841,7 +6949,7 @@ "listen": "prerequest", "script": { "exec": [ - "" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } @@ -7042,7 +7150,7 @@ "script": { "exec": [ "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 2000);" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } @@ -7219,6 +7327,15 @@ ], "type": "text/javascript" } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } } ], "request": { @@ -7348,7 +7465,7 @@ "script": { "exec": [ "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 2000);" + "setTimeout(() => {}, 5000);" ], "type": "text/javascript" } @@ -7787,7 +7904,7 @@ "listen": "prerequest", "script": { "exec": [ - "" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } @@ -7983,7 +8100,7 @@ "script": { "exec": [ "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 2000);" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } @@ -8187,7 +8304,7 @@ "script": { "exec": [ "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 2000);" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } @@ -8348,6 +8465,15 @@ ], "type": "text/javascript" } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } } ], "request": { @@ -8580,7 +8706,7 @@ "listen": "prerequest", "script": { "exec": [ - "" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } @@ -8745,7 +8871,7 @@ "script": { "exec": [ "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 2000);" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } @@ -8952,7 +9078,7 @@ "listen": "prerequest", "script": { "exec": [ - "" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } @@ -9142,7 +9268,7 @@ "listen": "prerequest", "script": { "exec": [ - "" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } @@ -9292,7 +9418,7 @@ "listen": "prerequest", "script": { "exec": [ - "" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } @@ -9489,7 +9615,7 @@ "script": { "exec": [ "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 2000);" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } @@ -9690,7 +9816,7 @@ "script": { "exec": [ "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 2000);" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } @@ -9990,7 +10116,7 @@ "listen": "prerequest", "script": { "exec": [ - "" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } @@ -10186,7 +10312,7 @@ "script": { "exec": [ "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 2000);" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } @@ -10390,7 +10516,7 @@ "script": { "exec": [ "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 2000);" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } @@ -10672,6 +10798,15 @@ ], "type": "text/javascript" } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } } ], "request": { @@ -10838,7 +10973,7 @@ "listen": "prerequest", "script": { "exec": [ - "" + "setTimeout(() => {}, 2000);" ], "type": "text/javascript" } @@ -10956,7 +11091,7 @@ "listen": "prerequest", "script": { "exec": [ - "" + "setTimeout(() => {}, 2000);" ], "type": "text/javascript" } @@ -11074,7 +11209,7 @@ "listen": "prerequest", "script": { "exec": [ - "" + "setTimeout(() => {}, 2000);" ], "type": "text/javascript" } @@ -11192,7 +11327,7 @@ "listen": "prerequest", "script": { "exec": [ - "" + "setTimeout(() => {}, 2000);" ], "type": "text/javascript" } @@ -11310,7 +11445,7 @@ "listen": "prerequest", "script": { "exec": [ - "" + "setTimeout(() => {}, 2000);" ], "type": "text/javascript" } @@ -11443,7 +11578,7 @@ "listen": "prerequest", "script": { "exec": [ - "" + "setTimeout(() => {}, 5000);" ], "type": "text/javascript" } @@ -11609,7 +11744,7 @@ "listen": "prerequest", "script": { "exec": [ - "" + "setTimeout(() => {}, 2000);" ], "type": "text/javascript" } @@ -11778,7 +11913,7 @@ "listen": "prerequest", "script": { "exec": [ - "" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } @@ -11907,7 +12042,7 @@ "listen": "prerequest", "script": { "exec": [ - "" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } @@ -12153,6 +12288,15 @@ ], "type": "text/javascript" } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } } ], "request": { @@ -12311,6 +12455,15 @@ ], "type": "text/javascript" } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } } ], "request": { @@ -12505,7 +12658,7 @@ "script": { "exec": [ "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 2000);" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } diff --git a/integration-tests/package.json b/integration-tests/package.json index bfe8f565..24d39a08 100644 --- a/integration-tests/package.json +++ b/integration-tests/package.json @@ -4,7 +4,7 @@ "description": "", "main": "index.js", "scripts": { - "test": "newman run checkmate.postman_collection.json -g ./env.json --delay-request 3000", + "test": "newman run checkmate.postman_collection.json -g ./env.json", "update-env": "ts-node ./update-env.ts" }, "author": "", From f3ffece772c52ecc500db69901a0c4da2f236c34 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Fri, 22 Sep 2023 21:17:52 +0800 Subject: [PATCH 08/12] added missing test wait --- integration-tests/checkmate.postman_collection.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/integration-tests/checkmate.postman_collection.json b/integration-tests/checkmate.postman_collection.json index 3c522b18..42c8db49 100644 --- a/integration-tests/checkmate.postman_collection.json +++ b/integration-tests/checkmate.postman_collection.json @@ -10015,7 +10015,8 @@ "listen": "prerequest", "script": { "exec": [ - "" + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } From 6c6a72c6cc6c77b661a147af77a72659745e2be5 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sat, 23 Sep 2023 09:38:21 +0800 Subject: [PATCH 09/12] added 1 test for simulated concurrent duplicates --- .../checkmate.postman_collection.json | 197 ++++++++++++++++-- 1 file changed, 181 insertions(+), 16 deletions(-) diff --git a/integration-tests/checkmate.postman_collection.json b/integration-tests/checkmate.postman_collection.json index 42c8db49..faf281c9 100644 --- a/integration-tests/checkmate.postman_collection.json +++ b/integration-tests/checkmate.postman_collection.json @@ -12576,7 +12576,7 @@ "response": [] }, { - "name": "Send WhatsApp message (15 Chars)", + "name": "Duplicate Info Message", "event": [ { "listen": "test", @@ -12593,19 +12593,7 @@ "listen": "prerequest", "script": { "exec": [ - "// 1. Retrieve the current messageCounter and increment it.\r", - "let messageCounter = 19\r", - "\r", - "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", - "\r", - "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", - "let n = messageCounter.toString().length;\r", - "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", - "let newId = basePart + messageCounter + \"==\";\r", - "\r", - "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", - "\r", - "// Allow time for firestore onUpdate event to complete\r" + "" ], "type": "text/javascript" } @@ -12645,7 +12633,7 @@ "listen": "test", "script": { "exec": [ - "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", + "pm.test(\"Check that message count did not increase\", function () {\r", " var jsonData = pm.response.json();\r", " const count = pm.variables.get(\"messageCount\")\r", " pm.expect(jsonData.documents.length).to.eql(count);\r", @@ -12699,7 +12687,7 @@ "listen": "test", "script": { "exec": [ - "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", + "pm.test(\"Check that info instance count did not increase\", function () {\r", " var jsonData = pm.response.json();\r", " pm.collectionVariables.set(\"messageCount\", jsonData.documents.length)\r", "});" @@ -12734,6 +12722,179 @@ } }, "response": [] + }, + { + "name": "New unsure message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 41\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "\r", + "// Allow time for firestore onUpdate event to complete\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_41}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is a whatever message that will be voted on 24601\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Mocked immediate retry", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_41}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is a whatever message that will be voted on 24601\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Get Count of Messages Copy", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that only 1 message and 1 instance was created\", function () {\r", + " var jsonData = pm.response.json();\r", + " const count = pm.variables.get(\"messageCount\") + 1\r", + " pm.expect(jsonData.documents.length).to.eql(count);\r", + " var filtered = jsonData.documents.filter((doc) => {\r", + " return doc.fields.text.stringValue == \"This is a whatever message that will be voted on 24601\"\r", + " })\r", + " pm.expect(filtered[0].fields.instanceCount.integerValue).to.eql(\"1\")\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 5000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "messages" + ] + } + }, + "response": [] } ] } @@ -13066,6 +13227,10 @@ { "key": "messageCount", "value": "" + }, + { + "key": "whatsapp_id_41", + "value": "" } ] } \ No newline at end of file From 12a78db5e5d0e2dbd8b1191120fd72c1130089dd Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sat, 23 Sep 2023 09:59:31 +0800 Subject: [PATCH 10/12] changed tests to use REST api firestore query --- .../checkmate.postman_collection.json | 87 ++++++++++++++++--- 1 file changed, 75 insertions(+), 12 deletions(-) diff --git a/integration-tests/checkmate.postman_collection.json b/integration-tests/checkmate.postman_collection.json index faf281c9..dbf61547 100644 --- a/integration-tests/checkmate.postman_collection.json +++ b/integration-tests/checkmate.postman_collection.json @@ -12839,20 +12839,15 @@ "response": [] }, { - "name": "[DB CALL] Get Count of Messages Copy", + "name": "[DB QUERY] Get Count of Messages", "event": [ { "listen": "test", "script": { "exec": [ - "pm.test(\"Check that only 1 message and 1 instance was created\", function () {\r", + "pm.test(\"Check that only 1 message was created\", function () {\r", " var jsonData = pm.response.json();\r", - " const count = pm.variables.get(\"messageCount\") + 1\r", - " pm.expect(jsonData.documents.length).to.eql(count);\r", - " var filtered = jsonData.documents.filter((doc) => {\r", - " return doc.fields.text.stringValue == \"This is a whatever message that will be voted on 24601\"\r", - " })\r", - " pm.expect(filtered[0].fields.instanceCount.integerValue).to.eql(\"1\")\r", + " pm.expect(jsonData.length).to.eql(1);\r", "});" ], "type": "text/javascript" @@ -12870,7 +12865,7 @@ } ], "request": { - "method": "GET", + "method": "POST", "header": [ { "key": "Authorization", @@ -12878,8 +12873,17 @@ "type": "text" } ], + "body": { + "mode": "raw", + "raw": "{\r\n \"structuredQuery\": {\r\n \"from\": [{\r\n \"collectionId\": \"messages\"\r\n }],\r\n \"where\": {\r\n \"fieldFilter\": {\r\n \"field\": {\r\n \"fieldPath\": \"text\"\r\n },\r\n \"op\": \"EQUAL\",\r\n \"value\": {\r\n \"stringValue\": \"This is a whatever message that will be voted on 24601\"\r\n }\r\n }\r\n }\r\n }\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages", + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents:runQuery", "host": [ "{{FIRESTORE_URL}}" ], @@ -12889,8 +12893,67 @@ "checkmate-373101", "databases", "(default)", - "documents", - "messages" + "documents:runQuery" + ] + } + }, + "response": [] + }, + { + "name": "[DB COLLECTIONGROUP QUERY] Get Count of Instances", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that only 1 instance was created\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData.length).to.eql(1);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"structuredQuery\": {\r\n \"from\": [{\r\n \"collectionId\": \"instances\",\r\n \"allDescendants\": true\r\n }],\r\n \"where\": {\r\n \"fieldFilter\": {\r\n \"field\": {\r\n \"fieldPath\": \"text\"\r\n },\r\n \"op\": \"EQUAL\",\r\n \"value\": {\r\n \"stringValue\": \"This is a whatever message that will be voted on 24601\"\r\n }\r\n }\r\n }\r\n }\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents:runQuery", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents:runQuery" ] } }, From 6e5cbd57abdf9fb6b52b07fc76ded0c9c850b3a3 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sat, 23 Sep 2023 11:05:00 +0800 Subject: [PATCH 11/12] extended timeouts --- integration-tests/checkmate.postman_collection.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/integration-tests/checkmate.postman_collection.json b/integration-tests/checkmate.postman_collection.json index dbf61547..8a91ecbc 100644 --- a/integration-tests/checkmate.postman_collection.json +++ b/integration-tests/checkmate.postman_collection.json @@ -1311,7 +1311,7 @@ "script": { "exec": [ "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 5000);" + "setTimeout(() => {}, 6000);" ], "type": "text/javascript" } @@ -1604,7 +1604,7 @@ "listen": "prerequest", "script": { "exec": [ - "setTimeout(() => {}, 5000);" + "setTimeout(() => {}, 6000);" ], "type": "text/javascript" } @@ -5297,7 +5297,7 @@ "script": { "exec": [ "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 5000);" + "setTimeout(() => {}, 6000);" ], "type": "text/javascript" } @@ -7465,7 +7465,7 @@ "script": { "exec": [ "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 5000);" + "setTimeout(() => {}, 6000);" ], "type": "text/javascript" } @@ -12647,7 +12647,7 @@ "script": { "exec": [ "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 3000);" + "setTimeout(() => {}, 6000);" ], "type": "text/javascript" } @@ -12858,7 +12858,7 @@ "script": { "exec": [ "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 5000);" + "setTimeout(() => {}, 6000);" ], "type": "text/javascript" } From 505f3b2034697a1e80348f3a66a9302d1b45ac86 Mon Sep 17 00:00:00 2001 From: bingwen Date: Thu, 28 Sep 2023 10:13:06 +0800 Subject: [PATCH 12/12] fixed db ref --- functions/src/definitions/common/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/src/definitions/common/utils.ts b/functions/src/definitions/common/utils.ts index a200af74..a042e75b 100644 --- a/functions/src/definitions/common/utils.ts +++ b/functions/src/definitions/common/utils.ts @@ -35,7 +35,7 @@ const checkUrl = function (urlString: string) { async function checkMessageId(messageId: string) { const db = admin.firestore() - const messageRef = db.doc(`messagesIds/${messageId}`) + const messageRef = db.collection("messageIds").doc(messageId) const messageSnap = await messageRef.get() return messageSnap.exists }