-
Notifications
You must be signed in to change notification settings - Fork 4
[ENG-4158]feat: show displayName for nested objects #1630
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
src/components/InstallWizard/steps/configure-objects/fields/FieldsContent.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| import type { | ||
| HydratedIntegrationFieldExistent, | ||
| IntegrationFieldMapping, | ||
| } from "@generated/api/src"; | ||
| import { describe, expect, it } from "@jest/globals"; | ||
|
|
||
| import { getFieldDisplayName, isIntegrationFieldMapping } from "./manifest"; | ||
|
|
||
| describe("isIntegrationFieldMapping", () => { | ||
| it("treats a field without fieldName as a mapping", () => { | ||
| expect(isIntegrationFieldMapping({ mapToName: "priority" })).toBe(true); | ||
| }); | ||
|
|
||
| it("treats a field with fieldName as an existent field", () => { | ||
| expect( | ||
| isIntegrationFieldMapping({ fieldName: "email", displayName: "Email" }), | ||
| ).toBe(false); | ||
| }); | ||
| }); | ||
|
|
||
| describe("getFieldDisplayName", () => { | ||
| describe("existent fields", () => { | ||
| it("uses the provider displayName when the builder defined no mapping", () => { | ||
| const field: HydratedIntegrationFieldExistent = { | ||
| fieldName: "email", | ||
| displayName: "Email", | ||
| }; | ||
|
|
||
| expect(getFieldDisplayName(field)).toBe("Email"); | ||
| }); | ||
|
|
||
| it("falls back to fieldName when there is no displayName", () => { | ||
| const field = { | ||
| fieldName: "estimate_number", | ||
| displayName: "", | ||
| } as HydratedIntegrationFieldExistent; | ||
|
|
||
| expect(getFieldDisplayName(field)).toBe("estimate_number"); | ||
| }); | ||
|
|
||
| // The reported bug. A nested field has no provider metadata, so the server | ||
| // hydrates displayName as TitleCase(fieldName) and the raw path renders. | ||
| it("prefers mapToDisplayName over a JSONPath displayName", () => { | ||
| const field: HydratedIntegrationFieldExistent = { | ||
| fieldName: "$['Customer']['Email']", | ||
| displayName: "$['Customer']['Email']", | ||
| mapToName: "customer_email", | ||
| mapToDisplayName: "Customer Email", | ||
| }; | ||
|
|
||
| expect(getFieldDisplayName(field)).toBe("Customer Email"); | ||
| }); | ||
|
|
||
| // displayName outranks mapToName, and the server always populates it, so a | ||
| // nested field needs mapToDisplayName to render a readable label. | ||
| it("falls back to displayName when mapToDisplayName is absent", () => { | ||
| const field: HydratedIntegrationFieldExistent = { | ||
| fieldName: "$['Customer']['First_name']", | ||
| displayName: "$['Customer']['First_name']", | ||
| mapToName: "customer_first_name", | ||
| }; | ||
|
|
||
| expect(getFieldDisplayName(field)).toBe("$['Customer']['First_name']"); | ||
| }); | ||
|
|
||
| it("prefers mapToDisplayName over a usable provider displayName", () => { | ||
| const field: HydratedIntegrationFieldExistent = { | ||
| fieldName: "firstname", | ||
| displayName: "First Name", | ||
| mapToName: "customer_first_name", | ||
| mapToDisplayName: "Customer First Name", | ||
| }; | ||
|
|
||
| expect(getFieldDisplayName(field)).toBe("Customer First Name"); | ||
| }); | ||
|
|
||
| it("prefers the provider displayName over mapToName", () => { | ||
| const field: HydratedIntegrationFieldExistent = { | ||
| fieldName: "phone", | ||
| displayName: "Business Phone", | ||
| mapToName: "customer_phone", | ||
| }; | ||
|
|
||
| expect(getFieldDisplayName(field)).toBe("Business Phone"); | ||
| }); | ||
| }); | ||
|
|
||
| describe("field mappings", () => { | ||
| it("uses mapToDisplayName when present", () => { | ||
| const field: IntegrationFieldMapping = { | ||
| mapToName: "priority", | ||
| mapToDisplayName: "Priority", | ||
| }; | ||
|
|
||
| expect(getFieldDisplayName(field)).toBe("Priority"); | ||
| }); | ||
|
|
||
| it("falls back to mapToName", () => { | ||
| const field: IntegrationFieldMapping = { mapToName: "priority" }; | ||
|
|
||
| expect(getFieldDisplayName(field)).toBe("priority"); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.