Skip to content

Commit

Permalink
fix: [IOBP-961] Missing German key for FAQ (#6479)
Browse files Browse the repository at this point in the history
> [!note]
> This PR depends on:
> * pagopa/io-dev-api-server#442

## Short description
This pull request includes several changes across multiple files to
update the locale data and improve the content reducer. The most
important changes include updating YAML file references, adding German
locale descriptions to Zendesk categories, and modifying the content
reducer to use a different locale function.


## List of changes proposed in this pull request
- Updated the `io_content_specs` reference to a new version.
- Replaced `getRemoteLocale` with `getCurrentLocale`
- Added German (`de-DE`) descriptions to various Zendesk categories and
test

## How to test
Check FAQ in the application with German language

---------

Co-authored-by: Alessandro <[email protected]>
  • Loading branch information
LeleDallas and Hantex9 authored Dec 3, 2024
1 parent 4713bd2 commit d7ae804
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"io_session_manager_api": "https://raw.githubusercontent.com/pagopa/io-auth-n-identity-domain/[email protected]/apps/io-session-manager/api/internal.yaml",
"io_session_manager_public_api": "https://raw.githubusercontent.com/pagopa/io-auth-n-identity-domain/[email protected]/apps/io-session-manager/api/public.yaml",
"io_public_api": "https://raw.githubusercontent.com/pagopa/io-backend/v16.4.0-RELEASE/api_public.yaml",
"io_content_specs": "https://raw.githubusercontent.com/pagopa/io-services-metadata/1.0.48/definitions.yml",
"io_content_specs": "https://raw.githubusercontent.com/pagopa/io-services-metadata/1.0.49/definitions.yml",
"io_cgn_specs": "https://raw.githubusercontent.com/pagopa/io-backend/v16.4.0-RELEASE/api_cgn.yaml",
"io_cgn_merchants_specs": "https://raw.githubusercontent.com/pagopa/io-backend/v16.4.0-RELEASE/api_cgn_operator_search.yaml",
"api_fci": "https://raw.githubusercontent.com/pagopa/io-backend/v16.4.0-RELEASE/api_io_sign.yaml",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ const mockedZendeskCategory = {
value: "mockedValue",
description: {
"it-IT": "mock_description",
"en-EN": "mock_description"
"en-EN": "mock_description",
"de-DE": "mock_description"
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ const mockedZendeskConfig: Zendesk = {
value: "mockedValue",
description: {
"it-IT": "mockedDescription",
"en-EN": "mockedDescription"
"en-EN": "mockedDescription",
"de-DE": "mockedDescription"
}
}
]
Expand All @@ -54,7 +55,8 @@ const mockedZendeskSubcategories: ZendeskSubCategories = {
value: "mockedSubcategoryValue",
description: {
"it-IT": "mockedSubcategorydescription",
"en-EN": "mockedSubcategorydescription"
"en-EN": "mockedSubcategorydescription",
"de-DE": "mockedSubcategorydescription"
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ const mockedCategory: ZendeskCategory = {
value: "mockedValue",
description: {
"it-IT": "mockedDescription",
"en-EN": "mockedDescription"
"en-EN": "mockedDescription",
"de-DE": "mockedDescription"
}
};

Expand All @@ -44,7 +45,8 @@ const mockedZendeskSubcategories: ZendeskSubCategories = {
value: "mockedSubcategoryValue",
description: {
"it-IT": "mockedSubcategorydescription",
"en-EN": "mockedSubcategorydescription"
"en-EN": "mockedSubcategorydescription",
"de-DE": "mockedSubcategorydescription"
}
}
]
Expand All @@ -54,7 +56,8 @@ const mockedCategoryWithSubcategory: ZendeskCategory = {
value: "mockedValue",
description: {
"it-IT": "mockedDescription",
"en-EN": "mockedDescription"
"en-EN": "mockedDescription",
"de-DE": "mockedDescription"
},
zendeskSubCategories: mockedZendeskSubcategories
};
Expand Down
6 changes: 4 additions & 2 deletions ts/features/zendesk/store/reducers/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@ const mockCategory: ZendeskCategory = {
value: "mock_value",
description: {
"it-IT": "mock_description",
"en-EN": "mock_description"
"en-EN": "mock_description",
"de-DE": "mock_description"
}
};
const mockSubcategory: ZendeskSubCategory = {
value: "mock_value",
description: {
"it-IT": "mock_description",
"en-EN": "mock_description"
"en-EN": "mock_description",
"de-DE": "mock_description"
}
};

Expand Down
25 changes: 15 additions & 10 deletions ts/store/reducers/content.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/**
* Implements the reducers for static content.
*/
import * as O from "fp-ts/lib/Option";
import * as pot from "@pagopa/ts-commons/lib/pot";
import { pipe } from "fp-ts/lib/function";
import * as O from "fp-ts/lib/Option";
import { createSelector } from "reselect";
import { getType } from "typesafe-actions";
import { pipe } from "fp-ts/lib/function";
import { ContextualHelp } from "../../../definitions/content/ContextualHelp";
import { Idp } from "../../../definitions/content/Idp";
import { IdpData } from "../../../definitions/content/IdpData";
import { Municipality as MunicipalityMetadata } from "../../../definitions/content/Municipality";
import { ScreenCHData } from "../../../definitions/content/ScreenCHData";
import { SpidIdp } from "../../../definitions/content/SpidIdp";
Expand All @@ -20,17 +21,17 @@ import {
remoteUndefined,
RemoteValue
} from "../../common/model/RemoteValue";
import { getRemoteLocale } from "../../features/messages/utils/messages";
import { CodiceCatastale } from "../../types/MunicipalityCodiceCatastale";
import { idps as idpsFallback, LocalIdpsFallback } from "../../utils/idps";
import { getRemoteLocale } from "../../features/messages/utils/messages";
import { getCurrentLocale } from "../../utils/locale";
import {
contentMunicipalityLoad,
loadContextualHelpData,
loadIdps
} from "../actions/content";
import { clearCache } from "../actions/profile";
import { Action } from "../actions/types";
import { IdpData } from "../../../definitions/content/IdpData";
import { currentRouteSelector } from "./navigation";
import { GlobalState } from "./types";

Expand Down Expand Up @@ -131,10 +132,12 @@ export const screenContextualHelpDataSelector = createSelector<
if (currentRoute === undefined) {
return O.none;
}
const locale = getRemoteLocale();
const locale = getCurrentLocale();

const localeData = data[locale];
const screenData =
data[locale] !== undefined
? data[locale].screens.find(
localeData !== undefined
? localeData.screens.find(
s =>
s.route_name.toLowerCase() === currentRoute.toLocaleLowerCase()
)
Expand All @@ -157,13 +160,15 @@ export const getContextualHelpDataFromRouteSelector = (route: string) =>
if (route === undefined) {
return O.none;
}
const locale = getRemoteLocale();
const locale = getCurrentLocale();
const localeData = data[locale];
const screenData =
data[locale] !== undefined
? data[locale].screens.find(
localeData !== undefined
? localeData.screens.find(
s => s.route_name.toLowerCase() === route.toLocaleLowerCase()
)
: undefined;

return O.fromNullable(screenData);
})
);
Expand Down
44 changes: 43 additions & 1 deletion ts/utils/__tests__/content.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { Locales } from "../../../locales/locales";
import { setLocale } from "../../i18n";
import {
idpContextualHelpDataFromIdSelector,
screenContextualHelpDataSelector
screenContextualHelpDataSelector,
getContextualHelpDataFromRouteSelector
} from "../../store/reducers/content";

const chData = {
Expand Down Expand Up @@ -200,3 +201,44 @@ describe("screenContextualHelpDataSelector", () => {
expect(pot.isSome(screenData) && O.isNone(screenData.value)).toBeTruthy();
});
});

describe("getContextualHelpDataFromRouteSelector", () => {
it("should return no data if route is empty", async () => {
const screenData = getContextualHelpDataFromRouteSelector("").resultFunc(
pot.some(chData)
);
expect(pot.isSome(screenData) && O.isNone(screenData.value)).toBeTruthy();
});

it("should return data (italian) if the route is present as key", async () => {
setLocale("it" as Locales);
assertRouteValues("title IT", "**content IT**");
});

it("should return data (english) if the route is present as key", async () => {
setLocale("en" as Locales);
assertRouteValues("title EN", "**content EN**");
});

it("should return data (italian) if the route is present as key and the set language is not supported", async () => {
setLocale("br" as Locales);
assertRouteValues("title IT", "**content IT**");
});

const assertRouteValues = (title: string, content: string) => {
const screenData = getContextualHelpDataFromRouteSelector(
"AUTHENTICATION_IDP_LOGIN"
).resultFunc(pot.some(chData));
if (pot.isSome(screenData) && O.isSome(screenData.value)) {
expect(screenData.value.value.title).toEqual(title);
expect(screenData.value.value.content).toEqual(content);
}
};

it("should return no data if the route is not present as key", async () => {
const screenData = getContextualHelpDataFromRouteSelector(
"NO_KEY"
).resultFunc(pot.some(chData));
expect(pot.isSome(screenData) && O.isNone(screenData.value)).toBeTruthy();
});
});
12 changes: 9 additions & 3 deletions ts/utils/supportAssistance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,20 +117,26 @@ export const zendeskVersionsHistoryId = "4419641151505";
export const zendeskFciId = "14874226407825";
export const zendeskPaymentCategory: ZendeskCategory = {
value: "pagamenti_pagopa",
description: { "it-IT": "Pagamento pagoPA", "en-EN": "pagoPA payment" }
description: {
"it-IT": "Pagamento pagoPA",
"en-EN": "pagoPA payment",
"de-DE": "pagoPA-Zahlung"
}
};
export const zendeskPaymentMethodCategory: ZendeskCategory = {
value: "metodo_di_pagamento",
description: {
"it-IT": "Metodo di pagamento",
"en-EN": "Payment method"
"en-EN": "Payment method",
"de-DE": "Zahlungsmethode"
}
};
export const zendeskFCICategory: ZendeskCategory = {
value: "firma_con_io",
description: {
"it-IT": "Firma con IO",
"en-EN": "Firma con IO"
"en-EN": "Firma con IO",
"de-DE": "Firma con IO"
}
};

Expand Down

0 comments on commit d7ae804

Please sign in to comment.