Skip to content

Commit

Permalink
Merge pull request #19 from duckduckgo/shane/windows-cookies
Browse files Browse the repository at this point in the history
feat: added windows support for 'Cookies Managed' row in primary screen
  • Loading branch information
shakyShane authored Dec 13, 2022
2 parents 37504f1 + 026ab90 commit 2d4869a
Show file tree
Hide file tree
Showing 20 changed files with 174 additions and 41 deletions.
70 changes: 49 additions & 21 deletions build/app/public/js/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -28341,7 +28341,7 @@ module.exports={
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.windowsViewModelSchema = exports.windowsIncomingVisibilitySchema = exports.windowsIncomingViewModelSchema = exports.windowsIncomingMessageSchema = exports.tabSchema = exports.stateBlockedSchema = exports.stateAllowedSchema = exports.setListOptionsSchema = exports.searchSchema = exports.ruleExceptionReasonSchema = exports.requestDataSchema = exports.refreshAliasResponseSchema = exports.protectionsStatusSchema = exports.protectionsDisabledReasonSchema = exports.parentEntitySchema = exports.ownedByFirstPartyReasonSchema = exports.otherThirdPartyRequestReasonSchema = exports.localeSettingsSchema = exports.getPrivacyDashboardDataSchema = exports.extensionMessageSetListOptionsSchema = exports.extensionMessageGetPrivacyDashboardDataSchema = exports.emailProtectionUserDataSchema = exports.detectedRequestSchema = exports.breakageReportSchema = exports.breakageReportRequestSchema = exports.apiSchema = exports.adClickAttributionReasonSchema = void 0;
exports.windowsViewModelSchema = exports.windowsIncomingVisibilitySchema = exports.windowsIncomingViewModelSchema = exports.windowsIncomingMessageSchema = exports.tabSchema = exports.stateBlockedSchema = exports.stateAllowedSchema = exports.setListOptionsSchema = exports.searchSchema = exports.ruleExceptionReasonSchema = exports.requestDataSchema = exports.refreshAliasResponseSchema = exports.protectionsStatusSchema = exports.protectionsDisabledReasonSchema = exports.parentEntitySchema = exports.ownedByFirstPartyReasonSchema = exports.otherThirdPartyRequestReasonSchema = exports.localeSettingsSchema = exports.getPrivacyDashboardDataSchema = exports.extensionMessageSetListOptionsSchema = exports.extensionMessageGetPrivacyDashboardDataSchema = exports.emailProtectionUserDataSchema = exports.detectedRequestSchema = exports.cookiePromptManagementStatusSchema = exports.breakageReportSchema = exports.breakageReportRequestSchema = exports.apiSchema = exports.adClickAttributionReasonSchema = void 0;
var _zod = require("zod");
// Generated by ts-to-zod

Expand Down Expand Up @@ -28417,6 +28417,12 @@ var windowsIncomingVisibilitySchema = _zod.z.object({
})
});
exports.windowsIncomingVisibilitySchema = windowsIncomingVisibilitySchema;
var cookiePromptManagementStatusSchema = _zod.z.object({
consentManaged: _zod.z["boolean"](),
optoutFailed: _zod.z["boolean"]().optional(),
selftestFailed: _zod.z["boolean"]().optional()
});
exports.cookiePromptManagementStatusSchema = cookiePromptManagementStatusSchema;
var refreshAliasResponseSchema = _zod.z.object({
personalAddress: _zod.z.string(),
privateAddress: _zod.z.string()
Expand Down Expand Up @@ -28471,7 +28477,8 @@ var windowsViewModelSchema = _zod.z.object({
upgradedHttps: _zod.z["boolean"](),
parentEntity: parentEntitySchema.optional(),
permissions: _zod.z.array(_zod.z.unknown()).optional(),
certificates: _zod.z.array(_zod.z.unknown()).optional()
certificates: _zod.z.array(_zod.z.unknown()).optional(),
cookiePromptManagementStatus: cookiePromptManagementStatusSchema.optional()
});
exports.windowsViewModelSchema = windowsViewModelSchema;
var windowsIncomingViewModelSchema = _zod.z.object({
Expand Down Expand Up @@ -28558,7 +28565,7 @@ var upgradedHttps;
var protections;
var isPendingUpdates;
var parentEntity;
var consentManaged;
var cookiePromptManagementStatus;

/** @type {string | undefined} */
var locale;
Expand All @@ -28567,7 +28574,7 @@ var combineSources = function combineSources() {
tab: Object.assign({}, trackerBlockingData || {}, {
isPendingUpdates: isPendingUpdates,
parentEntity: parentEntity,
consentManaged: consentManaged,
cookiePromptManagementStatus: cookiePromptManagementStatus,
locale: locale
}, permissionsData ? {
permissions: permissionsData
Expand Down Expand Up @@ -28879,7 +28886,7 @@ function setup() {
};
window.onChangeConsentManaged = function (data) {
var _channel7;
consentManaged = data;
cookiePromptManagementStatus = data;
(_channel7 = channel) === null || _channel7 === void 0 ? void 0 : _channel7.send('updateTabData', {
via: 'onChangeConsentManaged'
});
Expand Down Expand Up @@ -29907,7 +29914,7 @@ var upgradedHttps;
var protections;
var isPendingUpdates;
var parentEntity;
var consentManaged;
var cookiePromptManagementStatus;

/** @type {string | undefined} */
var locale;
Expand All @@ -29916,7 +29923,7 @@ var combineSources = function combineSources() {
tab: Object.assign({}, trackerBlockingData || {}, {
isPendingUpdates: isPendingUpdates,
parentEntity: parentEntity,
consentManaged: consentManaged,
cookiePromptManagementStatus: cookiePromptManagementStatus,
platformLimitations: true,
locale: locale
}, permissionsData ? {
Expand Down Expand Up @@ -30152,7 +30159,7 @@ function setupShared() {
};
window.onChangeConsentManaged = function (data) {
var _channel7;
consentManaged = data;
cookiePromptManagementStatus = data;
(_channel7 = channel) === null || _channel7 === void 0 ? void 0 : _channel7.send('updateTabData');
};
(0, _utils.setupGlobalOpenerListener)(function (href) {
Expand Down Expand Up @@ -30290,7 +30297,7 @@ function getOverrides(searchString) {
overrides.tab.protections = new _requestDetails.Protections(false, [], false, true);
}
if (params.get('consentManaged')) {
overrides.tab.consentManaged = {
overrides.tab.cookiePromptManagementStatus = {
consentManaged: true,
optoutFailed: false,
selftestFailed: false
Expand Down Expand Up @@ -30352,6 +30359,9 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
/**
* @typedef {import('../../../../schema/__generated__/schema.types.js').CookiePromptManagementStatus} CookiePromptManagementStatus
*/
var Protections = /*#__PURE__*/function () {
/**
* @param {boolean} unprotectedTemporary
Expand Down Expand Up @@ -30399,14 +30409,14 @@ var TabData = /*#__PURE__*/_createClass( /** @type {string | null | undefined} *
* @param {Protections} protections
* @param {any[] | null | undefined} permissions
* @param {RequestDetails} requestDetails
* @param {{consentManaged, optoutFailed, selftestFailed} | null | undefined} consentManaged
* @param {CookiePromptManagementStatus | undefined | null} cookiePromptManagementStatus
* @param {Record<string, any> | null | undefined} ctaScreens
* @param {Record<string, any> | null | undefined} search
* @param {Record<string, any> | null | undefined} emailProtection
* @param {{prevalence: number, displayName: string} | null | undefined} parentEntity
* @param {string | null | undefined} error
*/
function TabData(id, url, domain, specialDomainName, status, upgradedHttps, protections, permissions, requestDetails, consentManaged, ctaScreens, search, emailProtection, parentEntity, error) {
function TabData(id, url, domain, specialDomainName, status, upgradedHttps, protections, permissions, requestDetails, cookiePromptManagementStatus, ctaScreens, search, emailProtection, parentEntity, error) {
_classCallCheck(this, TabData);
_defineProperty(this, "locale", void 0);
_defineProperty(this, "isPendingUpdates", void 0);
Expand All @@ -30421,7 +30431,7 @@ function TabData(id, url, domain, specialDomainName, status, upgradedHttps, prot
this.protections = protections;
this.permissions = permissions;
this.requestDetails = requestDetails;
this.consentManaged = consentManaged;
this.cookiePromptManagementStatus = cookiePromptManagementStatus;
this.ctaScreens = ctaScreens;
this.search = search;
this.emailProtection = emailProtection;
Expand Down Expand Up @@ -30455,7 +30465,7 @@ var createTabData = function createTabData(tabUrl, upgradedHttps, protections, r
requestDetails: createRequestDetails(rawRequestData.requests, rawRequestData.installedSurrogates || []),
parentEntity: undefined,
permissions: undefined,
consentManaged: undefined,
cookiePromptManagementStatus: undefined,
ctaScreens: undefined,
search: undefined,
emailProtection: undefined,
Expand Down Expand Up @@ -30891,6 +30901,7 @@ function handleViewModelUpdate(viewModel) {
certificateData = viewModel.certificates || [];
protections = viewModel.protections;
trackerBlockingData = (0, _requestDetails.createTabData)(viewModel.tabUrl, upgradedHttps, viewModel.protections, viewModel.rawRequestData);
trackerBlockingData.cookiePromptManagementStatus = viewModel.cookiePromptManagementStatus;
if (trackerBlockingData) trackerBlockingData.upgradedHttps = upgradedHttps;
resolveInitialRender();
}
Expand Down Expand Up @@ -34308,19 +34319,21 @@ MainNavView.prototype = _jquery["default"].extend({}, _viewEs["default"].prototy
* @returns {HTMLElement}
*/
function template() {
var _this$model$tab, _this$model$tab$conse;
var consentRow = (0, _bel["default"])(_templateObject || (_templateObject = _taggedTemplateLiteral(["<li class=\"main-nav__row\">", "</li>"])), renderCookieConsentManaged(this.model));
return (0, _bel["default"])(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n <ul class='default-list card-list--bordered main-nav token-body-em js-site-main-nav'>\n <li class='main-nav__row'>\n ", "\n </li>\n <li class='main-nav__row js-site-show-page-trackers'>\n ", "\n </li>\n <li class='main-nav__row js-site-show-page-non-trackers'>\n ", "\n </li>\n ", "\n </ul>\n "])), renderConnection(this.model, this.nav.connection), renderTrackerNetworksNew(this.model, this.nav.trackers), renderThirdPartyNew(this.model, this.nav.nonTrackers), (_this$model$tab = this.model.tab) !== null && _this$model$tab !== void 0 && (_this$model$tab$conse = _this$model$tab.consentManaged) !== null && _this$model$tab$conse !== void 0 && _this$model$tab$conse.consentManaged ? consentRow : null);
var _model$tab, _model$tab$cookieProm;
/** @type {import('../models/site.es6.js').PublicSiteModel} */
var model = this.model;
var consentRow = (0, _bel["default"])(_templateObject || (_templateObject = _taggedTemplateLiteral(["<li class=\"main-nav__row\">", "</li>"])), renderCookieConsentManaged(model));
return (0, _bel["default"])(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n <ul class='default-list card-list--bordered main-nav token-body-em js-site-main-nav'>\n <li class='main-nav__row'>\n ", "\n </li>\n <li class='main-nav__row js-site-show-page-trackers'>\n ", "\n </li>\n <li class='main-nav__row js-site-show-page-non-trackers'>\n ", "\n </li>\n ", "\n </ul>\n "])), renderConnection(model, this.nav.connection), renderTrackerNetworksNew(model, this.nav.trackers), renderThirdPartyNew(model, this.nav.nonTrackers), (_model$tab = model.tab) !== null && _model$tab !== void 0 && (_model$tab$cookieProm = _model$tab.cookiePromptManagementStatus) !== null && _model$tab$cookieProm !== void 0 && _model$tab$cookieProm.consentManaged ? consentRow : null);
}
/**
* @param {import('../models/site.es6.js').PublicSiteModel} model
*/
function renderCookieConsentManaged(model) {
var _model$tab;
if (!((_model$tab = model.tab) !== null && _model$tab !== void 0 && _model$tab.consentManaged)) return null;
var _model$tab$consentMan = model.tab.consentManaged,
consentManaged = _model$tab$consentMan.consentManaged,
optoutFailed = _model$tab$consentMan.optoutFailed;
var _model$tab2;
if (!((_model$tab2 = model.tab) !== null && _model$tab2 !== void 0 && _model$tab2.cookiePromptManagementStatus)) return null;
var _model$tab$cookieProm2 = model.tab.cookiePromptManagementStatus,
consentManaged = _model$tab$cookieProm2.consentManaged,
optoutFailed = _model$tab$cookieProm2.optoutFailed;
if (consentManaged && !optoutFailed) {
return (0, _bel["default"])(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n <div class=\"main-nav__item\">\n <span class=\"main-nav__icon icon-small--secure\"></span>\n <span class=\"main-nav__text\">", "</span>\n </div>\n "])), _localize.i18n.t('site:cookiesMinimized.title'));
}
Expand Down Expand Up @@ -35022,6 +35035,7 @@ var MockData = /*#__PURE__*/function () {
* @param {any[]} [params.permissions]
* @param {boolean} [params.specialDomainName]
* @param {boolean} [params.emailUser]
* @param {boolean} [params.consentManaged]
*/
function MockData(params) {
var _params$upgradedHttps;
Expand All @@ -35040,6 +35054,15 @@ var MockData = /*#__PURE__*/function () {
this.allowlisted = params.allowlisted;
this.specialDomainName = params.specialDomainName;
this.emailUser = params.emailUser;
this.consentManaged = params.consentManaged;
if (this.consentManaged) {
/** @type {import('../../../../../schema/__generated__/schema.types').CookiePromptManagementStatus} */
this.cookiePromptManagementStatus = {
consentManaged: true,
optoutFailed: false,
selftestFailed: false
};
}

/** @type {Protections} */
this.protections = _requestDetails.Protections["default"]();
Expand Down Expand Up @@ -35105,6 +35128,11 @@ function mockToExtensionDashboardMessage(mock) {

/** @type {Record<string, MockData>} */
var dataStates = {
'consent-managed': new MockData({
url: 'https://example.com',
requests: [],
consentManaged: true
}),
'locale-pl': new MockData({
localeSettings: {
locale: 'pl'
Expand Down
4 changes: 4 additions & 0 deletions integration-tests/DashboardPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ export class DashboardPage {
await this.page.getByRole('switch', { name: 'Disable Protections' }).click()
}

async indicatesCookiesWereManaged() {
await this.page.getByText('Cookies Managed').waitFor({ timeout: 500 })
}

async toggleProtectionsOn() {
await this.page.locator('[aria-checked="false"]').click()
}
Expand Down
8 changes: 8 additions & 0 deletions integration-tests/android.spec-int.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,12 @@ if (!process.env.CI) {
})
}
})
test.describe('screenshots for cookies', () => {
test('primary screen', async ({ page }) => {
const dash = await DashboardPage.android(page)
await dash.addStates([dataStates['consent-managed']])
await dash.indicatesCookiesWereManaged()
await dash.screenshot('consent-managed.png')
})
})
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions integration-tests/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ export async function playTimeline(page, states, platform) {
const nextProtections = state.protections
const nextLocale = state.localeSettings
const nextPermissions = state.permissions
const nextCookiePromptManagementStatus = state.cookiePromptManagementStatus
const nextRequestData = { requests: state.requests }

if (platform?.name === 'windows') {
for (const listener of window.__playwright.listeners || []) {
// todo(Shane): Centralise this so that it's shared in the comms file
listener({
/** @type {import('../schema/__generated__/schema.types').WindowsIncomingViewModel} */
data: {
Feature: 'PrivacyDashboard',
Name: 'ViewModelUpdated',
Expand All @@ -43,6 +45,7 @@ export async function playTimeline(page, states, platform) {
parentEntity: nextParentEntity,
permissions: nextPermissions,
certificates: nextCerts,
cookiePromptManagementStatus: nextCookiePromptManagementStatus,
},
},
})
Expand Down Expand Up @@ -73,6 +76,9 @@ export async function playTimeline(page, states, platform) {
}
return
}
if (nextCookiePromptManagementStatus) {
window.onChangeConsentManaged(nextCookiePromptManagementStatus)
}
window.onChangeParentEntity(nextParentEntity)
window.onChangeProtectionStatus(nextProtections)
window.onChangeUpgradedHttps(nextUpgradedHttps)
Expand Down
8 changes: 8 additions & 0 deletions integration-tests/macos.spec-int.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,12 @@ if (!process.env.CI) {
})
}
})
test.describe('screenshots for cookies', () => {
test('primary screen', async ({ page }) => {
const dash = await DashboardPage.macos(page)
await dash.addStates([dataStates['consent-managed']])
await dash.indicatesCookiesWereManaged()
await dash.screenshot('consent-managed.png')
})
})
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions integration-tests/windows.spec-int.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,12 @@ if (!process.env.CI) {
})
}
})
test.describe('screenshots for cookies', () => {
test('primary screen', async ({ page }) => {
const dash = await DashboardPage.windows(page)
await dash.addStates([dataStates['consent-managed']])
await dash.indicatesCookiesWereManaged()
await dash.screenshot('consent-managed.png')
})
})
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion schema/__generated__/schema.parsers.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions schema/__generated__/schema.types.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2d4869a

Please sign in to comment.