Skip to content

Commit

Permalink
app-web tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
haworku committed Jun 4, 2024
1 parent 12f6129 commit 3583411
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 136 deletions.
2 changes: 0 additions & 2 deletions services/app-api/src/resolvers/rate/submitRate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,6 @@ describe('submitRate', () => {
})

it('returns the latest linked contracts', async () => {
l

const stateServer = await constructTestPostgresServer({
ldService,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ import {
fillOutIndexRate,
} from '../../../testHelpers/jestRateHelpers'
import { Rate } from '../../../gen/gqlClient'
import selectEvent from 'react-select-event'

describe('RateDetails', () => {
// BRING THESE TESTS BACK WHEN WE RE-p IMPLEMENT SINGLE RATE EDIT
/* eslint-disable jest/no-disabled-tests, jest/expect-expect */
describe.skip('handles edit of a single rate', () => {
it('renders without errors', async () => {
Expand Down Expand Up @@ -72,6 +72,104 @@ describe('RateDetails', () => {
expect(optionalLabels).toHaveLength(1)
})

it('progressively disclose new rate form fields as expected', async () => {
renderWithProviders(<RateDetails type="SINGLE" />, {
apolloProvider: {
mocks: [
fetchCurrentUserMock({
statusCode: 200,
}),
],
},
})

expect(
screen.getByText('Programs this rate certification covers')
).toBeInTheDocument()
expect(
screen.getByText('Rate certification type')
).toBeInTheDocument()
screen.getByLabelText('New rate certification').click()
expect(
screen.getByText(
'Does the actuary certify capitation rates specific to each rate cell or a rate range?'
)
).toBeInTheDocument()
screen
.getByLabelText(
'Certification of capitation rates specific to each rate cell'
)
.click()
const input = screen.getByLabelText(
'Upload one rate certification document'
)
await userEvent.upload(input, [TEST_DOC_FILE])
const hasSharedRateFieldset = screen
.getByText(
/Was this rate certification included with another submission/
)
.closest('fieldset')
await userEvent.click(
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
within(hasSharedRateFieldset!).getByLabelText(/No/i)
)

// check that now we can see hidden things
await waitFor(() => {
expect(screen.queryByText('Rating period')).toBeInTheDocument()
expect(screen.queryByText('Rating period')).toBeInTheDocument()
expect(screen.queryByText('Start date')).toBeInTheDocument()
expect(screen.queryByText('End date')).toBeInTheDocument()
expect(screen.queryByText('Date certified')).toBeInTheDocument()
expect(screen.queryAllByTestId('errorMessage')).toHaveLength(0)
})
// click "continue"
const continueButton = screen.getByRole('button', {
name: 'Continue',
})

fireEvent.click(continueButton)

// check for expected errors
await waitFor(() => {
expect(screen.queryAllByTestId('errorMessage')).toHaveLength(7)
expect(
screen.queryAllByText(
'You must select which rate(s) are included in this certification'
)
).toHaveLength(2)
expect(
screen.queryByText(
'You must provide a start and an end date'
)
).toBeInTheDocument()
expect(
screen.queryAllByText(
'You must enter the date the document was certified'
)
).toHaveLength(2)
expect(
screen.queryAllByText('You must provide a name')
).toHaveLength(2)
expect(
screen.queryAllByText('You must provide a title/role')
).toHaveLength(2)
expect(
screen.queryAllByText('You must provide an email address')
).toHaveLength(2)
expect(
screen.queryAllByText('You must select an actuarial firm')
).toHaveLength(2)
})

await fillOutFirstRate(screen)

//wait for all errors to clear
await waitFor(() =>
expect(screen.queryAllByTestId('errorMessage')).toHaveLength(0)
)
})

describe('submit', () => {
it('enabled on initial load but disabled with alert if valid rate cert file replaced with invalid file', async () => {
const rateID = 'abc-123'
Expand Down Expand Up @@ -246,136 +344,6 @@ describe('RateDetails', () => {
'Was this rate certification included with another submission?'
)
).toBeInTheDocument()
screen
.getByLabelText(
'Certification of capitation rates specific to each rate cell'
)
.click()
const input = screen.getByLabelText(
'Upload one rate certification document'
)
await userEvent.upload(input, [TEST_DOC_FILE])
const hasSharedRateFieldset = screen
.getByText(
/Was this rate certification included with another submission/
)
.closest('fieldset')
await userEvent.click(
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
within(hasSharedRateFieldset!).getByLabelText(/No/i)
)

// check that now we can see hidden things
await waitFor(() => {
expect(screen.queryByText('Rating period')).toBeInTheDocument()
expect(screen.queryByText('Rating period')).toBeInTheDocument()
expect(screen.queryByText('Start date')).toBeInTheDocument()
expect(screen.queryByText('End date')).toBeInTheDocument()
expect(screen.queryByText('Date certified')).toBeInTheDocument()
expect(screen.queryAllByTestId('errorMessage')).toHaveLength(0)
})
// click "continue"
const continueButton = screen.getByRole('button', {
name: 'Continue',
})

fireEvent.click(continueButton)

// check for expected errors
await waitFor(() => {
expect(screen.queryAllByTestId('errorMessage')).toHaveLength(7)
expect(
screen.queryAllByText(
'You must select which rate(s) are included in this certification'
)
).toHaveLength(2)
expect(
screen.queryByText(
'You must provide a start and an end date'
)
).toBeInTheDocument()
expect(
screen.queryAllByText(
'You must enter the date the document was certified'
)
).toHaveLength(2)
expect(
screen.queryAllByText('You must provide a name')
).toHaveLength(2)
expect(
screen.queryAllByText('You must provide a title/role')
).toHaveLength(2)
expect(
screen.queryAllByText('You must provide an email address')
).toHaveLength(2)
expect(
screen.queryAllByText('You must select an actuarial firm')
).toHaveLength(2)
})

await fillOutFirstRate(screen)

//wait for all errors to clear
await waitFor(() =>
expect(screen.queryAllByTestId('errorMessage')).toHaveLength(0)
)
})

it('displays program options based on current user state', async () => {
const mockUser = {
__typename: 'StateUser' as const,
role: 'STATE_USER',
name: 'Sheena in Minnesota',
email: 'Sheena@dmas.mn.gov',
state: {
name: 'Minnesota',
code: 'MN',
programs: [
{
id: 'first',
name: 'Program 1',
fullName: 'Program 1',
isRateProgram: false,
},
{
id: 'second',
name: 'Program Test',
fullName: 'Program Test',
isRateProgram: false,
},
{
id: 'third',
name: 'Program 3',
fullName: 'Program 3',
isRateProgram: false,
},
],
},
}

renderWithProviders(<RateDetails type="MULTI" />, {
apolloProvider: {
mocks: [
fetchCurrentUserMock({
user: mockUser,
statusCode: 200,
}),
],
},
})
const combobox = await screen.findByRole('combobox')

selectEvent.openMenu(combobox)

await waitFor(() => {
expect(screen.getByText('Program 3')).toBeInTheDocument()
})

await selectEvent.select(combobox, 'Program 1')
selectEvent.openMenu(combobox)
await selectEvent.select(combobox, 'Program 3')

// in react-select, only items that are selected have a "remove item" label
expect(
screen.queryByText('Upload one rate certification document')
).not.toBeInTheDocument()
Expand Down Expand Up @@ -1436,7 +1404,9 @@ describe('RateDetails', () => {
screen.getAllByText('You must upload a rate certification')
).toHaveLength(2)
expect(
screen.getAllByText('You must select a program')
screen.getAllByText(
'You must select which rate(s) are included in this certification'
)
).toHaveLength(2)
expect(
screen.getAllByText('You must choose a rate certification type')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,11 @@ describe('SubmissionSummary', () => {
user: mockValidCMSUser(),
statusCode: 200,
}),
fetchContractMockSuccess({
contract: mockContractPackageUnlocked({
id: '15',
}),
}),
],
},
routerProvider: {
Expand All @@ -845,10 +850,10 @@ describe('SubmissionSummary', () => {
)
expect(
await screen.findByTestId('unlockedBanner')
).toHaveTextContent('Unlocked by: bob@dmas.mn.govUnlocked')
).toHaveTextContent('Unlocked by: cms@example.com')
expect(
await screen.findByTestId('unlockedBanner')
).toHaveTextContent('Reason for unlock: Test unlock reason')
).toHaveTextContent('Reason for unlock: unlocked for a test')
})
})
})

0 comments on commit 3583411

Please sign in to comment.