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

[PDCL-7369] - Tests updates to support opt-back-in functionality #835

Merged
merged 3 commits into from
Mar 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
27 changes: 15 additions & 12 deletions test/functional/specs/Privacy/C14404.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { t } from "testcafe";
import createFixture from "../../helpers/createFixture";
import createNetworkLogger from "../../helpers/networkLogger";

Expand All @@ -7,9 +8,10 @@ import {
consentPending,
debugEnabled
} from "../../helpers/constants/configParts";
import createConsoleLogger from "../../helpers/consoleLogger";
import createAlloyProxy from "../../helpers/createAlloyProxy";
import { CONSENT_OUT, CONSENT_IN } from "../../helpers/constants/consent";
import cookies from "../../helpers/cookies";
import { MAIN_CONSENT_COOKIE_NAME } from "../../helpers/constants/cookies";

const config = compose(orgMainConfigMain, consentPending, debugEnabled);

Expand All @@ -27,21 +29,22 @@ test.meta({
TEST_RUN: "Regression"
});

test("Test C14404: User cannot consent to all purposes after consenting to no purposes", async t => {
test("Test C14404: User can consent to all purposes after consenting to no purposes", async () => {
const alloy = createAlloyProxy();
await alloy.configure(config);
await alloy.setConsent(CONSENT_OUT);
const setConsentErrorMessage = await alloy.setConsentErrorMessage(CONSENT_IN);

await t
.expect(setConsentErrorMessage)
.ok("Expected the setConsent command to be rejected");
await t.expect(setConsentErrorMessage).contains("EXEG-0302-409");
// set consent back to in for the same user
await alloy.setConsent(CONSENT_IN);

// make sure the instance still has no consent
const logger = await createConsoleLogger();
await t.expect(networkLogger.setConsentEndpointLogs.requests.length).eql(2);

const consentCookieValue = await cookies.get(MAIN_CONSENT_COOKIE_NAME);

await t.expect(consentCookieValue).ok("No consent cookie found.");
await t.expect(consentCookieValue).eql("general=in");

// make sure event goes out
await alloy.sendEvent();
await logger.warn.expectMessageMatching(/user declined consent/);
// make sure no event requests went out
await t.expect(networkLogger.edgeEndpointLogs.requests.length).eql(0);
await t.expect(networkLogger.edgeEndpointLogs.requests.length).eql(1);
});
12 changes: 3 additions & 9 deletions test/functional/specs/Privacy/C14411.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ test("Test C14411: User consents to no purposes after consenting to no purposes
await alloy.setConsent(CONSENT_OUT);
});

test("Test C14411: User consents to no purposes after consenting to no purposes without cache", async t => {
test("Test C14411: User consents to no purposes after consenting to no purposes without cache", async () => {
const alloy = createAlloyProxy();
await alloy.configure(config);
await alloy.setConsent(CONSENT_OUT);
Expand All @@ -39,12 +39,6 @@ test("Test C14411: User consents to no purposes after consenting to no purposes
await cookies.remove(MAIN_CONSENT_COOKIE_NAME);

await alloy.configure(config);
const setConsentErrorMessage = await alloy.setConsentErrorMessage(
CONSENT_OUT
);

await t
.expect(setConsentErrorMessage)
.ok("Expected the setConsent command to be rejected");
await t.expect(setConsentErrorMessage).contains("EXEG-0302-409");
// make sure this doesn't throw an error
await alloy.setConsent(CONSENT_OUT);
});