Skip to content

Commit

Permalink
test(connector): [Checkout] Add tests for 3DS and Gpay (#1267)
Browse files Browse the repository at this point in the history
Co-authored-by: Jagan Elavarasan <[email protected]>
Co-authored-by: Arjun Karthik <[email protected]>
  • Loading branch information
3 people authored Jun 28, 2023
1 parent 5f83fae commit 218803a
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 0 deletions.
96 changes: 96 additions & 0 deletions crates/router/tests/connectors/checkout_ui.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
use serial_test::serial;
use thirtyfour::{prelude::*, WebDriver};

use crate::{selenium::*, tester};

struct CheckoutSeleniumTest;

impl SeleniumTest for CheckoutSeleniumTest {
fn get_connector_name(&self) -> String {
"checkout".to_string()
}
}

async fn should_make_frictionless_3ds_payment(c: WebDriver) -> Result<(), WebDriverError> {
let mycon = CheckoutSeleniumTest {};
mycon
.make_redirection_payment(
c,
vec![
Event::Trigger(Trigger::Goto(&format!("{CHEKOUT_BASE_URL}/saved/18"))),
Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))),
Event::Assert(Assert::IsPresent("Google Search")),
Event::Trigger(Trigger::Sleep(5)), //url gets updated only after some time, so need this timeout to solve the issue
Event::Assert(Assert::ContainsAny(
Selector::QueryParamStr,
vec!["status=succeeded", "status=processing"],
)),
],
)
.await?;
Ok(())
}

async fn should_make_3ds_payment(c: WebDriver) -> Result<(), WebDriverError> {
let mycon = CheckoutSeleniumTest {};
mycon
.make_redirection_payment(
c,
vec![
Event::Trigger(Trigger::Goto(&format!("{CHEKOUT_BASE_URL}/saved/20"))),
Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))),
Event::Trigger(Trigger::Sleep(10)), //url gets updated only after some time, so need this timeout to solve the issue
Event::Trigger(Trigger::SwitchFrame(By::Name("cko-3ds2-iframe"))),
Event::Trigger(Trigger::SendKeys(By::Id("password"), "Checkout1!")),
Event::Trigger(Trigger::Click(By::Id("txtButton"))),
Event::Assert(Assert::IsPresent("Google")),
Event::Assert(Assert::ContainsAny(
Selector::QueryParamStr,
vec!["status=succeeded", "status=processing"],
)),
],
)
.await?;
Ok(())
}

async fn should_make_gpay_payment(c: WebDriver) -> Result<(), WebDriverError> {
let mycon = CheckoutSeleniumTest {};
mycon
.make_redirection_payment(
c,
vec![
Event::Trigger(Trigger::Goto(&format!("{CHEKOUT_BASE_URL}/saved/73"))),
Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))),
Event::Trigger(Trigger::Sleep(10)), //url gets updated only after some time, so need this timeout to solve the issue
Event::Trigger(Trigger::SwitchFrame(By::Name("cko-3ds2-iframe"))),
Event::Trigger(Trigger::SendKeys(By::Id("password"), "Checkout1!")),
Event::Trigger(Trigger::Click(By::Id("txtButton"))),
Event::Assert(Assert::IsPresent("Google")),
Event::Assert(Assert::ContainsAny(
Selector::QueryParamStr,
vec!["status=succeeded", "status=processing"],
)),
],
)
.await?;
Ok(())
}

#[test]
#[serial]
fn should_make_frictionless_3ds_payment_test() {
tester!(should_make_frictionless_3ds_payment);
}

#[test]
#[serial]
fn should_make_3ds_payment_test() {
tester!(should_make_3ds_payment);
}

#[test]
#[serial]
fn should_make_gpay_payment_test() {
tester!(should_make_gpay_payment);
}
1 change: 1 addition & 0 deletions crates/router/tests/connectors/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ mod bitpay;
mod bluesnap;
mod cashtocode;
mod checkout;
mod checkout_ui;
mod coinbase;
mod connector_auth;
mod cybersource;
Expand Down

0 comments on commit 218803a

Please sign in to comment.