Skip to content

Commit

Permalink
Merge branch 'main' into video-hoverplay
Browse files Browse the repository at this point in the history
  • Loading branch information
sukamat authored Aug 16, 2023
2 parents 04a1496 + e661c8f commit 309aaf3
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 8 deletions.
17 changes: 10 additions & 7 deletions libs/blocks/caas-config/caas-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,11 @@ const TagsPanel = ({ tagsData }) => {
`;
};

const CardsPanel = () => {
const CardsPanel = ({ tagsData }) => {
const context = useContext(ConfiguratorContext);

const allTags = getTagTree(tagsData);

const onChange = (prop) => (values) => {
context.dispatch({
type: 'SELECT_CHANGE',
Expand Down Expand Up @@ -449,6 +451,7 @@ const CardsPanel = () => {
>
<${FormInput} name="contentId" onValidate${isValidUuid} />
<//>
<${DropdownSelect} options=${allTags} prop="hideCtaTags" label="Tags that should hide CTAS" />
`;
};

Expand Down Expand Up @@ -696,9 +699,8 @@ const getInitialState = () => {
try {
state = JSON.parse(lsState);
/* c8 ignore next */
} catch (e) {
// Do nothing
}
// eslint-disable-next-line no-empty
} catch (e) {}
}
}

Expand Down Expand Up @@ -814,7 +816,7 @@ const getPanels = (tagsData) => [
},
{
title: 'Cards',
content: html`<${CardsPanel} />`,
content: html`<${CardsPanel} tagsData=${tagsData} />`,
},
{
title: 'Sort',
Expand Down Expand Up @@ -890,9 +892,9 @@ const Configurator = ({ rootEl }) => {
.then(() => {
setIsCaasLoaded(true);
})
.catch((error) => {
.catch((e) => {
/* c8 ignore next */
console.log('Error loading script: ', error);
console.log('Error loading script: ', e);
});
}, []);

Expand Down Expand Up @@ -961,6 +963,7 @@ const init = async (el) => {
};

export {
// eslint-disable-next-line no-restricted-exports
init as default,
cloneObj,
getHashConfig,
Expand Down
3 changes: 3 additions & 0 deletions libs/blocks/caas/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ export const getConfig = async (originalState, strs = {}) => {
const featuredCards = state.featuredCards && state.featuredCards.reduce(getContentIdStr, '');
const excludedCards = state.excludedCards && state.excludedCards.reduce(getContentIdStr, '');
const hideCtaIds = state.hideCtaIds ? state.hideCtaIds.reduce(getContentIdStr, '') : '';
const hideCtaTags = state.hideCtaTags ? state.hideCtaTags : [];
const targetActivity = state.targetEnabled
&& state.targetActivity ? `/${encodeURIComponent(state.targetActivity)}.json` : '';
const flatFile = targetActivity ? '&flatFile=false' : '';
Expand Down Expand Up @@ -399,6 +400,7 @@ export const getConfig = async (originalState, strs = {}) => {
additionalRequestParams: arrayToObj(state.additionalRequestParams),
},
hideCtaIds: hideCtaIds.split(URL_ENCODED_COMMA),
hideCtaTags,
featuredCards: featuredCards.split(URL_ENCODED_COMMA),
filterPanel: {
enabled: state.showFilters,
Expand Down Expand Up @@ -575,6 +577,7 @@ export const defaultState = {
gutter: '4x',
headers: [],
hideCtaIds: [],
hideCtaTags: [],
includeTags: [],
language: 'caas:language/en',
layoutType: '4up',
Expand Down
13 changes: 12 additions & 1 deletion test/blocks/caas-config/caas-config.test.html
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,17 @@
expect(config).to.eql(expectedConfig);
});


it('Can add tags to use for hiding ctas', async() => {
await tagSelectorModalChoose('Tags that should hide CTAS', [
['Topic', 'Contracts']
]);
const expectedConfig = cloneObj(defaultConfig);
expectedConfig.hideCtaTags = ['caas:topic/contracts'];
expect(config).to.eql(expectedConfig);

})

it('has error if tag URL is wrong', async () => {
const tagUrlInput = findByLabel('Tags Url', configPanelEl);
tagUrlInput.value = 'https://not.the.right.url/tags';
Expand Down Expand Up @@ -274,7 +285,7 @@
copyBtn.click();
await delay(50);
const copyTextArea = document.querySelector('.copy-text');
expect(copyTextArea.value.split('#')[1]).to.equal('eyJhZGRpdGlvbmFsUmVxdWVzdFBhcmFtcyI6W10sImFuYWx5dGljc0NvbGxlY3Rpb25OYW1lIjoiIiwiYW5hbHl0aWNzVHJhY2tJbXByZXNzaW9uIjpmYWxzZSwiYW5kTG9naWNUYWdzIjpbXSwiY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6ZmFsc2UsInNob3dTZWFyY2giOmZhbHNlLCJzaG93VG90YWxSZXN1bHRzIjpmYWxzZSwic29ydERhdGVBc2MiOmZhbHNlLCJzb3J0RGF0ZURlc2MiOmZhbHNlLCJzb3J0RGF0ZU1vZGlmaWVkIjpmYWxzZSwic29ydERlZmF1bHQiOiJkYXRlRGVzYyIsInNvcnRFbmFibGVQb3B1cCI6ZmFsc2UsInNvcnRFbmFibGVSYW5kb21TYW1wbGluZyI6ZmFsc2UsInNvcnRFdmVudFNvcnQiOmZhbHNlLCJzb3J0RmVhdHVyZWQiOmZhbHNlLCJzb3J0TW9kaWZpZWRBc2MiOmZhbHNlLCJzb3J0TW9kaWZpZWREZXNjIjpmYWxzZSwic29ydFJhbmRvbSI6ZmFsc2UsInNvcnRSZXNlcnZvaXJQb29sIjoxMDAwLCJzb3J0UmVzZXJ2b2lyU2FtcGxlIjozLCJzb3J0VGl0bGVBc2MiOmZhbHNlLCJzb3J0VGl0bGVEZXNjIjpmYWxzZSwic291cmNlIjpbImhhd2tzIl0sInRhZ3NVcmwiOiJ3d3cuYWRvYmUuY29tL2NoaW1lcmEtYXBpL3RhZ3MiLCJ0YXJnZXRBY3Rpdml0eSI6IiIsInRhcmdldEVuYWJsZWQiOmZhbHNlLCJ0aGVtZSI6ImxpZ2h0ZXN0IiwiZGV0YWlsc1RleHRPcHRpb24iOiJkZWZhdWx0IiwidGl0bGVIZWFkaW5nTGV2ZWwiOiJoMyIsInRvdGFsQ2FyZHNUb1Nob3ciOjEwLCJ1c2VMaWdodFRleHQiOmZhbHNlLCJ1c2VPdmVybGF5TGlua3MiOmZhbHNlLCJjb2xsZWN0aW9uQnV0dG9uU3R5bGUiOiJwcmltYXJ5IiwidXNlckluZm8iOltdfQ==')
});

it('Clones an object', () => {
Expand Down
1 change: 1 addition & 0 deletions test/blocks/caas-config/expectedConfigs/defaultConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const defaultConfig = {
hideCtaIds: [
'',
],
hideCtaTags: [],
featuredCards: [
'',
],
Expand Down
7 changes: 7 additions & 0 deletions test/blocks/caas/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ describe('arrayToObj', () => {
expect(arrayToObj({})).to.be.eql({});
});
});
describe('additionalQueryParams', () => {
expect(arrayToObj([{ key: 'a', value: 1 }, { key: 'b', value: 2 }])).to.be.eql({ a: 1, b: 2 });
expect(arrayToObj({})).to.be.eql({});
});

describe('loadStrings', () => {
const ogFetch = window.fetch;

Expand Down Expand Up @@ -194,6 +199,7 @@ describe('getConfig', () => {
featuredCards: ['a', 'b'],
headers: [],
hideCtaIds: [''],
hideCtaTags: [],
filterPanel: {
enabled: true,
eventFilter: '',
Expand Down Expand Up @@ -388,6 +394,7 @@ describe('getConfig', () => {
featuredCards: ['a', 'b'],
headers: [],
hideCtaIds: [''],
hideCtaTags: [],
filterPanel: {
enabled: true,
eventFilter: '',
Expand Down

0 comments on commit 309aaf3

Please sign in to comment.