Skip to content

Commit

Permalink
removed old tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ruizajtruss committed Apr 16, 2024
1 parent edd92fc commit 5653343
Showing 1 changed file with 0 additions and 287 deletions.
287 changes: 0 additions & 287 deletions services/app-web/src/pages/StateSubmission/Contacts/Contacts.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,58 +79,6 @@ describe('Contacts', () => {
expect(optionalLabels).toHaveLength(0)
})

it('displays correct form guidance for contract and rates submission', async () => {
jest.spyOn(
useHealthPlanPackageForm,
'useHealthPlanPackageForm'
).mockImplementation(() => {
return {
createDraft: jest.fn(),
updateDraft: mockUpdateDraftFn,
showPageErrorMessage: false,
draftSubmission: contractAndRatesWithEmptyContacts(),
}
})

renderWithProviders(<Contacts />, {
apolloProvider: {
mocks: [fetchCurrentUserMock({ statusCode: 200 })],
},
})

const requiredLabels = await screen.findAllByText('Required')
expect(requiredLabels).toHaveLength(2)
const optionalLabels = await screen.queryAllByText('Optional')
expect(optionalLabels).toHaveLength(0)
expect(
screen.getByText('Additional Actuary Contacts')
).toBeInTheDocument()
expect(
screen.getByText(
'Provide contact information for any additional actuaries who worked directly on this submission.'
)
).toBeInTheDocument()
expect(
screen.getByRole('button', { name: 'Add actuary contact' })
).toBeInTheDocument()
expect(
screen.getByText(
'Communication preference between CMS Office of the Actuary (OACT) and all state’s actuaries (i.e. certifying actuaries and additional actuary contacts)'
)
).toBeInTheDocument()
expect(
screen.getByText(
'OACT can communicate directly with the state’s actuaries but should copy the state on all written communication and all appointments for verbal discussions.'
)
).toBeInTheDocument()
expect(
screen.getByText(
'OACT can communicate directly with the state, and the state will relay all written communication to their actuaries and set up time for any potential verbal discussions.'
)
).toBeInTheDocument()
expect(screen.queryAllByTestId('actuary-contact')).toHaveLength(0)
})

