Skip to content

Instantly share code, notes, and snippets.

@shailpujan88
Last active March 25, 2024 15:48
Show Gist options
  • Save shailpujan88/e16c1b4fdb64394c2407535ccd62bd41 to your computer and use it in GitHub Desktop.
Save shailpujan88/e16c1b4fdb64394c2407535ccd62bd41 to your computer and use it in GitHub Desktop.
I've attached the independent test files for each functionality along with the file which included all the functionalities cummulated.

WhatsApp Message Sending Tests with Cypress

This README details Cypress integration tests designed to ensure seamless message sending functionality through the Infobip API using WhatsApp.

Functionality Tested

The test suite meticulously examines sending the following message categories via WhatsApp:

  • Text Messages: Fundamental method for conveying textual content.
  • Document Messages (PDFs): Enables sharing of Portable Document Format (PDF) files.
  • Video Messages: Facilitates sending multimedia content in video format.
  • Contact Messages: Streamlines sharing contact information, including names, emails, phone numbers, and more.
  • Image Messages: Enhances communication by incorporating visual elements.
  • Location Messages: Permits transmitting geographical coordinates for location pinpointing.

Test Case Breakdown

Each meticulously crafted test case simulates sending a specific message type through WhatsApp and rigorously validates a successful response from the Infobip API. Here's a closer look at the test cases:

  1. Template Message Test:

    • Constructs a template message payload with designated placeholders.
    • Fills placeholders with the desired content.
    • Sends the template message via WhatsApp using the Infobip API.
    • Verifies that the Infobip API returns a successful response, indicating message delivery.
  2. Text Message Test:

    • Creates a text message payload containing the message content.
    • Sends the text message via WhatsApp using the Infobip API.
    • Confirms that the Infobip API returns a successful response.
  3. Document Message Test:

    • Prepares a document message payload specifying the URL of the document (PDF) to be sent.
    • Sends the document message via WhatsApp using the Infobip API.
    • Ensures that the Infobip API returns a successful response.
  4. Video Message Test:

    • Constructs a video message payload, including the URL of the video to be sent.
    • Sends the video message via WhatsApp using the Infobip API.
    • Affirms that the Infobip API returns a successful response.
  5. Contact Message Test:

    • Meticulously builds a contact message payload encompassing details like name, phone numbers, email addresses, and organization (optional).
    • Sends the contact message via WhatsApp using the Infobip API.
    • Guarantees that the Infobip API returns a successful response.
  6. Image Message Test:

    • Creates an image message payload, incorporating the URL of the image to be sent.
    • Sends the image message via WhatsApp using the Infobip API.
    • Verifies that the Infobip API returns a successful response.
  7. Location Message Test:

    • Constructs a location message payload specifying the latitude and longitude coordinates.
    • Sends the location message via WhatsApp using the Infobip API.
    • Confirms that the Infobip API returns a successful response.

Test Execution Prerequisites

To execute these tests effectively, ensure you have the following in place:

  1. Node.js and npm:

  2. Clone the Project Repository: Use Git to clone the project repository that contains the test code.

  3. Install Cypress: Within the project directory, execute the following command in your terminal to install Cypress:

    bash npm install cypress

Running the Tests

  1. Launch Cypress Test Runner: Once Cypress is installed, initiate the Cypress Test Runner in your terminal using this command:

    bash npx cypress open

  2. Select Test File: A Cypress graphical user interface will open. Choose the test file named sendingWhatsAppMessages.test.js to execute the test suite.

