Skip to content

Commit

Permalink
Merge branch 'main' into dbex/97078-events-type-selection-shell
Browse files Browse the repository at this point in the history
  • Loading branch information
freeheeling authored Dec 26, 2024
2 parents 2aea3eb + d56bb41 commit 7c4f538
Show file tree
Hide file tree
Showing 152 changed files with 1,140 additions and 71 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -185,28 +185,22 @@ export const formConfig = {
path: 'options-selection',
uiSchema: addOrRemoveDependents.uiSchema,
schema: addOrRemoveDependents.schema,
depends: () =>
!window.location.pathname.includes('review-and-submit'),
},
addDependentOptions: {
hideHeaderRow: true,
title: 'What do you like to do?',
path: 'options-selection/add-dependents',
uiSchema: addDependentOptions.uiSchema,
schema: addDependentOptions.schema,
depends: form =>
form?.['view:addOrRemoveDependents']?.add &&
!window.location.pathname.includes('review-and-submit'),
depends: form => form?.['view:addOrRemoveDependents']?.add,
},
removeDependentOptions: {
hideHeaderRow: true,
title: 'What do you like to do?',
path: 'options-selection/remove-dependents',
uiSchema: removeDependentOptions.uiSchema,
schema: removeDependentOptions.schema,
depends: form =>
form?.['view:addOrRemoveDependents']?.remove &&
!window.location.pathname.includes('review-and-submit'),
depends: form => form?.['view:addOrRemoveDependents']?.remove,
},
},
},
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
@import "~@department-of-veterans-affairs/css-library/dist/tokens/scss/variables";
@import "~@department-of-veterans-affairs/css-library/dist/stylesheets/modules/m-process-list";
@import "~@department-of-veterans-affairs/css-library/dist/stylesheets/modules/m-form-process";
@import "../../../../platform/forms/sass/m-schemaform";
@import "../../../platform/forms/sass/m-schemaform";
@import "~@department-of-veterans-affairs/css-library/dist/stylesheets/modules/m-modal";
@import "~@department-of-veterans-affairs/css-library/dist/stylesheets/modules/m-omb-info";
@import "../../../../platform/forms/sass/m-form-confirmation";
@import "../../../platform/forms/sass/m-form-confirmation";

// a11y - Change gray box to white box with gray border.
// Needed because when using a web component which
Expand Down
2 changes: 1 addition & 1 deletion src/applications/edu-benefits/10215/config/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
ProgramSummary,
} from '../pages';

