Skip to content

Commit 97d5407

Browse files
committed
feat: [AB#12619] table labels on talkback read column header before cost content and total and subtotal content
1 parent d9a7f0a commit 97d5407

File tree

3 files changed

+89
-28
lines changed

3 files changed

+89
-28
lines changed

web/src/components/tasks/business-formation/billing/BillingStep.test.tsx

Lines changed: 57 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
22

3+
import { getDollarValue } from "@/lib/utils/formatters";
34
import { generateFormationDbaContent } from "@/test/factories";
45
import {
56
FormationPageHelpers,
@@ -54,6 +55,14 @@ describe("Formation - BillingStep", () => {
5455
const subtotalLabel = Config.formation.fields.paymentType.costSubtotalLabel;
5556
const totalLabel = "Total";
5657

58+
const composeSubTotalAria = (subTotalNumber: number): string => {
59+
return `${subtotalLabel} ${getDollarValue(subTotalNumber)}`;
60+
};
61+
62+
const composeTotalAria = (totalNumber: number): string => {
63+
return `* ${totalLabel} ${getDollarValue(totalNumber)}`;
64+
};
65+
5766
const getPageHelper = async (
5867
initialProfileData: Partial<ProfileData>,
5968
formationFormData: Partial<FormationFormData>,
@@ -160,8 +169,12 @@ describe("Formation - BillingStep", () => {
160169
const standingCost = Number.parseInt(Config.formation.fields.certificateOfStanding.cost);
161170
const expectedTotal = officialFormationCost + standingCost;
162171

163-
expect(screen.getByLabelText(subtotalLabel)).toHaveTextContent(expectedTotal.toString());
164-
expect(screen.getByLabelText(totalLabel)).toHaveTextContent(expectedTotal.toString());
172+
expect(
173+
screen.getByRole("generic", { name: composeTotalAria(expectedTotal) }),
174+
).toHaveTextContent(getDollarValue(expectedTotal));
175+
expect(
176+
screen.getByRole("generic", { name: composeSubTotalAria(expectedTotal) }),
177+
).toHaveTextContent(getDollarValue(expectedTotal));
165178
});
166179
}
167180

@@ -185,8 +198,12 @@ describe("Formation - BillingStep", () => {
185198
);
186199
const expectedTotal = officialFormationCost + standingCost;
187200

188-
expect(screen.getByLabelText(subtotalLabel)).toHaveTextContent(expectedTotal.toString());
189-
expect(screen.getByLabelText(totalLabel)).toHaveTextContent(expectedTotal.toString());
201+
expect(
202+
screen.getByRole("generic", { name: composeSubTotalAria(expectedTotal) }),
203+
).toHaveTextContent(expectedTotal.toString());
204+
expect(
205+
screen.getByRole("generic", { name: composeTotalAria(expectedTotal) }),
206+
).toHaveTextContent(expectedTotal.toString());
190207
});
191208
}
192209
});
@@ -220,35 +237,55 @@ describe("Formation - BillingStep", () => {
220237
},
221238
);
222239

