From 89687e911b9c32c8b00c3e5fa8f220448b3407d0 Mon Sep 17 00:00:00 2001 From: Arthur Morrow Date: Tue, 17 Sep 2024 11:18:49 -0400 Subject: [PATCH] fixed tests related to accessibility updates Jira ticket: CAMS-428 Co-authored-by: Arthur Morrow <133667008+amorrow-flexion@users.noreply.github.com> Co-authored-by: James Brooks <12275865+jamesobrooks@users.noreply.github.com> --- .../src/case-detail/CaseDetailScreen.test.tsx | 60 ++++++++++++++++--- .../panels/CaseDetailAuditHistory.test.tsx | 2 +- .../panels/CaseDetailHeader.test.tsx | 6 +- .../src/my-cases/MyCasesScreen.test.tsx | 6 +- .../screen/StaffAssignmentScreen.test.tsx | 19 +++++- 5 files changed, 77 insertions(+), 16 deletions(-) diff --git a/user-interface/src/case-detail/CaseDetailScreen.test.tsx b/user-interface/src/case-detail/CaseDetailScreen.test.tsx index f001fe9eb..5265a6737 100644 --- a/user-interface/src/case-detail/CaseDetailScreen.test.tsx +++ b/user-interface/src/case-detail/CaseDetailScreen.test.tsx @@ -7,6 +7,7 @@ import { formatDate } from '@/lib/utils/datetime'; import { CaseDetail } from '@common/cams/cases'; import { Debtor, DebtorAttorney } from '@common/cams/parties'; import { MockAttorneys } from '@common/cams/test-utilities/attorneys.mock'; +import * as detailHeader from './panels/CaseDetailHeader'; const caseId = '101-23-12345'; @@ -31,13 +32,57 @@ describe('Case Detail screen tests', () => { type MaybeString = string | undefined; - beforeAll(() => { + beforeEach(() => { + vi.restoreAllMocks(); process.env = { ...env, CAMS_PA11Y: 'true', }; }); + test('should render CaseDetailHeader', async () => { + const testCaseDetail: CaseDetail = { + caseId: caseId, + dxtrId: '123', + chapter: '15', + regionId: '02', + officeName: 'New York', + officeCode: '000', + caseTitle: 'The Beach Boys', + dateFiled: '01-04-1962', + judgeName: rickBHartName, + courtId: '01', + courtName: 'Court of Law', + courtDivisionName: 'Manhattan', + courtDivisionCode: '081', + debtorTypeLabel: 'Corporate Business', + petitionLabel: 'Voluntary', + closedDate: '01-08-1963', + dismissedDate: '01-08-1964', + assignments: [brianWilson, carlWilson], + debtor: { + name: 'Roger Rabbit', + address1: '123 Rabbithole Lane', + address2: 'Apt 117', + address3: 'Suite C', + cityStateZipCountry: 'Ciudad Obregón GR 25443, MX', + }, + debtorAttorney, + groupDesignator: '01', + regionName: 'Test Region', + }; + const headerSpy = vi.spyOn(detailHeader, 'default'); + + render( + + + , + ); + await waitFor(() => { + expect(headerSpy).toHaveBeenCalled(); + }); + }); + test('should display case title, case number, dates, assignees, judge name, and debtor for the case', async () => { const testCaseDetail: CaseDetail = { caseId: caseId, @@ -78,10 +123,11 @@ describe('Case Detail screen tests', () => { await waitFor( async () => { const title = screen.getByTestId('case-detail-heading-title'); - expect(title.innerHTML).toEqual('The Beach Boys'); + const expectedTitle = ` - ${testCaseDetail.caseTitle}`; + expect(title.innerHTML).toEqual(expectedTitle); const caseNumber = document.querySelector('.case-number'); - expect(caseNumber?.innerHTML).toEqual(getCaseNumber(caseId)); + expect(caseNumber?.innerHTML).toEqual(caseId); const dateFiled = screen.getByTestId('case-detail-filed-date'); expect(dateFiled).toHaveTextContent('Filed'); @@ -99,9 +145,7 @@ describe('Case Detail screen tests', () => { expect(chapter.innerHTML).toEqual('Voluntary Chapter 15'); const courtName = screen.getByTestId('court-name-and-district'); - expect(courtName.innerHTML).toEqual( - `Court of Law - Manhattan (${testCaseDetail.courtDivisionCode})`, - ); + expect(courtName.innerHTML).toEqual(`Court of Law (${testCaseDetail.courtDivisionName})`); const region = screen.getByTestId('case-detail-region-id'); expect(region.innerHTML).toEqual('Region 2 - New York Office'); @@ -607,11 +651,11 @@ describe('Case Detail screen tests', () => { , ); - + const expectedTitle = ` - ${testCaseDetail.caseTitle}`; await waitFor( async () => { const title = screen.getByTestId('case-detail-heading-title'); - expect(title.innerHTML).toEqual('The Beach Boys'); + expect(title.innerHTML).toEqual(expectedTitle); const unassignedElement = document.querySelector('.unassigned-placeholder'); expect(unassignedElement).toBeInTheDocument(); diff --git a/user-interface/src/case-detail/panels/CaseDetailAuditHistory.test.tsx b/user-interface/src/case-detail/panels/CaseDetailAuditHistory.test.tsx index 22b4425e6..955d9e902 100644 --- a/user-interface/src/case-detail/panels/CaseDetailAuditHistory.test.tsx +++ b/user-interface/src/case-detail/panels/CaseDetailAuditHistory.test.tsx @@ -133,7 +133,7 @@ describe('audit history tests', () => { render(); const emptyAssignments = await screen.findByTestId('empty-assignments-test-id'); - expect(emptyAssignments).toHaveTextContent('There are no assignments in the case history.'); + expect(emptyAssignments).toHaveTextContent('No changes have been made to this case'); const historyTable = screen.queryByTestId('history-table'); expect(historyTable).not.toBeInTheDocument(); diff --git a/user-interface/src/case-detail/panels/CaseDetailHeader.test.tsx b/user-interface/src/case-detail/panels/CaseDetailHeader.test.tsx index 32dee83e6..57ca6269c 100644 --- a/user-interface/src/case-detail/panels/CaseDetailHeader.test.tsx +++ b/user-interface/src/case-detail/panels/CaseDetailHeader.test.tsx @@ -67,14 +67,14 @@ describe('Case Detail Header tests', () => { const app = await screen.findByTestId('app-component-test-id'); await waitFor( async () => { - const heading = await screen.findByTestId('case-detail-heading'); - expect(heading.innerHTML).toEqual('Case Detail'); + const heading = await screen.findByTestId('case-detail-heading-title'); + expect(heading.innerHTML).toEqual(` - ${testCaseDetail.caseTitle}`); }, { timeout: 1000 }, ); await waitFor(async () => { const title = await screen.findByTestId('case-detail-heading-title'); - expect(title.innerHTML).toEqual(testCaseDetail.caseTitle); + expect(title.innerHTML).toEqual(` - ${testCaseDetail.caseTitle}`); }); let normalHeader = await screen.findByTestId('case-detail-header'); diff --git a/user-interface/src/my-cases/MyCasesScreen.test.tsx b/user-interface/src/my-cases/MyCasesScreen.test.tsx index 695845678..76268e757 100644 --- a/user-interface/src/my-cases/MyCasesScreen.test.tsx +++ b/user-interface/src/my-cases/MyCasesScreen.test.tsx @@ -82,7 +82,11 @@ describe('MyCasesScreen', () => { }); vi.spyOn(LocalStorage, 'getSession').mockReturnValue(MockData.getCamsSession({ user })); - render(); + render( + + + , + ); const body = document.querySelector('body'); expect(body).toHaveTextContent('Invalid user expectation'); diff --git a/user-interface/src/staff-assignment/screen/StaffAssignmentScreen.test.tsx b/user-interface/src/staff-assignment/screen/StaffAssignmentScreen.test.tsx index d02dbc5bb..8bb862956 100644 --- a/user-interface/src/staff-assignment/screen/StaffAssignmentScreen.test.tsx +++ b/user-interface/src/staff-assignment/screen/StaffAssignmentScreen.test.tsx @@ -12,6 +12,7 @@ import Api2 from '@/lib/models/api2'; import testingUtilities from '@/lib/testing/testing-utilities'; import { SearchResultsProps } from '@/search-results/SearchResults'; import { CamsRole } from '@common/cams/roles'; +import { BrowserRouter } from 'react-router-dom'; describe('StaffAssignmentScreen', () => { test('should render a list of cases assigned to a case assignment manager', async () => { @@ -39,7 +40,11 @@ describe('StaffAssignmentScreen', () => { .spyOn(staffAssignmentRow, 'StaffAssignmentRow') .mockReturnValue(<>); - render(); + render( + + + , + ); expect(SearchResults).toHaveBeenCalledWith( { @@ -62,7 +67,11 @@ describe('StaffAssignmentScreen', () => { test('should render permission invalid error when CaseAssignmentManager is not found in user roles', async () => { testingUtilities.setUserWithRoles([]); const alertSpy = testingUtilities.spyOnGlobalAlert(); - render(); + render( + + + , + ); expect(alertSpy.error).toHaveBeenCalledWith('Invalid Permissions'); }); @@ -71,7 +80,11 @@ describe('StaffAssignmentScreen', () => { testingUtilities.setUser({ offices: undefined, roles: [CamsRole.CaseAssignmentManager] }); const SearchResults = vi.spyOn(searchResultsModule, 'SearchResults'); - render(); + render( + + + , + ); expect(SearchResults).toHaveBeenCalledWith( {