@@ -566,7 +566,7 @@ describe("Fides-js TCF", () => {
566
566
. is . eql ( false ) ;
567
567
expect ( cookieKeyConsent . consent )
568
568
. property ( PRIVACY_NOTICE_KEY_2 )
569
- . is . eql ( false ) ;
569
+ . is . eql ( true ) ;
570
570
expect ( cookieKeyConsent . consent )
571
571
. property ( PRIVACY_NOTICE_KEY_3 )
572
572
. is . eql ( false ) ;
@@ -1129,7 +1129,7 @@ describe("Fides-js TCF", () => {
1129
1129
. is . eql ( false ) ;
1130
1130
expect ( cookieKeyConsent . consent )
1131
1131
. property ( PRIVACY_NOTICE_KEY_2 )
1132
- . is . eql ( false ) ;
1132
+ . is . eql ( true ) ;
1133
1133
expect ( cookieKeyConsent . consent )
1134
1134
. property ( PRIVACY_NOTICE_KEY_3 )
1135
1135
. is . eql ( false ) ;
@@ -1144,10 +1144,179 @@ describe("Fides-js TCF", () => {
1144
1144
} ) ;
1145
1145
} ) ;
1146
1146
1147
- // DEFER: can probably be removed
1148
- it . skip ( "can opt in to some and opt out of others" , ( ) => {
1149
- // todo- opt in to 1 custom notice, then test cookie and window.Fides obj
1147
+ it ( "can opt in to some custom consent and some tcf consent" , ( ) => {
1148
+ cy . getByTestId ( "consent-modal" ) . within ( ( ) => {
1149
+ // Custom notice should start off toggled off
1150
+ cy . getByTestId ( "toggle-Advertising English" ) . within ( ( ) => {
1151
+ cy . get ( "input" ) . should ( "not.be.checked" ) ;
1152
+ } ) ;
1153
+ // Opt-out notice should start toggled on
1154
+ cy . getByTestId ( "toggle-Analytics" ) . within ( ( ) => {
1155
+ cy . get ( "input" ) . should ( "be.checked" ) ;
1156
+ } ) ;
1157
+ // Notice-only should start off toggled on
1158
+ cy . getByTestId ( "toggle-Essential" ) . within ( ( ) => {
1159
+ cy . get ( "input" ) . should ( "be.checked" ) ;
1160
+ } ) ;
1161
+ // opt in to opt-in custom notice
1162
+ cy . getByTestId ( `toggle-Advertising English` ) . click ( ) ;
1163
+ // opt in to purpose 4
1164
+ cy . getByTestId ( `toggle-${ PURPOSE_4 . name } ` ) . click ( ) ;
1165
+ cy . get ( "#fides-tab-features" ) . click ( ) ;
1166
+ // opt in to special feat 1
1167
+ cy . getByTestId ( `toggle-${ SPECIAL_FEATURE_1 . name } ` ) . click ( ) ;
1168
+
1169
+ cy . get ( "#fides-tab-vendors" ) . click ( ) ;
1170
+ cy . get ( "#fides-panel-vendors" ) . within ( ( ) => {
1171
+ cy . get ( "button" ) . contains ( "Legitimate interest" ) . click ( ) ;
1172
+ } ) ;
1173
+ // opt out of system 1 (default is opt-in)
1174
+ cy . getByTestId ( `toggle-${ SYSTEM_1 . name } ` ) . click ( ) ;
1175
+ cy . get ( "button" ) . contains ( "Save" ) . click ( ) ;
1176
+ cy . get ( "@FidesUIChanged" ) . its ( "callCount" ) . should ( "equal" , 4 ) ;
1177
+ cy . wait ( "@patchPrivacyPreference" ) . then ( ( interception ) => {
1178
+ const { body } = interception . request ;
1179
+ expect ( interception . request . body . method ) . to . eql ( ConsentMethod . SAVE ) ;
1180
+ expect ( body . preferences ) . to . eql ( [
1181
+ {
1182
+ preference : "opt_in" ,
1183
+ privacy_notice_history_id :
1184
+ "pri_notice-history-advertising-en-000" ,
1185
+ } ,
1186
+ {
1187
+ preference : "opt_in" ,
1188
+ privacy_notice_history_id :
1189
+ "pri_notice-history-analytics-en-000" ,
1190
+ } ,
1191
+ {
1192
+ preference : "acknowledge" ,
1193
+ privacy_notice_history_id :
1194
+ "pri_notice-history-essential-en-000" ,
1195
+ } ,
1196
+ ] ) ;
1197
+ expect ( body . purpose_consent_preferences ) . to . eql ( [
1198
+ {
1199
+ id : PURPOSE_4 . id ,
1200
+ preference : "opt_in" ,
1201
+ } ,
1202
+ {
1203
+ id : PURPOSE_6 . id ,
1204
+ preference : "opt_out" ,
1205
+ } ,
1206
+ {
1207
+ id : PURPOSE_7 . id ,
1208
+ preference : "opt_out" ,
1209
+ } ,
1210
+ {
1211
+ id : PURPOSE_9 . id ,
1212
+ preference : "opt_out" ,
1213
+ } ,
1214
+ ] ) ;
1215
+ expect ( body . purpose_legitimate_interests_preferences ) . to . eql ( [
1216
+ {
1217
+ id : PURPOSE_2 . id ,
1218
+ preference : "opt_in" ,
1219
+ } ,
1220
+ ] ) ;
1221
+ expect ( body . special_purpose_preferences ) . to . eql ( undefined ) ;
1222
+ expect ( body . feature_preferences ) . to . eql ( undefined ) ;
1223
+ expect ( body . special_feature_preferences ) . to . eql ( [
1224
+ {
1225
+ id : SPECIAL_FEATURE_1 . id ,
1226
+ preference : "opt_in" ,
1227
+ } ,
1228
+ ] ) ;
1229
+ expect ( body . vendor_consent_preferences ) . to . eql ( [
1230
+ {
1231
+ id : VENDOR_1 . id ,
1232
+ preference : "opt_out" ,
1233
+ } ,
1234
+ ] ) ;
1235
+ expect ( body . vendor_legitimate_interests_preferences ) . to . eql ( [ ] ) ;
1236
+ expect ( body . system_legitimate_interests_preferences ) . to . eql ( [
1237
+ {
1238
+ id : SYSTEM_1 . id ,
1239
+ preference : "opt_out" ,
1240
+ } ,
1241
+ ] ) ;
1242
+ expect ( body . system_consent_preferences ) . to . eql ( [ ] ) ;
1243
+ } ) ;
1244
+ } ) ;
1245
+ // Verify the cookie on save
1246
+ cy . getCookie ( CONSENT_COOKIE_NAME ) . then ( ( cookie ) => {
1247
+ const cookieKeyConsent : FidesCookie = JSON . parse (
1248
+ decodeURIComponent ( cookie ! . value ) ,
1249
+ ) ;
1250
+ expect ( cookieKeyConsent . fides_meta . consentMethod ) . to . eql (
1251
+ ConsentMethod . SAVE ,
1252
+ ) ;
1253
+ expect ( cookieKeyConsent . consent )
1254
+ . property ( PRIVACY_NOTICE_KEY_1 )
1255
+ . is . eql ( true ) ;
1256
+ expect ( cookieKeyConsent . consent )
1257
+ . property ( PRIVACY_NOTICE_KEY_2 )
1258
+ . is . eql ( true ) ;
1259
+ expect ( cookieKeyConsent . consent )
1260
+ . property ( PRIVACY_NOTICE_KEY_3 )
1261
+ . is . eql ( true ) ;
1262
+ assertTcOptIns ( {
1263
+ cookie : cookieKeyConsent ,
1264
+ modelType : "purposeConsents" ,
1265
+ ids : [ PURPOSE_4 . id ] ,
1266
+ } ) ;
1267
+ assertTcOptIns ( {
1268
+ cookie : cookieKeyConsent ,
1269
+ modelType : "purposeLegitimateInterests" ,
1270
+ ids : [ PURPOSE_2 . id ] ,
1271
+ } ) ;
1272
+ assertTcOptIns ( {
1273
+ cookie : cookieKeyConsent ,
1274
+ modelType : "specialFeatureOptins" ,
1275
+ ids : [ SPECIAL_FEATURE_1 . id ] ,
1276
+ } ) ;
1277
+ assertTcOptIns ( {
1278
+ cookie : cookieKeyConsent ,
1279
+ modelType : "vendorConsents" ,
1280
+ ids : [ ] ,
1281
+ } ) ;
1282
+ assertTcOptIns ( {
1283
+ cookie : cookieKeyConsent ,
1284
+ modelType : "vendorLegitimateInterests" ,
1285
+ ids : [ ] ,
1286
+ } ) ;
1287
+ expect (
1288
+ cookieKeyConsent . tcf_consent
1289
+ . system_legitimate_interests_preferences ,
1290
+ )
1291
+ . property ( `${ SYSTEM_1 . id } ` )
1292
+ . is . eql ( false ) ;
1293
+ expect (
1294
+ cookieKeyConsent . tcf_consent . system_consent_preferences ,
1295
+ ) . to . eql ( { } ) ;
1296
+ // Confirm vendors_disclosed section does not exist
1297
+ expect ( cookieKeyConsent . fides_string ) . to . not . contain (
1298
+ vendorsDisclosed ,
1299
+ ) ;
1300
+ } ) ;
1301
+ } ) ;
1302
+
1303
+ it ( "can opt out of some custom consent and some tcf consent" , ( ) => {
1150
1304
cy . getByTestId ( "consent-modal" ) . within ( ( ) => {
1305
+ // Custom notice should start off toggled off
1306
+ cy . getByTestId ( "toggle-Advertising English" ) . within ( ( ) => {
1307
+ cy . get ( "input" ) . should ( "not.be.checked" ) ;
1308
+ } ) ;
1309
+ // Opt-out notice should start toggled on
1310
+ cy . getByTestId ( "toggle-Analytics" ) . within ( ( ) => {
1311
+ cy . get ( "input" ) . should ( "be.checked" ) ;
1312
+ } ) ;
1313
+ cy . getByTestId ( "toggle-Advertising English" ) . click ( ) ;
1314
+ // Notice-only should start off toggled on
1315
+ cy . getByTestId ( "toggle-Essential" ) . within ( ( ) => {
1316
+ cy . get ( "input" ) . should ( "be.checked" ) ;
1317
+ } ) ;
1318
+ // opt out to opt-out custom notice
1319
+ cy . getByTestId ( `toggle-Analytics` ) . click ( ) ;
1151
1320
// opt in to purpose 4
1152
1321
cy . getByTestId ( `toggle-${ PURPOSE_4 . name } ` ) . click ( ) ;
1153
1322
cy . get ( "#fides-tab-features" ) . click ( ) ;
@@ -1161,10 +1330,27 @@ describe("Fides-js TCF", () => {
1161
1330
// opt out of system 1 (default is opt-in)
1162
1331
cy . getByTestId ( `toggle-${ SYSTEM_1 . name } ` ) . click ( ) ;
1163
1332
cy . get ( "button" ) . contains ( "Save" ) . click ( ) ;
1164
- cy . get ( "@FidesUIChanged" ) . its ( "callCount" ) . should ( "equal" , 3 ) ;
1333
+ cy . get ( "@FidesUIChanged" ) . its ( "callCount" ) . should ( "equal" , 5 ) ;
1165
1334
cy . wait ( "@patchPrivacyPreference" ) . then ( ( interception ) => {
1166
1335
const { body } = interception . request ;
1167
1336
expect ( interception . request . body . method ) . to . eql ( ConsentMethod . SAVE ) ;
1337
+ expect ( body . preferences ) . to . eql ( [
1338
+ {
1339
+ preference : "opt_in" ,
1340
+ privacy_notice_history_id :
1341
+ "pri_notice-history-advertising-en-000" ,
1342
+ } ,
1343
+ {
1344
+ preference : "opt_out" ,
1345
+ privacy_notice_history_id :
1346
+ "pri_notice-history-analytics-en-000" ,
1347
+ } ,
1348
+ {
1349
+ preference : "acknowledge" ,
1350
+ privacy_notice_history_id :
1351
+ "pri_notice-history-essential-en-000" ,
1352
+ } ,
1353
+ ] ) ;
1168
1354
expect ( body . purpose_consent_preferences ) . to . eql ( [
1169
1355
{
1170
1356
id : PURPOSE_4 . id ,
@@ -1221,6 +1407,15 @@ describe("Fides-js TCF", () => {
1221
1407
expect ( cookieKeyConsent . fides_meta . consentMethod ) . to . eql (
1222
1408
ConsentMethod . SAVE ,
1223
1409
) ;
1410
+ expect ( cookieKeyConsent . consent )
1411
+ . property ( PRIVACY_NOTICE_KEY_1 )
1412
+ . is . eql ( true ) ;
1413
+ expect ( cookieKeyConsent . consent )
1414
+ . property ( PRIVACY_NOTICE_KEY_2 )
1415
+ . is . eql ( true ) ;
1416
+ expect ( cookieKeyConsent . consent )
1417
+ . property ( PRIVACY_NOTICE_KEY_3 )
1418
+ . is . eql ( false ) ;
1224
1419
assertTcOptIns ( {
1225
1420
cookie : cookieKeyConsent ,
1226
1421
modelType : "purposeConsents" ,
@@ -2653,7 +2848,7 @@ describe("Fides-js TCF", () => {
2653
2848
const { body } = interception . request ;
2654
2849
expect ( body . preferences [ 0 ] . preference ) . to . eql ( "opt_out" ) ;
2655
2850
expect ( body . preferences [ 1 ] . preference ) . to . eql ( "opt_out" ) ;
2656
- expect ( body . preferences [ 2 ] . preference ) . to . eql ( "opt_out " ) ;
2851
+ expect ( body . preferences [ 2 ] . preference ) . to . eql ( "acknowledge " ) ; // notice-only
2657
2852
// check a few to see they are empty arrays
2658
2853
expect ( body . purpose_consent_preferences ) . to . eql ( [ ] ) ;
2659
2854
expect ( body . purpose_legitimate_interests_preferences ) . to . eql ( [ ] ) ;
0 commit comments