11import { EmployerRates } from "@/components/employer-rates/EmployerRates" ;
2- import { DOL_EIN_CHARACTERS } from "@/components/employer-rates/EmployerRatesQuestions" ;
32import {
43 generateBusiness ,
54 generateEmployerRatesResponse ,
@@ -17,6 +16,7 @@ import { createTheme, ThemeProvider } from "@mui/material";
1716import * as api from "@/lib/api-client/apiClient" ;
1817import { WithStatefulUserData } from "@/test/mock/withStatefulUserData" ;
1918import { WithStatefulProfileData } from "@/test/mock/withStatefulProfileData" ;
19+ import { DOL_EIN_CHARACTERS } from "@/components/data-fields/DolEin" ;
2020
2121jest . mock ( "@businessnjgovnavigator/shared/dateHelpers" , ( ) => {
2222 const actual = jest . requireActual ( "@businessnjgovnavigator/shared/dateHelpers" ) ;
@@ -459,4 +459,79 @@ describe("EmployerRates", () => {
459459 expect ( screen . queryByTestId ( "noAccountError" ) ) . not . toBeInTheDocument ( ) ;
460460 expect ( await screen . findByRole ( "alert" ) ) . toBeInTheDocument ( ) ;
461461 } ) ;
462+
463+ it ( "removes the question and shows the success tables on successful response" , async ( ) => {
464+ mockApi . checkEmployerRates . mockResolvedValue (
465+ generateEmployerRatesResponse ( {
466+ error : "" ,
467+ } ) ,
468+ ) ;
469+
470+ renderComponentsWithOwning ( {
471+ employerAccessRegistration : true ,
472+ deptOfLaborEin : "123451234512345" ,
473+ businessName : "Test Business" ,
474+ } ) ;
475+
476+ const submit = await screen . findByRole ( "button" , {
477+ name : Config . employerRates . employerAccessYesButtonText ,
478+ } ) ;
479+
480+ await userEvent . click ( submit ) ;
481+
482+ expect ( screen . getByRole ( "alert" , { name : "success" } ) ) . toBeInTheDocument ( ) ;
483+ expect ( screen . getByRole ( "table" , { name : "Quarterly Contribution Rates" } ) ) . toBeInTheDocument ( ) ;
484+ expect ( screen . getByRole ( "table" , { name : "Total Contribution Rates" } ) ) . toBeInTheDocument ( ) ;
485+
486+ expect (
487+ screen . queryByRole ( "heading" , { name : Config . employerRates . employerAccessHeaderText } ) ,
488+ ) . not . toBeInTheDocument ( ) ;
489+ expect (
490+ screen . queryByRole ( "button" , { name : Config . employerRates . employerAccessYesButtonText } ) ,
491+ ) . not . toBeInTheDocument ( ) ;
492+ } ) ;
493+
494+ it ( "goes back to the question view if user edits quarter" , async ( ) => {
495+ mockApi . checkEmployerRates . mockResolvedValue (
496+ generateEmployerRatesResponse ( {
497+ error : "" ,
498+ } ) ,
499+ ) ;
500+
501+ renderComponentsWithOwning ( {
502+ employerAccessRegistration : true ,
503+ deptOfLaborEin : "123451234512345" ,
504+ businessName : "Test Business" ,
505+ } ) ;
506+
507+ const submit = await screen . findByRole ( "button" , {
508+ name : Config . employerRates . employerAccessYesButtonText ,
509+ } ) ;
510+
511+ await userEvent . click ( submit ) ;
512+
513+ expect ( screen . getByRole ( "alert" , { name : "success" } ) ) . toBeInTheDocument ( ) ;
514+ expect ( screen . getByRole ( "table" , { name : "Quarterly Contribution Rates" } ) ) . toBeInTheDocument ( ) ;
515+ expect ( screen . getByRole ( "table" , { name : "Total Contribution Rates" } ) ) . toBeInTheDocument ( ) ;
516+
517+ const editQuarter = screen . getByRole ( "button" , {
518+ name : Config . employerRates . editQuarterButtonText ,
519+ } ) ;
520+
521+ await userEvent . click ( editQuarter ) ;
522+ expect ( screen . queryByRole ( "alert" , { name : "success" } ) ) . not . toBeInTheDocument ( ) ;
523+ expect (
524+ screen . queryByRole ( "table" , { name : "Quarterly Contribution Rates" } ) ,
525+ ) . not . toBeInTheDocument ( ) ;
526+ expect (
527+ screen . queryByRole ( "table" , { name : "Total Contribution Rates" } ) ,
528+ ) . not . toBeInTheDocument ( ) ;
529+
530+ expect (
531+ screen . getByRole ( "heading" , { name : Config . employerRates . employerAccessHeaderText } ) ,
532+ ) . toBeInTheDocument ( ) ;
533+ expect (
534+ screen . getByRole ( "button" , { name : Config . employerRates . employerAccessYesButtonText } ) ,
535+ ) . toBeInTheDocument ( ) ;
536+ } ) ;
462537} ) ;
0 commit comments