Skip to content

Commit

Permalink
update e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
artyom-jaksov-tl committed Dec 6, 2024
1 parent 005f461 commit e7511dc
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 48 deletions.
36 changes: 32 additions & 4 deletions .github/workflows/e2e-tests.yml

Large diffs are not rendered by default.

7 changes: 1 addition & 6 deletions tests/e2e/fixtures/base-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { ProductPage } from "../pages/product-page";
import { CheckoutPage } from "../pages/checkout-page";
import { HostedPaymentsPage } from "../pages/hosted-payments-page";
import { MockUkBankPage } from "../pages/mock-uk-bank-page";
import { PaymentConfirmationPage } from "../pages/payment-confirmation-page";
import { MockUkBankAccountsPage } from "../pages/mock-uk-bank-accounts-page";
import { OrderConfirmationPage } from "../pages/order-confirmation-page";

Expand All @@ -14,7 +13,6 @@ export const test = base.extend<{
hostedPaymentsPage: HostedPaymentsPage;
mockUkBankPage: MockUkBankPage;
mockUkBankAccountsPage: MockUkBankAccountsPage;
paymentConfirmationPage: PaymentConfirmationPage;
orderConfirmationPage: OrderConfirmationPage;

}>({
Expand All @@ -33,10 +31,7 @@ export const test = base.extend<{
mockUkBankAccountsPage: async ({ page }, use) => {
await use(new MockUkBankAccountsPage(page));
},
paymentConfirmationPage: async ({ page }, use) => {
await use(new PaymentConfirmationPage(page));
},
orderConfirmationPage: async ({ page }, use) => {
await use(new OrderConfirmationPage(page));
},
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ test.describe('Truelayer magento plugin E2E Tests', () => {
hostedPaymentsPage,
mockUkBankPage,
mockUkBankAccountsPage,
paymentConfirmationPage,
orderConfirmationPage,
}) => {
// arrange
await productPage.navigateTo();
await productPage.addToCart();
await checkoutPage.navigateToShippingStep();
await checkoutPage.fillShippingDetailsAndSubmit('[email protected]');
await checkoutPage.fillShippingDetailsAndSubmit('[email protected]', isMobile);
await checkoutPage.clickPaymentMethod();
await checkoutPage.clickPlaceOrderButton();

Expand All @@ -28,7 +27,6 @@ test.describe('Truelayer magento plugin E2E Tests', () => {
}
await mockUkBankPage.enterOnlineBankingDetailsAndContinue();
await mockUkBankAccountsPage.selectAccountAndContinue();
// await paymentConfirmationPage.waitForProcessingAndContinue();
await orderConfirmationPage.waitForProcessingAndReturnToStore();
})
});
13 changes: 7 additions & 6 deletions tests/e2e/pages/checkout-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class CheckoutPage {

// Methods

async fillShippingDetailsAndSubmit(email: string) {
async fillShippingDetailsAndSubmit(email: string, isMobile: boolean = false) {
await this.emailField().isVisible();
await this.emailField().fill(email);
await this.firstNameField().isVisible();
Expand All @@ -41,6 +41,9 @@ export class CheckoutPage {
await this.addressField().fill('10 Downing Street')
await this.postcodeField().isVisible();
await this.postcodeField().fill('SW1A 2AB');
if (isMobile) {
await this.page.locator('body').click({position: {x: 0, y: 0}});
}

await this.submitShippingInfoAndWaitForPageLoad();
}
Expand All @@ -52,11 +55,9 @@ export class CheckoutPage {
}

async submitShippingInfoAndWaitForPageLoad() {
await this.nextStepButton().isEnabled();
await expect(this.nextStepButton()).toBeEnabled({timeout: 5000});
await this.nextStepButton().click();
await this.page.waitForSelector('.loading-mask', { state: 'visible' });
await this.page.waitForSelector('.loading-mask', { state: 'hidden' });
await this.page.waitForSelector(this.paymentMethodSelector, { state: 'visible' });
await this.page.waitForSelector(this.paymentMethodSelector, { state: 'visible', timeout: 15000 });
}

async clickPaymentMethod() {
Expand All @@ -72,4 +73,4 @@ export class CheckoutPage {
await this.placeOrderButton().isEnabled();
await this.placeOrderButton().click();
}
}
}
8 changes: 4 additions & 4 deletions tests/e2e/pages/hosted-payments-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export class HostedPaymentsPage {
}

// Locators
mockBank = () => this.page.getByLabel('Select Mock UK Payments - Redirect Flow', { exact: true });
continueButton = () => this.page.getByTestId('confirm-redirect-button');
continueOnDesktopButton = () => this.page.getByTestId('continue-desktop');
mockBank = () => this.page.getByText('Mock UK Payments - Redirect Flow', { exact: true });
continueButton = () => this.page.getByTestId('go-to-bank-button');
continueOnDesktopButton = () => this.page.getByText('on this device');

// Methods
async selectMockBankAndContinueOnDesktop() {
Expand All @@ -29,4 +29,4 @@ export class HostedPaymentsPage {
await this.continueButton().isVisible();
await this.continueButton().click();
}
}
}
8 changes: 6 additions & 2 deletions tests/e2e/pages/order-confirmation-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ export class OrderConfirmationPage {
// Methods
async waitForProcessingAndReturnToStore() {
await this.paymentBeingProcessedText().isVisible();
await expect(this.orderConfirmedText()).toBeVisible({timeout: 90000});
await this.expectOrderConfirmed(90000);
}
}

async expectOrderConfirmed(timeout: number) {
await expect(this.orderConfirmedText()).toBeVisible({timeout});
}
}
21 changes: 0 additions & 21 deletions tests/e2e/pages/payment-confirmation-page.ts

This file was deleted.

4 changes: 2 additions & 2 deletions tests/e2e/pages/product-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ export class ProductPage {
await this.addToCartButton().click();
const cartCounter = this.cartCounter()
await cartCounter.isVisible();
await expect(cartCounter).toHaveText('1', {timeout: 1000})
await expect(cartCounter).toHaveText('1', {timeout: 5000})
}

async navigateTo(){
const url = `${process.env.E2E_TEST_URL as string}/catalog/product/view/id/1/s/test-product/category/2/`;
await this.page.goto(url);
}
}
}

0 comments on commit e7511dc

Please sign in to comment.