-
Notifications
You must be signed in to change notification settings - Fork 79
/
Copy pathconsent-reporting.cy.ts
149 lines (139 loc) · 4.74 KB
/
consent-reporting.cy.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import { stubPlus } from "cypress/support/stubs";
import { CONSENT_REPORTING_ROUTE } from "~/features/common/nav/routes";
describe("Consent reporting", () => {
beforeEach(() => {
cy.login();
});
describe("access", () => {
it("can access the consent reporting page", () => {
stubPlus(true, {
core_fides_version: "1.9.6",
fidesplus_server: "healthy",
fidesplus_version: "1.9.6",
system_scanner: {
enabled: false,
cluster_health: null,
cluster_error: null,
},
dictionary: {
enabled: false,
service_health: null,
service_error: null,
},
tcf: {
enabled: false,
},
fides_cloud: {
enabled: false,
},
});
cy.visit(CONSENT_REPORTING_ROUTE);
cy.getByTestId("consent-reporting");
});
it("can't access without plus", () => {
stubPlus(false);
cy.visit(CONSENT_REPORTING_ROUTE);
cy.getByTestId("home-content");
});
});
describe("results view and download report", () => {
beforeEach(() => {
stubPlus(true, {
core_fides_version: "1.9.6",
fidesplus_server: "healthy",
fidesplus_version: "1.9.6",
system_scanner: {
enabled: false,
cluster_health: null,
cluster_error: null,
},
dictionary: {
enabled: false,
service_health: null,
service_error: null,
},
tcf: {
enabled: false,
},
fides_cloud: {
enabled: false,
},
});
cy.visit(CONSENT_REPORTING_ROUTE);
});
it("can request a report", () => {
cy.intercept({
url: "/api/v1/plus/consent_reporting*",
method: "GET",
}).as("getConsentReport");
cy.getByTestId("input-date-range").first().type("2023-11-01");
cy.getByTestId("input-date-range").last().type("2023-11-07");
cy.getByTestId("download-btn").click();
cy.getByTestId("download-report-btn").click();
cy.wait("@getConsentReport");
});
it("can lookup specific consent preferences", () => {
cy.intercept({
url: "/api/v1/current-privacy-preferences*",
method: "GET",
}).as("lookupConsentPreferences");
cy.getByTestId("consent-reporting-dropdown-btn").click();
cy.getByTestId("consent-preference-lookup-btn").click();
cy.getByTestId("subject-search-input").type("[email protected]{enter}");
cy.wait("@lookupConsentPreferences").then((interception) => {
const { url: requestUrl } = interception.request;
let url = new URL(requestUrl);
let params = new URLSearchParams(url.search);
expect(params.get("email")).to.equal("[email protected]");
expect(params.get("phone_number")).to.equal("[email protected]");
expect(params.get("fides_user_device_id")).to.equal("[email protected]");
expect(params.get("external_id")).to.equal("[email protected]");
});
});
it("loads the consent report table without date filters", () => {
cy.intercept(
{
url: "/api/v1/historical-privacy-preferences*",
method: "GET",
},
{
fixture: "consent-reporting/historical-privacy-preferences.json",
},
).as("getConsentReport");
cy.wait("@getConsentReport").then((interception) => {
const { url: requestUrl } = interception.request;
let url = new URL(requestUrl);
let params = new URLSearchParams(url.search);
expect(params.get("request_timestamp_gt")).to.be.null;
expect(params.get("request_timestamp_lt")).to.be.null;
});
cy.getByTestId("fidesTable-body").children().should("have.length", 22);
});
it("loads the consent report table with date filters", () => {
cy.intercept(
{
url: "/api/v1/historical-privacy-preferences*",
method: "GET",
},
{
fixture: "consent-reporting/historical-privacy-preferences.json",
},
).as("getConsentReport");
cy.wait("@getConsentReport");
cy.getByTestId("input-date-range").first().type("2023-11-01");
cy.getByTestId("input-date-range").last().type("2023-11-07{enter}");
cy.wait("@getConsentReport").then((interception) => {
const { url: requestUrl } = interception.request;
let url = new URL(requestUrl);
let params = new URLSearchParams(url.search);
expect(params.get("request_timestamp_gt")).to.equal(
"2023-11-01T00:00:00.000Z",
);
expect(params.get("request_timestamp_lt")).to.equal(
"2023-11-07T23:59:59.999Z",
);
});
cy.getByTestId("fidesTable-body").children().should("have.length", 22);
});
});
});