Skip to content

Commit

Permalink
Merge branch 'master' into f/11582-catalog-results-appearance-configu…
Browse files Browse the repository at this point in the history
…ration
  • Loading branch information
vivzhang authored Dec 3, 2024
2 parents 82047c2 + 1bbb9b3 commit 9e7fc34
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 5 deletions.
7 changes: 7 additions & 0 deletions packages/common/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## @esri/hub-common [15.13.2](https://github.com/Esri/hub.js/compare/@esri/[email protected]...@esri/[email protected]) (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/[email protected]...@esri/[email protected]) (2024-11-27)


Expand Down
4 changes: 2 additions & 2 deletions packages/common/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 2 additions & 2 deletions packages/common/src/events/edit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
116 changes: 116 additions & 0 deletions packages/common/test/events/edit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ describe("HubEvents edit module", () => {
canSetStatusToRemoved: true,
},
timeZone: "America/New_York",
description: null,
summary: null,
};

const defaultEntity: Partial<IHubEvent> = {
Expand Down Expand Up @@ -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", () => {
Expand Down

0 comments on commit 9e7fc34

Please sign in to comment.