Skip to content

Commit

Permalink
Improve end-to-end tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lchrusciel committed Oct 31, 2024
1 parent 1d4859a commit 7c0c57a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
18 changes: 3 additions & 15 deletions tests/E2E/Checkout/TpayCreditCardCheckoutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,38 +26,26 @@ protected function setUp(): void

$this->loadFixtures(['addressed_cart.yaml']);

// the cart is already addressed, so we go straight to selecting a shipping method
$this->loginShopUser('[email protected]', 'sylius');
$this->showSelectingShippingMethodStep();
$this->processWithDefaultShippingMethod();
}

public function test_it_completes_the_checkout_using_credit_card(): void
{
$this->loginShopUser('[email protected]', 'sylius');

$this->processWithPaymentMethod('tpay_card');
$this->fillCardData(self::FORM_ID, self::CARD_NUMBER, '123', '01', '2029');
$this->placeOrder();

$this->assertPageTitleContains('Thank you!');
$this->assertPageTitleContains('Waiting for payment');
}

public function test_it_completes_the_checkout_using_credit_card_and_saves_the_card(): void
{
$this->loginShopUser('[email protected]', 'sylius');

$this->processWithPaymentMethod('tpay_card');
$this->fillCardData(self::FORM_ID, self::CARD_NUMBER, '123', '01', '2029', true);
$this->placeOrder();

$this->assertPageTitleContains('Thank you!');
}

public function test_it_forbids_card_saving_for_not_logged_in_users(): void
{
$this->expectException(NoSuchElementException::class);

$this->processWithPaymentMethod('tpay_card');
$this->fillCardData(self::FORM_ID, self::CARD_NUMBER, '123', '01', '2029', true);
$this->assertPageTitleContains('Waiting for payment');
}
}
2 changes: 1 addition & 1 deletion tests/E2E/Helper/Order/TpayTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function fillCardData(string $formId, string $cardNumber, string $cvv, st
$this->client->findElement(WebDriverBy::id(sprintf('%s_tpay_card_expiration_date_year', $formId)))->sendKeys($year);

if ($saveCardForLater) {
$this->client->findElement(WebDriverBy::id(sprintf('%s_tpay_saveCreditCardForLater', $formId)))->click();
$this->client->findElement(WebDriverBy::id(sprintf('%s_tpay_save_credit_card_for_later', $formId)))->sendKeys(true);
}
}

Expand Down

0 comments on commit 7c0c57a

Please sign in to comment.