Skip to content

Commit

Permalink
WIP cypress tests
Browse files Browse the repository at this point in the history
  • Loading branch information
haworku committed Oct 30, 2023
1 parent 2b44a54 commit 59be128
Show file tree
Hide file tree
Showing 3 changed files with 227 additions and 0 deletions.
107 changes: 107 additions & 0 deletions services/cypress/integration/cmsWorkflow/rateReview.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
describe('CMS user can view rate reviews', () => {
beforeEach(() => {
cy.stubFeatureFlags()
cy.interceptGraphQL()
})
it('and navigate to a specific rate from the rates dashboard', () => {
// Assign Division to CMS user zuko
cy.apiAssignDivisionToCMSUser(cmsUser(), 'DMCO').then(() => {
// Create a new submission
cy.apiCreateAndSubmitContractOnlySubmission(stateUser()).then(
(pkg) => {
})
})
// state user adds a new package
cy.logInAsStateUser()
cy.startNewContractAndRatesSubmission()
cy.fillOutBaseContractDetails()
cy.navigateFormByButtonClick('CONTINUE')

cy.findByRole('heading', {
level: 2,
name: /Rate details/,
}).should('exist')
cy.fillOutNewRateCertification()
cy.navigateFormByButtonClick('CONTINUE')

cy.findByRole('heading', {
level: 2,
name: /Contacts/,
}).should('exist')
cy.fillOutStateContact()
cy.fillOutAdditionalActuaryContact()
cy.navigateFormByButtonClick('CONTINUE')

cy.findByRole('heading', {
level: 2,
name: /Supporting documents/,
}).should('exist')
cy.fillOutSupportingDocuments()
cy.navigateFormByButtonClick('CONTINUE')

// store submission id for reference later
let submissionId = ''
cy.location().then((fullUrl) => {
const { pathname } = fullUrl
const pathnameArray = pathname.split('/')
submissionId = pathnameArray[2]
})

// submit package
cy.findByRole('heading', { level: 2, name: /Review and submit/ })
cy.submitStateSubmissionForm()

// store submission name for later
cy.location().then((loc) => {
expect(loc.search).to.match(/.*justSubmitted=*/)
const submissionName = loc.search.split('=').pop()
if (submissionName === undefined) {
throw new Error('No submission name found' + loc.search)
}

// sign out state user
cy.logOut()
// sign in CMS user
cy.logInAsCMSUser()
cy.findByTestId('cms-dashboard-page').should('exist')
cy.findByRole('table').should('exist')
cy.findByText(submissionName).should('exist')
// check the table of submissions

// only one matching entry
cy.get('table')
.findAllByText(submissionName)
.should('have.length', 1)

// has proper row data
cy.get('table')
.should('exist')
.findByText(submissionName)
.parent()
.findByTestId('submission-date')
.should('not.be.empty')

cy.get('table')
.should('exist')
.findByText(submissionName)
.parent()
.siblings('[data-testid="submission-status"]')
.should('have.text', 'Submitted')

cy.get('table')
.contains('a', submissionName)
.parents('tr')
.findByTestId('submission-type')
.should('have.text', 'Contract action and rate certification')

cy.get('table')
.contains('a', submissionName)
.should('have.attr', 'href')

// can navigate to submission summary by clicking link
cy.findByText(submissionName).should('exist').click()
cy.url({ timeout: 10_000 }).should('contain', submissionId)
cy.findByTestId('submission-summary').should('exist')
})
})
})
50 changes: 50 additions & 0 deletions services/cypress/support/apiCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
DivisionType,
adminUser,
contractOnlyData,
contractAndRatesData,
newSubmissionInput,
CMSUserType,
} from '../utils/apollo-test-utils'
Expand Down Expand Up @@ -71,6 +72,55 @@ const createAndSubmitContractOnlyPackage = async (
return submission.data.submitHealthPlanPackage.pkg
}

