Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test → val (9 January 2025) #12001

Merged
merged 22 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
0d85103
playwright header logout test (#11965)
britt-mo Dec 12, 2024
be05d1e
Remove unnecessary prop drilling and add tests (#11972)
gmrabian Dec 12, 2024
d7285c2
CMDCT-4113: NAAAR "Analysis Methods" Page (#11958)
karla-vm Dec 18, 2024
c91ef1d
Bump Vite from 5.4.8 to 6.0.0 (#11975)
benmartin-coforma Dec 19, 2024
55618df
[Snyk] Upgrade aws-amplify from 6.8.0 to 6.10.0 (#11977)
mdct-github-service-account Dec 23, 2024
a53762a
[Snyk] Upgrade react-router-dom from 6.27.0 to 6.28.0 (#11978)
mdct-github-service-account Dec 23, 2024
71bf8fe
Security Upgrade: vite v6 (#11981)
karla-vm Jan 2, 2025
a8f9b72
Security Upgrade: aws-sdk/client-s3 (#11982)
karla-vm Jan 3, 2025
f8420d9
[Snyk] Upgrade sass from 1.80.7 to 1.83.0 (#11986)
mdct-github-service-account Jan 3, 2025
69917bb
[Snyk] Upgrade @emotion/styled from 11.13.0 to 11.14.0 (#11987)
mdct-github-service-account Jan 3, 2025
31170a5
fix some validation that was removing fields, and only add applicable…
gmrabian Jan 3, 2025
5c30f29
Security Upgrade: aws-sdk (database) (#11989)
karla-vm Jan 3, 2025
a881ac2
Analysis Methods page — edit default methods (#11980)
gmrabian Jan 6, 2025
0080001
[Snyk] Upgrade @aws-sdk/client-cognito-identity-provider from 3.699.0…
mdct-github-service-account Jan 7, 2025
955bd66
[Snyk] Upgrade dompurify from 2.5.7 to 2.5.8 (#11991)
mdct-github-service-account Jan 7, 2025
c91bca9
[Snyk] Upgrade @emotion/react from 11.13.3 to 11.14.0 (#11992)
mdct-github-service-account Jan 7, 2025
65ae9c7
[Snyk] Upgrade react-hook-form from 7.53.2 to 7.54.1 (#11993)
mdct-github-service-account Jan 7, 2025
2587c05
[Snyk] Upgrade fast-xml-parser from 4.5.0 to 4.5.1 (#11996)
mdct-github-service-account Jan 8, 2025
3d03acd
[Snyk] Upgrade vite-tsconfig-paths from 5.1.2 to 5.1.4 (#11997)
mdct-github-service-account Jan 8, 2025
6554f83
[Snyk] Upgrade @vitejs/plugin-react from 4.3.3 to 4.3.4 (#11998)
mdct-github-service-account Jan 9, 2025
11b0126
[Snyk] Upgrade fast-xml-parser from 4.5.0 to 4.5.1 (#11999)
mdct-github-service-account Jan 9, 2025
35d3302
CMDCT-4228: Address Pen Test Findings (#12000)
karla-vm Jan 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"homepage": "https://github.com/Enterprise-CMCS/macpro-mdct-mcr#readme",
"dependencies": {
"@enterprise-cmcs/serverless-waf-plugin": "^1.4.0",
"fast-xml-parser": "4.5.0",
"fast-xml-parser": "4.5.1",
"loader-utils": "2.0.4"
},
"devDependencies": {
Expand Down
141 changes: 140 additions & 1 deletion services/app-api/forms/naaar.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
"basePath": "/naaar",
"version": "NAAAR_2024-08-06",
"entities": {
"plans": { "required": true }
"plans": {
"required": true
},
"analysisMethods": {
"required": true
}
},
"routes": [
{
Expand Down Expand Up @@ -262,6 +267,140 @@
}
]
}
},
{
"name": "Analysis methods",
"path": "/naaar/state-and-program-information/analysis-methods",
"pageType": "drawer",
"entityType": "analysisMethods",
"verbiage": {
"intro": {
"section": "I. State and program information",
"subsection": "Analysis methods",
"info": [
{
"type": "p",
"content": "States should use this section of the tab to report on the analyses that the state uses to assess plan compliance with the state's 42 C.F.R. § 438.68 and 42 C.F.R. § 438.206 standards."
}
]
},
"dashboardTitle": "",
"addEntityButtonText": "Add other analysis method",
"editEntityButtonText": "",
"readOnlyEntityButtonText": "",
"tableHeader": "Analysis method <br/> Frequency and plan utilization",
"addEditModalAddTitle": "Analysis method: Add other",
"addEditModalEditTitle": "Analysis method: Edit other",
"deleteEntityButtonAltText": "Delete other analysis method",
"deleteModalTitle": "Are you sure you want to delete this analysis method?",
"deleteModalConfirmButtonText": "Yes, delete method",
"deleteModalWarning": "Are you sure you want to proceed? You will lose all information entered for this analysis method in the NAAAR. The method will remain in previously submitted NAAAR reports if applicable.",
"entityUnfinishedMessage": "Complete the remaining indicators for this access measure by entering details.",
"enterEntityDetailsButtonText": "Enter",
"readOnlyEntityDetailsButtonText": "View",
"drawerTitle": "Analysis method: "
},
"drawerForm": {
"id": "iam",
"fields": [
{
"id": "analysis_applicable",
"type": "radio",
"validation": "radio",
"props": {
"label": "Is this analysis method utilized to assess plan compliance?",
"hint": "Select “Yes” if the method is utilized to assess plan compliance with the state's 42 C.F.R. § 438.68 and 42 C.F.R. § 438.206 standards.",
"choices": [
{
"id": "KHvMO9SzSrkBhqCobPBUOY",
"label": "No"
},
{
"id": "Br7jPULxsYgbiuHV9zwyIB",
"label": "Yes",
"children": [
{
"id": "analysis_method_frequency",
"type": "radio",
"validation": {
"type": "radio",
"nested": true,
"parentFieldName": "analysis_applicable"
},
"props": {
"label": "Frequency of analysis",
"choices": [
{
"id": "Sol1W6HJCixyOVxw4vDgXQ",
"label": "Weekly"
},
{
"id": "YjI3qT3Ml9cZfP4a1RV6G9",
"label": "Bi-weekly"
},
{
"id": "L8q1N1DXEYv8LsDfGkdbOe",
"label": "Monthly"
},
{
"id": "05ThR4UN7kYDGpKaTWESOB",
"label": "Bi-monthly"
},
{
"id": "Y0Rkz7e3Kkxw0T4aFDb38j",
"label": "Quarterly"
},
{
"id": "mcn99pzTOqnEmr3uXiEOYs",
"label": "Semi-annually"
},
{
"id": "r938vpeMJxkPOqk53N7qW0",
"label": "Other, specify",
"children": [
{
"id": "analysis_method_frequency-otherText",
"type": "textarea",
"validation": {
"type": "text",
"nested": true,
"parentFieldName": "analysis_method_frequency"
}
}
]
},
{
"id": "WkqIis4bGGtK8Nzzqa6rPl",
"label": "Varies by plan"
}
]
}
},
{
"id": "analysis_method_applicable_plans",
"type": "checkbox",
"validation": {
"type": "checkbox",
"nested": true,
"parentFieldName": "analysis_applicable"
},
"props": {
"label": "Plans utilizing this method",
"choices": [
{
"id": "tvCUw5CcaGUFSIMByAopjF",
"label": "Fill in plans here"
}
]
}
}
]
}
]
}
}
]
}
}
]
},
Expand Down
72 changes: 69 additions & 3 deletions services/app-api/handlers/reports/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,25 @@ const creationEvent: APIGatewayProxyEvent = {
}),
};

const naaarCreationEvent: APIGatewayProxyEvent = {
const naaarCreationDisabledEvent: APIGatewayProxyEvent = {
...proxyEvent,
headers: { "cognito-identity-id": "test" },
pathParameters: { reportType: "NAAAR", state: "AL" },
body: JSON.stringify({
fieldData: {
contactName: "Contact Name",
analysisMethods: [
{
id: "id1",
name: "Geomapping",
isRequired: true,
},
{
id: "id2",
name: "Plan Provider Directory Review",
isRequired: true,
},
],
},
metadata: {
reportType: "NAAAR",
Expand All @@ -87,6 +99,40 @@ const naaarCreationEvent: APIGatewayProxyEvent = {
}),
};

const naaarCreationEvent: APIGatewayProxyEvent = {
...proxyEvent,
headers: { "cognito-identity-id": "test" },
pathParameters: { reportType: "NAAAR", state: "AL" },
body: JSON.stringify({
fieldData: {
contactName: "Contact Name",
analysisMethods: [
{
id: "id1",
name: "Geomapping",
isRequired: true,
},
{
id: "id2",
name: "Plan Provider Directory Review",
isRequired: true,
},
],
},
metadata: {
reportType: "NAAAR",
contactName: "Contact Name",
status: "Not started",
reportingPeriodStartDate: 162515200000,
reportingPeriodEndDate: 168515200000,
dueDate: 168515200000,
combinedData: false,
lastAlteredBy: "Thelonious States",
naaarReport: true,
},
}),
};

const createPccmEvent: APIGatewayProxyEvent = {
...mockProxyEvent,
body: JSON.stringify({
Expand Down Expand Up @@ -242,12 +288,12 @@ describe("Test createReport API method", () => {
});

test("Test NAAAR report creation when form is disabled throws 400 error", async () => {
const res = await createReport(naaarCreationEvent, null);
const res = await createReport(naaarCreationDisabledEvent, null);
expect(res.statusCode).toBe(StatusCodes.BadRequest);
expect(res.body).toContain(error.INVALID_DATA);
});

test("Test successful run of report creation, not copied", async () => {
test("Test successful run of MCPAR report creation, not copied", async () => {
dynamoClientMock.on(QueryCommand).resolves({
Items: [],
});
Expand Down Expand Up @@ -318,6 +364,26 @@ describe("Test createReport API method", () => {
expect(s3PutSpy).toHaveBeenCalled();
});

test("Test successful run of NAAAR report creation, not copied", async () => {
dynamoClientMock.on(QueryCommand).resolves({
Items: [],
});
const s3PutSpy = jest.spyOn(s3Lib, "put");
s3PutSpy.mockResolvedValue(mockS3PutObjectCommandOutput);
const res = await createReport(naaarCreationEvent, null);

const body = JSON.parse(res.body!);
expect(consoleSpy.debug).toHaveBeenCalled();
expect(res.statusCode).toBe(StatusCodes.Created);
expect(body.status).toContain("Not started");
expect(body.fieldDataId).toBeDefined;
expect(body.formTemplateId).toBeDefined;
expect(body.fieldData.analysisMethods).toBeDefined();
expect(body.fieldData.analysisMethods.length).toBeGreaterThan(0);
expect(body.fieldData.plans).toBeUndefined();
expect(s3PutSpy).toHaveBeenCalled();
});

test("Test dynamo issue throws error", async () => {
dynamoClientMock
.on(PutCommand)
Expand Down
8 changes: 7 additions & 1 deletion services/app-api/handlers/reports/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,17 @@ export const createReport = handler(async (event, _context) => {
const fieldDataId: string = KSUID.randomSync().string;
const formTemplateId: string = formTemplateVersion?.id;

const validationSchema = formTemplate.validationJson;
if (reportType === "NAAAR") {
// this entity does not have validation specified in the form template
validationSchema["analysisMethods"] = "objectArray";
}

// Validate field data
let validatedFieldData;
try {
validatedFieldData = await validateFieldData(
formTemplate.validationJson,
validationSchema,
unvalidatedFieldData
);
} catch {
Expand Down
69 changes: 68 additions & 1 deletion services/app-api/handlers/reports/update.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import { mockClient } from "aws-sdk-client-mock";
import { proxyEvent } from "../../utils/testing/proxyEvent";
import {
mockDynamoData,
mockDynamoNAAARData,
mockMcparReport,
mockNaaarReport,
mockReportFieldData,
mockReportJson,
mockS3PutObjectCommandOutput,
Expand Down Expand Up @@ -37,6 +39,13 @@ const mockProxyEvent: APIGatewayProxyEvent = {
body: JSON.stringify(mockMcparReport),
};

const mockNaaarProxyEvent: APIGatewayProxyEvent = {
...proxyEvent,
headers: { "cognito-identity-id": "test" },
pathParameters: { reportType: "NAAAR", state: "CO", id: "testReportId" },
body: JSON.stringify(mockNaaarReport),
};

const updateEvent: APIGatewayProxyEvent = {
...mockProxyEvent,
body: JSON.stringify({
Expand All @@ -61,6 +70,34 @@ const submissionEvent: APIGatewayProxyEvent = {
}),
};

const naaarSubmissionEvent: APIGatewayProxyEvent = {
...mockNaaarProxyEvent,
body: JSON.stringify({
...mockNaaarReport,
metadata: {
status: "submitted",
},
submittedBy: mockNaaarReport.metadata.lastAlteredBy,
submittedOnDate: Date.now(),
fieldData: {
...mockReportFieldData,
contactName: "Contact Name",
analysisMethods: [
{
id: "id1",
name: "Geomapping",
isRequired: true,
},
{
id: "id2",
name: "Plan Provider Directory Review",
isRequired: true,
},
],
},
}),
};

const invalidFieldDataSubmissionEvent: APIGatewayProxyEvent = {
...mockProxyEvent,
body: JSON.stringify({
Expand Down Expand Up @@ -113,7 +150,7 @@ describe("handlers/reports/update", () => {
mockAuthUtil.hasPermissions.mockReturnValue(true);
});

test("Test report update submission succeeds", async () => {
test("Test MCPAR report update submission succeeds", async () => {
// s3 mocks
const s3GetSpy = jest.spyOn(s3Lib, "get");
s3GetSpy
Expand Down Expand Up @@ -143,6 +180,36 @@ describe("handlers/reports/update", () => {
expect(mockPut).toHaveBeenCalled();
});

test("Test NAAAR report update submission succeeds", async () => {
// s3 mocks
const s3GetSpy = jest.spyOn(s3Lib, "get");
s3GetSpy
.mockResolvedValueOnce(mockReportJson)
.mockResolvedValueOnce(mockReportFieldData);
const s3PutSpy = jest.spyOn(s3Lib, "put");
s3PutSpy.mockResolvedValue(mockS3PutObjectCommandOutput);
// dynamodb mocks
const mockPut = jest.fn();
dynamoClientMock.on(PutCommand).callsFake(mockPut);
// fetch mock
mockedFetchReport.mockResolvedValue({
statusCode: 200,
headers: {
"Access-Control-Allow-Origin": "string",
"Access-Control-Allow-Credentials": true,
},
body: JSON.stringify(mockDynamoNAAARData),
});

const response = await updateReport(naaarSubmissionEvent, null);
const body = JSON.parse(response.body!);
expect(body.status).toContain("submitted");
expect(body.fieldData["analysisMethods"]).toBeDefined();
expect(consoleSpy.debug).toHaveBeenCalled();
expect(response.statusCode).toBe(StatusCodes.Ok);
expect(mockPut).toHaveBeenCalled();
});

test("Test attempted report update with no data returns 400", async () => {
const noBodyEvent = {
...submissionEvent,
Expand Down
Loading
Loading