Skip to content

Commit

Permalink
MWPW-147594: Consumers mappings for origin not being sent when using …
Browse files Browse the repository at this point in the history
…sidekick (#2413)

* Actually fixing original bug in sidekick

* Increasing code coverage

* Fixing missing export

---------

Co-authored-by: milo-pr-merge[bot] <169241390+milo-pr-merge[bot]@users.noreply.github.com>
  • Loading branch information
sanrai and milo-pr-merge[bot] authored Jun 11, 2024
1 parent af819cd commit eeca38e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion test/blocks/caas/send-to-caas.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
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, setConfig } from '../../../tools/send-to-caas/send-utils.js';

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

Expand All @@ -18,4 +18,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');
});
});
4 changes: 2 additions & 2 deletions tools/send-to-caas/send-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,15 @@ const processRepoForFloodgate = (repo, fgColor) => {
return repo;
};

const getOrigin = (fgColor) => {
export const getOrigin = (fgColor) => {
const { project, repo } = getConfig();
const origin = project || processRepoForFloodgate(repo, fgColor);

const mappings = {
cc: 'hawks',
dc: 'doccloud',
};
const originLC = (mappings[origin] || origin).toLowerCase();
const originLC = mappings[origin.toLowerCase()] || origin;
if (originLC) {
return originLC;
}
Expand Down

0 comments on commit eeca38e

Please sign in to comment.