223-
expect(screen.getByLabelText(subtotalLabel)).toHaveTextContent(
224-
officialFormationCost.toString(),
225-
);
240+
expect(
241+
screen.getByRole("generic", { name: composeSubTotalAria(officialFormationCost) }),
242+
).toHaveTextContent(officialFormationCost.toString());
226243
page.selectCheckboxByTestId("certificateOfStanding");
227-
expect(screen.getByLabelText(subtotalLabel)).toHaveTextContent(
228-
(officialFormationCost + certificateStandingCost).toString(),
229-
);
244+
expect(
245+
screen.getByRole("generic", {
246+
name: composeSubTotalAria(officialFormationCost + certificateStandingCost),
247+
}),
248+
).toHaveTextContent((officialFormationCost + certificateStandingCost).toString());
230249
page.selectCheckboxByTestId("certifiedCopyOfFormationDocument");
231-
expect(screen.getByLabelText(subtotalLabel)).toHaveTextContent(
250+
expect(
251+
screen.getByRole("generic", {
252+
name: composeSubTotalAria(
253+
officialFormationCost + certificateStandingCost + certifiedCopyCost,
254+
),
255+
}),
256+
).toHaveTextContent(
232257
(officialFormationCost + certificateStandingCost + certifiedCopyCost).toString(),
233258
);
234-
expect(screen.getByLabelText(totalLabel)).toHaveTextContent(
259+
expect(
260+
screen.getByRole("generic", {
261+
name: composeTotalAria(officialFormationCost + certificateStandingCost + certifiedCopyCost),
262+
}),
263+
).toHaveTextContent(
235264
(officialFormationCost + certificateStandingCost + certifiedCopyCost).toString(),
236265
);
237266
page.selectCheckboxByTestId("certificateOfStanding");
238267
const finalTotal = officialFormationCost + certifiedCopyCost;
239268

240-
expect(screen.getByLabelText(subtotalLabel)).toHaveTextContent(finalTotal.toString());
241-
expect(screen.getByLabelText(totalLabel)).toHaveTextContent(finalTotal.toString());
269+
expect(
270+
screen.getByRole("generic", { name: composeSubTotalAria(finalTotal) }),
271+
).toHaveTextContent(finalTotal.toString());
272+
expect(screen.getByRole("generic", { name: composeTotalAria(finalTotal) })).toHaveTextContent(
273+
finalTotal.toString(),
274+
);
242275

243276
fireEvent.click(screen.getByLabelText(Config.formation.fields.paymentType.creditCardLabel));
244-
expect(screen.getByLabelText(totalLabel)).toHaveTextContent(
245-
(finalTotal + ccInitialCost + ccExtraCost).toString(),
246-
);
277+
expect(
278+
screen.getByRole("generic", {
279+
name: composeTotalAria(finalTotal + ccInitialCost + ccExtraCost),
280+
}),
281+
).toHaveTextContent((finalTotal + ccInitialCost + ccExtraCost).toString());
247282
fireEvent.click(screen.getByLabelText(Config.formation.fields.paymentType.achLabel));
248283
const numberOfDocuments = 2;
249-
expect(screen.getByLabelText(totalLabel)).toHaveTextContent(
250-
(finalTotal + achCost * numberOfDocuments).toString(),
251-
);
284+
expect(
285+
screen.getByRole("generic", {
286+
name: composeTotalAria(finalTotal + achCost * numberOfDocuments),
287+
}),
288+
).toHaveTextContent((finalTotal + achCost * numberOfDocuments).toString());
252289
});
253290

254291
it("uses name from profile when business formation data is not set", async () => {

web/src/components/tasks/business-formation/billing/FormationChooseDocuments.tsx

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,20 @@ export const FormationChooseDocuments = (): ReactElement => {
6161
});
6262
};
6363