it('checks saved mocked state contacts correctly', async () => {
jest.spyOn(
useHealthPlanPackageForm,
Expand Down Expand Up @@ -273,44 +221,6 @@ describe('Contacts', () => {
})
})

it('after "Add actuary contact" button click, it should focus on the field name of the new actuary contact', async () => {
const mock = contractAndRatesWithEmptyContacts()
jest.spyOn(
useHealthPlanPackageForm,
'useHealthPlanPackageForm'
).mockImplementation(() => {
return {
createDraft: jest.fn(),
updateDraft: mockUpdateDraftFn,
showPageErrorMessage: false,
draftSubmission: mock,
}
})

renderWithProviders(<Contacts />, {
apolloProvider: {
mocks: [fetchCurrentUserMock({ statusCode: 200 })],
},
})

const addActuaryContactButton = screen.getByRole('button', {
name: 'Add actuary contact',
})

addActuaryContactButton.click()

await waitFor(() => {
expect(screen.getByText('Add actuary contact')).toBeInTheDocument()

expect(screen.getAllByLabelText('Name')).toHaveLength(2)

const firstActuaryContactName = screen.getAllByLabelText('Name')[1]

expect(firstActuaryContactName).toHaveValue('')
expect(firstActuaryContactName).toHaveFocus()
})
})

it('after state contact "Remove contact" button click, should focus on add new contact button', async () => {
renderWithProviders(<Contacts />, {
apolloProvider: {
Expand All @@ -334,40 +244,6 @@ describe('Contacts', () => {
expect(addStateContactButton).toHaveFocus()
})

it('after actuary contact "Remove contact" button click, should focus on add new actuary contact button', async () => {
jest.spyOn(
useHealthPlanPackageForm,
'useHealthPlanPackageForm'
).mockImplementation(() => {
return {
createDraft: jest.fn(),
updateDraft: mockUpdateDraftFn,
showPageErrorMessage: false,
draftSubmission: contractAndRatesWithEmptyContacts(),
}
})

renderWithProviders(<Contacts />, {
apolloProvider: {
mocks: [fetchCurrentUserMock({ statusCode: 200 })],
},
})
const addActuaryContactButton = screen.getByRole('button', {
name: 'Add actuary contact',
})
await userEvent.click(addActuaryContactButton)

expect(
screen.getByRole('button', { name: 'Remove contact' })
).toBeInTheDocument()

await userEvent.click(
screen.getByRole('button', { name: 'Remove contact' })
)

expect(addActuaryContactButton).toHaveFocus()
})

it('when there are multiple state contacts, they should numbered', async () => {
jest.spyOn(
useHealthPlanPackageForm,
Expand Down Expand Up @@ -396,167 +272,4 @@ describe('Contacts', () => {
expect(screen.getByText('State contacts 2')).toBeInTheDocument()
})
})

it('when there are multiple actuary contacts, they should numbered', async () => {
jest.spyOn(
useHealthPlanPackageForm,
'useHealthPlanPackageForm'
).mockImplementation(() => {
return {
createDraft: jest.fn(),
updateDraft: mockUpdateDraftFn,
showPageErrorMessage: false,
draftSubmission: contractAndRatesWithEmptyContacts(),
}
})

renderWithProviders(<Contacts />, {
apolloProvider: {
mocks: [fetchCurrentUserMock({ statusCode: 200 })],
},
})
const addActuaryContactButton = screen.getByRole('button', {
name: 'Add actuary contact',
})
addActuaryContactButton.click()
addActuaryContactButton.click()
await waitFor(() => {
expect(
screen.getByText('Additional actuary contact 1')
).toBeInTheDocument()
expect(
screen.getByText('Additional actuary contact 2')
).toBeInTheDocument()
})
})

/* This test is likely to time out if we use userEvent.type(). Converted to .paste() */
it('when there are multiple state and actuary contacts, remove button works as expected', async () => {
jest.spyOn(
useHealthPlanPackageForm,
'useHealthPlanPackageForm'
).mockImplementation(() => {
return {
createDraft: jest.fn(),
updateDraft: mockUpdateDraftFn,
showPageErrorMessage: false,
draftSubmission: contractAndRatesWithEmptyContacts(),
}
})

renderWithProviders(<Contacts />, {
apolloProvider: {
mocks: [fetchCurrentUserMock({ statusCode: 200 })],
},
})

screen.getAllByLabelText('Name')[0].focus()
await userEvent.paste('State Contact Person')

screen.getAllByLabelText('Title/Role')[0].focus()
await userEvent.paste('State Contact Title')

screen.getAllByLabelText('Email')[0].focus()
await userEvent.paste('[email protected]')

// add additional actuary contact
const addActuaryContactButton = screen.getByRole('button', {
name: 'Add actuary contact',
})
addActuaryContactButton.click()

await waitFor(() => {
expect(
screen.getByText('Additional actuary contact 1')
).toBeInTheDocument()
})

// fill out additional actuary contact 1
screen.getAllByLabelText('Name')[1].focus()
await userEvent.paste('Actuary Contact Person')

screen.getAllByLabelText('Title/Role')[1].focus()
await userEvent.paste('Actuary Contact Title')

screen.getAllByLabelText('Email')[1].focus()
await userEvent.paste('[email protected]')

await userEvent.click(screen.getAllByLabelText('Mercer')[0])

await userEvent.click(
screen.getByText(
`OACT can communicate directly with the state’s actuaries but should copy the state on all written communication and all appointments for verbal discussions.`
)
)

// Add additional state contact
await userEvent.click(
screen.getByRole('button', {
name: /Add another state contact/,
})
)

screen.getAllByLabelText('Name')[1].focus()
await userEvent.paste('State Contact Person 2')

screen.getAllByLabelText('Title/Role')[1].focus()
await userEvent.paste('State Contact Title 2')

screen.getAllByLabelText('Email')[1].focus()
await userEvent.paste('[email protected]')

expect(screen.queryAllByTestId('errorMessage')).toHaveLength(0)

// Add additional actuary contact
addActuaryContactButton.click()

screen.getAllByLabelText('Name')[1].focus()
await userEvent.paste('Actuary Contact Person 2')

screen.getAllByLabelText('Title/Role')[1].focus()
await userEvent.paste('Actuary Contact Title 2')

screen.getAllByLabelText('Email')[1].focus()
await userEvent.paste('[email protected]')

await userEvent.click(screen.getAllByLabelText('Mercer')[1])

// Remove additional state contact
expect(
screen.getAllByRole('button', { name: /Remove contact/ })
).toHaveLength(3) // there are two remove contact buttons on screen, one for state one for actuary
await userEvent.click(
screen.getAllByRole('button', { name: /Remove contact/ })[0]
)

expect(screen.queryByText('State contact 2')).toBeNull()
expect(
screen.queryByText('Additional actuary contact 2')
).toBeInTheDocument()
expect(
screen.queryByText('Additional actuary contact 1')
).toBeInTheDocument()

// Remove additional actuary contacts
expect(
screen.getAllByRole('button', { name: /Remove contact/ })
).toHaveLength(2) // there are 2 remove contact buttons on screen, for actuary

//Remove actuary contact 2
await userEvent.click(
screen.getAllByRole('button', { name: /Remove contact/ })[0]
)

expect(screen.queryByText('Additional actuary contact 2')).toBeNull()
expect(
screen.queryByText('Additional actuary contact 1')
).toBeInTheDocument()

//Remove actuary contact 1
await userEvent.click(
screen.getAllByRole('button', { name: /Remove contact/ })[0]
)

expect(screen.queryByText('Additional actuary contact 1')).toBeNull()
})
})

0 comments on commit 5653343

Please sign in to comment.