// sendMessage.spec.js
describe('Send WhatsApp Contact Test', () => {
it('Should send a WhatsApp contact with the given payload', () => {
const contactmsg = {
from: "447860099299",
to: "919065562412",
messageId: "7a9473d7-4907-404f-8bdc-8f8ddbf2ca80",
content: {
contacts: [{
addresses: [{
street: "Boring Road",
city: "Patna",
zip: "80001",
country: "India",
countryCode: "HR",
type: "WORK"
},
{
street: "boring Road",
city: "Patna",
zip: "80001",
country: "India",
countryCode: "HR",
type: "HOME"
}
],
birthday: "2000-08-19",
emails: [{
email: "muskan@gmail.com",
type: "WORK"
},
{
email: "shail8690@gmail.com",
type: "HOME"
}
],
name: {
firstName: "Yah",
lastName: "Pujan",
middleName: "Raj",
namePrefix: "Mr.",
formattedName: "Mr. Yash Raj Pujan"
},
org: {
company: "Company Name",
department: "Department",
title: "Director"
},
phones: [{
phone: "919065562412",
type: "HOME",
waId: "9065562412"
},
{
phone: "919065562412",
type: "WORK",
waId: "9065562412"
}
]
}]
}
};
const apiKey = 'b43f4d67f5bd098d3e3f8c4ceaa004ae-ff08ce05-2c51-40fe-8d5f-18bb4410c4dd';
cy.request({
method: 'POST',
url: 'https://6g3w9r.api.infobip.com/whatsapp/1/message/contact', // Replace with your WhatsApp API endpoint
body: contactmsg,
headers: {
'Content-Type': 'application/json',
Authorization: `App ${apiKey}`
// Add any other required headers
}
}).then((response) => {
// Check if the request was successful
cy.log(JSON.stringify(response.body));
expect(response.status).to.eq(200);
});
});
});
describe('Send WhatsApp Document Message Test', () => {
it('Successfully sends a WhatsApp document message', () => {
// Define the payload for sending a WhatsApp document message
const documentmsg = {
from: '447860099299',
to: '919065562412',
messageId: '7a9473d7-4907-404f-8bdc-8f8ddbf2ca80',
content: {
mediaUrl: 'https://css4.pub/2017/newsletter/drylab.pdf'
},
}
// Replace 'YOUR_API_KEY' with your actual Infobip API key
const apiKey = 'b43f4d67f5bd098d3e3f8c4ceaa004ae-ff08ce05-2c51-40fe-8d5f-18bb4410c4dd';
// Send the POST request using cy.request
cy.request({
method: 'POST',
url: 'https://6g3w9r.api.infobip.com/whatsapp/1/message/document',
headers: {
'Content-Type': 'application/json',
Authorization: `App ${apiKey}`
},
body: documentmsg
}).then((response) => {
// Check if the message was sent successfully
cy.log(JSON.stringify(response.body));
expect(response.status).to.eq(200);
// Add additional assertions if needed
// Verify the response body contains the expected properties
});
});
});
describe('Send WhatsApp Video Message Test', () => {
it('Successfully sends a WhatsApp video message', () => {
const videomsg = {
from: '447860099299', // Your Infobip WhatsApp number
to: '919065562412', // Your own phone number or the number to receive the message
messageId: '7a9473d7-4907-404f-8bdc-8f8ddbf2ca80',
content: {
mediaUrl: 'https://media.istockphoto.com/id/1449503427/video/aerial-top-down-view-of-a-teenage-girl-jumping-on-trampoline-in-a-backyard.mp4?s=mp4-640x640-is&k=20&c=FFCzW6d03rXTvE2vDdOrNB9rhZAI9ZqMIQdciT_zOoI=' // URL to a video (can be any publicly accessible URL)
}
};
// Replace 'YOUR_API_KEY' with your actual Infobip API key
const apiKey = 'b43f4d67f5bd098d3e3f8c4ceaa004ae-ff08ce05-2c51-40fe-8d5f-18bb4410c4dd';
// Send the POST request using cy.request
cy.request({
method: 'POST',
url: 'https://6g3w9r.api.infobip.com/whatsapp/1/message/video',
headers: {
'Content-Type': 'application/json',
Authorization: `App ${apiKey}`
},
body: videomsg
}).then((response) => {
// Check if the message was sent successfully
cy.log(JSON.stringify(response.body));
expect(response.status).to.eq(200);
});
});
});
describe('Send WhatsApp Image Message Test', () => {
const apiKey = 'b43f4d67f5bd098d3e3f8c4ceaa004ae-ff08ce05-2c51-40fe-8d5f-18bb4410c4dd'; // Replace 'YOUR_API_KEY' with your actual Infobip API key
it('Successfully sends a WhatsApp image message', () => {
const payload = {
from: '447860099299',
to: '919065562412',
messageId: '7a9473d7-4907-404f-8bdc-8f8ddbf2ca80',
content: {
mediaUrl: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ1Go-H8GMEh1cmMNiS_JV5om--MYYmxlsjCa_kZkUJhg&s' // Replace with your image URL
}
};
cy.request({
method: 'POST',
url: 'https://6g3w9r.api.infobip.com/whatsapp/1/message/image',
headers: {
'Content-Type': 'application/json',
Authorization: `App ${apiKey}`
},
body: payload
}).then((response) => {
// Check if the message was sent successfully
cy.log(JSON.stringify(response.body));
expect(response.status).to.eq(200);
});
});
});
describe('Send WhatsApp Location Message Test', () => {
const apiKey = 'b43f4d67f5bd098d3e3f8c4ceaa004ae-ff08ce05-2c51-40fe-8d5f-18bb4410c4dd'; // Replace 'YOUR_API_KEY' with your actual Infobip API key
it('Successfully sends a WhatsApp location message', () => {
const locationmap = {
from: '447860099299',
to: '919065562412',
messageId: '7a9473d7-4907-404f-8bdc-8f8ddbf2ca80',
content: {
latitude: 44.9526862,
longitude: 13.8545217
}
};
cy.request({
method: 'POST',
url: 'https://6g3w9r.api.infobip.com/whatsapp/1/message/location',
headers: {
'Content-Type': 'application/json',
Authorization: `App ${apiKey}`
},
body: locationmap
}).then((response) => {
// Check if the message was sent successfully
cy.log(JSON.stringify(response.body));
expect(response.status).to.eq(200);
});
});
});
/*here I was trying to check the UPI payment payu status functionality of whatsapp integration test.
But because of the payment gateway I think it is unsucessfull.I am not sure but I am attaching the code here please look at it.*/
describe('Checking PayU Payment Status', () => {
it('Retrieve Payment Status from PayU', () => {
// Your PayU API key
const apiKey = 'YOUR_PAYU_API_KEY';
// Sender's WhatsApp number
const sender = 'YOUR_SENDER_NUMBER';
// PayU Transaction ID for the payment
const paymentId = 'YOUR_PAYU_TRANSACTION_ID';
// Making a request to PayU API to get payment status
cy.request({
method: 'GET',
url: `https://6g3w9r.api.infobip.com/whatsapp/1/senders/${sender}/payments/upi/payu/${paymentId}`,
headers: {
'Content-Type': 'application/json',
Authorization: `App ${apiKey}`,
Accept: 'application/json',
},
// Not failing the test on non-2xx status codes
failOnStatusCode: false,
}).then((response) => {
// Handling different status codes
if (response.status === 403) {
// Insufficient permissions
cy.log('Oops! I couldn\'t check the payment status. Looks like I don\'t have enough permissions.');
// Expecting a 'Forbidden' status text
expect(response.statusText).to.equal('Forbidden');
} else if (response.status === 404) {
// Transaction not found
cy.log('Hmm, I couldn\'t find the transaction. It might not exist.');
// Expecting a 'Not Found' status text
expect(response.statusText).to.equal('Not Found');
} else if (response.status === 200) {
// Payment status retrieved successfully
cy.log('Got it! Payment status retrieved successfully.');
// Logging the response body for more details
cy.log(response.body);
// Expecting a 200 status
expect(response.status).to.equal(200);
// You can add more checks based on the response body
} else {
// Unexpected status
cy.log(`Hmm, something unexpected happened. Status: ${response.status}`);
}
});
});
});
describe('Send WhatsApp Template Messages Tests', () => {
const apiKey = 'b43f4d67f5bd098d3e3f8c4ceaa004ae-ff08ce05-2c51-40fe-8d5f-18bb4410c4dd';
it("Successfully sends a WhatsApp template message", () => {
const tempMsg= {
"messages": [{
"from": "447860099299",
"to": "<RECEPIENT_PHONE_NO",
"messageId": "7a9473d7-4907-404f-8bdc-8f8ddbf2ca80",
"content": {
"templateName": "message_test",
"templateData": {
"body": {
"placeholders": ["SHAIL PUJAN"]
}
},
"language": "en"
}
}]
};
const requestBody = JSON.stringify(tempMsg);
cy.request({
method: "POST",
url: "https://6g3w9r.api.infobip.com/whatsapp/1/message/template",
headers: {
'Content-Type': 'application/json',
Authorization: `App ${apiKey}`
},
body: requestBody,
redirect: "follow"
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body).to.have.property('messages');
cy.log(JSON.stringify(response.body));
});
});
});
describe('Send WhatsApp Text Messages Tests', () => {
const apiKey = 'b43f4d67f5bd098d3e3f8c4ceaa004ae-ff08ce05-2c51-40fe-8d5f-18bb4410c4dd'; // Replace 'YOUR_API_KEY' with your actual Infobip API key
// Test sending a WhatsApp text message
it('Successfully sends a WhatsApp text message', () => {
const textmsg = {
from: '447860099299',
to: '919065562412',
messageId: '"7a9473d7-4907-404f-8bdc-8f8ddbf2ca80',
content: {
text: 'Hello I am SHAIL PUJAN. I am developing the test case to ensure the functionality and reliability of the proposed features!!!'
}
};
cy.request({
method: 'POST',
url: 'https://6g3w9r.api.infobip.com/whatsapp/1/message/text',
headers: {
'Content-Type': 'application/json',
Authorization: `App ${apiKey}`
},
body: textmsg
}).then((response) => {
cy.log(JSON.stringify(response.body));
expect(response.status).to.eq(200);
});
});
});
describe('Send WhatsApp Document Message Test', () => {
it('Successfully sends a WhatsApp document message', () => {
// Define the payload for sending a WhatsApp document message
const documentmsg = {
from: '447860099299',
to: '919065562412',
messageId: '7a9473d7-4907-404f-8bdc-8f8ddbf2ca80',
content: {
mediaUrl: 'https://css4.pub/2017/newsletter/drylab.pdf'
},
}
// Replace 'YOUR_API_KEY' with your actual Infobip API key
const apiKey = 'b43f4d67f5bd098d3e3f8c4ceaa004ae-ff08ce05-2c51-40fe-8d5f-18bb4410c4dd';
// Send the POST request using cy.request
cy.request({
method: 'POST',
url: 'https://6g3w9r.api.infobip.com/whatsapp/1/message/document',
headers: {
'Content-Type': 'application/json',
Authorization: `App ${apiKey}`
},
body: documentmsg
}).then((response) => {
// Check if the message was sent successfully
cy.log(JSON.stringify(response.body));
expect(response.status).to.eq(200);
// Add additional assertions if needed
// Verify the response body contains the expected properties
});
});
});
describe('Send WhatsApp Video Message Test', () => {
it('Successfully sends a WhatsApp video message', () => {
const videomsg = {
from: '447860099299', // Your Infobip WhatsApp number
to: '919065562412', // Your own phone number or the number to receive the message
messageId: '7a9473d7-4907-404f-8bdc-8f8ddbf2ca80',
content: {
mediaUrl: 'https://media.istockphoto.com/id/1449503427/video/aerial-top-down-view-of-a-teenage-girl-jumping-on-trampoline-in-a-backyard.mp4?s=mp4-640x640-is&k=20&c=FFCzW6d03rXTvE2vDdOrNB9rhZAI9ZqMIQdciT_zOoI=' // URL to a video (can be any publicly accessible URL)
}
};
// Replace 'YOUR_API_KEY' with your actual Infobip API key
const apiKey = 'b43f4d67f5bd098d3e3f8c4ceaa004ae-ff08ce05-2c51-40fe-8d5f-18bb4410c4dd';
// Send the POST request using cy.request
cy.request({
method: 'POST',
url: 'https://6g3w9r.api.infobip.com/whatsapp/1/message/video',
headers: {
'Content-Type': 'application/json',
Authorization: `App ${apiKey}`
},
body: videomsg
}).then((response) => {
// Check if the message was sent successfully
cy.log(JSON.stringify(response.body));
expect(response.status).to.eq(200);
});
});
});
//THIS IS CODE IN which IT included all the functionalities cummulated.
// Test suite for sending various types of WhatsApp messages
//Each test case verifies that the corresponding message type can be successfully sent using the Infobip API, and it checks for a successful response from the API.
//The code provided demonstrates how to interact with Infobip's WhatsApp API using Cypress for testing purposes.
// It begins with sending a WhatsApp template message.
//This template message is constructed with specific placeholders filled with content, such as the recipient's name.
//The message is then sent to a recipient's WhatsApp number.
//After sending the template message, the code proceeds to test sending various other types of messages: text, document, video, contact, image, and location.
describe("Sending WhatsApp Messages as Text, video, images, docs, videos", () => {
// API key for authorization
const apiKey = 'b43f4d67f5bd098d3e3f8c4ceaa004ae-ff08ce05-2c51-40fe-8d5f-18bb4410c4dd';
//This test sends a WhatsApp template message using the specified template name and data.//It constructs the template message payload with placeholders.
//The POST request is made to the Infobip API for sending the template message.
//Assertions are made to check the response status and the presence of the 'messages' property in the response body
it("Successfully sends a WhatsApp template message", () => {
// Template message payload
const tempMsg = {
"messages": [{
"from": "447860099299",
"to": "919065562412",
"messageId": "238bd887-d0f4-4a5d-9c09-c633b44230d9",
"content": {
"templateName": "message_test",
"templateData": {
"body": {
"placeholders": ["SHAIL PUJAN"]
}
},
"language": "en"
}
}]
};
// Convert payload to JSON string
const requestBody = JSON.stringify(tempMsg);
// Send a POST request to Infobip API for sending a template message
cy.request({
method: "POST",
url: "https://6g3w9r.api.infobip.com/whatsapp/1/message/template",
headers: {
'Content-Type': 'application/json',
Authorization: `App ${apiKey}`
},
body: requestBody,
redirect: "follow"
}).then((response) => {
// Check if the response status is 200 (OK)
expect(response.status).to.eq(200);
// Check if the response body has 'messages' property
expect(response.body).to.have.property('messages');
// Log the response body
cy.log(JSON.stringify(response.body));
});
});
// Test for sending a WhatsApp text message
/*This test sends a simple text message.
It creates the text message payload with the sender, recipient, and message content.
The POST request is sent to the Infobip API for sending the text message.
Assertions are made to check the response status.*/
it('Sends a WhatsApp text message', () => {
// Text message payload
const textmsg = {
from: '447860099299',
to: '919065562412',
messageId: '7a9473d7-4907-404f-8bdc-8f8ddbf2ca80',
content: {
text: 'Hello I am SHAIL PUJAN. I am developing the test case to ensure the functionality and reliability of the proposed features!!!'
}
};
// Send a POST request to Infobip API for sending a text message
cy.request({
method: 'POST',
url: 'https://6g3w9r.api.infobip.com/whatsapp/1/message/text',
headers: {
'Content-Type': 'application/json',
Authorization: `App ${apiKey}`
},
body: textmsg
}).then((response) => {
// Check if the response status is 200 (OK)
expect(response.status).to.eq(200);
// Log the response body
cy.log(JSON.stringify(response.body));
});
});
// Test for sending a WhatsApp document message
/* This test sends a document message, typically a PDF.
**The document message payload includes the media URL of the document to be sent.
**The POST request is sent to the Infobip API for sending the document message.
**Assertions are made to check the response status.*/
it('Sends a WhatsApp document message', () => {
// Document message payload
const documentmsg = {
from: '447860099299',
to: '919065562412',
messageId: '7a9473d7-4907-404f-8bdc-8f8ddbf2ca80',
content: {
//here you have to put url of document you want to send
mediaUrl: 'https://css4.pub/2015/textbook/somatosensory.pdf'
}
};
// Send a POST request to Infobip API for sending a document message
cy.request({
method: 'POST',
url: 'https://6g3w9r.api.infobip.com/whatsapp/1/message/document',
headers: {
'Content-Type': 'application/json',
Authorization: `App ${apiKey}`
},
body: documentmsg
}).then((response) => {
// Check if the response status is 200 (OK)
expect(response.status).to.eq(200);
// Log the response body
cy.log(JSON.stringify(response.body));
});
});
// Test for sending a WhatsApp video message
/*This test sends a video message.
The video message payload includes the media URL of the video to be sent.
The POST request is sent to the Infobip API for sending the video message.
Assertions are made to check the response status.*/
it('Sends a WhatsApp video message', () => {
// Video message payload
const videomsg = {
from: '447860099299',
to: '919065562412',
messageId: '7a9473d7-4907-404f-8bdc-8f8ddbf2ca80',
content: {
//Here you have to give the url of the video youant to send to the recipient
mediaUrl: 'https://media.istockphoto.com/id/1449503427/video/aerial-top-down-view-of-a-teenage-girl-jumping-on-trampoline-in-a-backyard.mp4?s=mp4-640x640-is&k=20&c=FFCzW6d03rXTvE2vDdOrNB9rhZAI9ZqMIQdciT_zOoI='
}
};
// Send a POST request to Infobip API for sending a video message
cy.request({
method: 'POST',
url: 'https://6g3w9r.api.infobip.com/whatsapp/1/message/video',
headers: {
'Content-Type': 'application/json',
Authorization: `App ${apiKey}`
},
body: videomsg
}).then((response) => {
// Check if the response status is 200 (OK)
expect(response.status).to.eq(200);
// Log the response body
cy.log(JSON.stringify(response.body));
});
});
// Test for sending a WhatsApp contact message
/* This test sends a contact message.
The contact message payload includes details like addresses, emails, name, organization, and phones of the contact.
The POST request is sent to the Infobip API for sending the contact message.
Assertions are made to check the response status.*/
it('Should send a WhatsApp contact with the given payload', () => {
// Contact message payload
const contactmsg = {
from: "447860099299",
to: "919065562412",
messageId: "7a9473d7-4907-404f-8bdc-8f8ddbf2ca80",
content: {
contacts: [{
addresses: [{
street: "Boring Road",
city: "Patna",
zip: "80001",
country: "India",
countryCode: "HR",
type: "WORK"
},
{
street: "boring Road",
city: "Patna",
zip: "80001",
country: "India",
countryCode: "HR",
type: "HOME"
}
],
birthday: "2000-08-19",
emails: [{
email: "muskan@gmail.com",
type: "WORK"
},
{
email: "shail8690@gmail.com",
type: "HOME"
}
],
name: {
firstName: "Yah",
lastName: "Pujan",
middleName: "Raj",
namePrefix: "Mr.",
formattedName: "Mr. Yash Raj Pujan"
},
org: {
company: "Company Name",
department: "Department",
title: "Director"
},
phones: [{
phone: "919065562412",
type: "HOME",
waId: "9065562412"
},
{
phone: "919065562412",
type: "WORK",
waId: "9065562412"
}
]
}]
}
};
// Send a POST request to Infobip API for sending a contact message
cy.request({
method: 'POST',
url: 'https://6g3w9r.api.infobip.com/whatsapp/1/message/contact',
body: contactmsg,
headers: {
'Content-Type': 'application/json',
Authorization: `App ${apiKey}`
}
}).then((response) => {
// Check if the response status is 200 (OK)
expect(response.status).to.eq(200);
// Log the response body
cy.log(JSON.stringify(response.body));
// Additional assertions can be added as needed
});
});
// Test for sending a WhatsApp image message
/*This test sends an image message.
The image message payload includes the media URL of the image to be sent.
The POST request is sent to the Infobip API for sending the image message.
Assertions are made to check the response status.*/
it('Sends a WhatsApp image message', () => {
// Image message payload
const imagemessage = {
from: '447860099299',
to: '919065562412',
messageId: '7a9473d7-4907-404f-8bdc-8f8ddbf2ca80',
content: {
mediaUrl: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ1Go-H8GMEh1cmMNiS_JV5om--MYYmxlsjCa_kZkUJhg&s'
}
};
// Send a POST request to Infobip API for sending an image message
cy.request({
method: 'POST',
url: 'https://6g3w9r.api.infobip.com/whatsapp/1/message/image',
headers: {
'Content-Type': 'application/json',
Authorization: `App ${apiKey}`
},
body: imagemessage
}).then((response) => {
// Check if the response status is 200 (OK)
expect(response.status).to.eq(200);
// Log the response body
cy.log(JSON.stringify(response.body));
// Additional assertions can be added as needed
});
});
// Test for sending a WhatsApp location message
/*This test sends a location message.
The location message payload includes the latitude and longitude of the location.
The POST request is sent to the Infobip API for sending the location message.
Assertions are made to check the response status.*/
it('Successfully sends a WhatsApp location message', () => {
// Location message payload
const locationmap = {
from: '447860099299',
to: '919065562412',
messageId: '7a9473d7-4907-404f-8bdc-8f8ddbf2ca80',
content: {
latitude: 44.9526862,//add the latitude of the location you want to send
longitude: 13.8545217//add the longtitude of the location you want to send
}
};
// Send a POST request to Infobip API for sending a location message
cy.request({
method: 'POST',
url: 'https://6g3w9r.api.infobip.com/whatsapp/1/message/location',
headers: {
'Content-Type': 'application/json',
Authorization: `App ${apiKey}`
},
body: locationmap
}).then((response) => {
// Check if the response status is 200 (OK)
expect(response.status).to.eq(200);
// Log the response body
cy.log(JSON.stringify(response.body));
// Additional assertions can be added as needed
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment