Skip to content

Commit

Permalink
PROD-1389 for TCF, any consent pref that is not defined on cookie sho…
Browse files Browse the repository at this point in the history
…uld be assumed opt-out (#4430)
  • Loading branch information
eastandwestwind committed Nov 14, 2023
1 parent 685bae6 commit 6b93c7d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 27 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ The types of changes are:
- Redact cli, database, and redis configuration information from GET api/v1/config API request responses. [#4379](https://github.com/ethyca/fides/pull/4379)
- Button ordering in fides.js UI [#4407](https://github.com/ethyca/fides/pull/4407)
- Add different classnames to consent buttons for easier selection [#4411](https://github.com/ethyca/fides/pull/4411)
- Updates default consent preference to opt-out for TCF when fides_string exists [#4430](https://github.com/ethyca/fides/pull/4430)

### Fixed
- Persist bulk system add filter modal state [#4412](https://github.com/ethyca/fides/pull/4412)
Expand Down
9 changes: 7 additions & 2 deletions clients/fides-js/src/lib/cookie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,13 +311,18 @@ export const buildTcfEntitiesFromCookie = (
const cookieConsent = cookie.tcf_consent[cookieKey] ?? {};
// @ts-ignore the array map should ensure we will get the right record type
tcfEntities[experienceKey] = experience[experienceKey]?.map((item) => {
const defaultPreference = cookie.fides_string
? ConsentMechanism.OPT_OUT
: item.default_preference;
const preference = Object.hasOwn(cookieConsent, item.id)
? transformConsentToFidesUserPreference(
Boolean(cookieConsent[item.id]),
ConsentMechanism.OPT_IN
)
: // if experience contains a tcf entity not defined by tcfEntities, we override experience current pref with the default pref
item.default_preference;
: // If experience contains a tcf entity not defined by tcfEntities, this means:
// A) If fides_string exists, user has probably opted out. Since opt-outs are not tracked by TC string, in this case we assume opt-out.
// B) There is a new tcf entity that requires consent. In this case we would use the default on the experience.
defaultPreference;
return { ...item, current_preference: preference };
});
});
Expand Down
50 changes: 25 additions & 25 deletions clients/privacy-center/cypress/e2e/consent-banner-tcf.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1634,14 +1634,14 @@ describe("Fides-js TCF", () => {
});
cy.getByTestId(`toggle-${PURPOSE_9.name}`).within(() => {
// this purpose is set to true in the experience, but since it was not defined in the fides_string,
// it should use the default preference set in the experience which is false
// it should use false as the default
cy.get("input").should("not.be.checked");
});
cy.get("button").contains("Legitimate interest").click();
cy.getByTestId(`toggle-${PURPOSE_2.name}`).within(() => {
// this purpose is set to true in the experience, but since it was not defined in the fides_string,
// it should use the default preference set in the experience which is true
cy.get("input").should("be.checked");
// it should use false as the default
cy.get("input").should("not.be.checked");
});
// Features
cy.get("#fides-tab-Features").click();
Expand All @@ -1650,15 +1650,15 @@ describe("Fides-js TCF", () => {
});
// Vendors
// this purpose is set to true in the experience, but since it was not defined in the fides_string,
// it should use the default preference set in the experience which is true
// it should use false as the default
cy.get("#fides-tab-Vendors").click();
cy.getByTestId(`toggle-${VENDOR_1.name}`).within(() => {
cy.get("input").should("not.be.checked");
});
cy.get("#fides-panel-Vendors").within(() => {
cy.get("button").contains("Legitimate interest").click();
cy.getByTestId(`toggle-${SYSTEM_1.name}`).within(() => {
cy.get("input").should("be.checked");
cy.get("input").should("not.be.checked");
});
});

Expand Down Expand Up @@ -1729,14 +1729,14 @@ describe("Fides-js TCF", () => {
});
cy.getByTestId(`toggle-${PURPOSE_9.name}`).within(() => {
// this purpose is set to true in the experience, but since it was not defined in the fides_string,
// it should use the default preference set in the experience which is false
// it should use false as the default
cy.get("input").should("not.be.checked");
});
cy.get("button").contains("Legitimate interest").click();
cy.getByTestId(`toggle-${PURPOSE_2.name}`).within(() => {
// this purpose is set to true in the experience, but since it was not defined in the fides_string,
// it should use the default preference set in the experience which is true
cy.get("input").should("be.checked");
// it should use false as the default
cy.get("input").should("not.be.checked");
});
// Features
cy.get("#fides-tab-Features").click();
Expand All @@ -1745,15 +1745,15 @@ describe("Fides-js TCF", () => {
});
// Vendors
// this purpose is set to true in the experience, but since it was not defined in the fides_string,
// it should use the default preference set in the experience which is true
// it should use false as the default
cy.get("#fides-tab-Vendors").click();
cy.getByTestId(`toggle-${VENDOR_1.name}`).within(() => {
cy.get("input").should("not.be.checked");
});
cy.get("#fides-panel-Vendors").within(() => {
cy.get("button").contains("Legitimate interest").click();
cy.getByTestId(`toggle-${SYSTEM_1.name}`).within(() => {
cy.get("input").should("be.checked");
cy.get("input").should("not.be.checked");
});
});

Expand Down Expand Up @@ -1865,14 +1865,14 @@ describe("Fides-js TCF", () => {
});
cy.getByTestId(`toggle-${PURPOSE_9.name}`).within(() => {
// this purpose is set to true in the experience, but since it was not defined in the fides_string,
// it should use the default preference set in the experience which is false
// it should use false as the default
cy.get("input").should("not.be.checked");
});
cy.get("button").contains("Legitimate interest").click();
cy.getByTestId(`toggle-${PURPOSE_2.name}`).within(() => {
// this purpose is set to true in the experience, but since it was not defined in the fides_string,
// it should use the default preference set in the experience which is true
cy.get("input").should("be.checked");
// it should use false as the default
cy.get("input").should("not.be.checked");
});
// Features
cy.get("#fides-tab-Features").click();
Expand All @@ -1881,15 +1881,15 @@ describe("Fides-js TCF", () => {
});
// Vendors
// this purpose is set to true in the experience, but since it was not defined in the fides_string,
// it should use the default preference set in the experience which is true
// it should use false as the default
cy.get("#fides-tab-Vendors").click();
cy.getByTestId(`toggle-${VENDOR_1.name}`).within(() => {
cy.get("input").should("not.be.checked");
});
cy.get("#fides-panel-Vendors").within(() => {
cy.get("button").contains("Legitimate interest").click();
cy.getByTestId(`toggle-${SYSTEM_1.name}`).within(() => {
cy.get("input").should("be.checked");
cy.get("input").should("not.be.checked");
});
});

Expand Down Expand Up @@ -2047,14 +2047,14 @@ describe("Fides-js TCF", () => {
});
cy.getByTestId(`toggle-${PURPOSE_9.name}`).within(() => {
// this purpose is set to true in the experience, but since it was not defined in the fides_string,
// it should use the default preference set in the experience which is false
// it should use false as the default
cy.get("input").should("not.be.checked");
});
cy.get("button").contains("Legitimate interest").click();
cy.getByTestId(`toggle-${PURPOSE_2.name}`).within(() => {
// this purpose is set to true in the experience, but since it was not defined in the fides_string,
// it should use the default preference set in the experience which is true
cy.get("input").should("be.checked");
// it should use false as the default
cy.get("input").should("not.be.checked");
});
// Features
cy.get("#fides-tab-Features").click();
Expand All @@ -2070,9 +2070,9 @@ describe("Fides-js TCF", () => {
cy.get("button").contains("Legitimate interest").click();
});
// this purpose is set to true in the experience, but since it was not defined in the fides_string,
// it should use the default preference set in the experience which is true
// it should use false as the default
cy.getByTestId(`toggle-${SYSTEM_1.name}`).within(() => {
cy.get("input").should("be.checked");
cy.get("input").should("not.be.checked");
});

// verify CMP API
Expand Down Expand Up @@ -2166,14 +2166,14 @@ describe("Fides-js TCF", () => {
});
cy.getByTestId(`toggle-${PURPOSE_9.name}`).within(() => {
// this purpose is set to true in the experience, but since it was not defined in the fides_string,
// it should use the default preference set in the experience which is false
// it should use false as the default
cy.get("input").should("not.be.checked");
});
cy.get("button").contains("Legitimate interest").click();
cy.getByTestId(`toggle-${PURPOSE_2.name}`).within(() => {
// this purpose is set to true in the experience, but since it was not defined in the fides_string,
// it should use the default preference set in the experience which is true
cy.get("input").should("be.checked");
// it should use false as the default
cy.get("input").should("not.be.checked");
});
// Features
cy.get("#fides-tab-Features").click();
Expand All @@ -2182,7 +2182,7 @@ describe("Fides-js TCF", () => {
});
// Vendors
// this purpose is set to true in the experience, but since it was not defined in the fides_string,
// it should use the default preference set in the experience which is true
// it should use false as the default
cy.get("#fides-tab-Vendors").click();
cy.getByTestId(`toggle-${VENDOR_1.name}`).within(() => {
cy.get("input").should("not.be.checked");
Expand All @@ -2191,7 +2191,7 @@ describe("Fides-js TCF", () => {
cy.get("button").contains("Legitimate interest").click();
});
cy.getByTestId(`toggle-${SYSTEM_1.name}`).within(() => {
cy.get("input").should("be.checked");
cy.get("input").should("not.be.checked");
});

// verify CMP API
Expand Down

0 comments on commit 6b93c7d

Please sign in to comment.