From 1ceb5efe1e585ee1230741f5e1670fa564df9ce7 Mon Sep 17 00:00:00 2001 From: Julianna Apicella <42875581+juliannaeapicella@users.noreply.github.com> Date: Mon, 2 Dec 2024 12:15:43 -0500 Subject: [PATCH 1/2] fix(hub-common): fix event summary validation error (#1751) --- packages/common/src/events/edit.ts | 4 +- packages/common/test/events/edit.test.ts | 116 +++++++++++++++++++++++ 2 files changed, 118 insertions(+), 2 deletions(-) diff --git a/packages/common/src/events/edit.ts b/packages/common/src/events/edit.ts index 518dce1cc1c..be472b1e904 100644 --- a/packages/common/src/events/edit.ts +++ b/packages/common/src/events/edit.ts @@ -119,7 +119,7 @@ export async function updateHubEvent( associations, attendanceType: model.attendanceType, categories: model.categories, - description: model.description, + description: model.description?.trim() || null, editGroups: model.editGroups, endDate: model.endDate, endTime: model.endTime, @@ -130,7 +130,7 @@ export async function updateHubEvent( startDate: model.startDate, startTime: model.startTime, status: model.status, - summary: model.summary, + summary: model.summary?.trim() || null, tags: model.tags, timeZone: model.timeZone, title: model.title, diff --git a/packages/common/test/events/edit.test.ts b/packages/common/test/events/edit.test.ts index ab9af446594..4dd36caf1de 100644 --- a/packages/common/test/events/edit.test.ts +++ b/packages/common/test/events/edit.test.ts @@ -84,6 +84,8 @@ describe("HubEvents edit module", () => { canSetStatusToRemoved: true, }, timeZone: "America/New_York", + description: null, + summary: null, }; const defaultEntity: Partial = { @@ -374,6 +376,120 @@ describe("HubEvents edit module", () => { }); expect(res.name).toEqual("my event"); }); + + it("should handle empty summary and description", async () => { + const updatedRecord = { + ...defaultRecord, + id: "92x", + title: "my event", + timeZone: "America/New_York", + createdAt: new Date().toISOString(), + updatedAt: new Date().toISOString(), + associations: [ + { + eventId: "92x", + entityId: "t36", + entityType: "Hub Site Application", + }, + { + eventId: "92x", + entityId: "8nd", + entityType: "Hub Project", + }, + ] as IEventAssociation[], + }; + const updateEventApiSpy = spyOn( + eventsModule, + "updateEvent" + ).and.returnValue(new Promise((resolve) => resolve(updatedRecord))); + const res = await updateHubEvent( + { + name: "my event", + timeZone: "America/New_York", + id: "92x", + isCanceled: true, + inPersonCapacity: 50, + inPersonCapacityType: HubEventCapacityType.Fixed, + location: { + type: "custom", + spatialReference: {}, + extent: [[]], + geometries: [], + name: "", + }, + referencedContentIds: ["8nd"], + referencedContentIdsByType: [ + { + entityId: "t36", + entityType: "Hub Site Application", + }, + ], + summary: " ", + description: " ", + }, + context.hubRequestOptions + ); + expect(buildDefaultEventEntitySpy).toHaveBeenCalledTimes(1); + expect(buildDefaultEventEntitySpy).toHaveBeenCalledWith(); + expect(buildDefaultEventRecordSpy).toHaveBeenCalledTimes(1); + expect(buildDefaultEventRecordSpy).toHaveBeenCalledWith(); + expect(buildEventAssociationsSpy).toHaveBeenCalledTimes(1); + expect(buildEventAssociationsSpy).toHaveBeenCalledWith( + [ + { + entityId: "t36", + entityType: "Hub Site Application", + }, + ], + ["8nd"], + context.hubRequestOptions + ); + expect(updateEventApiSpy).toHaveBeenCalledTimes(1); + expect(updateEventApiSpy).toHaveBeenCalledWith({ + eventId: "92x", + data: { + access: defaultRecord.access, + allDay: defaultRecord.allDay, + allowRegistration: defaultRecord.allowRegistration, + attendanceType: defaultRecord.attendanceType, + associations: [ + { + entityId: "t36", + entityType: "Hub Site Application", + }, + { + entityId: "8nd", + entityType: "Hub Project", + }, + ], + categories: defaultRecord.categories, + description: defaultRecord.description, + editGroups: defaultRecord.editGroups, + endDate: defaultRecord.endDate, + endTime: defaultRecord.endTime, + inPersonCapacity: defaultRecord.inPersonCapacity, + notifyAttendees: defaultRecord.notifyAttendees, + onlineMeeting: defaultRecord.onlineMeeting, + readGroups: defaultRecord.readGroups, + startDate: defaultRecord.startDate, + startTime: defaultRecord.startTime, + status: EventStatus.CANCELED, + summary: defaultRecord.summary, + tags: defaultRecord.tags, + timeZone: defaultRecord.timeZone, + title: "my event", + location: { + type: "custom", + spatialReference: {}, + extent: [[]], + geometries: [], + placeName: "", + }, + }, + ...context.hubRequestOptions, + }); + expect(res.name).toEqual("my event"); + }); }); describe("deleteHubEvent", () => { From 1bbb9b3d70fa298c5bc73661a912496b2804d3c1 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Mon, 2 Dec 2024 18:32:31 +0000 Subject: [PATCH 2/2] chore(release): 15.13.2 [skip ci] ## @esri/hub-common [15.13.2](https://github.com/Esri/hub.js/compare/@esri/hub-common@15.13.1...@esri/hub-common@15.13.2) (2024-12-02) ### Bug Fixes * **hub-common:** fix event summary validation error ([#1751](https://github.com/Esri/hub.js/issues/1751)) ([1ceb5ef](https://github.com/Esri/hub.js/commit/1ceb5efe1e585ee1230741f5e1670fa564df9ce7)) --- packages/common/CHANGELOG.md | 7 +++++++ packages/common/package-lock.json | 4 ++-- packages/common/package.json | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/common/CHANGELOG.md b/packages/common/CHANGELOG.md index 4e4b9c8d0b0..86cfd630308 100644 --- a/packages/common/CHANGELOG.md +++ b/packages/common/CHANGELOG.md @@ -1,3 +1,10 @@ +## @esri/hub-common [15.13.2](https://github.com/Esri/hub.js/compare/@esri/hub-common@15.13.1...@esri/hub-common@15.13.2) (2024-12-02) + + +### Bug Fixes + +* **hub-common:** fix event summary validation error ([#1751](https://github.com/Esri/hub.js/issues/1751)) ([1ceb5ef](https://github.com/Esri/hub.js/commit/1ceb5efe1e585ee1230741f5e1670fa564df9ce7)) + ## @esri/hub-common [15.13.1](https://github.com/Esri/hub.js/compare/@esri/hub-common@15.13.0...@esri/hub-common@15.13.1) (2024-11-27) diff --git a/packages/common/package-lock.json b/packages/common/package-lock.json index 5db4cc05373..a8c5b9e332d 100644 --- a/packages/common/package-lock.json +++ b/packages/common/package-lock.json @@ -1,12 +1,12 @@ { "name": "@esri/hub-common", - "version": "15.13.1", + "version": "15.13.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@esri/hub-common", - "version": "15.13.1", + "version": "15.13.2", "license": "Apache-2.0", "dependencies": { "@terraformer/arcgis": "^2.1.2", diff --git a/packages/common/package.json b/packages/common/package.json index 6147b613bd1..8a1ec7964bb 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -1,6 +1,6 @@ { "name": "@esri/hub-common", - "version": "15.13.1", + "version": "15.13.2", "description": "Common TypeScript types and utility functions for @esri/hub.js.", "main": "dist/node/index.js", "module": "dist/esm/index.js",