generated from adobe/aem-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MWPW-156866 [MILO][MEP] Create martech metadata table if placeholders…
… are used in non EN page (#2780) * Initial checkin - Working state. * Optimization. Good State. * Semi-colon fix. * Linting fixes. * Unit test file creation. * Placeholders update/fix. * Fixed US data values. * Unit testing WIP. * fix unit test * unit test working * add before each * fix linter issue of using same name above * update processTrackingLabels * add coverage to attributes.js unit test * Unit test updates. --------- Co-authored-by: vgoodric <[email protected]>
- Loading branch information
1 parent
bc61484
commit 47dea19
Showing
5 changed files
with
193 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
test/features/personalization/createMartechMetadata.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { expect } from '@esm-bundle/chai'; | ||
import { createMartechMetadata } from '../../../libs/features/personalization/personalization.js'; | ||
import placeholders from './mocks/placeholders.js'; | ||
|
||
const config = { | ||
locale: { ietf: 'fr-fr' }, | ||
mep: {}, | ||
}; | ||
|
||
// Note that the manifestPath doesn't matter as we stub the fetch | ||
describe('test martech metadata creation', () => { | ||
beforeEach(() => { | ||
config.mep = {}; | ||
}); | ||
it('test two non US manifests', async () => { | ||
expect(config.mep).to.deep.equal({}); | ||
|
||
await createMartechMetadata(placeholders.geoTest, config, 'fr'); | ||
expect(config.mep.analyticLocalization).to.deep.equal({ | ||
'value1 fr': 'value1 en us', | ||
'value2 fr': 'value2 en us', | ||
'bonjour fr': 'Hello en us', | ||
'buy now fr': 'buy now en us', | ||
'try now fr': 'try now en us', | ||
}); | ||
await createMartechMetadata(placeholders.secondManifestTest, config, 'fr'); | ||
expect(config.mep.analyticLocalization).to.deep.equal({ | ||
'new fr': 'new en us', | ||
'value1 fr': 'value1 en us', | ||
'value2 fr': 'new2 en us', | ||
'bonjour fr': 'Hello en us', | ||
'buy now fr': 'buy now en us', | ||
'try now fr': 'try now en us', | ||
}); | ||
}); | ||
it('test one manifest non US withou en-us keys', async () => { | ||
await createMartechMetadata(placeholders.keyTest, config, 'fr'); | ||
expect(config.mep.analyticLocalization).to.deep.equal({ | ||
'value1 fr': 'test placeholder', | ||
'value2 fr': 'test placeholder2', | ||
'bonjour fr': 'marquee headline', | ||
'buy now fr': 'marquee hollow', | ||
'try now fr': 'marquee solid', | ||
}); | ||
}); | ||
it('test one manifest en-US', async () => { | ||
config.locale.ietf = 'en-US'; | ||
await createMartechMetadata(placeholders.keyTest, config, 'us'); | ||
expect(config.mep).to.deep.equal({}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
const placeholders = { | ||
geoTest: [ | ||
{ | ||
key: 'test-placeholder', | ||
'mobile-device & us': 'US Mobile Value', | ||
us: 'value1-us', | ||
'en-us': 'value1-en-us', | ||
'ca & not fr': 'value1-ca-not-fr', | ||
fr: 'value1-fr', | ||
'mobile-device': 'value1-mobile', | ||
}, | ||
{ | ||
key: 'test-placeholder2', | ||
'mobile-device & us': 'US Mobile Value2', | ||
us: 'value2-us', | ||
'en-us': 'value2-en-us', | ||
'ca & not fr': 'value2-ca-not-fr', | ||
fr: 'value2-fr', | ||
'mobile-device': 'value2-mobile', | ||
}, | ||
{ | ||
key: 'marquee-headline', | ||
'mobile-device & us': 'hello US mobile', | ||
us: 'hello-us', | ||
'en-us': 'Hello-en-us', | ||
'ca & not fr': 'hello-ca-not-fr', | ||
fr: 'bonjour-fr', | ||
'mobile-device': 'hello-mobile', | ||
}, | ||
{ | ||
key: 'marquee-hollow', | ||
'mobile-device & us': 'buy-now-mobile-us', | ||
us: 'buy-now-us', | ||
'en-us': 'buy-now-en-us', | ||
'ca & not fr': 'buy-now-ca-not-fr', | ||
fr: 'buy-now-fr', | ||
'mobile-device': 'buy-now-mobile', | ||
}, | ||
{ | ||
key: 'marquee-solid', | ||
'mobile-device & us': 'try-now-mobile-us', | ||
us: 'try-now-us', | ||
'en-us': 'try-now-en-us', | ||
'ca & not fr': 'try-now-ca-not-fr', | ||
fr: 'try-now-fr', | ||
'mobile-device': 'try-now-mobile', | ||
}, | ||
], | ||
secondManifestTest: [ | ||
{ | ||
key: 'test-placeholder', | ||
'mobile-device & us': 'US Mobile Value', | ||
us: 'value1-us', | ||
'en-us': 'new-en-us', | ||
'ca & not fr': 'value1-ca-not-fr', | ||
fr: 'new-fr', | ||
'mobile-device': 'value1-mobile', | ||
}, | ||
{ | ||
key: 'test-placeholder2', | ||
'mobile-device & us': 'US Mobile Value2', | ||
us: 'value2-us', | ||
'en-us': 'new2-en-us', | ||
'ca & not fr': 'value2-ca-not-fr', | ||
fr: 'value2-fr', | ||
'mobile-device': 'value2-mobile', | ||
}, | ||
], | ||
keyTest: [ | ||
{ | ||
key: 'test-placeholder', | ||
'mobile-device & us': 'US Mobile Value', | ||
fr: 'value1-fr', | ||
'mobile-device': 'value1-mobile', | ||
}, | ||
{ | ||
key: 'test-placeholder2', | ||
'mobile-device & us': 'US Mobile Value2', | ||
fr: 'value2-fr', | ||
'mobile-device': 'value2-mobile', | ||
}, | ||
{ | ||
key: 'marquee-headline', | ||
'mobile-device & us': 'hello US mobile', | ||
fr: 'bonjour-fr', | ||
'mobile-device': 'hello-mobile', | ||
}, | ||
{ | ||
key: 'marquee-hollow', | ||
'mobile-device & us': 'buy-now-mobile-us', | ||
fr: 'buy-now-fr', | ||
'mobile-device': 'buy-now-mobile', | ||
}, | ||
{ | ||
key: 'marquee-solid', | ||
'mobile-device & us': 'try-now-mobile-us', | ||
fr: 'try-now-fr', | ||
'mobile-device': 'try-now-mobile', | ||
}, | ||
], | ||
}; | ||
|
||
export default placeholders; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters