Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E2E tests for riverty #1169

Merged
merged 6 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,8 @@
}, {
"id": "ja_JP",
"currencyCode": "JPY"
},
{
"id": "de_DE",
"currencyCode": "EUR"
}]
1 change: 1 addition & 0 deletions tests/playwright/data/enums.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export const regionsEnum = {
SE: 'sv_SE',
IN: 'hi_IN',
JP: 'ja_JP',
DE: 'de_DE',
};
17 changes: 17 additions & 0 deletions tests/playwright/data/shopperData.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,21 @@ export class ShopperData {
houseNumberOrName: '37',
},
};
DERiverty = {
shopperName: {
firstName: 'John',
lastName: 'Doe',
},
telephone: '0513744112',
successShopperEmail: '[email protected]',
refusalShopperEmail: '[email protected]',
address: {
city: 'Verl',
country: 'DE',
stateOrProvince: '',
postalCode: '33415',
street: 'Gütersloher Str.',
houseNumberOrName: '123',
},
};
}
44 changes: 44 additions & 0 deletions tests/playwright/fixtures/countriesEUR/DE.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,48 @@ for (const environment of environments) {
await checkoutPage.expectRefusal() || test.skip();
});
});

test.describe.parallel(`${environment.name} Riverty EUR DE`, () => {
test.beforeEach(async ({ page }) => {
await page.goto(`${environment.urlExtension}`);
checkoutPage = new environment.CheckoutPage(page);
});

async function rivertyCheckoutFlow({ page, email, shopperDetails, expectSuccess = true }) {
await checkoutPage.goToCheckoutPageWithFullCart(regionsEnum.DE, 1, email);
await checkoutPage.setShopperDetails(shopperDetails);

// SFRA 5 email setting flow is different
if (environment.name.indexOf('v5') !== -1) {
await checkoutPage.setEmail(email);
}
redirectShopper = new RedirectShopper(page);
await redirectShopper.doRivertyPayment(email);
await checkoutPage.completeCheckout();

if (expectSuccess) {
await checkoutPage.expectSuccess();
} else {
await checkoutPage.expectRefusal();
}
}

test('Riverty Success @quick', async ({ page }) => {
await rivertyCheckoutFlow({
page,
email: shopperData.DERiverty.successShopperEmail,
shopperDetails: shopperData.DERiverty,
expectSuccess: true,
});
});

test('Riverty Failure @quick', async ({ page }) => {
await rivertyCheckoutFlow({
page,
email: shopperData.DERiverty.refusalShopperEmail,
shopperDetails: shopperData.DERiverty,
expectSuccess: false,
});
});
});
}
4 changes: 2 additions & 2 deletions tests/playwright/pages/CheckoutPageSFRA5.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ export default class CheckoutPageSFRA5 {
await this.submitShipping();
};

setEmail = async () => {
setEmail = async (email = '[email protected]') => {
await this.checkoutPageUserEmailInput.fill('');
await this.checkoutPageUserEmailInput.fill('[email protected]');
await this.checkoutPageUserEmailInput.fill(email);
// Pressing Tab to simulate component re-rendering and waiting the components to re-mount
await this.page.keyboard.press('Tab');
await new Promise(r => setTimeout(r, 2000));
Expand Down
8 changes: 4 additions & 4 deletions tests/playwright/pages/CheckoutPageSFRA6.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ export default class CheckoutPageSFRA {
await this.page.goto(this.getCartUrl(locale));
}

goToCheckoutPageWithFullCart = async (locale, itemCount = 1) => {
goToCheckoutPageWithFullCart = async (locale, itemCount = 1, email) => {
await this.addProductToCart(locale, itemCount);
await this.successMessage.waitFor({ visible: true, timeout: 20000 });

await this.navigateToCheckout(locale);
await this.setEmail();
await this.setEmail(email);
await this.checkoutGuest.click();
};

Expand Down Expand Up @@ -165,13 +165,13 @@ export default class CheckoutPageSFRA {
await this.submitShipping();
};

setEmail = async () => {
setEmail = async (email = '[email protected]') => {
/* After filling the shopper details, clicking "Next" has an autoscroll
feature, which leads the email field to be missed, hence the flakiness.
Waiting until the full page load prevents this situation */
await this.page.waitForLoadState('networkidle');
await this.checkoutPageUserEmailInput.fill('');
await this.checkoutPageUserEmailInput.fill('[email protected]');
await this.checkoutPageUserEmailInput.fill(email);
};

submitShipping = async () => {
Expand Down
10 changes: 2 additions & 8 deletions tests/playwright/pages/PaymentMethodsPage.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -453,14 +453,8 @@ export default class PaymentMethodsPage {
cancelKlarnaPayment = async () => {
await this.waitForKlarnaLoad();
await this.page.waitForLoadState('networkidle', { timeout: 20000 });
this.firstCancelButton = this.page.locator('#collectPhonePurchaseFlow__nav-bar__right-icon-wrapper');
this.secondCancelButton = this.page.locator("button[title='Close']");
await this.firstCancelButton.waitFor({
state: 'visible',
timeout: 25000,
});
await this.firstCancelButton.click();
await this.secondCancelButton.first().click();
this.cancelButton = this.page.locator("button[title='Close']");
await this.cancelButton.click();
await this.page.click("button[id='payment-cancel-dialog-express__confirm']");
};

Expand Down
8 changes: 8 additions & 0 deletions tests/playwright/paymentFlows/redirectShopper.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ export class RedirectShopper {
await this.page.click('#rb_giropay');
};

doRivertyPayment = async (email) => {
await this.page.click('#rb_riverty');
await this.page.fill('input[name="dateOfBirth"]', '1980-01-11');
await this.page.fill('input[name="shopperEmail"]', email);
// There is no static locator to click the checkbox
await this.page.locator('label:has-text("Ich stimme den")').click();
};

completeGiropayRedirect = async (success) => {
if (success) {
await this.paymentMethodsPage.confirmGiropayPayment();
Expand Down
Loading