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

copy update for update amount SP form (with old min amount) #1352

Merged
merged 2 commits into from
Jul 3, 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 @@ -80,7 +80,13 @@ function validateChoice(
} else if (!chosenAmount || isNaN(chosenOptionNum)) {
return 'There is a problem with the amount you have selected, please make sure it is a valid amount';
} else if (!isNaN(chosenOptionNum) && chosenOptionNum < minAmount) {
return `${mainPlan.currency}${minAmount} per ${mainPlan.billingPeriod} is the minimum payment to receive this subscription. Please call our customer service team to lower your ${monthlyOrAnnual} amount below ${mainPlan.currency}${minAmount} via the Help Centre`;
return `${mainPlan.currency}${minAmount} per ${
mainPlan.billingPeriod
} is the ${
currentAmount < minAmount ? 'new ' : ''
}minimum payment to receive this subscription. Please call our customer service team to lower your ${monthlyOrAnnual} amount below ${
mainPlan.currency
}${minAmount} via the Help Centre`;
} else if (!isNaN(chosenOptionNum) && chosenOptionNum > maxAmount) {
return `There is a maximum ${mainPlan.billingPeriod}ly amount of ${mainPlan.currency}${maxAmount} ${mainPlan.currencyISO}`;
}
Expand All @@ -104,6 +110,8 @@ export const SupporterPlusUpdateAmountForm = (
] || supporterPlusPriceConfigByCountryGroup.international)[
props.mainPlan.billingPeriod
];
const currentAmountIsBelowNewMin =
props.currentAmount < priceConfig.minAmount;

const minPriceDisplay = `${props.mainPlan.currency}${priceConfig.minAmount}`;
const monthlyOrAnnual = getBillingPeriodAdjective(
Expand Down Expand Up @@ -355,17 +363,21 @@ export const SupporterPlusUpdateAmountForm = (
size="medium"
/>
<p>
If you would like to lower your{' '}
{monthlyOrAnnual.toLowerCase()} amount below{' '}
{minPriceDisplay} please call us via the{' '}
If you would like to{' '}
{currentAmountIsBelowNewMin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would change work in both cases here? Only ask because it would simplify the code a bit!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah possibly .. I took a steer from the stakeholders re the copy here:
Screenshot 2024-07-03 at 11 35 20

? 'change'
: 'lower'}{' '}
your {monthlyOrAnnual.toLowerCase()} amount
below {minPriceDisplay} please call us via the{' '}
<Link href="/help-centre#call-us">
Help Centre
</Link>
</p>
</div>
<p css={smallPrintCss}>
{minPriceDisplay} per {props.mainPlan.billingPeriod}{' '}
is the minimum payment to receive this subscription.
is the {currentAmountIsBelowNewMin ? 'new ' : ''}
minimum payment to receive this subscription.
</p>
</div>
</div>
Expand Down
8 changes: 8 additions & 0 deletions client/fixtures/productBuilder/testProducts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,14 @@ export function supporterPlusMonthlyAllAccessDigital() {
.getProductDetailObject();
}

export function supporterPlusMonthlyAllAccessDigitalBeforePriceRise() {
return new ProductBuilder(baseSupporterPlus())
.payByCard()
.withPrice(1000)
.withBillingPeriod('month')
.getProductDetailObject();
}

export function supporterPlusAnnual() {
return new ProductBuilder(baseSupporterPlus())
.payByCard()
Expand Down
64 changes: 62 additions & 2 deletions cypress/tests/mocked/parallel-1/updateContributionAmount.cy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
contributionPaidByCard,
supporterPlus,
supporterPlusMonthlyAllAccessDigital,
supporterPlusMonthlyAllAccessDigitalBeforePriceRise,
} from '../../../../client/fixtures/productBuilder/testProducts';
import { toMembersDataApiResponse } from '../../../../client/fixtures/mdapiResponse';
import { signInAndAcceptCookies } from '../../../lib/signInAndAcceptCookies';
Expand Down Expand Up @@ -87,7 +88,9 @@ describe('Update contribution amount', () => {
it('Updates supporter plus amount', () => {
cy.intercept('GET', '/api/me/mma', {
statusCode: 200,
body: toMembersDataApiResponse(supporterPlus()),
body: toMembersDataApiResponse(
supporterPlusMonthlyAllAccessDigital(),
),
});
cy.visit('/?withFeature=supporterPlusUpdateAmount');

Expand All @@ -98,6 +101,10 @@ describe('Update contribution amount', () => {

cy.findByText('Change amount').click();

cy.contains(
/£\d{2,3} per month is the minimum payment to receive this subscription./,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we fuzzy matching the amount here to account for future config changes? (I.e. so this test doesn't have to be updated each time the config changes?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I fuzzy matched here to reduce the number of places that you would have to update if/when we do another price rise ... there are still places where you have to do it manually though, so this doesn't solve that 'problem' everywhere, only here.

).should('exist');

cy.get(
'[data-cy="supporter-plus-amount-choices"] label:first-of-type',
).click();
Expand All @@ -110,4 +117,57 @@ describe('Update contribution amount', () => {
'We have successfully updated the amount of your support.',
).should('exist');
});

it('Updates supporter plus amount (for user on old lower min amount)', () => {
cy.intercept('GET', '/api/me/mma', {
statusCode: 200,
body: toMembersDataApiResponse(
supporterPlusMonthlyAllAccessDigitalBeforePriceRise(),
),
});
cy.visit('/?withFeature=supporterPlusUpdateAmount');

setSignInStatus();

cy.findByText('Manage subscription').click();
cy.wait('@cancelled');

cy.findByText('Change amount').click();

cy.get(
'[data-cy="supporter-plus-amount-choices"] label:last-of-type',
).click();

cy.contains('label', 'Other amount (£)').parent().find('input').clear();
cy.contains('label', 'Other amount (£)')
.parent()
.find('input')
.type('11');

cy.contains(
/If you would like to change your monthly amount below £\d{2,3} please call us via the/,
).should('exist');

cy.contains(
/£\d{2,3} per month is the new minimum payment to receive this subscription. Please call our customer service team to lower your monthly amount below £\d{2,3} via the Help Centre/,
).should('exist');

cy.contains(
/£\d{2,3} per month is the new minimum payment to receive this subscription.$/,
).should('exist');

cy.contains('label', 'Other amount (£)').parent().find('input').clear();
cy.contains('label', 'Other amount (£)')
.parent()
.find('input')
.type('16');

cy.findByText('Change amount').click();

cy.wait('@supporter_plus_update_amount');

cy.contains(
'We have successfully updated the amount of your support.',
).should('exist');
});
});
Loading