64+
const costColumnHeader = Config.formation.fields.paymentType.costColumnLabel;
65+
6466
return (
6567
<div className={`margin-top-3`}>
66-
<table className="business-formation-table business-formation-document">
68+
<table className="business-formation-table business-formation-document" role="table">
6769
<thead>
6870
<tr>
69-
<th className="text-bold">{Config.formation.fields.paymentType.serviceColumnLabel}</th>
71+
<th scope="col" role="columnheader" className="text-bold">
72+
{Config.formation.fields.paymentType.serviceColumnLabel}
73+
</th>
7074
<th></th>
71-
<th className="text-bold">{Config.formation.fields.paymentType.costColumnLabel}</th>
75+
<th scope="col" role="columnheader" className="text-bold">
76+
{costColumnHeader}
77+
</th>
7278
</tr>
7379
</thead>
7480
<tbody>
@@ -90,7 +96,10 @@ export const FormationChooseDocuments = (): ReactElement => {
9096
/>
9197
</label>
9298
</td>
93-
<td className={"text-primary-dark text-bold"}>
99+
<td
100+
className={"text-primary-dark text-bold"}
101+
aria-label={`${costColumnHeader} ${getDollarValue(officialFormationCost)}`}
102+
>
94103
{getDollarValue(officialFormationCost)}
95104
</td>
96105
</tr>
@@ -129,6 +138,7 @@ export const FormationChooseDocuments = (): ReactElement => {
129138
className={
130139
state.formationFormData.certificateOfStanding ? "text-primary-dark text-bold" : ""
131140
}
141+
aria-label={`${costColumnHeader} ${getDollarValue(certificateStandingCost)}`}
132142
>
133143
{getDollarValue(certificateStandingCost)}
134144
</td>
@@ -173,7 +183,9 @@ export const FormationChooseDocuments = (): ReactElement => {
173183
: ""
174184
}
175185
>
176-
{getDollarValue(certifiedCopyCost)}
186+
<div aria-label={`${costColumnHeader} ${getDollarValue(certifiedCopyCost)}`}>
187+
{getDollarValue(certifiedCopyCost)}
188+
</div>
177189
</td>
178190
</tr>
179191
</tbody>
@@ -188,7 +200,10 @@ export const FormationChooseDocuments = (): ReactElement => {
188200
</td>
189201
<td colSpan={1}></td>
190202
<td colSpan={1}>
191-
<div className="text-align-right text-bold" aria-label="Subtotal">
203+
<div
204+
className="text-align-right text-bold"
205+
aria-label={`${Config.formation.fields.paymentType.costSubtotalLabel} ${getDollarValue(totalCost)}`}
206+
>
192207
{getDollarValue(totalCost)}
193208
</div>
194209
</td>

web/src/components/tasks/business-formation/billing/PaymentTypeTable.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export const PaymentTypeTable = (): ReactElement => {
7777
};
7878

7979
const hasError = doesFieldHaveError(fieldName);
80+
const costColumnHeader = Config.formation.fields.paymentType.costColumnLabel;
8081

8182
return (
8283
<ScrollableFormFieldWrapper fieldName={fieldName}>
@@ -86,7 +87,9 @@ export const PaymentTypeTable = (): ReactElement => {
8687
<tr>
8788
<th className="text-bold">{Config.formation.fields.paymentType.label}</th>
8889
<th></th>
89-
<th className="text-bold">{Config.formation.fields.paymentType.costColumnLabel}</th>
90+
<th className="text-bold" id="cost-column-header">
91+
{costColumnHeader}
92+
</th>
9093
</tr>
9194
{hasError && (
9295
<tr>
@@ -130,6 +133,7 @@ export const PaymentTypeTable = (): ReactElement => {
130133
className={
131134
state.formationFormData.paymentType === "CC" ? "text-primary-dark text-bold" : ""
132135
}
136+
aria-label={`${costColumnHeader} ${getDollarValue(creditCardCost)}`}
133137
>
134138
{getDollarValue(creditCardCost)}
135139
</td>
@@ -165,6 +169,7 @@ export const PaymentTypeTable = (): ReactElement => {
165169
className={
166170
state.formationFormData.paymentType === "ACH" ? "text-primary-dark text-bold" : ""
167171
}
172+
aria-label={`${costColumnHeader} ${getDollarValue(achCost)}`}
168173
>
169174
{getDollarValue(achCost)}
170175
</td>
@@ -180,7 +185,11 @@ export const PaymentTypeTable = (): ReactElement => {
180185
</div>
181186
</td>
182187
<td colSpan={1}>
183-
<div className="text-align-right text-bold" aria-label={"Total"}>
188+
<div
189+
className="text-align-right text-bold"
190+
data-testid="something"
191+
aria-label={`${Config.formation.fields.paymentType.costTotalLabel} ${getDollarValue(totalCost)}`}
192+
>
184193
{getDollarValue(totalCost)}
185194
</div>
186195
</td>

0 commit comments

Comments
 (0)