const arrayBuilderOptions = {
export const arrayBuilderOptions = {
arrayPath: 'programs',
nounSingular: 'program',
nounPlural: 'programs',
Expand Down
9 changes: 5 additions & 4 deletions src/applications/edu-benefits/10215/config/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ export default function transform(formConfig, form) {
//
// Include total enrolled FTE And supported student percentage FTE if 10+ supported students enrolled
//
formData.data.programs = formData.data.programs.map(program => {
formData.data.programs = formData.data?.programs?.map(program => {
const programWithCalcs = program;
if (!Number(program.supportedStudents) < 10 && program.fte) {
const { total, supportedFTEPercent } = getFTECalcs(program);
programWithCalcs.fte.totalFTE = total;
programWithCalcs.fte.supportedPercentageFTE = supportedFTEPercent;
const fteCalcs = getFTECalcs(program);
programWithCalcs.fte.totalFTE = fteCalcs?.total;
programWithCalcs.fte.supportedPercentageFTE =
fteCalcs?.supportedFTEPercent;
}
return programWithCalcs;
});
Expand Down
10 changes: 8 additions & 2 deletions src/applications/edu-benefits/10215/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import * as institutionDetails from './institutionDetails';
import { ProgramIntro } from './program-intro';
import { programInfo } from './program-info';
import { ProgramSummary } from './program-summary';
import { ProgramSummary, arrayBuilderOptions } from './program-summary';

export { institutionDetails, ProgramIntro, programInfo, ProgramSummary };
export {
institutionDetails,
ProgramIntro,
programInfo,
ProgramSummary,
arrayBuilderOptions,
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
arrayBuilderYesNoUI,
} from '~/platform/forms-system/src/js/web-component-patterns';

const arrayBuilderOptions = {
export const arrayBuilderOptions = {
arrayPath: 'programs',
nounSingular: 'program',
nounPlural: 'programs',
Expand Down
42 changes: 42 additions & 0 deletions src/applications/edu-benefits/10215/tests/config/form.unit.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { expect } from 'chai';
import sinon from 'sinon';
import { render } from '@testing-library/react';
import formConfig, { arrayBuilderOptions } from '../../config/form';
import manifest from '../../manifest.json';

describe('22-10215 Form Config', () => {
it('should render', () => {
expect(formConfig).to.be.an('object');
});
it('should have a required properties', () => {
expect(formConfig.rootUrl).to.contain(manifest.rootUrl);
expect(formConfig.title).to.contain('Report 85/15 Rule enrollment ratio');
const { getByText } = render(formConfig.subTitle()); // Render the subTitle component
expect(
getByText(
'Statement of Assurance of Compliance with 85% Enrollment Ratios (VA Form 22-10215)',
),
).of.exist;
expect(formConfig).to.have.property('chapters');
});
it('should return the correct item name', () => {
const item = { programName: 'Test Program' };
expect(arrayBuilderOptions.text.getItemName(item)).to.equal('Test Program');
});

it('should return the correct card description', () => {
const item = {
programName: 'Test Program',
supportedFTEPercent: 50,
};
const mockGetFTECalcs = sinon.stub().returns({ supportedFTEPercent: 50 });
global.getFTECalcs = mockGetFTECalcs;
const description = arrayBuilderOptions.text.cardDescription(item);
expect(description).to.not.equal('50 supported student FTE');

mockGetFTECalcs.returns({ supportedFTEPercent: null });
expect(arrayBuilderOptions.text.cardDescription(item)).to.be.null;

delete global.getFTECalcs;
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { expect } from 'chai';
import sinon from 'sinon';
import * as helpers from '../../helpers';
import transform from '../../config/transform';

describe('transform utility function', () => {
let formConfig;
let form;
let getFTECalcsStub;

beforeEach(() => {
formConfig = {};
form = {
data: {
programs: [
{
programName: 'Program A',
supportedStudents: '10',
fte: {
totalFTE: 0,
supportedPercentageFTE: 0,
},
},
{
programName: 'Program B',
supportedStudents: '9',
fte: {
totalFTE: 0,
supportedPercentageFTE: 0,
},
},
],
},
};
getFTECalcsStub = sinon.stub(helpers, 'getFTECalcs');
});

afterEach(() => {
getFTECalcsStub.restore();
});
it('should not modify FTE fields if the program has fewer than 10 supported students', () => {
form.data.programs = [
{
programName: 'Program C',
supportedStudents: '8',
fte: {
totalFTE: 0,
supportedPercentageFTE: 0,
},
},
];

const resultString = transform(formConfig, form);
const resultObject = JSON.parse(resultString);
expect(resultObject.educationBenefitsClaim).to.exist;
expect(resultObject.educationBenefitsClaim.form).to.exist;
});
});
2 changes: 0 additions & 2 deletions src/applications/edu-benefits/10215/tests/form.unit.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,4 @@ describe('22-10215 - Form Config', () => {
expect(formConfig).to.have.property('submit');
expect(formConfig).to.have.property('saveInProgress');
});

// Introduction and Get Help components to be added
});
60 changes: 60 additions & 0 deletions src/applications/edu-benefits/10215/tests/helper.unit.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// src/applications/edu-benefits/10215/helpers.test.js
import { expect } from 'chai';
import { getFTECalcs } from '../helpers';

describe('getFTECalcs', () => {
it('should return correct FTE calculations for supported and non-supported values', () => {
const program = { fte: { supported: 5, nonSupported: 15 } };
const result = getFTECalcs(program);
expect(result).to.deep.equal({
supported: 5,
nonSupported: 15,
total: 20,
supportedFTEPercent: '25%',
});
});

it('should handle zero supported and non-supported values', () => {
const program = { fte: { supported: 0, nonSupported: 0 } };
const result = getFTECalcs(program);
expect(result).to.deep.equal({
supported: 0,
nonSupported: 0,
total: 0,
supportedFTEPercent: null,
});
});

it('should handle only supported values', () => {
const program = { fte: { supported: 10, nonSupported: 0 } };
const result = getFTECalcs(program);
expect(result).to.deep.equal({
supported: 10,
nonSupported: 0,
total: 10,
supportedFTEPercent: '100%',
});
});

it('should handle only non-supported values', () => {
const program = { fte: { supported: 0, nonSupported: 10 } };
const result = getFTECalcs(program);
expect(result).to.deep.equal({
supported: 0,
nonSupported: 10,
total: 10,
supportedFTEPercent: null,
});
});

it('should return null for supportedFTEPercent when total is NaN', () => {
const program = { fte: { supported: null, nonSupported: null } };
const result = getFTECalcs(program);
expect(result).to.deep.equal({
supported: 0,
nonSupported: 0,
total: 0,
supportedFTEPercent: null,
});
});
});
81 changes: 81 additions & 0 deletions src/applications/edu-benefits/10215/tests/pages/calcs.unit.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// src/applications/edu-benefits/10215/pages/calcs.test.js
import React from 'react';
import { mount } from 'enzyme';
import { expect } from 'chai';
import { Provider } from 'react-redux';
import configureStore from 'redux-mock-store';
import Calcs from '../../pages/calcs';

const mockStore = configureStore();

describe('<Calcs />', () => {
const mockData = {
programs: [
{
supported: true,
nonSupported: false,
total: 10,
supportedFTEPercent: 100,
},
],
};

it('should render correctly with given props', () => {
const store = mockStore({ form: { data: mockData } });
const wrapper = mount(
<Provider store={store}>
<Calcs data={mockData} />
</Provider>,
);

expect(
wrapper
.find('label')
.at(0)
.text(),
).to.equal('Total Enrolled FTE');
expect(
wrapper
.find('span')
.at(0)
.text(),
).to.equal('--');
expect(
wrapper
.find('label')
.at(1)
.text(),
).to.equal('Supported student percentage FTE');
expect(
wrapper
.find('span')
.at(1)
.text(),
).to.equal('--%');
wrapper.unmount();
});

it('should render "--" when no data is available', () => {
const emptyData = { programs: [] };
const store = mockStore({ form: { data: emptyData } });
const wrapper = mount(
<Provider store={store}>
<Calcs data={emptyData} />
</Provider>,
);

expect(
wrapper
.find('span')
.at(0)
.text(),
).to.equal('--');
expect(
wrapper
.find('span')
.at(1)
.text(),
).to.equal('--%');
wrapper.unmount();
});
});
Loading

0 comments on commit 7c4f538

Please sign in to comment.