From cd5d948e226384b11a9fb6657af8eec3ec4e4109 Mon Sep 17 00:00:00 2001 From: Rocio De Santiago Date: Mon, 23 Dec 2024 13:57:06 -0600 Subject: [PATCH] update reportType with QMS --- .env.tpl | 2 +- serverless-compose.yml | 2 +- services/app-api/handlers/reports/create.test.ts | 4 ++-- services/app-api/handlers/reports/update.test.ts | 10 +++++----- services/app-api/libs/tests/param-lib.test.ts | 14 +++++++------- services/app-api/serverless.yml | 4 ++-- services/app-api/storage/reports.test.ts | 14 +++++++------- services/app-api/testing/setupJest.ts | 2 +- services/database/serverless.yml | 14 +++++++------- 9 files changed, 33 insertions(+), 33 deletions(-) diff --git a/.env.tpl b/.env.tpl index f54a820b..d2e6581a 100755 --- a/.env.tpl +++ b/.env.tpl @@ -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 diff --git a/serverless-compose.yml b/serverless-compose.yml index 6230bcb5..d6c58063 100644 --- a/serverless-compose.yml +++ b/serverless-compose.yml @@ -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: diff --git a/services/app-api/handlers/reports/create.test.ts b/services/app-api/handlers/reports/create.test.ts index b38b4ae0..701719b8 100644 --- a/services/app-api/handlers/reports/create.test.ts +++ b/services/app-api/handlers/reports/create.test.ts @@ -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" }, }; @@ -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); diff --git a/services/app-api/handlers/reports/update.test.ts b/services/app-api/handlers/reports/update.test.ts index 5c398416..90fa4b79 100644 --- a/services/app-api/handlers/reports/update.test.ts +++ b/services/app-api/handlers/reports/update.test.ts @@ -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, }; @@ -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); @@ -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; diff --git a/services/app-api/libs/tests/param-lib.test.ts b/services/app-api/libs/tests/param-lib.test.ts index b8776229..0b1f4a24 100644 --- a/services/app-api/libs/tests/param-lib.test.ts +++ b/services/app-api/libs/tests/param-lib.test.ts @@ -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"); }); @@ -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(); @@ -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"); }); @@ -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(); @@ -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(); diff --git a/services/app-api/serverless.yml b/services/app-api/serverless.yml index 2830de73..291e6cc9 100644 --- a/services/app-api/serverless.yml +++ b/services/app-api/serverless.yml @@ -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} @@ -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: diff --git a/services/app-api/storage/reports.test.ts b/services/app-api/storage/reports.test.ts index 6fbb1576..8b77c249 100644 --- a/services/app-api/storage/reports.test.ts +++ b/services/app-api/storage/reports.test.ts @@ -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; @@ -30,7 +30,7 @@ describe("Report storage helpers", () => { expect(mockPut).toHaveBeenCalledWith( { - TableName: "local-qm-reports", + TableName: "local-qms-reports", Item: mockReport, }, expect.any(Function) @@ -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) @@ -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); }); }); @@ -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" }, diff --git a/services/app-api/testing/setupJest.ts b/services/app-api/testing/setupJest.ts index 7bd55e83..f011a980 100644 --- a/services/app-api/testing/setupJest.ts +++ b/services/app-api/testing/setupJest.ts @@ -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"; /* diff --git a/services/database/serverless.yml b/services/database/serverless.yml index ff368e52..ca6f19ec 100644 --- a/services/database/serverless.yml +++ b/services/database/serverless.yml @@ -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 @@ -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: @@ -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}