Skip to content

Commit

Permalink
Tbolt/3355 budget and ffp validation (#4224)
Browse files Browse the repository at this point in the history
  • Loading branch information
tbolt authored Sep 2, 2022
1 parent fb20bcf commit cf3acf8
Show file tree
Hide file tree
Showing 14 changed files with 1,259 additions and 2,425 deletions.
2 changes: 2 additions & 0 deletions common/schemas/apdOverview.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Joi from 'joi';

const apdOverviewSchema = Joi.object({
// Funding sources is not a user input but we use this as a dependency for
// conditionally validating the narratives below
fundingSources: Joi.array().items(Joi.string()).required(),
programOverview: Joi.string().messages({
'string.empty': 'Provide a brief introduction to the state program.'
Expand Down
35 changes: 35 additions & 0 deletions common/schemas/costAllocateFFP.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const Joi = require('joi');

const costAllocateFFPSchema = Joi.object({
costAllocation: Joi.object().pattern(
/\d{4}/,
Joi.object({
ffp: Joi.object({
federal: Joi.number().required(),
state: Joi.alternatives()
.conditional('federal', {
switch: [
{
is: 90,
then: Joi.number().valid(10)
},
{
is: 75,
then: Joi.number().valid(25)
},
{
is: 50,
then: Joi.number().valid(50)
}
]
})
.messages({
'alternatives.any': 'Select a federal-state split.'
})
}),
other: Joi.any()
})
)
});

export default costAllocateFFPSchema;
69 changes: 69 additions & 0 deletions common/schemas/costAllocateFFPQuarterly.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
const Joi = require('joi');

const costAllocateFFPQuarterlySchema = Joi.object({
formData: Joi.object({
1: Joi.object({
combined: Joi.any(),
contractors: Joi.object({
dollars: Joi.number(),
percent: Joi.number()
}),
inHouse: Joi.object({
dollars: Joi.number(),
percent: Joi.number()
})
}),
2: Joi.object({
combined: Joi.any(),
contractors: Joi.object({
dollars: Joi.number(),
percent: Joi.number()
}),
inHouse: Joi.object({
dollars: Joi.number(),
percent: Joi.number()
})
}),
3: Joi.object({
combined: Joi.any(),
contractors: Joi.object({
dollars: Joi.number(),
percent: Joi.number()
}),
inHouse: Joi.object({
dollars: Joi.number(),
percent: Joi.number()
})
}),
4: Joi.object({
combined: Joi.any(),
contractors: Joi.object({
dollars: Joi.number(),
percent: Joi.number()
}),
inHouse: Joi.object({
dollars: Joi.number(),
percent: Joi.number()
})
}),
subtotal: Joi.object({
combined: Joi.any(),
contractors: Joi.object({
dollars: Joi.any(),
percent: Joi.number().precision(3).valid(1).messages({
'any.only':
'Private Contractor Costs quarterly percentages must total 100%'
})
}),
inHouse: Joi.object({
dollars: Joi.any(),
percent: Joi.number().precision(3).valid(1).messages({
'any.only':
'State Staff and Expenses (In-House Costs) quarterly percentages must total 100%'
})
})
})
})
});

export default costAllocateFFPQuarterlySchema;
2 changes: 1 addition & 1 deletion e2e/cypress/helpers/apd/activity/check-default-activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export const checkDefaultActivity = years => {

// Check Federal State Split Functionality
defaultData.splits.forEach(split => {
cy.get('[class="ds-c-field"]').eq(0).select(split);
cy.get('[data-cy="cost-allocation-dropdown"]').eq(0).select(split);

cy.get('[data-cy="FFPFedStateSplitTable"]')
.eq(0)
Expand Down
6 changes: 3 additions & 3 deletions e2e/cypress/integration/02-apd/01-apd-basics.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ describe('APD Basics', { tags: ['@apd', '@default'] }, () => {
.within(() => {
budgetPage.checkSplitFunctionality();

cy.get('[class="ds-c-field"]').select('75-25');
cy.get('[data-cy="cost-allocation-dropdown"]').select('75-25');
cy.waitForSave();
budgetPage.checkCostSplitTable({
federalSharePercentage: 0.75,
Expand All @@ -863,7 +863,7 @@ describe('APD Basics', { tags: ['@apd', '@default'] }, () => {
totalComputableMedicaidCost: 150000
});

cy.get('[class="ds-c-field"]').select('50-50');
cy.get('[data-cy="cost-allocation-dropdown"]').select('50-50');
cy.waitForSave();
budgetPage.checkCostSplitTable({
federalSharePercentage: 0.5,
Expand All @@ -873,7 +873,7 @@ describe('APD Basics', { tags: ['@apd', '@default'] }, () => {
totalComputableMedicaidCost: 150000
});

cy.get('[class="ds-c-field"]').select('90-10');
cy.get('[data-cy="cost-allocation-dropdown"]').select('90-10');
cy.waitForSave();
budgetPage.checkCostSplitTable({
federalSharePercentage: 0.9,
Expand Down
16 changes: 14 additions & 2 deletions e2e/cypress/page-objects/budget-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,26 @@ class BudgetPage {
};

checkSplitFunctionality = () => {
cy.get('[class="ds-c-field"]').parent().click();
cy.get('[data-cy="cost-allocation-dropdown"]').parent().click();
cy.contains('Select an option').should('exist');

cy.contains('90-10').should('exist');
cy.contains('75-25').should('exist');
cy.contains('50-50').should('exist');

cy.get('[class="ds-c-field"]')
cy.get('[data-cy="cost-allocation-dropdown"]')
.find(':selected')
.should('have.value', '0-100');

cy.get('[data-cy="cost-allocation-dropdown"]').blur();

cy.get('[data-cy="cost-allocation-dropdown"]').next();
cy.contains('Select a federal-state split.').should('exist');

cy.get('[data-cy="cost-allocation-dropdown"]').select('90-10');
cy.get('[data-cy="cost-allocation-dropdown"]').blur();

cy.contains('Select a federal-state split.').should('not.exist');
};

checkCostSplitTable = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const ContractorResourceForm = forwardRef(
hourly,
years
} = JSON.parse(JSON.stringify({ ...item }));

const {
control,
formState: { errors, isValid },
Expand Down
Loading

0 comments on commit cf3acf8

Please sign in to comment.