-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat(test)-submit lambda #987
Merged
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8f327b5
feat(test)-submit lambda
thwalker6 22e5173
Update withdrawpackage to withdrawrai
thwalker6 c657f89
linter corrections
thwalker6 093ed80
Fix some test
thwalker6 cb5046f
Test for malformed objects
thwalker6 bec8485
Remove import vs code added in
thwalker6 aac3da6
remove console.log
thwalker6 a198821
Updatign to use get requestcontext
thwalker6 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,359 @@ | ||
import { submit } from "./index"; | ||
import { APIGatewayEvent } from "node_modules/shared-types"; | ||
import { describe, it, expect, vi, afterEach, beforeEach } from "vitest"; | ||
import { | ||
capitatedAmendmentBase, | ||
appkBase, | ||
capitatedInitial, | ||
capitatedRenewal, | ||
contractingAmmendment, | ||
contractingInitial, | ||
contractingRenewal, | ||
newChipSubmission, | ||
newMedicaidSubmission, | ||
respondToRai, | ||
temporaryExtension, | ||
toggleWithdrawRai, | ||
uploadSubsequentDocuments, | ||
withdrawPackage, | ||
withdrawRai, | ||
} from "mocks/data/submit/base"; | ||
|
||
import { makoStateSubmitter } from "mocks"; | ||
vi.mock("kafkajs", () => { | ||
const producer = { | ||
connect: vi.fn(), | ||
send: vi.fn(), | ||
disconnect: vi.fn(), | ||
}; | ||
const kafka = { | ||
producer: () => producer, | ||
}; | ||
return { | ||
Kafka: vi.fn(() => kafka), | ||
Producer: vi.fn(() => producer), | ||
}; | ||
}); | ||
describe("submit Lambda function", () => { | ||
let brokerString: string | undefined; | ||
beforeEach(() => { | ||
brokerString = process.env.brokerString; | ||
process.env.brokerString = "broker1,broker2"; | ||
}); | ||
|
||
afterEach(() => { | ||
process.env.brokerString = brokerString; | ||
}); | ||
it("should have no body", async () => { | ||
const event = {} as APIGatewayEvent; | ||
const result = await submit(event); | ||
expect(result.statusCode).toEqual(400); | ||
expect(result.body).toEqual('"Event body required"'); | ||
}); | ||
it("should have no event in the body", async () => { | ||
const event = { | ||
body: `{"event": ""}`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you could use JSON.stringify() here, I think that's what the other tests are doing for event bodies |
||
} as unknown as APIGatewayEvent; | ||
const result = await submit(event); | ||
expect(result.statusCode).toEqual(400); | ||
expect(result.body).toEqual('{"message":"Bad Request - Missing event name in body"}'); | ||
}); | ||
|
||
it("should have a bad event in the body", async () => { | ||
const event = { | ||
body: `{"event": "Not a real event"}`, | ||
} as unknown as APIGatewayEvent; | ||
const result = await submit(event); | ||
expect(result.statusCode).toEqual(400); | ||
expect(result.body).toEqual('{"message":"Bad Request - Unknown event type Not a real event"}'); | ||
}); | ||
it("should start to create an capitated ammendment event", async () => { | ||
const base = JSON.stringify(capitatedAmendmentBase); | ||
|
||
const event = { | ||
body: base, | ||
requestContext: { | ||
identity: { | ||
makoStateSubmitter, | ||
cognitoAuthenticationProvider: | ||
"https://cognito-idp.us-east-1.amazonaws.com/us-east-1_userPool1,https://cognito-idp.us-east-1.amazonaws.com/us-east-1_userPool1:CognitoSignIn:53832e35-1fbe-4c74-9111-4a0cd29ce2cf", | ||
}, | ||
}, | ||
} as unknown as APIGatewayEvent; | ||
const result = await submit(event); | ||
expect(result.statusCode).toEqual(200); | ||
expect(result.body).toEqual('{"message":"success"}'); | ||
}); | ||
it("should start to create an capitated ammendment event", async () => { | ||
const base = JSON.stringify(capitatedAmendmentBase); | ||
|
||
const event = { | ||
body: base, | ||
requestContext: { | ||
identity: { | ||
makoStateSubmitter, | ||
cognitoAuthenticationProvider: | ||
"https://cognito-idp.us-east-1.amazonaws.com/us-east-1_userPool1,https://cognito-idp.us-east-1.amazonaws.com/us-east-1_userPool1:CognitoSignIn:53832e35-1fbe-4c74-9111-4a0cd29ce2cf", | ||
}, | ||
}, | ||
} as unknown as APIGatewayEvent; | ||
const result = await submit(event); | ||
expect(result.statusCode).toEqual(200); | ||
expect(result.body).toEqual('{"message":"success"}'); | ||
}); | ||
it("should start to create an app-k event", async () => { | ||
const base = JSON.stringify(appkBase); | ||
|
||
const event = { | ||
body: base, | ||
requestContext: { | ||
identity: { | ||
makoStateSubmitter, | ||
cognitoAuthenticationProvider: | ||
"https://cognito-idp.us-east-1.amazonaws.com/us-east-1_userPool1,https://cognito-idp.us-east-1.amazonaws.com/us-east-1_userPool1:CognitoSignIn:53832e35-1fbe-4c74-9111-4a0cd29ce2cf", | ||
}, | ||
}, | ||
} as unknown as APIGatewayEvent; | ||
const result = await submit(event); | ||
expect(result.statusCode).toEqual(200); | ||
expect(result.body).toEqual('{"message":"success"}'); | ||
}); | ||
it("should start to create an capitated initial event", async () => { | ||
const base = JSON.stringify(capitatedInitial); | ||
|
||
const event = { | ||
body: base, | ||
requestContext: { | ||
identity: { | ||
makoStateSubmitter, | ||
cognitoAuthenticationProvider: | ||
"https://cognito-idp.us-east-1.amazonaws.com/us-east-1_userPool1,https://cognito-idp.us-east-1.amazonaws.com/us-east-1_userPool1:CognitoSignIn:53832e35-1fbe-4c74-9111-4a0cd29ce2cf", | ||
}, | ||
}, | ||
} as unknown as APIGatewayEvent; | ||
const result = await submit(event); | ||
expect(result.statusCode).toEqual(200); | ||
expect(result.body).toEqual('{"message":"success"}'); | ||
}); | ||
it("should start to create an contracting ammendment event", async () => { | ||
const base = JSON.stringify(contractingAmmendment); | ||
|
||
const event = { | ||
body: base, | ||
requestContext: { | ||
identity: { | ||
makoStateSubmitter, | ||
cognitoAuthenticationProvider: | ||
"https://cognito-idp.us-east-1.amazonaws.com/us-east-1_userPool1,https://cognito-idp.us-east-1.amazonaws.com/us-east-1_userPool1:CognitoSignIn:53832e35-1fbe-4c74-9111-4a0cd29ce2cf", | ||
}, | ||
}, | ||
} as unknown as APIGatewayEvent; | ||
const result = await submit(event); | ||
expect(result.statusCode).toEqual(200); | ||
expect(result.body).toEqual('{"message":"success"}'); | ||
}); | ||
it("should start to create an contracting initial event", async () => { | ||
const base = JSON.stringify(contractingInitial); | ||
|
||
const event = { | ||
body: base, | ||
requestContext: { | ||
identity: { | ||
makoStateSubmitter, | ||
cognitoAuthenticationProvider: | ||
"https://cognito-idp.us-east-1.amazonaws.com/us-east-1_userPool1,https://cognito-idp.us-east-1.amazonaws.com/us-east-1_userPool1:CognitoSignIn:53832e35-1fbe-4c74-9111-4a0cd29ce2cf", | ||
}, | ||
}, | ||
} as unknown as APIGatewayEvent; | ||
const result = await submit(event); | ||
expect(result.statusCode).toEqual(200); | ||
expect(result.body).toEqual('{"message":"success"}'); | ||
}); | ||
it("should start to create an contracting renewal event", async () => { | ||
const base = JSON.stringify(contractingRenewal); | ||
|
||
const event = { | ||
body: base, | ||
requestContext: { | ||
identity: { | ||
makoStateSubmitter, | ||
cognitoAuthenticationProvider: | ||
"https://cognito-idp.us-east-1.amazonaws.com/us-east-1_userPool1,https://cognito-idp.us-east-1.amazonaws.com/us-east-1_userPool1:CognitoSignIn:53832e35-1fbe-4c74-9111-4a0cd29ce2cf", | ||
}, | ||
}, | ||
} as unknown as APIGatewayEvent; | ||
const result = await submit(event); | ||
expect(result.statusCode).toEqual(200); | ||
expect(result.body).toEqual('{"message":"success"}'); | ||
}); | ||
it("should start to create an new chip submission event", async () => { | ||
const base = JSON.stringify(newChipSubmission); | ||
|
||
const event = { | ||
body: base, | ||
requestContext: { | ||
identity: { | ||
makoStateSubmitter, | ||
cognitoAuthenticationProvider: | ||
"https://cognito-idp.us-east-1.amazonaws.com/us-east-1_userPool1,https://cognito-idp.us-east-1.amazonaws.com/us-east-1_userPool1:CognitoSignIn:53832e35-1fbe-4c74-9111-4a0cd29ce2cf", | ||
}, | ||
}, | ||
} as unknown as APIGatewayEvent; | ||
const result = await submit(event); | ||
expect(result.statusCode).toEqual(200); | ||
expect(result.body).toEqual('{"message":"success"}'); | ||
}); | ||
it("should start to create an new chip medicaid submission event", async () => { | ||
const base = JSON.stringify(newMedicaidSubmission); | ||
|
||
const event = { | ||
body: base, | ||
requestContext: { | ||
identity: { | ||
makoStateSubmitter, | ||
cognitoAuthenticationProvider: | ||
"https://cognito-idp.us-east-1.amazonaws.com/us-east-1_userPool1,https://cognito-idp.us-east-1.amazonaws.com/us-east-1_userPool1:CognitoSignIn:53832e35-1fbe-4c74-9111-4a0cd29ce2cf", | ||
}, | ||
}, | ||
} as unknown as APIGatewayEvent; | ||
const result = await submit(event); | ||
expect(result.statusCode).toEqual(200); | ||
expect(result.body).toEqual('{"message":"success"}'); | ||
}); | ||
it("should start to create an new respond to rai event", async () => { | ||
const base = JSON.stringify(respondToRai); | ||
|
||
const event = { | ||
body: base, | ||
requestContext: { | ||
identity: { | ||
makoStateSubmitter, | ||
cognitoAuthenticationProvider: | ||
"https://cognito-idp.us-east-1.amazonaws.com/us-east-1_userPool1,https://cognito-idp.us-east-1.amazonaws.com/us-east-1_userPool1:CognitoSignIn:53832e35-1fbe-4c74-9111-4a0cd29ce2cf", | ||
}, | ||
}, | ||
} as unknown as APIGatewayEvent; | ||
const result = await submit(event); | ||
expect(result.statusCode).toEqual(200); | ||
expect(result.body).toEqual('{"message":"success"}'); | ||
}); | ||
it("should start to create an temporary extension event", async () => { | ||
const base = JSON.stringify(temporaryExtension); | ||
|
||
const event = { | ||
body: base, | ||
requestContext: { | ||
identity: { | ||
makoStateSubmitter, | ||
cognitoAuthenticationProvider: | ||
"https://cognito-idp.us-east-1.amazonaws.com/us-east-1_userPool1,https://cognito-idp.us-east-1.amazonaws.com/us-east-1_userPool1:CognitoSignIn:53832e35-1fbe-4c74-9111-4a0cd29ce2cf", | ||
}, | ||
}, | ||
} as unknown as APIGatewayEvent; | ||
const result = await submit(event); | ||
expect(result.statusCode).toEqual(200); | ||
expect(result.body).toEqual('{"message":"success"}'); | ||
}); | ||
it("should start to create an toggle withdraw event", async () => { | ||
const base = JSON.stringify(toggleWithdrawRai); | ||
|
||
const event = { | ||
body: base, | ||
requestContext: { | ||
identity: { | ||
makoStateSubmitter, | ||
cognitoAuthenticationProvider: | ||
"https://cognito-idp.us-east-1.amazonaws.com/us-east-1_userPool1,https://cognito-idp.us-east-1.amazonaws.com/us-east-1_userPool1:CognitoSignIn:53832e35-1fbe-4c74-9111-4a0cd29ce2cf", | ||
}, | ||
}, | ||
} as unknown as APIGatewayEvent; | ||
const result = await submit(event); | ||
expect(result.statusCode).toEqual(200); | ||
expect(result.body).toEqual('{"message":"success"}'); | ||
}); | ||
it("should start to create an withdraw package event", async () => { | ||
const base = JSON.stringify(withdrawPackage); | ||
|
||
const event = { | ||
body: base, | ||
requestContext: { | ||
identity: { | ||
makoStateSubmitter, | ||
cognitoAuthenticationProvider: | ||
"https://cognito-idp.us-east-1.amazonaws.com/us-east-1_userPool1,https://cognito-idp.us-east-1.amazonaws.com/us-east-1_userPool1:CognitoSignIn:53832e35-1fbe-4c74-9111-4a0cd29ce2cf", | ||
}, | ||
}, | ||
} as unknown as APIGatewayEvent; | ||
const result = await submit(event); | ||
expect(result.statusCode).toEqual(200); | ||
expect(result.body).toEqual('{"message":"success"}'); | ||
}); | ||
it("should start to create an withdraw rai event", async () => { | ||
const base = JSON.stringify(withdrawRai); | ||
|
||
const event = { | ||
body: base, | ||
requestContext: { | ||
identity: { | ||
makoStateSubmitter, | ||
cognitoAuthenticationProvider: | ||
"https://cognito-idp.us-east-1.amazonaws.com/us-east-1_userPool1,https://cognito-idp.us-east-1.amazonaws.com/us-east-1_userPool1:CognitoSignIn:53832e35-1fbe-4c74-9111-4a0cd29ce2cf", | ||
}, | ||
}, | ||
} as unknown as APIGatewayEvent; | ||
const result = await submit(event); | ||
expect(result.statusCode).toEqual(200); | ||
expect(result.body).toEqual('{"message":"success"}'); | ||
}); | ||
it("should start to create an capitated renewal event", async () => { | ||
const base = JSON.stringify(capitatedRenewal); | ||
|
||
const event = { | ||
body: base, | ||
requestContext: { | ||
identity: { | ||
makoStateSubmitter, | ||
cognitoAuthenticationProvider: | ||
"https://cognito-idp.us-east-1.amazonaws.com/us-east-1_userPool1,https://cognito-idp.us-east-1.amazonaws.com/us-east-1_userPool1:CognitoSignIn:53832e35-1fbe-4c74-9111-4a0cd29ce2cf", | ||
}, | ||
}, | ||
} as unknown as APIGatewayEvent; | ||
const result = await submit(event); | ||
expect(result.statusCode).toEqual(200); | ||
expect(result.body).toEqual('{"message":"success"}'); | ||
}); | ||
it("should start to create an contracting initial event", async () => { | ||
const base = JSON.stringify(contractingInitial); | ||
|
||
const event = { | ||
body: base, | ||
requestContext: { | ||
identity: { | ||
makoStateSubmitter, | ||
cognitoAuthenticationProvider: | ||
"https://cognito-idp.us-east-1.amazonaws.com/us-east-1_userPool1,https://cognito-idp.us-east-1.amazonaws.com/us-east-1_userPool1:CognitoSignIn:53832e35-1fbe-4c74-9111-4a0cd29ce2cf", | ||
}, | ||
}, | ||
} as unknown as APIGatewayEvent; | ||
const result = await submit(event); | ||
expect(result.statusCode).toEqual(200); | ||
expect(result.body).toEqual('{"message":"success"}'); | ||
}); | ||
it("should start to create an upload subsequent documents event", async () => { | ||
const base = JSON.stringify(uploadSubsequentDocuments); | ||
|
||
const event = { | ||
body: base, | ||
requestContext: { | ||
identity: { | ||
makoStateSubmitter, | ||
cognitoAuthenticationProvider: | ||
"https://cognito-idp.us-east-1.amazonaws.com/us-east-1_userPool1,https://cognito-idp.us-east-1.amazonaws.com/us-east-1_userPool1:CognitoSignIn:53832e35-1fbe-4c74-9111-4a0cd29ce2cf", | ||
}, | ||
}, | ||
} as unknown as APIGatewayEvent; | ||
const result = await submit(event); | ||
expect(result.statusCode).toEqual(200); | ||
expect(result.body).toEqual('{"message":"success"}'); | ||
}); | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a new object that gets pulled into the search