Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions libs/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1028,11 +1028,6 @@ export async function getLingoRegion({ useGeoLocation = false } = {}) {

if (!regions || !Object.keys(regions).length) return null;

if (useGeoLocation) {
const intlPrefix = sessionStorage.getItem('international') || getCookie('international');
if (intlPrefix) return Object.values(regions).find((r) => r.prefix === `/${intlPrefix}`) ?? null;
}

const country = useGeoLocation
? normCountryCode(await getCountry())
: (await resolveDetectedMarketCountry())?.toLowerCase();
Expand Down
12 changes: 7 additions & 5 deletions test/blocks/susi-light-login/susi-light-login.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe('susi light', () => {
expect(susiElement.authParams.dctx_id).equals('v:2,test-id');
});
});
describe('lingo sign-in locale follows the explicit region pick', () => {
describe('lingo sign-in locale follows the user geo (physical location)', () => {
before(async () => {
const lingoMeta = document.createElement('meta');
lingoMeta.setAttribute('name', 'langfirst');
Expand All @@ -100,9 +100,10 @@ describe('susi light', () => {
},
pathname: '/de/',
};
// Explicit CH-German region pick; a divergent FR market cookie must be
// ignored on the sign-in path (it drives pricing only).
document.cookie = 'international=ch_de; path=/';
// Physically in CH (geo). Neither the `international` cookie (a divergent
// region pick) nor the market `country` cookie (pricing) is consulted here.
sessionStorage.setItem('akamai', 'ch');
document.cookie = 'international=de; path=/';
document.cookie = 'country=fr; path=/';
document.body.innerHTML = susiHtml;
setConfig(config);
Expand All @@ -111,10 +112,11 @@ describe('susi light', () => {
});
after(() => {
document.querySelector('meta[name="langfirst"]')?.remove();
sessionStorage.removeItem('akamai');
document.cookie = 'international=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/';
document.cookie = 'country=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/';
});
it('uses the international pick (de-CH), not the market cookie (fr)', async () => {
it('uses geo (de-CH), ignoring the international and market cookies', async () => {
susiElement = document.querySelector('susi-sentry-light');
expect(susiElement.authParams.locale).equals('de-CH');
});
Expand Down
22 changes: 11 additions & 11 deletions test/utils/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2836,31 +2836,31 @@ describe('Utils', () => {
expect(region.prefix).to.equal('/ch_de');
});

it('with useGeoLocation honors the international cookie (explicit pick) over geo', async () => {
it('with useGeoLocation ignores the international cookie and resolves from geo', async () => {
const lingoMeta = document.createElement('meta');
lingoMeta.setAttribute('name', 'langfirst');
lingoMeta.setAttribute('content', 'on');
document.head.append(lingoMeta);
lingoModule.setConfig(lingoRegionConfig);
// Explicit CH region pick; geo says US (no region) — the pick wins.
// The `international` cookie is no longer consulted; geo (US, no region) wins.
document.cookie = 'international=ch_de; path=/';
sessionStorage.setItem('akamai', 'us');
const region = await lingoModule.getLingoRegion({ useGeoLocation: true });
expect(region).to.not.be.null;
expect(region.prefix).to.equal('/ch_de');
expect(region).to.be.null;
});

it('with useGeoLocation, an explicit base/root pick is not overridden by geo', async () => {
it('with useGeoLocation, geo picks the region even when the international cookie diverges', async () => {
const lingoMeta = document.createElement('meta');
lingoMeta.setAttribute('name', 'langfirst');
lingoMeta.setAttribute('content', 'on');
document.head.append(lingoMeta);
lingoModule.setConfig(lingoRegionConfig);
// User explicitly chose the root (us) — geo CH must NOT pull them to ch_de.
// `international=us` is ignored; geo (CH) resolves to ch_de.
document.cookie = 'international=us; path=/';
sessionStorage.setItem('akamai', 'ch');
const region = await lingoModule.getLingoRegion({ useGeoLocation: true });
expect(region).to.be.null;
expect(region).to.not.be.null;
expect(region.prefix).to.equal('/ch_de');
});

it('by default honors the market cookie over geo (mep/content callers)', async () => {
Expand Down Expand Up @@ -3047,8 +3047,8 @@ describe('Utils', () => {
expect(window.adobeid.redirect_uri).to.equal('https://www.stage.adobe.com/home?acomLocale=ca_fr');
});

// Explicit region pick (international cookie) wins over a divergent geo.
it('uses the international cookie over geo for the Adobe Home redirect_uri', async () => {
// The international cookie is no longer consulted; geo picks the region.
it('ignores the international cookie and uses geo for the Adobe Home redirect_uri', async () => {
const lingoMeta = document.createElement('meta');
lingoMeta.setAttribute('name', 'langfirst');
lingoMeta.setAttribute('content', 'on');
Expand All @@ -3058,12 +3058,12 @@ describe('Utils', () => {
ahomeMeta.setAttribute('content', 'on');
document.head.append(ahomeMeta);
lingoModule.setConfig(imsLingoConfig);
// Explicitly picked CA French; physically in CH — the pick wins over geo.
// international=ca_fr is ignored; geo (CH) resolves to ch_fr.
document.cookie = 'international=ca_fr; path=/';
sessionStorage.setItem('akamai', 'ch');
lingoModule.loadIms().catch(() => {});
await new Promise((resolve) => { setTimeout(resolve, 100); });
expect(window.adobeid.redirect_uri).to.equal('https://www.stage.adobe.com/home?acomLocale=ca_fr');
expect(window.adobeid.redirect_uri).to.equal('https://www.stage.adobe.com/home?acomLocale=ch_fr');
});

it('builds a bare /home redirect_uri (no acomLocale) on the root locale', async () => {
Expand Down
Loading