Skip to content
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

fix: remove additionalInfo from userResultToCardModel #1162

Merged
merged 1 commit into from
Aug 16, 2023
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
2 changes: 1 addition & 1 deletion package-lock.json

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

31 changes: 2 additions & 29 deletions packages/common/src/users/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const userResultToCardModel: ResultToCardModelFn = (

const titleUrl = getCardModelUrlFromResult(searchResult, target, baseUrl);
return {
...getSharedUserCardModel(searchResult, locale),
...getSharedUserCardModel(searchResult),
actionLinks,
...(searchResult.index && { index: searchResult.index }),
titleUrl,
Expand All @@ -43,33 +43,7 @@ export const userResultToCardModel: ResultToCardModelFn = (
* @param user user search result
* @param locale internationalization locale
*/
const getSharedUserCardModel = (
user: IHubSearchResult,
locale: string
): IHubCardViewModel => {
const additionalInfo = [
{
i18nKey: "org",
value: user.orgName,
},
{
i18nKey: "type",
value: user.type,
},
...(user.tags?.length
? [
{
i18nKey: "tags",
value: user.tags.join(", "),
},
]
: []),
{
i18nKey: "dateUpdated",
value: user.updatedDate.toLocaleDateString(locale),
},
];

const getSharedUserCardModel = (user: IHubSearchResult): IHubCardViewModel => {
return {
access: user.access,
badges: [],
Expand All @@ -79,6 +53,5 @@ const getSharedUserCardModel = (
summary: user.summary,
title: user.name || `@${user.id}`,
type: user.type,
additionalInfo,
};
};
22 changes: 0 additions & 22 deletions packages/common/test/users/view.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,30 +47,8 @@ describe("user view module:", () => {
titleUrl: "https://mock-title-url.com",
thumbnailUrl: USER_HUB_SEARCH_RESULT.links?.thumbnail,
type: USER_HUB_SEARCH_RESULT.type,
additionalInfo: [
{ i18nKey: "org", value: USER_HUB_SEARCH_RESULT.orgName },
{ i18nKey: "type", value: USER_HUB_SEARCH_RESULT.type },
{
i18nKey: "tags",
value: USER_HUB_SEARCH_RESULT.tags?.join(", ") as string,
},
{
i18nKey: "dateUpdated",
value:
USER_HUB_SEARCH_RESULT.updatedDate.toLocaleDateString("en-US"),
},
],
});
});
it("does not include tags/categories in the view model's additional info if none are defined", () => {
const modifiedSearchResult = cloneObject(USER_HUB_SEARCH_RESULT);
modifiedSearchResult.tags = undefined;
modifiedSearchResult.categories = undefined;

const result = userResultToCardModel(modifiedSearchResult);

expect(result.additionalInfo?.length).toBe(3);
});
it("title and source fall back to expected default vals", () => {
const modifiedSearchResult = cloneObject(USER_HUB_SEARCH_RESULT);
modifiedSearchResult.name = undefined as any;
Expand Down