const createAndSubmitContractWithRates = async (
apolloClient: ApolloClient<NormalizedCacheObject>
): Promise<HealthPlanPackage> => {
const newSubmission1 = await apolloClient.mutate({
mutation: CreateHealthPlanPackageDocument,
variables: {
input: newSubmissionInput({submissionType: 'CONTRACT_AND_RATES'}),
},
})
const pkg1 = newSubmission1.data.createHealthPlanPackage.pkg
const pkg1FirstRev = pkg1.revisions[0].node

const formData1 = base64ToDomain(pkg1FirstRev.formDataProto)
if (formData1 instanceof Error) {
throw new Error(formData1.message)
}

const fullFormData1 = {
...formData1,
...contractAndRatesData(),
}

const formDataProto = domainToBase64(fullFormData1)

await apolloClient.mutate({
mutation: UpdateHealthPlanFormDataDocument,
variables: {
input: {
healthPlanFormData: formDataProto,
pkgID: pkg1.id,
},
},
})

const submission1 = await apolloClient.mutate({
mutation: SubmitHealthPlanPackageDocument,
variables: {
input: {
pkgID: pkg1.id,
submittedReason: 'Submit package for Rates Dashboard tests',
},
},
})


return submission1.data.submitHealthPlanPackage.pkg
}


const assignCmsDivision = async (
apolloClient: ApolloClient<NormalizedCacheObject>,
cmsUser: CMSUserType,
Expand Down
70 changes: 70 additions & 0 deletions services/cypress/utils/apollo-test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,76 @@ const contractOnlyData = (): Partial<UnlockedHealthPlanFormDataType>=> ({
rateInfos: [],
})

const contractAndRatesData = (): Partial<UnlockedHealthPlanFormDataType>=> ({
stateContacts: [
{
name: 'Name',
titleRole: 'Title',
email: 'example@example.com',
},
],
addtlActuaryContacts: [],
documents: [],
contractExecutionStatus: 'EXECUTED' as const,
contractDocuments: [
{
name: 'Contract Cert.pdf',
s3URL: 's3://local-uploads/1684382956834-Contract Cert.pdf/Contract Cert.pdf',
documentCategories: ['CONTRACT'],
sha256: 'abc123',
},
],
contractDateStart: new Date('2023-05-01T00:00:00.000Z'),
contractDateEnd: new Date('2023-05-31T00:00:00.000Z'),
contractAmendmentInfo: {
modifiedProvisions: {
inLieuServicesAndSettings: false,
modifiedRiskSharingStrategy: false,
modifiedIncentiveArrangements: false,
modifiedWitholdAgreements: false,
modifiedStateDirectedPayments: false,
modifiedPassThroughPayments: false,
modifiedPaymentsForMentalDiseaseInstitutions: false,
modifiedNonRiskPaymentArrangements: false,
},
},
managedCareEntities: ['MCO'],
federalAuthorities: ['STATE_PLAN'],
rateInfos:[
{
id: uuidv4(),
rateType: 'NEW' as const,
rateDateStart: new Date(Date.UTC(2025, 5, 1)),
rateDateEnd: new Date(Date.UTC(2026, 4, 30)),
rateDateCertified: new Date(Date.UTC(2025, 3, 15)),
rateDocuments: [
{
name: 'rateDocument.pdf',
s3URL: 'fakeS3URL',
sha256: 'fakesha',
documentCategories: ['RATES' as const],
},
],
supportingDocuments: [],
//We only want one rate ID and use last program in list to differentiate from programID if possible.
rateProgramIDs: [ratePrograms.reverse()[0].id],
actuaryContacts: [
{
name: 'test name',
titleRole: 'test title',
email: 'email@example.com',
actuarialFirm: 'MERCER' as const,
actuarialFirmOther: '',
},
],
actuaryCommunicationPreference: 'OACT_TO_ACTUARY' as const,
packagesWithSharedRateCerts: [],
},
]


})

const newSubmissionInput = (): Partial<UnlockedHealthPlanFormDataType> => ({
populationCovered: 'MEDICAID',
programIDs: ['abbdf9b0-c49e-4c4c-bb6f-040cb7b51cce'],
Expand Down

0 comments on commit 59be128

Please sign in to comment.