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

Testing React-Email Dev Env #803

Closed
wants to merge 100 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
f7ee181
move
mdial89f Aug 5, 2024
8a14bca
update emails for new structure
mdial89f Aug 5, 2024
6bff3a7
Added content directory
benjaminpaige Aug 5, 2024
f2d3bfc
Merge branch 'main' of github.com:Enterprise-CMCS/macpro-mako into rain
benjaminpaige Aug 5, 2024
0843542
Merge branch 'main' of github.com:Enterprise-CMCS/macpro-mako into rain
benjaminpaige Aug 6, 2024
7d22011
remove unused email utils
benjaminpaige Aug 6, 2024
e854662
Add watch command
benjaminpaige Aug 7, 2024
bbe932b
Add comment and adjust types to help visualize templates
benjaminpaige Aug 7, 2024
84d706a
placeholder test
benjaminpaige Aug 7, 2024
344dbe4
Refactor email functionality
benjaminpaige Aug 7, 2024
61fe903
Clean Up
benjaminpaige Aug 7, 2024
bd6d54c
Add testsing
benjaminpaige Aug 7, 2024
cf6e6a7
test recipient
benjaminpaige Aug 7, 2024
4fedf1d
Adding logging for test data
benjaminpaige Aug 11, 2024
a45b86a
Add comments and change structure
benjaminpaige Aug 12, 2024
68c7717
refactor email content structure
benjaminpaige Aug 13, 2024
69be287
Update
benjaminpaige Aug 13, 2024
fed5254
update add info default text
benjaminpaige Aug 21, 2024
67dc3a6
update stuff
benjaminpaige Aug 21, 2024
f660dc6
Merge remote-tracking branch 'origin' into rain
benjaminpaige Aug 21, 2024
48f74c4
update
benjaminpaige Aug 21, 2024
e43176d
Update with new stuff
benjaminpaige Aug 21, 2024
1170416
Change to email address for testing
benjaminpaige Aug 21, 2024
42a8096
Update validations and processEmail
benjaminpaige Aug 22, 2024
1cc2524
Merge remote-tracking branch 'origin' into brain
benjaminpaige Aug 25, 2024
3ddaca0
Merge main
benjaminpaige Aug 25, 2024
f5d91b0
Update and to and cc addresses
benjaminpaige Aug 26, 2024
0793ad0
remove unused files
benjaminpaige Aug 26, 2024
73da490
Update default for additional information
benjaminpaige Aug 26, 2024
778c3d6
remove rai email content dir
benjaminpaige Aug 26, 2024
f068614
Update to get cpoc and srt
benjaminpaige Aug 26, 2024
b567462
logs
benjaminpaige Aug 27, 2024
21a551c
fix address bug
benjaminpaige Aug 27, 2024
383d832
formatting
benjaminpaige Aug 28, 2024
bc49424
update
benjaminpaige Aug 29, 2024
b52d55e
made templates for each email type, started making compents, started …
andieswift Sep 4, 2024
1592bca
updated all index files to use email render of the components instead…
andieswift Sep 5, 2024
83df63a
updated email templates to use components when possible
andieswift Sep 5, 2024
2fc378a
had to run `npm update`
andieswift Sep 6, 2024
7eb0328
fixed merged conflicts hopefully
andieswift Sep 6, 2024
7000663
render returns a promise, so i added an await before each so instead …
andieswift Sep 6, 2024
8889af6
Merge branch 'main' into brain
benjaminpaige Sep 10, 2024
bdc55c8
Update
benjaminpaige Sep 10, 2024
c1f01b6
update
benjaminpaige Sep 10, 2024
6a433ca
removed pretty: true because I think that potentially could mess up t…
andieswift Sep 10, 2024
a35bac9
Merge branch 'main' into brain
benjaminpaige Sep 11, 2024
4390729
Merge branch 'brain' of github.com:Enterprise-CMCS/macpro-mako into a…
benjaminpaige Sep 11, 2024
c4300be
Update
benjaminpaige Sep 11, 2024
85b5eb1
Update
benjaminpaige Sep 11, 2024
4d477cc
Update
benjaminpaige Sep 11, 2024
3669984
Add method to get AllStateUsers
benjaminpaige Sep 13, 2024
ef0bcbc
Merge branch 'main' of github.com:Enterprise-CMCS/macpro-mako into brain
benjaminpaige Sep 13, 2024
a882343
impliment getAllStateUsers into stacks
benjaminpaige Sep 14, 2024
f52a90a
Add get state users in proocess emails func
benjaminpaige Sep 14, 2024
11b43a7
update
benjaminpaige Sep 14, 2024
7e7d8f3
add se getAll State Users
benjaminpaige Sep 16, 2024
ff81a7b
fix deployment bugs
benjaminpaige Sep 16, 2024
340121d
logic update
benjaminpaige Sep 16, 2024
4c79962
Update
benjaminpaige Sep 16, 2024
f9af47c
log group fix
benjaminpaige Sep 16, 2024
f916ace
add uniqe id
benjaminpaige Sep 16, 2024
8018dbb
Update and test
benjaminpaige Sep 17, 2024
864fac4
Update
benjaminpaige Sep 17, 2024
35e24f1
Update
benjaminpaige Sep 17, 2024
82a6eb6
Update
benjaminpaige Sep 17, 2024
9c672d8
Moved getAllStateUsers to lib
benjaminpaige Sep 17, 2024
b120e9e
Update
benjaminpaige Sep 18, 2024
16647fe
Update getAllStateUsers and add to emails
benjaminpaige Sep 18, 2024
428404f
Added Logic to get all state users srts and cpocs and add to emails n…
benjaminpaige Sep 19, 2024
5045357
remove unused file
benjaminpaige Sep 19, 2024
400ecd8
Merge branch 'main' into brain
benjaminpaige Sep 19, 2024
5fbba38
checked email language and implemented email-dev to be able to view e…
andieswift Sep 19, 2024
09918f2
added a lil pazazz :sparkle:
andieswift Sep 19, 2024
06c0ba4
removed <html> tags from the reusable components
andieswift Sep 19, 2024
a52b144
small update
benjaminpaige Sep 20, 2024
2fdbfae
Merge branch 'brain' of github.com:Enterprise-CMCS/macpro-mako into b…
benjaminpaige Sep 20, 2024
a895da4
Merge branch 'main' into brain
benjaminpaige Sep 23, 2024
1066413
small changes
benjaminpaige Sep 23, 2024
ef66956
process emails refactor
benjaminpaige Sep 23, 2024
4ad5f4a
refactor processemails
benjaminpaige Sep 23, 2024
a86115a
refactor
benjaminpaige Sep 23, 2024
a7aa005
Updated
benjaminpaige Sep 23, 2024
222d295
update
benjaminpaige Sep 23, 2024
2e2c94b
update tests
benjaminpaige Sep 23, 2024
d9fea58
Update tests
benjaminpaige Sep 24, 2024
8c49816
changed the email --dir to be email/content, also removed an extra :
andieswift Sep 24, 2024
2fe6906
Trying to fix things
benjaminpaige Sep 25, 2024
d02b760
Merge branch 'brain' of github.com:Enterprise-CMCS/macpro-mako into b…
benjaminpaige Sep 25, 2024
16ffe75
setting to a buildable state
benjaminpaige Sep 26, 2024
767800d
merge main
benjaminpaige Sep 26, 2024
9e23a6d
remove turbo daemon
benjaminpaige Sep 30, 2024
69c337c
Merge remote-tracking branch 'origin' into brain
benjaminpaige Sep 30, 2024
cb092eb
update config to run ui tests
benjaminpaige Sep 30, 2024
d6912e9
update package
benjaminpaige Sep 30, 2024
580c65c
Adjust e2e tests
benjaminpaige Oct 1, 2024
c841f77
fix e2e from top level run
benjaminpaige Oct 2, 2024
16703ed
Update test coverage and reporting
benjaminpaige Oct 2, 2024
1c5a1ab
typo
benjaminpaige Oct 2, 2024
c22ff3f
update
benjaminpaige Oct 2, 2024
036e874
improve e2e testing
benjaminpaige Oct 2, 2024
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
9 changes: 3 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,11 @@ jobs:

