test(connector): Add tests for Paypal, Adyen and Airwallex (#1290)

Co-authored-by: Jagan Elavarasan <jaganelavarasan@gmail.com>
This commit is contained in:
Prasunna Soppa
2023-06-30 10:28:51 +05:30
committed by GitHub
parent 60e15ddabb
commit cd4dbcb3f6
4 changed files with 154 additions and 8 deletions

View File

@ -11,9 +11,56 @@ impl SeleniumTest for AdyenSeleniumTest {
}
}
async fn should_make_adyen_gpay_payment(c: WebDriver) -> Result<(), WebDriverError> {
async fn should_make_adyen_3ds_payment_failed(web_driver: WebDriver) -> Result<(), WebDriverError> {
let conn = AdyenSeleniumTest {};
conn.make_gpay_payment(c,
conn.make_redirection_payment(
web_driver,
vec![
Event::Trigger(Trigger::Goto(&format!("{CHEKOUT_BASE_URL}/saved/177"))),
Event::Assert(Assert::IsPresent("Expiry Year")),
Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))),
Event::Trigger(Trigger::SwitchFrame(By::Name("threeDSIframe"))),
Event::Assert(Assert::Eq(Selector::Title, "Payment Authentication")),
Event::Trigger(Trigger::SendKeys(By::ClassName("input-field"), "password")),
Event::Trigger(Trigger::Click(By::Id("buttonSubmit"))),
Event::Trigger(Trigger::Sleep(5)),
Event::Assert(Assert::IsPresent("Google")),
Event::Assert(Assert::Contains(Selector::QueryParamStr, "status=failed")),
],
)
.await?;
Ok(())
}
async fn should_make_adyen_3ds_payment_success(
web_driver: WebDriver,
) -> Result<(), WebDriverError> {
let conn = AdyenSeleniumTest {};
conn.make_redirection_payment(
web_driver,
vec![
Event::Trigger(Trigger::Goto(&format!("{CHEKOUT_BASE_URL}/saved/62"))),
Event::Assert(Assert::IsPresent("Expiry Year")),
Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))),
Event::Trigger(Trigger::SwitchFrame(By::Name("threeDSIframe"))),
Event::Assert(Assert::Eq(Selector::Title, "Payment Authentication")),
Event::Trigger(Trigger::SendKeys(By::ClassName("input-field"), "password")),
Event::Trigger(Trigger::Click(By::Id("buttonSubmit"))),
Event::Trigger(Trigger::Sleep(5)),
Event::Assert(Assert::IsPresent("Google")),
Event::Assert(Assert::Contains(
Selector::QueryParamStr,
"status=processing",
)),
],
)
.await?;
Ok(())
}
async fn should_make_adyen_gpay_payment(web_driver: WebDriver) -> Result<(), WebDriverError> {
let conn = AdyenSeleniumTest {};
conn.make_gpay_payment(web_driver,
&format!("{CHEKOUT_BASE_URL}/gpay?gatewayname=adyen&gatewaymerchantid=JuspayDEECOM&amount=70.00&country=US&currency=USD"),
vec![
Event::Assert(Assert::IsPresent("succeeded")),
@ -21,9 +68,11 @@ async fn should_make_adyen_gpay_payment(c: WebDriver) -> Result<(), WebDriverErr
Ok(())
}
async fn should_make_adyen_gpay_mandate_payment(c: WebDriver) -> Result<(), WebDriverError> {
async fn should_make_adyen_gpay_mandate_payment(
web_driver: WebDriver,
) -> Result<(), WebDriverError> {
let conn = AdyenSeleniumTest {};
conn.make_gpay_payment(c,
conn.make_gpay_payment(web_driver,
&format!("{CHEKOUT_BASE_URL}/gpay?gatewayname=adyen&gatewaymerchantid=JuspayDEECOM&amount=70.00&country=US&currency=USD&mandate_data[customer_acceptance][acceptance_type]=offline&mandate_data[customer_acceptance][accepted_at]=1963-05-03T04:07:52.723Z&mandate_data[customer_acceptance][online][ip_address]=127.0.0.1&mandate_data[customer_acceptance][online][user_agent]=amet%20irure%20esse&mandate_data[mandate_type][multi_use][amount]=7000&mandate_data[mandate_type][multi_use][currency]=USD"),
vec![
Event::Assert(Assert::IsPresent("succeeded")),
@ -37,10 +86,10 @@ async fn should_make_adyen_gpay_mandate_payment(c: WebDriver) -> Result<(), WebD
}
async fn should_make_adyen_gpay_zero_dollar_mandate_payment(
c: WebDriver,
web_driver: WebDriver,
) -> Result<(), WebDriverError> {
let conn = AdyenSeleniumTest {};
conn.make_gpay_payment(c,
conn.make_gpay_payment(web_driver,
&format!("{CHEKOUT_BASE_URL}/gpay?gatewayname=adyen&gatewaymerchantid=JuspayDEECOM&amount=0.00&country=US&currency=USD&mandate_data[customer_acceptance][acceptance_type]=offline&mandate_data[customer_acceptance][accepted_at]=1963-05-03T04:07:52.723Z&mandate_data[customer_acceptance][online][ip_address]=127.0.0.1&mandate_data[customer_acceptance][online][user_agent]=amet%20irure%20esse&mandate_data[mandate_type][multi_use][amount]=700&mandate_data[mandate_type][multi_use][currency]=USD"),
vec![
Event::Assert(Assert::IsPresent("succeeded")),
@ -53,9 +102,11 @@ async fn should_make_adyen_gpay_zero_dollar_mandate_payment(
Ok(())
}
async fn should_make_adyen_klarna_mandate_payment(c: WebDriver) -> Result<(), WebDriverError> {
async fn should_make_adyen_klarna_mandate_payment(
web_driver: WebDriver,
) -> Result<(), WebDriverError> {
let conn = AdyenSeleniumTest {};
conn.make_redirection_payment(c,
conn.make_redirection_payment(web_driver,
vec![
Event::Trigger(Trigger::Goto(&format!("{CHEKOUT_BASE_URL}/klarna-redirect?amount=70.00&country=SE&currency=SEK&mandate_data[customer_acceptance][acceptance_type]=offline&mandate_data[customer_acceptance][accepted_at]=1963-05-03T04:07:52.723Z&mandate_data[customer_acceptance][online][ip_address]=127.0.0.1&mandate_data[customer_acceptance][online][user_agent]=amet%20irure%20esse&mandate_data[mandate_type][multi_use][amount]=700&mandate_data[mandate_type][multi_use][currency]=SEK&return_url={CHEKOUT_BASE_URL}/payments"))),
Event::Trigger(Trigger::Click(By::Id("klarna-redirect-btn"))),
@ -105,4 +156,16 @@ fn should_make_adyen_klarna_mandate_payment_test() {
tester!(should_make_adyen_klarna_mandate_payment);
}
#[test]
#[serial]
fn should_make_adyen_3ds_payment_failed_test() {
tester!(should_make_adyen_3ds_payment_failed);
}
#[test]
#[serial]
fn should_make_adyen_3ds_payment_success_test() {
tester!(should_make_adyen_3ds_payment_success);
}
// https://hs-payments-test.netlify.app/paypal-redirect?amount=70.00&country=US&currency=USD&mandate_data[customer_acceptance][acceptance_type]=offline&mandate_data[customer_acceptance][accepted_at]=1963-05-03T04:07:52.723Z&mandate_data[customer_acceptance][online][ip_address]=127.0.0.1&mandate_data[customer_acceptance][online][user_agent]=amet%20irure%20esse&mandate_data[mandate_type][multi_use][amount]=700&mandate_data[mandate_type][multi_use][currency]=USD&apikey=dev_uFpxA0r6jjbVaxHSY3X0BZLL3erDUzvg3i51abwB1Bknu3fdiPxw475DQgnByn1z

View File

@ -0,0 +1,44 @@
use serial_test::serial;
use thirtyfour::{prelude::*, WebDriver};
use crate::{selenium::*, tester};
struct AirwallexSeleniumTest;
impl SeleniumTest for AirwallexSeleniumTest {
fn get_connector_name(&self) -> String {
"airwallex".to_string()
}
}
async fn should_make_airwallex_3ds_payment(web_driver: WebDriver) -> Result<(), WebDriverError> {
let conn = AirwallexSeleniumTest {};
conn.make_redirection_payment(
web_driver,
vec![
Event::Trigger(Trigger::Goto(&format!("{CHEKOUT_BASE_URL}/saved/85"))),
Event::Assert(Assert::IsPresent("Expiry Year")),
Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))),
Event::Trigger(Trigger::Query(By::ClassName("title"))),
Event::Assert(Assert::Eq(
Selector::Title,
"Airwallex - Create 3D Secure Payment",
)),
Event::Trigger(Trigger::SendKeys(By::Id("challengeDataEntry"), "1234")),
Event::Trigger(Trigger::Click(By::Id("submit"))),
Event::Assert(Assert::IsPresent("Google")),
Event::Assert(Assert::Contains(
Selector::QueryParamStr,
"status=succeeded",
)),
],
)
.await?;
Ok(())
}
#[test]
#[serial]
fn should_make_airwallex_3ds_payment_test() {
tester!(should_make_airwallex_3ds_payment);
}

View File

@ -9,6 +9,7 @@ mod aci;
mod adyen;
mod adyen_uk_ui;
mod airwallex;
mod airwallex_ui;
mod authorizedotnet;
mod bambora;
mod bambora_ui;
@ -42,6 +43,7 @@ mod opennode;
mod payeezy;
mod payme;
mod paypal;
mod paypal_ui;
mod payu;
mod payu_ui;
mod rapyd;

View File

@ -0,0 +1,37 @@
use serial_test::serial;
use thirtyfour::{prelude::*, WebDriver};
use crate::{selenium::*, tester};
struct PaypalSeleniumTest;
impl SeleniumTest for PaypalSeleniumTest {
fn get_connector_name(&self) -> String {
"paypal".to_string()
}
}
async fn should_make_paypal_paypal_wallet_payment(
web_driver: WebDriver,
) -> Result<(), WebDriverError> {
let conn = PaypalSeleniumTest {};
conn.make_paypal_payment(
web_driver,
&format!("{CHEKOUT_BASE_URL}/saved/21"),
vec![
Event::Assert(Assert::IsPresent("Google")),
Event::Assert(Assert::ContainsAny(
Selector::QueryParamStr,
vec!["status=succeeded"],
)),
],
)
.await?;
Ok(())
}
#[test]
#[serial]
fn should_make_paypal_paypal_wallet_payment_test() {
tester!(should_make_paypal_paypal_wallet_payment);
}