This is my json payloads for each request I am trying to send. These are the various scenarios I want to test but I want to test each in a single request by putting them in an array and pass it as the body in the post request
Please let me know if I need to provide more details. Thanks
{
"validTransaction": [
{
"password": "VhIDsPpHsqNGtARyQgKsOx5I794bunij",
"amount": "10",
"transaction_type": "01",
"cc_expiry": "1224",
"cardholder_name": "Simon Jones",
"gateway_id": "KE5905-88",
"cc_number": "5187013017662435",
"cvv": "123"
}],
"invalid_transactionType": [
{
"amount": "10",
"cardholder_name": "Simon Jones",
"cc_expiry": "1221",
"cc_number": "4761739001010119",
"gateway_id": "KE5905-88",
"password": "VhIDsPpHsqNGtARyQgKsOx5I794bunij",
"transaction_type": "08",
"cvv": "201"
}],
"missing_transactionType": [
{
"amount": "10",
"cardholder_name": "Simon Jones",
"cc_expiry": "1221",
"cc_number": "4761739001010119",
"gateway_id": "KE5905-88",
"password": "VhIDsPpHsqNGtARyQgKsOx5I794bunij",
"transaction_type": "",
"cvv": "201"
}],
"invalid_CardNumber": [
{
"amount": "10",
"cardholder_name": "Simon Jones",
"cc_expiry": "1224",
"cc_number": "47617390010119",
"gateway_id": "KE5905-88",
"password": "VhIDsPpHsqNGtARyQgKsOx5I794bunij",
"transaction_type": "01",
"cvv": "201"
}],
"invalid_expDate": [
{
"amount": "10",
"cardholder_name": "Simon Jones",
"cc_expiry": "1521",
"cc_number": "4761739001010119",
"gateway_id": "KE5905-88",
"password": "VhIDsPpHsqNGtARyQgKsOx5I794bunij",
"transaction_type": "01",
"cvv": "201"
}],
"invalid_gatewayId": [
{
"amount": "10",
"cardholder_name": "Simon Jones",
"cc_expiry": "1224",
"cc_number": "4761739001010119",
"gateway_id": "KE590511-88",
"password": "VhIDsPpHsqNGtARyQgKsOx5I794bunij",
"transaction_type": "01",
"cvv": "201"
}],
"invalid_password": [
{
"amount": "10",
"cardholder_name": "Simon Jones",
"cc_expiry": "1224",
"cc_number": "4761739001010119",
"gateway_id": "KE590511-88",
"password": "12gKsOx5I794bunij",
"transaction_type": "01",
"cvv": "201"
}],
"invalid_amount": [
{
"amount": "",
"cardholder_name": "Simon Jones",
"cc_expiry": "1224",
"cc_number": "4761739001010119",
"gateway_id": "KE590511-88",
"password": "12gKsOx5I794bunij",
"transaction_type": "01",
"cvv": "201"
}],
"invalid_cvv": [
{
"amount": "10",
"cardholder_name": "Simon Jones",
"cc_expiry": "1224",
"cc_number": "4761739001010119",
"gateway_id": "KE590511-88",
"password": "12gKsOx5I794bunij",
"transaction_type": "01",
"cvv": "20"
}]
}
And below is the test
let request;
describe('Given the Users api', () => {
before(function () {
cy.fixture("transactionRequest").then(data => {
this.data = data;
request = [
this.data.invalid_transactionType,
this.data.missing_transactionType,
this.data.invalid_CardNumber,
this.data.invalid_expDate,
this.data.invalid_gatewayId,
this.data.invalid_password,
this.data.invalid_amount,
this.data.invalid_cvv,
]
})
})
context('When I send POST /transaction', () => {
it('Then it should send a transaction', () => {
cy.request({
method: 'POST',
url: "/transaction",
body: request
})
.should((response) => {
expect(response.status, 'successful POST').eq(200)
});
});
});
});