Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion packages/common/src/featureServiceHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,10 @@ export function setNamesAndTitles(templates: IItemTemplate[]): IItemTemplate[] {

// The name length limit is 98
// Limit the baseName to 50 characters before the _<guid>
const name: string = baseName.substring(0, 50) + "_" + guid;
// If the baseName includes '{{params' it is likely being used in a template replacement, so do not truncate.
const name: string = baseName.includes("{{params")
? baseName + "_" + guid
: baseName.substring(0, 50) + "_" + guid;

// If the name + GUID already exists then append "_occurrenceCount"
t.item.name = names.indexOf(name) === -1 ? name : `${name}_${names.filter((n) => n === name).length}`;
Expand Down
20 changes: 20 additions & 0 deletions packages/common/test/featureServiceHelpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1972,6 +1972,26 @@ describe("Module `featureServiceHelpers`: utility functions for feature-service
const actual: IItemTemplate[] = setNamesAndTitles(_templates);
expect(actual).toEqual(expected);
});

it("should not truncate if '{{param' is used", () => {
const t: IItemTemplate = templates.getItemTemplateSkeleton();
t.item.type = "Feature Service";
t.item.name = "{{params.buildSolution.items.46c2f61bc5bc4f3aad6b391360e8e53d.title}}";
t.item.title = "TheName";
const _templates: IItemTemplate[] = [t];

spyOn(generalHelpers, "generateGUID").and.returnValue("212dbc19b03943008fdfaf8d6adca00e");

const expectedTemplate: IItemTemplate = templates.getItemTemplateSkeleton();
expectedTemplate.item.type = "Feature Service";
expectedTemplate.item.name = `{{params.buildSolution.items.46c2f61bc5bc4f3aad6b391360e8e53d.title}}_212dbc19b03943008fdfaf8d6adca00e`;
expectedTemplate.item.title = "TheName";
const expected: IItemTemplate[] = [expectedTemplate];

const actual: IItemTemplate[] = setNamesAndTitles(_templates);
expect(actual).toEqual(expected);
});

});

describe("updateSettingsFieldInfos", () => {
Expand Down
Loading