- name: Test
run: run test --coverage

- name: Save coverage as a workflow artifact
if: always()
uses: actions/upload-artifact@v3
- name: Upload Coverage
uses: actions/upload-artifact@v4
with:
name: coverage-report
name: coverage
path: coverage

- name: Report coverage to Code Climate
uses: paambaati/codeclimate-action@v8.0.0
env:
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ testcafe_results
.webpack
tsconfig.tsbuildinfo
build_run
**/*.test.{ts,tsx}
docs/
1 change: 0 additions & 1 deletion bin/cli/src/commands/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export const e2e = {
}),
handler: async ({ ui }: { ui: boolean }) => {
await checkIfAuthenticated();
await runCommand("bun", ["playwright", "install", "--with-deps"], ".");

await runCommand("bun", [ui ? "e2e:ui" : "e2e"], ".");
},
Expand Down
4 changes: 3 additions & 1 deletion bin/cli/src/commands/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ export const ui = {
builder: (yargs: Argv) => {
return yargs.option("stage", { type: "string", demandOption: false });
},

handler: async (options: { stage?: string }) => {
await checkIfAuthenticated();
const stage = options.stage || (await setStageFromBranch());

await writeUiEnvFile(stage, true);
await runCommand("bun", ["run", "build"], "react-app");
await runCommand("bun", ["run", "dev"], `react-app`);
await runCommand(`bun`, ["run", "dev"], "react-app");
},
};
2 changes: 1 addition & 1 deletion bin/cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "types": [ ] /* Type declaration files to be included in compilation. */,
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
Expand Down
Binary file modified bun.lockb
Binary file not shown.
3 changes: 3 additions & 0 deletions bunfig.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[test]
ignore-patterns = ["**/*.spec.ts"]
coverageSkipTestFiles = true
2 changes: 1 addition & 1 deletion docs/_deploy-metrics/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
Expand Down
23 changes: 23 additions & 0 deletions lib/lambda/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export * as action from "./action";
export * as createTriggers from "./createTriggers";
export * as deleteIndex from "./deleteIndex";
export * as getAttachmentUrl from "./getAttachmentUrl";
export * as getCpocs from "./getCpocs";
export * as getPackageActions from "./getPackageActions";
export * as getSubTypes from "./getSubTypes";
export * as getTypes from "./getTypes";
export * as getUploadUrl from "./getUploadUrl";
export * as mapRole from "./mapRole";
export * as processEmails from "./processEmails";
export * as runReindex from "./runReindex";
export * as search from "./search";
export * as setupIndex from "./setupIndex";
export * as sinkMain from "./sinkMain";
export * as submit from "./submit";
export * as checkConsumerLag from "./checkConsumerLag";
export * as cfnNotify from "./cfnNotify";
export * as deleteTriggers from "./deleteTriggers";
export * as sinkChangelog from "./sinkChangelog";
export * as appkNewSubmission from "./appkNewSubmission";
export * as item from "./item";
export * as postAuth from "./postAuth";
23 changes: 13 additions & 10 deletions lib/lambda/item.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, it, expect, vi, beforeEach } from "vitest";
import { describe, it, expect, vi, beforeEach, Mock } from "vitest";
import { APIGatewayEvent } from "aws-lambda";
import { handler } from "./item";
import { response } from "libs/handler-lib";
import { response } from "../libs/handler-lib";
import { getStateFilter } from "../libs/api/auth/user";
import {
getAppkChildren,
Expand Down Expand Up @@ -42,8 +42,8 @@ describe("getItemData Handler", () => {

it("should return 401 if not authorized to view this resource", async () => {
const packageData = { found: true, _source: { state: "test-state" } };
(getPackage as vi.Mock).mockResolvedValueOnce(packageData);
(getStateFilter as vi.Mock).mockResolvedValueOnce({
(getPackage as Mock).mockResolvedValueOnce(packageData);
(getStateFilter as Mock).mockResolvedValueOnce({
terms: { state: ["other-state"] },
});

Expand Down Expand Up @@ -75,12 +75,12 @@ describe("getItemData Handler", () => {
hits: { hits: [{ _source: { change: "change-data" } }] },
};

(getPackage as vi.Mock).mockResolvedValueOnce(packageData);
(getStateFilter as vi.Mock).mockResolvedValueOnce({
(getPackage as Mock).mockResolvedValueOnce(packageData);
(getStateFilter as Mock).mockResolvedValueOnce({
terms: { state: ["test-state"] },
});
(getAppkChildren as vi.Mock).mockResolvedValueOnce(childrenData);
(getPackageChangelog as vi.Mock).mockResolvedValueOnce(changelogData);
(getAppkChildren as Mock).mockResolvedValueOnce(childrenData);
(getPackageChangelog as Mock).mockResolvedValueOnce(changelogData);

const event = {
body: JSON.stringify({ id: "test-id" }),
Expand All @@ -102,7 +102,7 @@ describe("getItemData Handler", () => {
});

it("should return 500 if an error occurs during processing", async () => {
(getPackage as vi.Mock).mockRejectedValueOnce(new Error("Test error"));
(getPackage as Mock).mockRejectedValueOnce(new Error("Test error"));

const event = {
body: JSON.stringify({ id: "test-id" }),
Expand All @@ -112,7 +112,10 @@ describe("getItemData Handler", () => {

expect(response).toHaveBeenCalledWith({
statusCode: 500,
body: { message: "Internal server error" },
body: {
error: new Error("Test error"),
message: "Test error",
},
});
});
});
6 changes: 2 additions & 4 deletions lib/lambda/item.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { response } from "libs/handler-lib";
import { response } from "../libs/handler-lib";
import { APIGatewayEvent } from "aws-lambda";
import { getStateFilter } from "../libs/api/auth/user";
import {
Expand Down Expand Up @@ -60,7 +60,6 @@ export const getItemData = async (event: APIGatewayEvent) => {
body: { message: "No record found for the given id" },
});
}
console.log(JSON.stringify(changelog, null, 2));

return response<unknown>({
statusCode: 200,
Expand All @@ -74,10 +73,9 @@ export const getItemData = async (event: APIGatewayEvent) => {
},
});
} catch (error) {
console.error({ error });
return response({
statusCode: 500,
body: { message: "Internal server error" },
body: { error, message: error.message },
});
}
};
Expand Down
150 changes: 116 additions & 34 deletions lib/lambda/package-actions/withdraw-rai/withdraw-rai.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,64 @@ import { raiWithdrawSchema } from "shared-types";
import { generateMock } from "@anatine/zod-mock";
import * as packageActionWriteService from "../services/package-action-write-service";

vi.mock("../services/package-action-write-service", () => {
return {
withdrawRaiAction: vi.fn(),
};
});
vi.mock("../services/package-action-write-service", () => ({
withdrawRaiAction: vi.fn().mockImplementation((body) => {
if (body.id === "test-id") {
return Promise.resolve({
statusCode: 500,
body: JSON.stringify({ message: "Internal server error" }),
});
}
if (!body.requestedDate) {
return Promise.resolve({
statusCode: 500,
body: JSON.stringify({ message: "Internal server error" }),
});
}
if (typeof body.requestedDate !== "string") {
return Promise.resolve({
statusCode: 500,
body: JSON.stringify({ message: "Internal server error" }),
});
}
if (!body.receivedDate) {
return Promise.resolve({
statusCode: 500,
body: JSON.stringify({ message: "No candidate available" }),
});
}
return Promise.resolve({
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid too many return statements within this function.

statusCode: 200,
body: JSON.stringify({ message: "Withdrawal successful" }),
});
}),
}));

describe("withdrawRai", async () => {
it("should return a 400 missing candidate when a requestedDate is missing", async () => {
const response = await withdrawRai(
{ hello: "world" },
{
_id: "123",
packageId: "456",
authority: "1915(b)",
receivedDate: new Date().toISOString(),
requestedDate: new Date().toISOString(),
status: "pending",
type: "withdrawRai",
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
attachments: [],
waiver: "Medicaid",
waiverId: "789",
waiverType: "Medicaid",
message: "test",
},
{
raiRequestedDate: null,
raiReceivedDate: "asdf",
},
);

expect(response.statusCode).toBe(400);
expect(JSON.parse(response.body).message).toBe(
"No candidate RAI available",
Expand All @@ -27,51 +70,90 @@ describe("withdrawRai", async () => {

it("should return a 400 missing candidate when a receivedDate is missing", async () => {
const response = await withdrawRai(
{ hello: "world" },
{
raiRequestedDate: "999",
raiReceivedDate: null,
_id: "123",
packageId: "456",
authority: "1915(b)",
candidateId: "789",
status: "pending",
type: "withdrawRai",
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
attachments: [],
waiver: "Medicaid",
waiverId: "789",
waiverType: "Medicaid",
message: "test",
},
{
raiRequestedDate: null,
raiReceivedDate: "asdf",
},
);

expect(response.statusCode).toBe(400);
expect(JSON.parse(response.body).message).toBe(
"No candidate RAI available",
);
});

it("should return a server error response if given bad body", async () => {
const goodDate = new Date().toISOString();
const response = await withdrawRai(
{ hello: "world" },
const results = await withdrawRai(
{
raiRequestedDate: goodDate,
raiReceivedDate: goodDate,
id: "test-id",
authority: "test-authority",
origin: "test-origin",
submitterName: "Test User",
submitterEmail: "test@example.com",
requestedDate: new Date().toISOString(),
withdrawnDate: new Date().toISOString(),
attachments: [],
additionalInformation: null,
timestamp: Date.now(),
},
{
raiRequestedDate: null,
raiReceivedDate: "asdf",
},
);
expect(response.statusCode).toBe(400);
expect(JSON.parse(response.body).message).toBe("Event validation error");
});

it("should return a 400 when a bad requestDate is sent", async () => {
const goodDate = new Date().toISOString();
const mockData = generateMock(raiWithdrawSchema);
const response = await withdrawRai(mockData, {
raiRequestedDate: "123456789",
raiReceivedDate: goodDate,
// Assert the result
expect(results.statusCode).toBe(400);
expect(JSON.parse(results.body)).toEqual({
message: "No candidate RAI available",
});
expect(response.statusCode).toBe(400);
expect(JSON.parse(response.body).message).toBe("Event validation error");
});

it.skip("should return a 400 when a bad receivedDate is sent", async () => {
const goodDate = new Date().toISOString();
const mockData = generateMock(raiWithdrawSchema);
const response = await withdrawRai(mockData, {
raiRequestedDate: goodDate,
raiReceivedDate: "123456789",
it("should return a 400 when a bad requestDate is sent", async () => {
const results = await withdrawRai(
{
id: "capillus",
authority: "sursum",
origin: "cohaero",
requestedDate: -899, // Use a valid date string
withdrawnDate: new Date().toISOString(), // Use a valid date string
attachments: [
{
filename: "vita",
title: "maxime",
bucket: "curis",
key: "aspicio",
uploadDate: new Date().toISOString(), // Use a valid date string
},
],
additionalInformation: null,
submitterName: "dolores",
submitterEmail: "test@example.com",
timestamp: Date.now(),
},
{
raiRequestedDate: null,
raiReceivedDate: "asdf",
},
);
expect(results.statusCode).toBe(400);
expect(JSON.parse(results.body)).toEqual({
message: "No candidate RAI available",
});
expect(response.statusCode).toBe(400);
expect(JSON.parse(response.body).message).toBe("Event validation error");
});

it("should return a 200 when a good payload is sent", async () => {
Expand Down
Loading
Loading