-
Notifications
You must be signed in to change notification settings - Fork 56
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
Oil 98/fix test reset #127
Conversation
ltparis2018
commented
Jun 11, 2018
•
edited
Loading
edited
- new test util function resetOil() to be used within beforeEach() methods in all tests -> resets oil layer initialization
- new test util function setupVendorListSpies() to be used in all tests for features based on the vendor list (uses predefined test specific small vendor list 'fixtures/vendorlist/simple_vendor_list.json')
…fixTestReset # Conflicts: # test/specs/core/core_config.spec.js
…fixTestReset # Conflicts: # test/specs/core/core_config.spec.js
Pull Request Test Coverage Report for Build 178
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great effort! The only issue I am seeing is that sometimes the configuration from the HTML does not seem to get reset. Specifially this test
"should renderOil with ADVANCED-SETTINGS as CPC template if vendors and purposes are not available" sometimes failed with always different actual results. Repeatedly running the tests would not show this behaviour so we should treat it in a different PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please undo the formatting of the release folder. Everything else is great.
@@ -607,7 +607,7 @@ <h2 id="deprecated"><a class="anchor" href="#deprecated"></a>DEPRECATED</h2> | |||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you formatting auto-generated files?
release/1.1.2/hub.html
Outdated
@@ -3,7 +3,476 @@ | |||
<head> | |||
<meta charset="utf-8"/> | |||
<title>OIL - Hub-HTML</title> | |||
<script>/*! 1.1.2-RELEASE */!function(e){var n={};function t(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,t),r.l=!0,r.exports}t.m=e,t.c=n,t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="//oil.axelspringer.com/release/1.1.2/",t(t.s=62)}([function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.logError=function(){((0,o.isDev)()||(0,r.isVerboseCookieSet)())&&window.console&&s(window.console.error,arguments)},n.logInfo=function(){((0,o.isDev)()||(0,r.isVerboseCookieSet)())&&window.console&&s(window.console.info,arguments)},n.logWarn=function(){((0,o.isDev)()||(0,r.isVerboseCookieSet)())&&window.console&&s(window.console.warn,arguments)},n.logPreviewInfo=function(){((0,o.isDev)()||(0,i.isPreviewMode)()||(0,r.isPreviewCookieSet)()||(0,r.isVerboseCookieSet)())&&s(window.console.info,arguments)};var o=t(1),r=t(6),i=t(2),a="OIL: ";function s(e,n){window.console||(window.console={}),window.console.log||(window.console.log=function(){});var t=[a].concat(Array.prototype.slice.call(n));if(e)try{e.apply(window.console,t)}catch(n){try{e(u(t))}catch(e){}}else window.console.log(u(t))}function u(e){for(var n="",t=0;t<e.length;t++)n+=e[t];return n}},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.OilVersion=void 0,n.isProd=function(){return!1},n.isDev=function(){return!1},n.getOrigin=a,n.sendEventToHostSite=function(e){window.postMessage(e,a()),(0,o.logInfo)("Sent postmessage event: "+e)},n.removeMessageListener=function(e){l(f,e,!1)},n.registerMessageListener=function(e){c(d,e,!1)},n.getClientTimestamp=function(){return Date.now||(Date.now=function(){return(new Date).getTime()}),Date.now()},n.arrayContains=function(e,n){for(var t=e.length,o=0;o<t;o++)if(e[o]===n)return!0;return!1},n.setGlobalOilObject=function(e,n){window[r.OIL_GLOBAL_OBJECT_NAME]||(window[r.OIL_GLOBAL_OBJECT_NAME]={}),window[r.OIL_GLOBAL_OBJECT_NAME][e]=n},n.getGlobalOilObject=function(e){return window[r.OIL_GLOBAL_OBJECT_NAME]?window[r.OIL_GLOBAL_OBJECT_NAME][e]:void 0},n.getLocaleVariantVersion=function(){var e=(0,i.getLocale)();return e&&e.version?e.version:0},n.getCommandCollection=function(){return window.__cmp?window.__cmp.commandCollection:void 0},n.fetchJsonData=function(e){return new Promise(function(n,t){var r=new XMLHttpRequest;(0,o.logInfo)("Fetching data from url: "+e),r.open("GET",e),r.onreadystatechange=function(){if(r.readyState===this.DONE)if(200===r.status)n(JSON.parse(r.responseText));else{var o=void 0;if(0!==r.status){var i=JSON.parse(r.responseText);o=new Error(i.errorMessage)}else o=new Error("Connection error occurred while fetching JSON data from "+e+"!");t(o)}},r.send()})},n.isObject=function(e){return e instanceof Object&&e.constructor===Object};var o=t(0),r=t(5),i=t(2);function a(){return window.location.origin||(window.location.origin=window.location.protocol+"//"+window.location.hostname+(window.location.port?":"+window.location.port:"")),window.location.origin}var s=window.addEventListener?"addEventListener":"attachEvent",u=window.removeEventListener?"removeEventListener":"removeEvent",c=window[s],l=window[u],d="attachEvent"===s?"onmessage":"message",f="removeEvent"===u?"onmessage":"message";n.OilVersion={get:function(){return"1.1.2-RELEASE"},getLatestReleaseVersion:function(){return"1.1.2"}}},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.getConfigValue=s,n.isPreviewMode=function(){return s(o.OIL_CONFIG.ATTR_PREVIEW_MODE,!1)},n.isPoiActive=function(){return s(o.OIL_CONFIG.ATTR_ACTIVATE_POI,!1)},n.isSubscriberSetCookieActive=function(){return s(o.OIL_CONFIG.ATTR_SUB_SET_COOKIE,!0)},n.getHubOrigin=c,n.getHubPath=l,n.getPublicPath=d,n.getLocaleUrl=f,n.getIabVendorListUrl=function(){return s(o.OIL_CONFIG.ATTR_IAB_VENDOR_LIST_URL,"https://vendorlist.consensu.org/vendorlist.json")},n.getIabVendorBlacklist=function(){return s(o.OIL_CONFIG.ATTR_IAB_VENDOR_BLACKLIST,void 0)},n.getIabVendorWhitelist=function(){return s(o.OIL_CONFIG.ATTR_IAB_VENDOR_WHITELIST,void 0)},n.getPoiGroupName=function(){return s(o.OIL_CONFIG.ATTR_POI_GROUP_NAME,"default")},n.getCookieExpireInDays=function(){return s(o.OIL_CONFIG.ATTR_COOKIE_EXPIRES_IN_DAYS,31)},n.getLocaleVariantName=p,n.getLanguage=function(){return g(p())},n.getLanguageFromLocale=g,n.getHubLocation=function(){return c()&&l()?c()+l():null},n.resetConfiguration=function(){(0,i.setGlobalOilObject)("CONFIG",null)},n.getCustomPurposes=_,n.getCustomPurposeIds=function(){return _().map(function(e){return e.id})},n.getAdvancedSettingsPurposesDefault=function(){return s(o.OIL_CONFIG.ATTR_ADVANCED_SETTINGS_PURPOSES_DEFAULT,!1)},n.getDefaultToOptin=function(){return s(o.OIL_CONFIG.ATTR_DEFAULT_TO_OPTIN,!1)},n.getLocale=v,n.setLocale=function(e){u(o.OIL_CONFIG.ATTR_LOCALE,e)};var o=t(5),r=t(0),i=t(1);function a(){if(!(0,i.getGlobalOilObject)("CONFIG")){var e=document.querySelector('script[type="application/configuration"]#oil-configuration');null===e&&(0,r.logInfo)("Using default config"),(0,i.setGlobalOilObject)("CONFIG",function(e){var n={};try{e&&e.text&&(n=JSON.parse(e.text),(0,r.logInfo)("Parsed config",n))}catch(e){(0,r.logError)("Error config",e)}return n}(e)),(a=v())&&"string"!=typeof a||void 0!==f()||((0,r.logError)("Incorrect or missing locale parameter found. Please review documentation on how to set the locale object in your configuration."),n="https://oil-backend.herokuapp.com/oil/api/userViewLocales/"+p(),u(o.OIL_CONFIG.ATTR_LOCALE_URL,n)),d()&&(t.p=d())}var n,a;return(0,i.getGlobalOilObject)("CONFIG")}function s(e,n){var t=a();return t&&t[e]?t[e]:n}function u(e,n){a()[e]=n}function c(){var e=s(o.OIL_CONFIG.ATTR_HUB_ORIGIN,"//oil.axelspringer.com");return e?-1!==e.indexOf("http")?e:location.protocol+e:null}function l(){return s(o.OIL_CONFIG.ATTR_HUB_PATH,"/release/"+i.OilVersion.getLatestReleaseVersion()+"/hub.html")}function d(){return s(o.OIL_CONFIG.ATTR_PUBLIC_PATH,void 0)}function f(){return s(o.OIL_CONFIG.ATTR_LOCALE_URL,void 0)}function p(){var e=v();return e||(e="enEN_01"),e&&(0,i.isObject)(e)?e.localeId:e}function g(e){return e.substring(0,2)}function _(){return s(o.OIL_CONFIG.ATTR_CUSTOM_PURPOSES,[])}function v(){return s(o.OIL_CONFIG.ATTR_LOCALE,void 0)}},,,function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.OIL_SPEC={CMP_ID:80,CMP_VERSION:1,LATEST_CONSENT_STRING_VERSION:1},n.OIL_CONFIG={ATTR_ACTIVATE_POI:"poi_activate_poi",ATTR_HUB_ORIGIN:"poi_hub_origin",ATTR_HUB_PATH:"poi_hub_path",ATTR_PUBLIC_PATH:"publicPath",ATTR_HUB_LOCATION:"poi_hub_location",ATTR_SUB_SET_COOKIE:"poi_subscriber_set_cookie",ATTR_PREVIEW_MODE:"preview_mode",ATTR_COOKIE_EXPIRES_IN_DAYS:"cookie_expires_in_days",ATTR_TIMESTAMP:"timestamp",ATTR_PRIVACY_PAGE_URL:"privacy_page_url",ATTR_POI_GROUP_NAME:"poi_group_name",ATTR_ADVANCED_SETTINGS:"advanced_settings",ATTR_PERSIST_MINIMUM_TRACKING:"persist_min_tracking",ATTR_LOCALE:"locale",ATTR_THEME:"theme",ATTR_TIMEOUT:"timeout",ATTR_LOCALE_URL:"locale_url",ATTR_IAB_VENDOR_LIST_URL:"iabVendorListUrl",ATTR_CUSTOM_PURPOSES:"customPurposes",ATTR_IAB_VENDOR_BLACKLIST:"iabVendorBlacklist",ATTR_IAB_VENDOR_WHITELIST:"iabVendorWhitelist",ATTR_ADVANCED_SETTINGS_PURPOSES_DEFAULT:"advanced_settings_purposes_default",ATTR_DEFAULT_TO_OPTIN:"default_to_optin"},n.EVENT_NAME_OPT_IN="oil_optin_done",n.EVENT_NAME_SOI_OPT_IN="oil_soi_optin_done",n.EVENT_NAME_POI_OPT_IN="oil_poi_optin_done",n.PRIVACY_MINIMUM_TRACKING=0,n.PRIVACY_FULL_TRACKING=1,n.EVENT_NAME_AS_PRIVACY_SELECTED="oil_as_cpc_privacy_selected",n.EVENT_NAME_ADVANCED_SETTINGS="oil_click_advanced_settings",n.EVENT_NAME_TIMEOUT="oil_hide_layer",n.EVENT_NAME_COMPANY_LIST="oil_click_company_list",n.EVENT_NAME_THIRD_PARTY_LIST="oil_click_thirdparty_list",n.EVENT_NAME_BACK_TO_MAIN="oil_click_back_to_main",n.EVENT_NAME_NO_COOKIES_ALLOWED="oil_no_cookies_allowed",n.EVENT_NAME_OIL_SHOWN="oil_shown",n.EVENT_NAME_HAS_OPTED_IN="oil_has_optedin",n.POI_FALLBACK_NAME="fallback",n.POI_FALLBACK_GROUP_NAME="group_name",n.POI_PAYLOAD="payload",n.DATAQA_PRIVACY_PAGE="oil-PrivacyPage",n.DATA_CONTEXT_YES="YES",n.DATA_CONTEXT_ADVANCED_SETTINGS="ADVANCEDSETTINGS",n.DATA_CONTEXT_BACK="BACK",n.OIL_PAYLOAD_PRIVACY="p",n.OIL_PAYLOAD_VERSION="v",n.OIL_PAYLOAD_LOCALE_VARIANT_NAME="lvn",n.OIL_PAYLOAD_LOCALE_VARIANT_VERSION="lvv",n.OIL_PAYLOAD_CUSTOM_PURPOSES="cp",n.OIL_GLOBAL_OBJECT_NAME="AS_OIL"},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};n.setSessionCookie=m,n.setDomainCookie=O,n.getOilCookie=I,n.hasOutdatedOilCookie=A,n.getSoiCookie=function(){var e=S(),n=A(e)?function(e){var n=i.default.getJSON(_),t=e.defaultCookieContent;return t.opt_in=n.opt_in,t.version=n.version,t.localeVariantName=n.localeVariantName,t.localeVariantVersion=n.localeVariantVersion,t.customPurposes=L(n.privacy),t.consentData.setConsentLanguage((0,s.getLanguageFromLocale)(n.localeVariantName)),t.consentData.setPurposesAllowed(C(n.privacy)),t.consentData.setVendorsAllowed((0,l.getLimitedVendorIds)()),t.consentData.setGlobalVendorList((0,l.getVendorList)()),t.consentString=t.consentData.getConsentString(),t}(e):I(e);return(0,a.logInfo)("Current Oil data from domain cookie: ",n),n},n.setSoiCookieWithConsentData=function(e,n){return new Promise(function(t,o){(0,l.loadVendorList)().then(function(){var o=S();e.setGlobalVendorList((0,l.getVendorList)());var r={opt_in:!0,version:o.defaultCookieContent.version,localeVariantName:o.defaultCookieContent.localeVariantName,localeVariantVersion:o.defaultCookieContent.localeVariantVersion,customPurposes:n,consentString:e.getConsentString()};O(o.name,r,o.expires),t(r)}).catch(function(e){return o(e)})})},n.buildSoiCookie=h,n.setSoiCookie=function(e){return new Promise(function(n,t){h(e).then(function(e){O(_,e,(0,s.getCookieExpireInDays)()),n(e)}).catch(function(e){return t(e)})})},n.setPreviewCookie=function(){m(p,"true")},n.setVerboseCookie=function(){m(g,"true")},n.removePreviewCookie=function(){i.default.remove(p)},n.removeVerboseCookie=function(){i.default.remove(g)},n.isPreviewCookieSet=function(){return"true"===i.default.get(p)},n.isVerboseCookieSet=function(){return"true"===i.default.get(g)},n.removeSubscriberCookies=y,n.removeHubCookie=function(e){y(),e&&i.default.remove(e+"_"+_)},n.isBrowserCookieEnabled=function(){i.default.set("oil_cookie_exp","cookiedata");var e=w("oil_cookie_exp");return i.default.remove("oil_cookie_exp"),e},n.getStandardPurposesWithConsent=C,n.getCustomPurposesWithConsent=L;var r,i=(r=t(10))&&r.__esModule?r:{default:r},a=t(0),s=t(2),u=t(1),c=t(5),l=t(9),d=t(1),f=t(20).ConsentString,p="oil_preview",g="oil_verbose",_="oil_data",v="oil_data_session";function m(e,n){i.default.set(e,n)}function O(e,n,t){delete n.consentData,i.default.set(e,n,{expires:t})}function I(e){if(V(e.name,Object.keys(e.defaultCookieContent))){var n=i.default.getJSON(e.name);return n.consentData=new f(n.consentString),n}return e.defaultCookieContent}function A(e){return V(e.name,e.outdated_cookie_content_keys)}function h(e){return new Promise(function(n,t){(0,l.loadVendorList)().then(function(){var t=S(),o=t.defaultCookieContent.consentData;o.setGlobalVendorList((0,l.getVendorList)()),o.setPurposesAllowed(C(e)),o.setVendorsAllowed((0,l.getLimitedVendorIds)()),n({opt_in:!0,version:t.defaultCookieContent.version,localeVariantName:t.defaultCookieContent.localeVariantName,localeVariantVersion:t.defaultCookieContent.localeVariantVersion,customPurposes:L(e),consentString:o.getConsentString()})}).catch(function(e){return t(e)})})}function y(){i.default.remove(_),i.default.remove(v)}function C(e){return"object"===(void 0===e?"undefined":o(e))?(0,l.getPurposes)().map(function(e){return e.id}).filter(function(n){return e[n]}):1===e?(0,l.getPurposes)().map(function(e){return e.id}):[]}function L(e,n){return n||(n=(0,s.getCustomPurposes)()),"object"===(void 0===e?"undefined":o(e))?n.map(function(e){return e.id}).filter(function(n){return e[n]}):1===e?n.map(function(e){return e.id}):[]}function w(e){return void 0!==i.default.get(e)}function V(e,n){return function(e,n){if("string"==typeof e&&Array.isArray(n)&&w(e)){var t=i.default.getJSON(e);return n.every(function(e){return"consentData"===e||t.hasOwnProperty(e)})}return!1}(e,n)}function S(){var e=new f;return e.setCmpId(c.OIL_SPEC.CMP_ID),e.setCmpVersion(c.OIL_SPEC.CMP_VERSION),e.setConsentScreen(1),e.setConsentLanguage((0,s.getLanguage)()),e.setPurposesAllowed((0,s.getDefaultToOptin)()?(0,l.getPurposes)().map(function(e){return e.id}):[]),e.setVendorsAllowed((0,s.getDefaultToOptin)()?(0,l.getLimitedVendorIds)():[]),e.setGlobalVendorList((0,l.getVendorList)()),{name:_,expires:(0,s.getCookieExpireInDays)(),defaultCookieContent:{opt_in:!1,version:d.OilVersion.get(),localeVariantName:(0,s.getLocaleVariantName)(),localeVariantVersion:(0,u.getLocaleVariantVersion)(),customPurposes:L((0,s.getDefaultToOptin)()?1:0),consentData:e,consentString:e.getConsentString()},outdated_cookie_content_keys:["opt_in","timestamp","version","localeVariantName","localeVariantVersion","privacy"]}}},,,function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.cachedVendorList=n.DEFAULT_VENDOR_LIST=void 0,n.loadVendorList=function(){return new Promise(function(e){if(s)e(s);else{var t=(0,o.getIabVendorListUrl)();(0,i.fetchJsonData)(t).then(function(t){var o;n.cachedVendorList=s=t,(o=s).vendors=o.vendors.sort(function(e,n){return e.id-n.id}),e(s)}).catch(function(n){(0,r.logError)("OIL getVendorList failed and returned error: "+n+". Falling back to default vendor list!"),e(d())})}})},n.getPurposes=u,n.getPurposeIds=function(){return u().map(function(e){return e.id})},n.getVendors=c,n.getVendorIds=l,n.getVendorListVersion=function(){return s?s.vendorListVersion:a.vendorListVersion},n.getVendorList=d,n.clearVendorListCache=function(){n.cachedVendorList=s=void 0},n.getLimitedVendorIds=function(){var e=void 0;e=s?l():f();var n=(0,o.getIabVendorWhitelist)(),t=(0,o.getIabVendorBlacklist)();return n&&n.length>0?e=e.filter(function(e){return n.indexOf(e)>-1}):t&&t.length>0&&(e=e.filter(function(e){return-1===t.indexOf(e)})),e};var o=t(2),r=t(0),i=t(1),a=n.DEFAULT_VENDOR_LIST={vendorListVersion:36,maxVendorId:380,lastUpdated:"2018-05-30T16:00:15Z",purposeIds:[1,2,3,4,5]},s=n.cachedVendorList=void 0;function u(){return s?s.purposes:p(a.purposeIds)}function c(){return s?s.vendors:p(f())}function l(){return c().map(function(e){return e.id})}function d(){return s||{vendorListVersion:a.vendorListVersion,lastUpdated:a.lastUpdated,vendors:p(f()),purposes:p(a.purposeIds),features:[],isDefault:!0}}function f(){return function(e,n){for(;e--;)n[e]=e+1;return n}(a.maxVendorId,[])}function p(e){return e.map(function(e){return{id:e}})}},function(e,n,t){var o,r,i; | |||
<script>/*! 1.1.2-RELEASE */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, this is not good. These are the releases files and will be referenced
f1ad4ab
to
cb9762a
Compare
… OIL-98/fixTestReset
…ie setting is not expected)