From 018d0b3e82946da61a78c10095d2172d5595e9d8 Mon Sep 17 00:00:00 2001 From: Serban Andrei Stancu Date: Wed, 14 Aug 2024 13:37:37 -0600 Subject: [PATCH] PLATIR-42315 Ensure audience cookies are set on the default path. (#1160) --- src/utils/cookieJar.js | 9 +++++---- test/functional/specs/Audiences/C12412.js | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/utils/cookieJar.js b/src/utils/cookieJar.js index f83f3b43e..ce1a8beff 100644 --- a/src/utils/cookieJar.js +++ b/src/utils/cookieJar.js @@ -12,9 +12,10 @@ governing permissions and limitations under the License. import cookie from "js-cookie"; + export default { - get: cookie.get, - set: cookie.set, - remove: cookie.remove, - withConverter: cookie.withConverter + get: cookie.get.bind(cookie), + set: cookie.set.bind(cookie), + remove: cookie.remove.bind(cookie), + withConverter: cookie.withConverter.bind(cookie) }; diff --git a/test/functional/specs/Audiences/C12412.js b/test/functional/specs/Audiences/C12412.js index 18224f10a..7895402c7 100644 --- a/test/functional/specs/Audiences/C12412.js +++ b/test/functional/specs/Audiences/C12412.js @@ -57,3 +57,18 @@ test(`Verify cookie destinations are returned in the response when turned on in await t.expect(setCookieAttributes[0].sameSite).eql("none"); await t.expect(setCookieAttributes[0].secure).eql(true); }); + +test(`Verify cookie is set on the / path `, async () => { + const alloy = createAlloyProxy(); + + await alloy.configure(compose(orgMainConfigMain, debugEnabled)); + await alloy.sendEvent(); + + const cookies = await t.getCookies("C12412"); + + // In Firefox, the t.getCookies method returns an empty array even if the cookie is present. + // The if condition below is to handle this issue. + if (cookies.length > 0) { + await t.expect(cookies[0].path).eql("/"); + } +});