Skip to content

Commit

Permalink
update reportType with QMS
Browse files Browse the repository at this point in the history
  • Loading branch information
Rocio De Santiago authored and Rocio De Santiago committed Dec 23, 2024
1 parent 570e7e7 commit cd5d948
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .env.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ LOCAL_LOGIN=true
LOGGING_BUCKET=log-bucket
S3_LOCAL_ENDPOINT=http://localhost:4569
SKIP_PREFLIGHT_CHECK=true
QM_REPORT_TABLE_NAME=local-qm-reports
QMS_REPORT_TABLE_NAME=local-qms-reports

# Values used for short-circuiting ssm: lookups, most likely won't need locally
VPC_ID=local-nonsense
Expand Down
2 changes: 1 addition & 1 deletion serverless-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ services:
path: services/app-api
params:
BannerTableName: ${database.BannerTableName}
QmReportTableName: ${database.QmReportTableName}
QmsReportTableName: ${database.QmsReportTableName}

# wave 3: depends on many
ui-auth:
Expand Down
4 changes: 2 additions & 2 deletions services/app-api/handlers/reports/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jest.mock("./buildReport", () => ({

const testEvent: APIGatewayProxyEvent = {
...proxyEvent,
pathParameters: { reportType: "QM", state: "PA" },
pathParameters: { reportType: "QMS", state: "PA" },
headers: { "cognito-identity-id": "test" },
};

Expand All @@ -48,7 +48,7 @@ describe("Test create report handler", () => {
test("Test missing body", async () => {
const emptyBodyEvent = {
...proxyEvent,
pathParameters: { reportType: "QM", state: "PA" },
pathParameters: { reportType: "QMS", state: "PA" },
body: null,
} as APIGatewayProxyEvent;
const res = await createReport(emptyBodyEvent);
Expand Down
10 changes: 5 additions & 5 deletions services/app-api/handlers/reports/update.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ jest.mock("../../storage/reports", () => ({
putReport: () => jest.fn(),
}));

const reportObj = { type: "QM", state: "PA", id: "QMPA123" };
const reportObj = { type: "QMS", state: "PA", id: "QMPA123" };
const report = JSON.stringify(reportObj);

const testEvent: APIGatewayProxyEvent = {
...proxyEvent,
pathParameters: { reportType: "QM", state: "PA", id: "QMPA123" },
pathParameters: { reportType: "QMS", state: "PA", id: "QMPA123" },
headers: { "cognito-identity-id": "test" },
body: report,
};
Expand Down Expand Up @@ -52,7 +52,7 @@ describe("Test update report handler", () => {
test("Test missing body", async () => {
const emptyBodyEvent = {
...proxyEvent,
pathParameters: { reportType: "QM", state: "PA", id: "QMPA123" },
pathParameters: { reportType: "QMS", state: "PA", id: "QMPA123" },
body: null,
} as APIGatewayProxyEvent;
const res = await updateReport(emptyBodyEvent);
Expand All @@ -67,12 +67,12 @@ describe("Test update report handler", () => {
} as APIGatewayProxyEvent;
const badState = {
...proxyEvent,
pathParameters: { reportType: "QM", state: "PA", id: "QMPA123" },
pathParameters: { reportType: "QMS", state: "PA", id: "QMPA123" },
body: JSON.stringify({ ...reportObj, state: "OR" }),
} as APIGatewayProxyEvent;
const badId = {
...proxyEvent,
pathParameters: { reportType: "QM", state: "PA", id: "ZZOR1234" },
pathParameters: { reportType: "QMS", state: "PA", id: "ZZOR1234" },
body: report,
} as APIGatewayProxyEvent;

Expand Down
14 changes: 7 additions & 7 deletions services/app-api/libs/tests/param-lib.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ describe("Path parameter parsing", () => {
it("should validate report type and state", () => {
const event = {
...proxyEvent,
pathParameters: { reportType: "QM", state: "CO" },
pathParameters: { reportType: "QMS", state: "CO" },
};
const result = parseReportTypeAndState(event)!;
expect(result).toBeDefined();
expect(result.reportType).toBe("QM");
expect(result.reportType).toBe("QMS");
expect(result.state).toBe("CO");
});

Expand All @@ -26,7 +26,7 @@ describe("Path parameter parsing", () => {
it("should return false for invalid state", () => {
const event = {
...proxyEvent,
pathParameters: { reportType: "QM", state: "XX" },
pathParameters: { reportType: "QMS", state: "XX" },
};
const result = parseReportTypeAndState(event);
expect(result).toBeUndefined();
Expand All @@ -37,11 +37,11 @@ describe("Path parameter parsing", () => {
it("should validate report type and state", () => {
const event = {
...proxyEvent,
pathParameters: { reportType: "QM", state: "CO", id: "foo" },
pathParameters: { reportType: "QMS", state: "CO", id: "foo" },
};
const result = parseReportParameters(event)!;
expect(result).toBeDefined();
expect(result.reportType).toBe("QM");
expect(result.reportType).toBe("QMS");
expect(result.state).toBe("CO");
expect(result.id).toBe("foo");
});
Expand All @@ -58,7 +58,7 @@ describe("Path parameter parsing", () => {
it("should return false for invalid state", () => {
const event = {
...proxyEvent,
pathParameters: { reportType: "QM", state: "XX", id: "foo" },
pathParameters: { reportType: "QMS", state: "XX", id: "foo" },
};
const result = parseReportParameters(event);
expect(result).toBeUndefined();
Expand All @@ -67,7 +67,7 @@ describe("Path parameter parsing", () => {
it("should return false for missing report ID", () => {
const event = {
...proxyEvent,
pathParameters: { reportType: "QM", state: "CO" },
pathParameters: { reportType: "QMS", state: "CO" },
};
const result = parseReportParameters(event);
expect(result).toBeUndefined();
Expand Down
4 changes: 2 additions & 2 deletions services/app-api/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ custom:
dotenv:
path: ../../.env
bannerTableName: ${env:BANNER_TABLE_NAME, param:BannerTableName}
qmReportTableName: ${env:QM_REPORT_TABLE_NAME, param:QmReportTableName}
qmsReportTableName: ${env:QMS_REPORT_TABLE_NAME, param:QmsReportTableName}
webAclName: ${self:service}-${self:custom.stage}-webacl-waf
associateWaf:
name: ${self:custom.webAclName}
Expand Down Expand Up @@ -81,7 +81,7 @@ provider:
environment:
STAGE: ${self:custom.stage}
BANNER_TABLE_NAME: ${self:custom.bannerTableName}
QM_REPORT_TABLE_NAME: ${self:custom.qmReportTableName}
QMS_REPORT_TABLE_NAME: ${self:custom.qmsReportTableName}

functions:
createBanner:
Expand Down
14 changes: 7 additions & 7 deletions services/app-api/storage/reports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { mockClient } from "aws-sdk-client-mock";

const mockDynamo = mockClient(DynamoDBDocumentClient);
const mockReport = {
type: "QM",
type: "QMS",
id: "mock-report-id",
state: "CO",
} as Report;
Expand All @@ -30,7 +30,7 @@ describe("Report storage helpers", () => {

expect(mockPut).toHaveBeenCalledWith(
{
TableName: "local-qm-reports",
TableName: "local-qms-reports",
Item: mockReport,
},
expect.any(Function)
Expand All @@ -45,12 +45,12 @@ describe("Report storage helpers", () => {
});
mockDynamo.on(GetCommand).callsFake(mockGet);

const report = await getReport(ReportType.QM, "CO", "mock-report-id");
const report = await getReport(ReportType.QMS, "CO", "mock-report-id");

expect(report).toBe(mockReport);
expect(mockGet).toHaveBeenCalledWith(
{
TableName: "local-qm-reports",
TableName: "local-qms-reports",
Key: { state: "CO", id: "mock-report-id" },
},
expect.any(Function)
Expand All @@ -59,7 +59,7 @@ describe("Report storage helpers", () => {

it("should return undefined if report is not found", async () => {
mockDynamo.on(GetCommand).resolvesOnce({});
const report = await getReport(ReportType.QM, "CO", "mock-report-id");
const report = await getReport(ReportType.QMS, "CO", "mock-report-id");
expect(report).toBe(undefined);
});
});
Expand All @@ -72,12 +72,12 @@ describe("Report storage helpers", () => {
});
mockDynamo.on(QueryCommand).callsFake(mockQuery);

const reports = await queryReportsForState(ReportType.QM, "CO");
const reports = await queryReportsForState(ReportType.QMS, "CO");

expect(reports).toEqual([mockReport]);
expect(mockQuery).toHaveBeenCalledWith(
{
TableName: "local-qm-reports",
TableName: "local-qms-reports",
KeyConditionExpression: "#state = :state",
ExpressionAttributeValues: { ":state": "CO" },
ExpressionAttributeNames: { "#state": "state" },
Expand Down
2 changes: 1 addition & 1 deletion services/app-api/testing/setupJest.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
process.env.STAGE = "local";
process.env.QM_REPORT_TABLE_NAME = "local-qm-reports";
process.env.QMS_REPORT_TABLE_NAME = "local-qms-reports";
process.env.BANNER_TABLE_NAME = "local-banners";

/*
Expand Down
14 changes: 7 additions & 7 deletions services/database/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ custom:
dotenv:
path: ../../.env
bannerTableName: ${self:custom.stage}-banners
qmReportTableName: ${self:custom.stage}-qm-reports
qmsReportTableName: ${self:custom.stage}-qms-reports
dynamodb:
stages:
- local
Expand Down Expand Up @@ -79,10 +79,10 @@ resources:
- AttributeName: key
KeyType: HASH
BillingMode: PAY_PER_REQUEST # Set the capacity to auto-scale
QmReportTable:
QmsReportTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:custom.qmReportTableName}
TableName: ${self:custom.qmsReportTableName}
PointInTimeRecoverySpecification:
PointInTimeRecoveryEnabled: true
StreamSpecification:
Expand All @@ -101,9 +101,9 @@ resources:
Outputs:
BannerTableName:
Value: !Ref BannerTable
QmReportTableName:
Value: !Ref QmReportTable
QmReportTableArn:
Value: !GetAtt QmReportTable.Arn
QmsReportTableName:
Value: !Ref QmsReportTable
QmsReportTableArn:
Value: !GetAtt QmsReportTable.Arn
Region:
Value: !Sub ${AWS::Region}

0 comments on commit cd5d948

Please sign in to comment.