11/* eslint-disable @typescript-eslint/no-explicit-any */
22
3+ import { getDollarValue } from "@/lib/utils/formatters" ;
34import { generateFormationDbaContent } from "@/test/factories" ;
45import {
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 ( ) => {
0 commit comments