Skip to content

Commit 002f83b

Browse files
Merge pull request #103 from janaki-r-bhagwath/MWPW-182107
Ignore incomplete/wrong rules in config
2 parents 3006fa6 + 5d69ca7 commit 002f83b

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

nx/blocks/loc/connectors/glaas/locPageRules.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ function buildLanguageUrlSets(assignments) {
113113

114114
assignments.forEach((assignment) => {
115115
const { lang, url, workflow, workflowName } = assignment;
116+
if (!workflow || !workflowName) {
117+
console.warn(`Skipping assignment with empty workflow/workflowName: lang=${lang}, url=${url}, workflow="${workflow}", workflowName="${workflowName}"`);
118+
return;
119+
}
116120
const workflowKey = `${workflow}/${workflowName}`;
117121

118122
if (!languageUrlSets[lang]) {

test/loc/glaas/locPageRules.test.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,5 +425,38 @@ describe('locPageRules', () => {
425425

426426
expect(result).to.deep.equal(expected);
427427
});
428+
429+
it('should handle empty workflowName gracefully (bug fix for hash add4effe)', () => {
430+
// This tests the fix for the bug where empty workflowName created "WCMS/DX/"
431+
// instead of "WCMS/DX/Human Translation", causing hash add4effe
432+
const urls = ['/page1', '/page2'];
433+
434+
const languageObjects = [
435+
{ code: 'de', workflow: 'WCMS/DX', workflowName: 'Human Translation' }, // Valid
436+
{ code: 'fr', workflow: 'WCMS/DX', workflowName: '' }, // Empty workflowName - should be skipped
437+
{ code: 'ja', workflow: 'WCMS/DX', workflowName: undefined }, // Undefined - should be skipped
438+
{ code: 'es', workflow: '', workflowName: 'Human Translation' },
439+
];
440+
441+
const config = {};
442+
443+
const result = groupUrlsByWorkflow(urls, languageObjects, config);
444+
445+
// Only 'de' should be included, 'fr' and 'ja' should be skipped
446+
const expected = {
447+
'WCMS/DX/Human Translation': [
448+
{
449+
languages: ['de'],
450+
urlPaths: ['/page1', '/page2'],
451+
},
452+
],
453+
};
454+
455+
expect(result).to.deep.equal(expected);
456+
457+
// Verify that languages with empty/undefined workflowName are excluded
458+
expect(result['WCMS/DX/Human Translation'][0].languages).to.not.include('fr');
459+
expect(result['WCMS/DX/Human Translation'][0].languages).to.not.include('ja');
460+
});
428461
});
429462
});

0 commit comments

Comments
 (0)