Merge pull request #14644 from mozilla/update-payment-modes

[subplat] test(subplat): add test for resubscription and update mode of payment
This commit is contained in:
Ankita Shrivastava 2022-12-19 15:06:40 -05:00 коммит произвёл GitHub
Родитель 5dc1f39863 0360730a92
Коммит de16174254
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 128 добавлений и 37 удалений

Просмотреть файл

@ -18,6 +18,20 @@ export class SubscriptionManagementPage extends BaseLayout {
]);
}
async changeStripeCardDetails() {
await this.page
.locator('[data-testid="reveal-payment-update-button"]')
.click();
await this.page.locator('[data-testid="name"]').fill('Test User');
const frame = this.page.frame({ url: /elements-inner-card/ });
await frame.fill('.InputElement[name=cardnumber]', '');
await frame.fill('.InputElement[name=cardnumber]', '5555555555554444');
await frame.fill('.InputElement[name=exp-date]', '444');
await frame.fill('.InputElement[name=cvc]', '777');
await frame.fill('.InputElement[name=postal]', '88888');
await this.page.locator('[data-testid="submit"]').click();
}
async resubscribe() {
return Promise.all([
await this.page
@ -32,6 +46,12 @@ export class SubscriptionManagementPage extends BaseLayout {
]);
}
getCardInfo() {
return this.page
.locator('[data-testid="card-logo-and-last-four"]')
.textContent();
}
getResubscriptionPrice() {
return this.page
.locator('[data-testid="price-details-standalone"]')

Просмотреть файл

@ -180,41 +180,4 @@ test.describe('coupon test', () => {
// Verify the discount is removed
expect(await subscribe.discountLineItem()).toBe(false);
});
test('resubscribe successfully with the same coupon after canceling', async ({
page,
pages: { relier, subscribe, login, settings, subscriptionManagement },
}) => {
await relier.goto();
await relier.clickSubscribe6Month();
// 'auto10pforever' is a 10% forever discount coupon for a 6mo plan
await subscribe.addCouponCode('auto10pforever');
// Verify the coupon is applied successfully
expect(await subscribe.discountAppliedSuccess()).toBe(true);
const total = await subscribe.getTotalPrice();
//Subscribe successfully
await subscribe.setFullName();
await subscribe.setCreditCardInfo();
await subscribe.clickPayNow();
await subscribe.submit();
//Login to FxA account
await login.goto();
await login.clickSignIn();
const subscriptionPage = await settings.clickPaidSubscriptions();
subscriptionManagement.page = subscriptionPage;
//Cancel subscription
await subscriptionManagement.cancelSubscription();
await subscriptionManagement.resubscribe();
//Verify that the resubscription has the same coupon applied
expect(await subscriptionManagement.getResubscriptionPrice()).toEqual(
total
);
});
});

Просмотреть файл

@ -0,0 +1,108 @@
import { test, expect } from '../../../lib/fixtures/standard';
test.describe('resubscription test', () => {
test.beforeEach(() => {
test.slow();
});
test('resubscribe successfully with the same coupon after canceling for stripe', async ({
page,
pages: { relier, subscribe, login, settings, subscriptionManagement },
}) => {
await relier.goto();
await relier.clickSubscribe6Month();
// 'auto10pforever' is a 10% forever discount coupon for a 6mo plan
await subscribe.addCouponCode('auto10pforever');
// Verify the coupon is applied successfully
expect(await subscribe.discountAppliedSuccess()).toBe(true);
const total = await subscribe.getTotalPrice();
//Subscribe successfully with Stripe
await subscribe.setFullName();
await subscribe.setCreditCardInfo();
await subscribe.clickPayNow();
await subscribe.submit();
//Login to FxA account
await login.goto();
await login.clickSignIn();
const subscriptionPage = await settings.clickPaidSubscriptions();
subscriptionManagement.page = subscriptionPage;
//Cancel subscription and then resubscribe
await subscriptionManagement.cancelSubscription();
await subscriptionManagement.resubscribe();
//Verify that the resubscription has the same coupon applied
expect(await subscriptionManagement.getResubscriptionPrice()).toEqual(
total
);
});
test('resubscribe successfully with the same coupon after canceling for paypal', async ({
page,
pages: { relier, subscribe, login, settings, subscriptionManagement },
}) => {
await relier.goto();
await relier.clickSubscribe6Month();
// 'auto10pforever' is a 10% forever discount coupon for a 6mo plan
await subscribe.addCouponCode('auto10pforever');
// Verify the coupon is applied successfully
expect(await subscribe.discountAppliedSuccess()).toBe(true);
const total = await subscribe.getTotalPrice();
//Subscribe successfully using Paypal
await subscribe.setPayPalInfo();
await subscribe.submit();
//Login to FxA account
await login.goto();
await login.clickSignIn();
const subscriptionPage = await settings.clickPaidSubscriptions();
subscriptionManagement.page = subscriptionPage;
//Cancel subscription and then resubscribe
await subscriptionManagement.cancelSubscription();
await subscriptionManagement.resubscribe();
//Verify that the resubscription has the same coupon applied
expect(await subscriptionManagement.getResubscriptionPrice()).toEqual(
total
);
});
test('update mode of payment for stripe', async ({
page,
pages: { relier, subscribe, login, settings, subscriptionManagement },
}) => {
await relier.goto();
await relier.clickSubscribe6Month();
// 'auto10pforever' is a 10% forever discount coupon for a 6mo plan
await subscribe.addCouponCode('auto10pforever');
//Subscribe successfully
await subscribe.setFullName();
await subscribe.setCreditCardInfo();
await subscribe.clickPayNow();
await subscribe.submit();
//Login to FxA account
await login.goto();
await login.clickSignIn();
const subscriptionPage = await settings.clickPaidSubscriptions();
subscriptionManagement.page = subscriptionPage;
//Change stripe card information
await subscriptionManagement.changeStripeCardDetails();
//Verify that the card info is updated
expect(await subscriptionManagement.getCardInfo()).toContain('4444');
});
});