Skip to content

Commit

Permalink
feat: Screen reader /mo for messages and modals (DTCRCMERC-1941) (#980)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikacolette29 authored Sep 26, 2023
1 parent cd574dd commit 507709e
Show file tree
Hide file tree
Showing 24 changed files with 71 additions and 20 deletions.
7 changes: 6 additions & 1 deletion content/messages/US/long_term_multi_eqz.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@
"headline": [
["Buy now, pay later.", ["default", "xsmall"]],
["Buy now and pay later.", ["xsmall.2"]],
[["As low as ${formattedMonthlyPayment}/mo at 0% APR."], ["small", "medium", "large", "xlarge"]]
[
[
"As low as ${formattedMonthlyPayment}/<span aria-hidden='true'>mo</span><span class='sr-only'>month</span> at 0% APR."
],
["small", "medium", "large", "xlarge"]
]
],
"subHeadline": [],
"disclaimer": [["<span aria-hidden='true'>Learn more</span><span class='sr-only'> Learn more</span>", ["default"]]]
Expand Down
7 changes: 6 additions & 1 deletion content/messages/US/long_term_multi_eqz_mixed.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@
"headline": [
["Buy now, pay later.", ["default", "xsmall"]],
["Buy now and pay later.", ["xsmall.2"]],
[["As low as ${formattedMonthlyPayment}/mo or 0% APR."], ["small", "medium", "large", "xlarge"]]
[
[
"As low as ${formattedMonthlyPayment}/<span aria-hidden='true'>mo</span><span class='sr-only'>month</span> or 0% APR."
],
["small", "medium", "large", "xlarge"]
]
],
"subHeadline": [],
"disclaimer": [["<span aria-hidden='true'>Learn more</span><span class='sr-only'> Learn more</span>", ["default"]]]
Expand Down
7 changes: 6 additions & 1 deletion content/messages/US/long_term_multi_gtz.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@
"headline": [
["Buy now, pay later.", ["default", "xsmall"]],
["Buy now and pay later.", ["xsmall.2"]],
[["As low as ${formattedMonthlyPayment}/mo."], ["small", "medium", "large", "xlarge"]]
[
[
"As low as ${formattedMonthlyPayment}/<span aria-hidden='true'>mo.</span><span class='sr-only'>month.</span>"
],
["small", "medium", "large", "xlarge"]
]
],
"subHeadline": [],
"disclaimer": [["<span aria-hidden='true'>Learn more</span><span class='sr-only'> Learn more</span>", ["default"]]]
Expand Down
4 changes: 3 additions & 1 deletion content/messages/US/long_term_single_eqz.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
["Buy now, pay later.", ["default", "xsmall"]],
["Buy now and pay later.", ["xsmall.2"]],
[
["Make ${total_payments} payments of ${formattedMonthlyPayment}/mo at 0% APR."],
[
"Make ${total_payments} payments of ${formattedMonthlyPayment}/<span aria-hidden='true'>mo</span><span class='sr-only'>month</span> at 0% APR."
],
["small", "medium", "large", "xlarge"]
]
],
Expand Down
4 changes: 3 additions & 1 deletion content/messages/US/long_term_single_eqz_mixed.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
["Buy now, pay later.", ["default", "xsmall"]],
["Buy now and pay later.", ["xsmall.2"]],
[
["Make ${total_payments} payments of ${formattedMonthlyPayment}/mo or 0% APR."],
[
"Make ${total_payments} payments of ${formattedMonthlyPayment}/<span aria-hidden='true'>mo</span><span class='sr-only'>month</span> or 0% APR."
],
["small", "medium", "large", "xlarge"]
]
],
Expand Down
7 changes: 6 additions & 1 deletion content/messages/US/long_term_single_gtz.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@
"headline": [
["Buy now, pay later.", ["default", "xsmall"]],
["Buy now and pay later.", ["xsmall.2"]],
[["Make ${total_payments} payments of ${formattedMonthlyPayment}/mo."], ["small", "medium", "large", "xlarge"]]
[
[
"Make ${total_payments} payments of ${formattedMonthlyPayment}/<span aria-hidden='true'>mo.</span><span class='sr-only'>month.</span>"
],
["small", "medium", "large", "xlarge"]
]
],
"subHeadline": [],
"disclaimer": [["<span aria-hidden='true'>Learn more</span><span class='sr-only'> Learn more</span>", ["default"]]]
Expand Down
11 changes: 9 additions & 2 deletions content/messages/US/ppc_ezp_multi_eqz.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,18 @@
},
"headline": [
[
[["As low as", "weak"], "{formattedMonthlyPayment}/mo.", ["at 0% APR.", "weakest"]],
[
["As low as", "weak"],
"{formattedMonthlyPayment}/<span aria-hidden='true'>mo.</span><span class='sr-only'>month.</span>",
["at 0% APR.", "weakest"]
],
["default", "small"]
],
[
[["Pay as low as", "weak"], "{formattedMonthlyPayment}/mo. at 0% APR"],
[
["Pay as low as", "weak"],
"{formattedMonthlyPayment}/<span aria-hidden='true'>mo.</span><span class='sr-only'>month.</span> at 0% APR"
],
["small.2", "medium", "large", "xlarge"]
],
["Enjoy Easy Payments.", ["legacy-small"]],
Expand Down
10 changes: 8 additions & 2 deletions content/messages/US/ppc_ezp_multi_gtz.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,17 @@
},
"headline": [
[
[["As low as", "weak"], "{formattedMonthlyPayment}/mo."],
[
["As low as", "weak"],
"{formattedMonthlyPayment}/<span aria-hidden='true'>mo.</span><span class='sr-only'>month.</span>"
],
["default", "xsmall"]
],
[
[["Pay as low as", "weak"], "{formattedMonthlyPayment}/mo."],
[
["Pay as low as", "weak"],
"{formattedMonthlyPayment}/<span aria-hidden='true'>mo.</span><span class='sr-only'>month.</span>"
],
["small", "medium", "large", "xlarge"]
],
["Enjoy Easy Payments.", ["legacy-xsmall"]]
Expand Down
6 changes: 5 additions & 1 deletion content/messages/US/ppc_ezp_single_eqz.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
},
"headline": [
[
[["Make {total_payments} payments of", "weak"], "{formattedMonthlyPayment}/mo.", ["at 0% APR.", "weakest"]],
[
["Make {total_payments} payments of", "weak"],
"{formattedMonthlyPayment}/<span aria-hidden='true'>mo.</span><span class='sr-only'>month.</span>",
["at 0% APR.", "weakest"]
],
["default", "small"]
],
["Enjoy Easy Payments.", ["legacy-xsmall"]],
Expand Down
5 changes: 4 additions & 1 deletion content/messages/US/ppc_ezp_single_gtz.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
},
"headline": [
[
[["Make {total_payments} payments of", "weak"], "{formattedMonthlyPayment}/mo."],
[
["Make {total_payments} payments of", "weak"],
"{formattedMonthlyPayment}/<span aria-hidden='true'>mo.</span><span class='sr-only'>month.</span>"
],
["default", "small"]
],
["Enjoy Easy Payments.", ["legacy-xsmall"]]
Expand Down
2 changes: 1 addition & 1 deletion content/offers/US/v2_long_term.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"nonZeroAPR": "*APR is 9.99% to 29.99% based on your credit. Terms may vary based on purchase amount."
},
"termsLabel": {
"offerHeader": "{formattedPeriodicPayment}/mo. for {total_payments} months",
"offerHeader": "{formattedPeriodicPayment}/<span aria-hidden='true'>mo.</span><span class='sr-only'>month.</span> for {total_payments} months",
"zeroApr": "APR",
"nonZeroApr": "<span aria-hidden='true'>Est. APR*</span><span class='sr-only'>Estimated APR, see star for more details below.</span>",
"totalInterest": "Interest",
Expand Down
4 changes: 3 additions & 1 deletion src/components/modal/v2/parts/OfferCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ const OfferCard = ({ offer: { content, meta } }) => {
const { termsLabel } = content;
const aprRemoveTrailingZeros = meta?.apr.replace(/\D00$/, '');
const aprFieldTitle = aprRemoveTrailingZeros === '0' ? termsLabel?.zeroApr : termsLabel?.nonZeroApr;
const offerHeaderField = termsLabel?.offerHeader;

return (
<div className="offer__container">
<div className="offer__row">
<strong className="offer__field-header">{termsLabel.offerHeader}</strong>
{/* eslint-disable-next-line react/no-danger */}
<strong className="offer__field-header" dangerouslySetInnerHTML={{ __html: offerHeaderField }} />
</div>
<div className="offer__row">
<div className="offer__field-col">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default {
headline: [
{
tag: 'medium',
br: ['mo.', 'as']
br: ['mo. <span>', 'as']
},
{
tag: 'xsmall'
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 10 additions & 5 deletions tests/functional/v2/testFn/longTerm.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ export const showCorrectOfferInfo = async (contentWindow, modalContent, testName
await contentWindow.waitForSelector(contentWrapper);
await contentWindow.waitForSelector(`${offerRow}:first-child`);
const offerFieldHeadline = await contentWindow.$eval(offerRow, element => element.innerText);
expect(offerFieldHeadline).toContain(modalContent.offerHeadline);
const newOfferFieldHeadline = offerFieldHeadline.replace('month.', '').replace(/\n/g, '');
expect(newOfferFieldHeadline).toContain(modalContent.offerHeadline);
await modalSnapshot(testName, contentWindow);
};

Expand Down Expand Up @@ -79,7 +80,8 @@ export const updateTermsViaCalc = async (contentWindow, modalContent, testName)

await contentWindow.waitForSelector(`${offerRow}:first-child`);
const offerFieldHeadline = await contentWindow.$eval(offerRow, element => element.innerText);
expect(offerFieldHeadline).toContain(modalContent.updatedOfferHeadline);
const newOfferFieldHeadline = offerFieldHeadline.replace('month.', '').replace(/\n/g, '');
expect(newOfferFieldHeadline).toContain(modalContent.updatedOfferHeadline);
await modalSnapshot(testName, contentWindow);
};

Expand All @@ -101,7 +103,8 @@ export const showCorrectAPRDisclaimer = async (contentWindow, modalContent, test
await contentWindow.waitForSelector(contentWrapper);
await contentWindow.waitForSelector(`${offerRow}:first-child`);
const offerFieldHeadline = await contentWindow.$eval(offerRow, element => element.innerText);
expect(offerFieldHeadline).toContain(modalContent.offerHeadline);
const newOfferFieldHeadline = offerFieldHeadline.replace('month.', '').replace(/\n/g, '');
expect(newOfferFieldHeadline).toContain(modalContent.offerHeadline);
await modalSnapshot(testName, contentWindow);
};

Expand All @@ -118,7 +121,8 @@ export const showCorrectOfferInfoAccordion = async (contentWindow, modalContent,
await contentWindow.waitForSelector(openAccordion);
await contentWindow.waitForSelector(accordionHeaderContainer);
const accordionOfferFieldHeadline = await contentWindow.$eval(accordionFieldHeader, element => element.innerText);
expect(accordionOfferFieldHeadline).toContain(modalContent.offerHeadline);
const newOfferFieldHeadline = accordionOfferFieldHeadline.replace('month.', '').replace(/\n/g, '');
expect(newOfferFieldHeadline).toContain(modalContent.offerHeadline);
await modalSnapshot(testName, contentWindow);
};

Expand Down Expand Up @@ -152,6 +156,7 @@ export const updateOfferAccordionTermsViaCalc = async (contentWindow, modalConte
await contentWindow.waitForSelector(openAccordion);
await contentWindow.waitForSelector(accordionHeaderContainer);
const accordionOfferFieldHeadline = await contentWindow.$eval(accordionFieldHeader, element => element.innerText);
expect(accordionOfferFieldHeadline).toContain(modalContent.updatedOfferHeadline);
const newOfferFieldHeadline = accordionOfferFieldHeadline.replace('month.', '').replace(/\n/g, '');
expect(newOfferFieldHeadline).toContain(modalContent.updatedOfferHeadline);
await modalSnapshot(testName, contentWindow);
};

0 comments on commit 507709e

Please sign in to comment.