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

LA-141 Apply privacy policy override even when locale doesn't match #5515

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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ The types of changes are:

### Changed
- Allow hiding systems via a `hidden` parameter and add two flags on the `/system` api endpoint; `show_hidden` and `dnd_relevant`, to display only systems with integrations [#5484](https://github.com/ethyca/fides/pull/5484)
- The CMP override `fides_privacy_policy_url` will now apply even if the `fides_override_language` doesn't match [#5515](https://github.com/ethyca/fides/pull/5515)
- Updated POST taxonomy endpoints to handle creating resources without specifying fides_key [#5468](https://github.com/ethyca/fides/pull/5468)
- Disabled connection pooling for task workers and added retries and keep-alive configurations for database connections [#5448](https://github.com/ethyca/fides/pull/5448)

Expand Down
33 changes: 28 additions & 5 deletions clients/fides-js/__tests__/lib/i18n/i18n-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,11 @@ describe("i18n-utils", () => {
expect(mockI18n.load).toHaveBeenCalledWith("en", mockI18nCatalogLoad[0]);
});

it("sets overrides experience_config translations when no locale match", () => {
it("sets overrides experience_config translations when locale matches", () => {
const experienceTranslationOverrides: Partial<FidesExperienceTranslationOverrides> =
{
title: "My override title",
description: "My override description",
privacy_policy_url: "https://example.com/privacy",
override_language: "en",
};
loadMessagesFromExperience(
Expand All @@ -338,8 +337,6 @@ describe("i18n-utils", () => {
...mockI18nCatalogLoad[0],
...{
"exp.description": experienceTranslationOverrides.description,
"exp.privacy_policy_url":
experienceTranslationOverrides.privacy_policy_url,
"exp.title": experienceTranslationOverrides.title,
},
});
Expand All @@ -351,7 +348,6 @@ describe("i18n-utils", () => {
{
title: "My override title",
description: "My override description",
privacy_policy_url: "https://example.com/privacy",
override_language: "ja",
};
loadMessagesFromExperience(
Expand All @@ -365,6 +361,33 @@ describe("i18n-utils", () => {
expect(mockI18n.load).toHaveBeenCalledWith("es", mockI18nCatalogLoad[1]);
});

it("always override privacy_policy_url, even if locale doesn't match", () => {
const experienceTranslationOverrides: Partial<FidesExperienceTranslationOverrides> =
{
title: "My override title",
description: "My override description",
privacy_policy_url: "https://example.com/privacy",
override_language: "ja",
};
loadMessagesFromExperience(
mockI18n,
mockExperience,
experienceTranslationOverrides,
);
const EXPECTED_NUM_TRANSLATIONS = 2;
expect(mockI18n.load).toHaveBeenCalledTimes(EXPECTED_NUM_TRANSLATIONS);
expect(mockI18n.load).toHaveBeenCalledWith("en", {
...mockI18nCatalogLoad[0],
"exp.privacy_policy_url":
experienceTranslationOverrides.privacy_policy_url,
});
expect(mockI18n.load).toHaveBeenCalledWith("es", {
...mockI18nCatalogLoad[1],
"exp.privacy_policy_url":
experienceTranslationOverrides.privacy_policy_url,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice 👍

});
});

describe("when loading from a tcf_overlay experience", () => {
it("reads all messages from gvl translations API response and loads into the i18n catalog", () => {
// Mock out a partial response for a tcf_overlay including translations
Expand Down
9 changes: 8 additions & 1 deletion clients/fides-js/src/lib/i18n/i18n-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,14 @@ function extractMessagesFromExperienceConfig(
const messages: Messages = {};
EXPERIENCE_TRANSLATION_FIELDS.forEach((key) => {
let overrideValue: string | null | undefined = null;
if (experienceTranslationOverrides && localeHasOverride) {

const isPrivacyPolicyUrl = key === "privacy_policy_url";
// Override value when matching translation override exists for the language.
// Override privacy_policy_url, even if the translation doesn't match the language
const shouldOverrideValue =
experienceTranslationOverrides &&
(localeHasOverride || isPrivacyPolicyUrl);
if (shouldOverrideValue) {
overrideValue =
key in experienceTranslationOverrides
? experienceTranslationOverrides[
Expand Down
71 changes: 59 additions & 12 deletions clients/privacy-center/cypress/e2e/consent-i18n.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,6 @@ describe("Consent i18n", () => {
const experienceTranslationOverrides = {
fides_title: "My override title",
fides_description: "My override description",
fides_privacy_policy_url: "https://example.com/privacy",
fides_override_language: "ja",
};
cy.fixture("consent/experience_banner_modal.json").then(
Expand Down Expand Up @@ -1082,11 +1081,6 @@ describe("Consent i18n", () => {
cy.get(
"div#fides-banner-description.fides-banner-description",
).contains(translation.banner_description as string);
cy.get("#fides-privacy-policy-link a").should(
"have.attr",
"href",
translation.privacy_policy_url as string,
);
});
// Open the modal
cy.contains("button", "Manage preferences").click();
Expand All @@ -1101,6 +1095,36 @@ describe("Consent i18n", () => {
},
);
});
it("does apply fides_privacy_policy_url override", () => {
const experienceTranslationOverrides = {
fides_privacy_policy_url: "https://example.com/privacy",
fides_override_language: "ja",
};
cy.fixture("consent/experience_banner_modal.json").then(
(experience) => {
const experienceItem = experience.items[0];
stubConfig(
{
options: {
customOptionsPath: TEST_OVERRIDE_WINDOW_PATH,
},
experience: experienceItem,
},
null,
null,
undefined,
{ ...experienceTranslationOverrides },
);
cy.get("div#fides-banner").within(() => {
cy.get("#fides-privacy-policy-link a").should(
"have.attr",
"href",
experienceTranslationOverrides.fides_privacy_policy_url as string,
);
});
},
);
});
});

describe("when fides_override_language is not provided", () => {
Expand All @@ -1115,7 +1139,6 @@ describe("Consent i18n", () => {
const experienceTranslationOverrides = {
fides_title: "My override title",
fides_description: "My override description",
fides_privacy_policy_url: "https://example.com/privacy",
// skips setting fides_override_language
};
cy.fixture("consent/experience_banner_modal.json").then(
Expand Down Expand Up @@ -1144,11 +1167,6 @@ describe("Consent i18n", () => {
cy.get(
"div#fides-banner-description.fides-banner-description",
).contains(translation.banner_description as string);
cy.get("#fides-privacy-policy-link a").should(
"have.attr",
"href",
translation.privacy_policy_url as string,
);
});
// Open the modal
cy.contains("button", "Manage preferences").click();
Expand All @@ -1163,6 +1181,35 @@ describe("Consent i18n", () => {
},
);
});
it("does apply fides_privacy_policy_url override", () => {
const experienceTranslationOverrides = {
fides_privacy_policy_url: "https://example.com/privacy",
};
cy.fixture("consent/experience_banner_modal.json").then(
(experience) => {
const experienceItem = experience.items[0];
stubConfig(
{
options: {
customOptionsPath: TEST_OVERRIDE_WINDOW_PATH,
},
experience: experienceItem,
},
null,
null,
undefined,
{ ...experienceTranslationOverrides },
);
cy.get("div#fides-banner").within(() => {
cy.get("#fides-privacy-policy-link a").should(
"have.attr",
"href",
experienceTranslationOverrides.fides_privacy_policy_url as string,
);
});
},
);
});
});
});
});
Expand Down
Loading