Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MWPW-147594: Consumers mappings for origin not being sent when using sidekick #2413

Merged
merged 4 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 8 additions & 1 deletion test/blocks/caas/send-to-caas.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { readFile } from '@web/test-runner-commands';
import { expect } from '@esm-bundle/chai';

import { checkUrl } from '../../../tools/send-to-caas/send-utils.js';
import { checkUrl, getOrigin } from '../../../tools/send-to-caas/send-utils.js';
sanrai marked this conversation as resolved.
Show resolved Hide resolved
import { setConfig } from '../../../tools/send-to-caas/send-utils.js';
sanrai marked this conversation as resolved.
Show resolved Hide resolved
sanrai marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't this be grouped with the import on top of it?


document.body.innerHTML = await readFile({ path: './mocks/body.html' });

Expand All @@ -18,4 +19,10 @@ describe('checkUrl function', () => {
const result = checkUrl(inputUrl, 'Error message');
expect(result).to.equal(inputUrl);
});

it('should return consumer mapping when set', () => {
setConfig({ project: 'dc' });
const result = getOrigin('someFloodgateColor');
expect(result).to.equal('doccloud');
});
});
5 changes: 3 additions & 2 deletions tools/send-to-caas/send-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,9 @@ const getOrigin = (fgColor) => {
cc: 'hawks',
dc: 'doccloud',
};
if (mappings[origin.toLowerCase()] || origin) {
return mappings[origin.toLowerCase()] || origin;
const originLC = mappings[origin.toLowerCase()] || origin;
if (originLC) {
return originLC;
}

if (window.location.hostname.endsWith('.hlx.page')) {
Expand Down
Loading