From 4fbb1c7434af4172c5ebad5f85e6a807e5fa0733 Mon Sep 17 00:00:00 2001 From: Jason Quaccia Date: Wed, 31 Jan 2024 11:06:48 -0800 Subject: [PATCH] Topics fpd module : fix for intermitent failing test (#11013) * test pr for circleci * fix for failing topicsFpdModule tests * formatting fix * minor refactor * triggered another circle ci build --- modules/topicsFpdModule.js | 4 +++- test/spec/modules/topicsFpdModule_spec.js | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/modules/topicsFpdModule.js b/modules/topicsFpdModule.js index 617ce0ad6f4..a31d72fc179 100644 --- a/modules/topicsFpdModule.js +++ b/modules/topicsFpdModule.js @@ -14,9 +14,11 @@ const MODULE_NAME = 'topicsFpd'; const DEFAULT_EXPIRATION_DAYS = 21; const DEFAULT_FETCH_RATE_IN_DAYS = 1; let LOAD_TOPICS_INITIALISE = false; +let iframeLoadedURL = []; export function reset() { LOAD_TOPICS_INITIALISE = false; + iframeLoadedURL = []; } const bidderIframeList = { @@ -29,11 +31,11 @@ const bidderIframeList = { iframeURL: 'https://topics.authorizedvault.com/topicsapi.html' }] } + export const coreStorage = getCoreStorageManager(MODULE_NAME); export const topicStorageName = 'prebid:topics'; export const lastUpdated = 'lastUpdated'; -const iframeLoadedURL = []; const TAXONOMIES = { // map from topic taxonomyVersion to IAB segment taxonomy '1': 600, diff --git a/test/spec/modules/topicsFpdModule_spec.js b/test/spec/modules/topicsFpdModule_spec.js index bc7df85db0d..4a79e7f77fd 100644 --- a/test/spec/modules/topicsFpdModule_spec.js +++ b/test/spec/modules/topicsFpdModule_spec.js @@ -384,6 +384,22 @@ describe('topics', () => { }); describe('cross-frame messages', () => { + before(() => { + config.setConfig({ + userSync: { + topics: { + maxTopicCaller: 3, + bidders: [ + { + bidder: 'pubmatic', + iframeURL: 'https://ads.pubmatic.com/AdServer/js/topics/topics_frame.html' + } + ], + }, + } + }); + }); + beforeEach(() => { // init iframe logic so that the receiveMessage origin check passes loadTopicsForBidders({ @@ -398,6 +414,10 @@ describe('topics', () => { }); }); + after(() => { + config.resetConfig(); + }) + it('should store segments if receiveMessage event is triggered with segment data', () => { receiveMessage(evt); let segments = new Map(safeJSONParse(storage.getDataFromLocalStorage(topicStorageName))); @@ -421,11 +441,13 @@ describe('handles fetch request for topics api headers', () => { beforeEach(() => { stubbedFetch = sinon.stub(window, 'fetch'); + reset(); }); afterEach(() => { stubbedFetch.restore(); storage.removeDataFromLocalStorage(topicStorageName); + config.resetConfig(); }); it('should make a fetch call when a fetchUrl is present for a selected bidder', () => { @@ -444,6 +466,7 @@ describe('handles fetch request for topics api headers', () => { }); stubbedFetch.returns(Promise.resolve(true)); + loadTopicsForBidders({ browsingTopics: true, featurePolicy: {