@blaze-cms/react-page-builder 0.134.0-admin-updates.0 → 0.134.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -9
- package/lib/HOC/withTitle.js +12 -2
- package/lib/HOC/withTitle.js.map +1 -1
- package/lib/components/Banner/AdSlotRender.js +3 -12
- package/lib/components/Banner/AdSlotRender.js.map +1 -1
- package/lib/components/Banner/Banner.js +7 -4
- package/lib/components/Banner/Banner.js.map +1 -1
- package/lib/components/Banner/BannerRender.js +1 -5
- package/lib/components/Banner/BannerRender.js.map +1 -1
- package/lib/components/DataSummary/helpers/build-loop-props-content.js +2 -3
- package/lib/components/DataSummary/helpers/build-loop-props-content.js.map +1 -1
- package/lib/components/DataSummary/helpers/get-link-to-published-content.js +0 -2
- package/lib/components/DataSummary/helpers/get-link-to-published-content.js.map +1 -1
- package/lib-es/HOC/withTitle.js +11 -2
- package/lib-es/HOC/withTitle.js.map +1 -1
- package/lib-es/components/Banner/AdSlotRender.js +3 -12
- package/lib-es/components/Banner/AdSlotRender.js.map +1 -1
- package/lib-es/components/Banner/Banner.js +7 -4
- package/lib-es/components/Banner/Banner.js.map +1 -1
- package/lib-es/components/Banner/BannerRender.js +2 -6
- package/lib-es/components/Banner/BannerRender.js.map +1 -1
- package/lib-es/components/DataSummary/helpers/build-loop-props-content.js +2 -3
- package/lib-es/components/DataSummary/helpers/build-loop-props-content.js.map +1 -1
- package/lib-es/components/DataSummary/helpers/get-link-to-published-content.js +1 -2
- package/lib-es/components/DataSummary/helpers/get-link-to-published-content.js.map +1 -1
- package/package.json +10 -10
- package/src/HOC/withTitle.js +12 -2
- package/src/components/Banner/AdSlotRender.js +5 -9
- package/src/components/Banner/Banner.js +11 -9
- package/src/components/Banner/BannerRender.js +0 -4
- package/src/components/DataSummary/helpers/build-loop-props-content.js +2 -3
- package/src/components/DataSummary/helpers/get-link-to-published-content.js +1 -4
- package/tests/unit/src/HOC/withTitle.test.js +4 -4
- package/tests/unit/src/components/Banner/AdSlotRender.test.js +11 -6
- package/tests/unit/src/components/Banner/BannerRender.test.js +4 -0
- package/tests/unit/src/components/Banner/__snapshots__/AdSlotRender.test.js.snap +25 -45
- package/tests/unit/src/components/Banner/__snapshots__/BannerRender.test.js.snap +3 -8
- package/tests/unit/src/components/Button.test.js +4 -0
- package/tests/unit/src/components/Card/CardContainer.test.js +4 -0
- package/tests/unit/src/components/Carousel/CarouselRender/CarouselRender.test.js +4 -0
- package/tests/unit/src/components/Code/Code.test.js +4 -0
- package/tests/unit/src/components/Code.test.js +4 -0
- package/tests/unit/src/components/DataSummary/DataSummaryTypes/ItemDetailsSummary.test.js +4 -0
- package/tests/unit/src/components/DataSummary/DataSummaryTypes/LargeSummary.test.js +4 -0
- package/tests/unit/src/components/DataSummary/DataSummaryTypes/ListSummary.test.js +4 -0
- package/tests/unit/src/components/DataSummary/DataSummaryTypes/TextSummary.test.js +4 -0
- package/tests/unit/src/components/DataSummary/helpers/build-loop-props-content.test.js +0 -41
- package/tests/unit/src/components/DataSummary/helpers/get-link-to-published-content.test.js +0 -21
- package/tests/unit/src/components/List/components/Cards/CardsRender.test.js +4 -0
- package/tests/unit/src/components/List/components/Cards/CardsRenderWrapper.test.js +4 -0
- package/tests/unit/src/components/SearchFilter/components/Checkbox.test.js +4 -0
- package/tests/unit/src/components/SearchFilter/components/Select.test.js +4 -0
- package/tests/unit/src/components/SearchFilter/components/TextSearch.test.js +4 -0
- package/tests/unit/src/components/SearchFilterSort/SearchFilterSort.test.js +4 -0
- package/tests/unit/src/components/SocialFollow/SocialFollow.test.js +4 -0
- package/tests/unit/src/components/TextBlock/TextBlock.test.js +4 -0
- package/tests/unit/src/components/PlaceholderIcon/__snapshots__/index.test.js.snap +0 -72
- package/tests/unit/src/components/PlaceholderIcon/index.test.js +0 -20
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Banner.js","names":["React","useContext","MainContext","checkIfLoggedIn","PropTypes","flatten","useQuery","useRouter","buildUserQuery","buildPropsData","getSingleEntitySchema","getUser","BannerRender","buildPropsQuery","getClassModifiers","getEntityRenderProps","Banner","_ref","type","otherProps","_objectWithoutProperties","_excluded","router","isPreview","id","userId","asPath","parent","entity","sizeId","propsToDisplay","userPropsToDisplay","userQuery","itemEntity","data","error","loading","variables","userData","userLoading","skip","length","message","modifiers","queryProps","map","propertiesToDisplay","userPropsData","actionKey","action","bannerKey","createElement","_extends","key","propTypes","string","defaultProps"],"sources":["../../../src/components/Banner/Banner.js"],"sourcesContent":["import React, { useContext } from 'react';\nimport { MainContext } from '@blaze-cms/nextjs-components';\nimport { checkIfLoggedIn } from '@blaze-cms/core-auth-ui';\nimport PropTypes from 'prop-types';\nimport flatten from 'lodash.flatten';\nimport { useQuery } from '@apollo/client';\nimport { useRouter } from 'next/router';\nimport { buildUserQuery, buildPropsData } from './helpers';\nimport { getSingleEntitySchema, getUser } from '../../application/query';\nimport BannerRender from './BannerRender';\nimport buildPropsQuery from '../../helpers/build-props-query';\nimport { getClassModifiers } from '../../utils';\nimport getEntityRenderProps from '../../helpers/get-entity-render-props';\n\nconst Banner = ({ type, ...otherProps }) => {\n const router = useRouter();\n const { isPreview } = useContext(MainContext);\n const { id: userId } = checkIfLoggedIn();\n const { asPath } = router;\n const { parent, entity, sizeId, propsToDisplay = [], userPropsToDisplay = [] } = otherProps;\n const userQuery = buildUserQuery(userPropsToDisplay);\n const { itemEntity } = parent;\n const { data, error, loading } = useQuery(getSingleEntitySchema, {\n variables: { id: entity || itemEntity }\n });\n const { data: { getUser: userData } = {}, loading: userLoading } = useQuery(getUser(userQuery), {\n variables: { id: userId },\n skip: !userPropsToDisplay.length || !userId\n });\n\n if (loading || userLoading) return '';\n if (error) return error.message;\n if (!data) return null;\n if (!sizeId) return null;\n\n const modifiers = getClassModifiers('banner', otherProps);\n const queryProps = buildPropsQuery(\n data,\n propsToDisplay.length\n ? flatten(propsToDisplay.map(({ propertiesToDisplay }) => propertiesToDisplay))\n : []\n );\n\n const userPropsData = buildPropsData(userData, userPropsToDisplay);\n const { actionKey, action } = getEntityRenderProps(queryProps, data, isPreview);\n const bannerKey = `${sizeId}${asPath}`;\n\n return (\n <BannerRender\n
|
|
1
|
+
{"version":3,"file":"Banner.js","names":["React","useContext","MainContext","checkIfLoggedIn","PropTypes","flatten","useQuery","useRouter","buildUserQuery","buildPropsData","getSingleEntitySchema","getUser","Wrapper","BannerRender","buildPropsQuery","getClassModifiers","getEntityRenderProps","Banner","_ref","type","otherProps","_objectWithoutProperties","_excluded","router","isPreview","id","userId","asPath","parent","entity","sizeId","propsToDisplay","userPropsToDisplay","userQuery","itemEntity","data","error","loading","variables","userData","userLoading","skip","length","message","modifiers","queryProps","map","propertiesToDisplay","userPropsData","actionKey","action","bannerKey","createElement","className","_extends","key","propTypes","string","defaultProps"],"sources":["../../../src/components/Banner/Banner.js"],"sourcesContent":["import React, { useContext } from 'react';\nimport { MainContext } from '@blaze-cms/nextjs-components';\nimport { checkIfLoggedIn } from '@blaze-cms/core-auth-ui';\nimport PropTypes from 'prop-types';\nimport flatten from 'lodash.flatten';\nimport { useQuery } from '@apollo/client';\nimport { useRouter } from 'next/router';\nimport { buildUserQuery, buildPropsData } from './helpers';\nimport { getSingleEntitySchema, getUser } from '../../application/query';\nimport Wrapper from '../Wrapper';\nimport BannerRender from './BannerRender';\nimport buildPropsQuery from '../../helpers/build-props-query';\nimport { getClassModifiers } from '../../utils';\nimport getEntityRenderProps from '../../helpers/get-entity-render-props';\n\nconst Banner = ({ type, ...otherProps }) => {\n const router = useRouter();\n const { isPreview } = useContext(MainContext);\n const { id: userId } = checkIfLoggedIn();\n const { asPath } = router;\n const { parent, entity, sizeId, propsToDisplay = [], userPropsToDisplay = [] } = otherProps;\n const userQuery = buildUserQuery(userPropsToDisplay);\n const { itemEntity } = parent;\n const { data, error, loading } = useQuery(getSingleEntitySchema, {\n variables: { id: entity || itemEntity }\n });\n const { data: { getUser: userData } = {}, loading: userLoading } = useQuery(getUser(userQuery), {\n variables: { id: userId },\n skip: !userPropsToDisplay.length || !userId\n });\n\n if (loading || userLoading) return '';\n if (error) return error.message;\n if (!data) return null;\n if (!sizeId) return null;\n\n const modifiers = getClassModifiers('banner', otherProps);\n const queryProps = buildPropsQuery(\n data,\n propsToDisplay.length\n ? flatten(propsToDisplay.map(({ propertiesToDisplay }) => propertiesToDisplay))\n : []\n );\n\n const userPropsData = buildPropsData(userData, userPropsToDisplay);\n const { actionKey, action } = getEntityRenderProps(queryProps, data, isPreview);\n const bannerKey = `${sizeId}${asPath}`;\n\n return (\n <Wrapper className={type} modifiers={modifiers}>\n <BannerRender\n key={bannerKey}\n {...otherProps}\n action={action}\n actionKey={actionKey}\n asPath={asPath}\n userPropsData={userPropsData}\n />\n </Wrapper>\n );\n};\n\nBanner.propTypes = {\n type: PropTypes.string\n};\n\nBanner.defaultProps = {\n type: 'banner'\n};\n\nexport default Banner;\n"],"mappings":";;;AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,SAASC,WAAW,QAAQ,8BAA8B;AAC1D,SAASC,eAAe,QAAQ,yBAAyB;AACzD,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,OAAO,MAAM,gBAAgB;AACpC,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,cAAc,EAAEC,cAAc,QAAQ,WAAW;AAC1D,SAASC,qBAAqB,EAAEC,OAAO,QAAQ,yBAAyB;AACxE,OAAOC,OAAO,MAAM,YAAY;AAChC,OAAOC,YAAY,MAAM,gBAAgB;AACzC,OAAOC,eAAe,MAAM,iCAAiC;AAC7D,SAASC,iBAAiB,QAAQ,aAAa;AAC/C,OAAOC,oBAAoB,MAAM,uCAAuC;AAExE,MAAMC,MAAM,GAAGC,IAAA,IAA6B;EAAA,IAA5B;MAAEC;IAAoB,CAAC,GAAAD,IAAA;IAAZE,UAAU,GAAAC,wBAAA,CAAAH,IAAA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AAe,CAChCqB,IAAI,EACJJ,cAAc,CAACW,MAAM,GACjBrC,OAAO,CAAC0B,cAAc,CAACe,GAAG,CAAC,CAAC;IAAEC;EAAoB,CAAC,KAAKA,mBAAmB,CAAC,CAAC,GAC7E,EACN,CAAC;EAED,MAAMC,aAAa,GAAGvC,cAAc,CAAC8B,QAAQ,EAAEP,kBAAkB,CAAC;EAClE,MAAM;IAAEiB,SAAS;IAAEC;EAAO,CAAC,GAAGlC,oBAAoB,CAAC6B,UAAU,EAAEV,IAAI,EAAEX,SAAS,CAAC;EAC/E,MAAM2B,SAAS,GAAI,GAAErB,MAAO,GAAEH,MAAO,EAAC;EAEtC,oBACE3B,KAAA,CAAAoD,aAAA,CAACxC,OAAO;IAACyC,SAAS,EAAElC,IAAK;IAACyB,SAAS,EAAEA;EAAU,gBAC7C5C,KAAA,CAAAoD,aAAA,CAACvC,YAAY,EAAAyC,QAAA;IACXC,GAAG,EAAEJ;EAAU,GACX/B,UAAU;IACd8B,MAAM,EAAEA,MAAO;IACfD,SAAS,EAAEA,SAAU;IACrBtB,MAAM,EAAEA,MAAO;IACfqB,aAAa,EAAEA;EAAc,EAC9B,CACM,CAAC;AAEd,CAAC;AAED/B,MAAM,CAACuC,SAAS,GAAG;EACjBrC,IAAI,EAAEf,SAAS,CAACqD;AAClB,CAAC;AAEDxC,MAAM,CAACyC,YAAY,GAAG;EACpBvC,IAAI,EAAE;AACR,CAAC;AAED,eAAeF,MAAM"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
const _excluded = ["baseAdunit", "adunit", "sizeId", "sizes", "propsToDisplay", "entity", "targetings", "parent", "asPath", "action", "actionKey", "renderCounter", "userPropsData"
|
|
3
|
+
const _excluded = ["baseAdunit", "adunit", "sizeId", "sizes", "propsToDisplay", "entity", "targetings", "parent", "asPath", "action", "actionKey", "renderCounter", "userPropsData"];
|
|
4
4
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
5
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
6
|
import React from 'react';
|
|
@@ -25,8 +25,7 @@ const BannerRender = _ref => {
|
|
|
25
25
|
action,
|
|
26
26
|
actionKey,
|
|
27
27
|
renderCounter,
|
|
28
|
-
userPropsData
|
|
29
|
-
modifiers
|
|
28
|
+
userPropsData
|
|
30
29
|
} = _ref,
|
|
31
30
|
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
32
31
|
const {
|
|
@@ -89,7 +88,6 @@ const BannerRender = _ref => {
|
|
|
89
88
|
sizeId: sizeId,
|
|
90
89
|
parsedAdunit: parsedAdunit,
|
|
91
90
|
parsedSizes: parsedSizes,
|
|
92
|
-
modifiers: modifiers,
|
|
93
91
|
targetingArguments: targetingArguments
|
|
94
92
|
});
|
|
95
93
|
};
|
|
@@ -106,7 +104,6 @@ BannerRender.propTypes = {
|
|
|
106
104
|
targetings: PropTypes.string,
|
|
107
105
|
sizes: PropTypes.string,
|
|
108
106
|
renderCounter: PropTypes.number,
|
|
109
|
-
modifiers: PropTypes.string,
|
|
110
107
|
userPropsData: PropTypes.object
|
|
111
108
|
};
|
|
112
109
|
BannerRender.defaultProps = {
|
|
@@ -118,7 +115,6 @@ BannerRender.defaultProps = {
|
|
|
118
115
|
targetings: '',
|
|
119
116
|
sizes: '',
|
|
120
117
|
renderCounter: null,
|
|
121
|
-
modifiers: '',
|
|
122
118
|
userPropsData: {}
|
|
123
119
|
};
|
|
124
120
|
export default withTitle(BannerRender);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BannerRender.js","names":["React","PropTypes","useQuery","generateSingleItemQuery","getCount","buildBannerSizes","buildContextualTargeting","buildParsedAdunit","buildSizeMapping","setCustomTargetings","BANNER_QUERY_PROPS","COUNT_CONTENT_HIERARCHIES","GET_BANNER","PUBLISHED","withTitle","AdSlotRender","BannerRender","_ref","baseAdunit","adunit","sizeId","sizes","propsToDisplay","entity","targetings","parent","asPath","action","actionKey","renderCounter","userPropsData","
|
|
1
|
+
{"version":3,"file":"BannerRender.js","names":["React","PropTypes","useQuery","generateSingleItemQuery","getCount","buildBannerSizes","buildContextualTargeting","buildParsedAdunit","buildSizeMapping","setCustomTargetings","BANNER_QUERY_PROPS","COUNT_CONTENT_HIERARCHIES","GET_BANNER","PUBLISHED","withTitle","AdSlotRender","BannerRender","_ref","baseAdunit","adunit","sizeId","sizes","propsToDisplay","entity","targetings","parent","asPath","action","actionKey","renderCounter","userPropsData","otherProps","_objectWithoutProperties","_excluded","id","itemId","data","entityRecordData","variables","where","skip","bannerData","parentId","childEntity","_ilike","parsedTargetings","entityData","bannerSizes","sizeMapping","parsedSizes","countContentHierarchies","parsedAdunit","isContextualTargetingSet","length","Object","keys","isContextualTargetingReady","shouldShowBanner","customTargetings","targetingArguments","_objectSpread","createElement","propTypes","object","isRequired","string","array","number","defaultProps"],"sources":["../../../src/components/Banner/BannerRender.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\n\nimport { useQuery } from '@apollo/client';\n\nimport { generateSingleItemQuery, getCount } from '../../application/query';\nimport {\n buildBannerSizes,\n buildContextualTargeting,\n buildParsedAdunit,\n buildSizeMapping,\n setCustomTargetings\n} from './helpers';\nimport {\n BANNER_QUERY_PROPS,\n COUNT_CONTENT_HIERARCHIES,\n GET_BANNER,\n PUBLISHED\n} from '../../constants';\nimport { withTitle } from '../../HOC';\nimport AdSlotRender from './AdSlotRender';\n\nconst BannerRender = ({\n baseAdunit,\n adunit,\n sizeId,\n sizes,\n propsToDisplay,\n entity,\n targetings,\n parent,\n asPath,\n action,\n actionKey,\n renderCounter,\n userPropsData,\n ...otherProps\n}) => {\n const { id } = otherProps;\n const { itemId } = parent;\n\n const { data: entityRecordData = {} } = useQuery(action, {\n variables: { where: { id: id || itemId } },\n skip: id && id !== itemId\n });\n\n const { data: bannerData = {} } = useQuery(\n generateSingleItemQuery(GET_BANNER, BANNER_QUERY_PROPS),\n {\n variables: { id: sizeId },\n skip: !sizeId\n }\n );\n\n const { data = {} } = useQuery(getCount(COUNT_CONTENT_HIERARCHIES), {\n variables: {\n where: {\n parentId: id || itemId,\n childEntity: {\n _ilike: `${PUBLISHED}_%`\n }\n }\n }\n });\n\n const parsedTargetings = buildContextualTargeting(actionKey, entityRecordData, propsToDisplay);\n const { entityData } = bannerData;\n const { sizes: bannerSizes } = entityData || {};\n\n const sizeMapping = buildSizeMapping(sizeId, bannerSizes);\n const parsedSizes = buildBannerSizes(sizeId, bannerSizes, sizes);\n\n const { countContentHierarchies } = data;\n\n const parsedAdunit = buildParsedAdunit(asPath, countContentHierarchies, baseAdunit, adunit);\n const isContextualTargetingSet =\n propsToDisplay.length && parsedTargetings && Object.keys(parsedTargetings).length;\n const isContextualTargetingReady = isContextualTargetingSet || !propsToDisplay.length;\n const shouldShowBanner =\n parsedAdunit && parsedSizes && !!parsedSizes.length && isContextualTargetingReady;\n\n const customTargetings = setCustomTargetings(targetings, renderCounter);\n\n const targetingArguments = { ...parsedTargetings, ...customTargetings, ...userPropsData };\n\n return (\n <AdSlotRender\n shouldShowBanner={!!shouldShowBanner}\n sizeMapping={sizeMapping}\n sizeId={sizeId}\n parsedAdunit={parsedAdunit}\n parsedSizes={parsedSizes}\n targetingArguments={targetingArguments}\n />\n );\n};\n\nBannerRender.propTypes = {\n parent: PropTypes.object.isRequired,\n asPath: PropTypes.string.isRequired,\n action: PropTypes.object.isRequired,\n actionKey: PropTypes.string.isRequired,\n adunit: PropTypes.string,\n baseAdunit: PropTypes.string,\n sizeId: PropTypes.string,\n propsToDisplay: PropTypes.array,\n entity: PropTypes.string,\n targetings: PropTypes.string,\n sizes: PropTypes.string,\n renderCounter: PropTypes.number,\n userPropsData: PropTypes.object\n};\n\nBannerRender.defaultProps = {\n adunit: '',\n baseAdunit: '',\n sizeId: '',\n propsToDisplay: [],\n entity: '',\n targetings: '',\n sizes: '',\n renderCounter: null,\n userPropsData: {}\n};\n\nexport default withTitle(BannerRender);\n"],"mappings":";;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAElC,SAASC,QAAQ,QAAQ,gBAAgB;AAEzC,SAASC,uBAAuB,EAAEC,QAAQ,QAAQ,yBAAyB;AAC3E,SACEC,gBAAgB,EAChBC,wBAAwB,EACxBC,iBAAiB,EACjBC,gBAAgB,EAChBC,mBAAmB,QACd,WAAW;AAClB,SACEC,kBAAkB,EAClBC,yBAAyB,EACzBC,UAAU,EACVC,SAAS,QACJ,iBAAiB;AACxB,SAASC,SAAS,QAAQ,WAAW;AACrC,OAAOC,YAAY,MAAM,gBAAgB;AAEzC,MAAMC,YAAY,GAAGC,IAAA,IAef;EAAA,IAfgB;MACpBC,UAAU;MACVC,MAAM;MACNC,MAAM;MACNC,KAAK;MACLC,cAAc;MACdC,MAAM;MACNC,UAAU;MACVC,MAAM;MACNC,MAAM;MACNC,MAAM;MACNC,SAAS;MACTC,aAAa;MACbC;IAEF,CAAC,GAAAb,IAAA;IADIc,UAAU,GAAAC,wBAAA,CAAAf,IAAA,EAAAgB,SAAA;EAEb,MAAM;IAAEC;EAAG,CAAC,GAAGH,UAAU;EACzB,MAAM;IAAEI;EAAO,CAAC,GAAGV,MAAM;EAEzB,MAAM;IAAEW,IAAI,EAAEC,gBAAgB,GAAG,CAAC;EAAE,CAA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AAEpB,SAAS,CAACgE,MAAM;EACvBpC,aAAa,EAAE5B,SAAS,CAACkE,MAAM;EAC/BrC,aAAa,EAAE7B,SAAS,CAAC8D;AAC3B,CAAC;AAED/C,YAAY,CAACoD,YAAY,GAAG;EAC1BjD,MAAM,EAAE,EAAE;EACVD,UAAU,EAAE,EAAE;EACdE,MAAM,EAAE,EAAE;EACVE,cAAc,EAAE,EAAE;EAClBC,MAAM,EAAE,EAAE;EACVC,UAAU,EAAE,EAAE;EACdH,KAAK,EAAE,EAAE;EACTQ,aAAa,EAAE,IAAI;EACnBC,aAAa,EAAE,CAAC;AAClB,CAAC;AAED,eAAehB,SAAS,CAACE,YAAY,CAAC"}
|
|
@@ -44,11 +44,10 @@ const buildLoopPropsContent = (loopProps = [], propsToDisplay = [], limit = 0, d
|
|
|
44
44
|
} = options;
|
|
45
45
|
return propertiesToDisplay.map(key => {
|
|
46
46
|
const loopValue = loopValues[key];
|
|
47
|
-
const
|
|
48
|
-
const propValue = loopValueItem ? getLoopValue(loopValueItem) : regularValues[key];
|
|
47
|
+
const propValue = loopValue ? getLoopValue(loopValue[i]) : regularValues[key];
|
|
49
48
|
if (!propValue) return null;
|
|
50
49
|
const processedValue = processDataSummaryValue(propValue, options);
|
|
51
|
-
const linkToPublishedContent = getLinkToPublishedContent(key, data
|
|
50
|
+
const linkToPublishedContent = getLinkToPublishedContent(key, data);
|
|
52
51
|
return [upperFirst(label), processedValue, linkToPublishedContent, modifier];
|
|
53
52
|
});
|
|
54
53
|
})).filter(Boolean);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-loop-props-content.js","names":["upperFirst","flatten","getLinkToPublishedContent","getLoopPropsLimit","getPropValue","processDataSummaryValue","getLoopValue","value","keyField","separateValues","propsToDisplay","loopProps","data","regularValues","loopValues","forEach","options","propertiesToDisplay","prop","isArrayValue","Array","isArray","isLoopableProp","includes","buildLoopPropsContent","limit","loopPropsWithContent","loopLimit","i","propsArray","map","label","modifier","key","loopValue","
|
|
1
|
+
{"version":3,"file":"build-loop-props-content.js","names":["upperFirst","flatten","getLinkToPublishedContent","getLoopPropsLimit","getPropValue","processDataSummaryValue","getLoopValue","value","keyField","separateValues","propsToDisplay","loopProps","data","regularValues","loopValues","forEach","options","propertiesToDisplay","prop","isArrayValue","Array","isArray","isLoopableProp","includes","buildLoopPropsContent","limit","loopPropsWithContent","loopLimit","i","propsArray","map","label","modifier","key","loopValue","propValue","processedValue","linkToPublishedContent","filter","Boolean","push"],"sources":["../../../../src/components/DataSummary/helpers/build-loop-props-content.js"],"sourcesContent":["import upperFirst from 'lodash.upperfirst';\nimport flatten from 'lodash.flatten';\nimport getLinkToPublishedContent from './get-link-to-published-content';\nimport getLoopPropsLimit from './get-loop-props-limit';\nimport getPropValue from './get-prop-value';\nimport { processDataSummaryValue } from '../../../helpers';\n\nconst getLoopValue = value => {\n const { keyField } = value;\n return value[keyField];\n};\n\nconst separateValues = (propsToDisplay, loopProps, data) => {\n const regularValues = {};\n const loopValues = {};\n\n propsToDisplay.forEach(options => {\n const { propertiesToDisplay } = options;\n propertiesToDisplay.forEach(prop => {\n const value = getPropValue(prop, data, options);\n const isArrayValue = Array.isArray(value);\n if (!value) return;\n const isLoopableProp = loopProps.includes(prop) && isArrayValue;\n\n if (isLoopableProp) {\n loopValues[prop] = value;\n } else {\n regularValues[prop] = value;\n }\n });\n });\n return [regularValues, loopValues];\n};\n\nconst buildLoopPropsContent = (loopProps = [], propsToDisplay = [], limit = 0, data = {}) => {\n const loopPropsWithContent = [];\n const [regularValues, loopValues] = separateValues(propsToDisplay, loopProps, data);\n\n const loopLimit = getLoopPropsLimit(loopValues, limit);\n\n for (let i = 0; i < loopLimit; i += 1) {\n const propsArray = flatten(\n propsToDisplay.map(options => {\n const { propertiesToDisplay, label, modifier = '' } = options;\n\n return propertiesToDisplay.map(key => {\n const loopValue = loopValues[key];\n const propValue = loopValue ? getLoopValue(loopValue[i]) : regularValues[key];\n if (!propValue) return null;\n\n const processedValue = processDataSummaryValue(propValue, options);\n const linkToPublishedContent = getLinkToPublishedContent(key, data);\n return [upperFirst(label), processedValue, linkToPublishedContent, modifier];\n });\n })\n ).filter(Boolean);\n loopPropsWithContent.push(propsArray);\n }\n\n return flatten(loopPropsWithContent);\n};\n\nexport default buildLoopPropsContent;\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,mBAAmB;AAC1C,OAAOC,OAAO,MAAM,gBAAgB;AACpC,OAAOC,yBAAyB,MAAM,iCAAiC;AACvE,OAAOC,iBAAiB,MAAM,wBAAwB;AACtD,OAAOC,YAAY,MAAM,kBAAkB;AAC3C,SAASC,uBAAuB,QAAQ,kBAAkB;AAE1D,MAAMC,YAAY,GAAGC,KAAK,IAAI;EAC5B,MAAM;IAAEC;EAAS,CAAC,GAAGD,KAAK;EAC1B,OAAOA,KAAK,CAACC,QAAQ,CAAC;AACxB,CAAC;AAED,MAAMC,cAAc,GAAGA,CAACC,cAAc,EAAEC,SAAS,EAAEC,IAAI,KAAK;EAC1D,MAAMC,aAAa,GAAG,CAAC,CAAC;EACxB,MAAMC,UAAU,GAAG,CAAC,CAAC;EAErBJ,cAAc,CAACK,OAAO,CAACC,OAAO,IAAI;IAChC,MAAM;MAAEC;IAAoB,CAAC,GAAGD,OAAO;IACvCC,mBAAmB,CAACF,OAAO,CAACG,IAAI,IAAI;MAClC,MAAMX,KAAK,GAAGH,YAAY,CAACc,IAAI,EAAEN,IAAI,EAAEI,OAAO,CAAC;MAC/C,MAAMG,YAAY,GAAGC,KAAK,CAACC,OAAO,CAACd,KAAK,CAAC;MACzC,IAAI,CAACA,KAAK,EAAE;MACZ,MAAMe,cAAc,GAAGX,SAAS,CAACY,QAAQ,CAACL,IAAI,CAAC,IAAIC,YAAY;MAE/D,IAAIG,cAAc,EAAE;QAClBR,UAAU,CAACI,IAAI,CAAC,GAAGX,KAAK;MAC1B,CAAC,MAAM;QACLM,aAAa,CAACK,IAAI,CAAC,GAAGX,KAAK;MAC7B;IACF,CAAC,CAA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AACM,MAAM,CAACC,OAAO,CAAC;IACjBb,oBAAoB,CAACc,IAAI,CAACX,UAAU,CAAC;EACvC;EAEA,OAAO5B,OAAO,CAACyB,oBAAoB,CAAC;AACtC,CAAC;AAED,eAAeF,qBAAqB"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
const getLinkToPublishedContent = (key = '', props = {}
|
|
1
|
+
const getLinkToPublishedContent = (key = '', props = {}) => {
|
|
2
2
|
const [baseKey] = key.split('.');
|
|
3
3
|
if (!props[baseKey]) return '';
|
|
4
|
-
if (currentValue && typeof currentValue.url !== 'undefined') return currentValue.url;
|
|
5
4
|
const content = Array.isArray(props[baseKey]) ? props[baseKey][0] : props[baseKey];
|
|
6
5
|
return content && content.url ? content.url : '';
|
|
7
6
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-link-to-published-content.js","names":["getLinkToPublishedContent","key","props","
|
|
1
|
+
{"version":3,"file":"get-link-to-published-content.js","names":["getLinkToPublishedContent","key","props","baseKey","split","content","Array","isArray","url"],"sources":["../../../../src/components/DataSummary/helpers/get-link-to-published-content.js"],"sourcesContent":["const getLinkToPublishedContent = (key = '', props = {}) => {\n const [baseKey] = key.split('.');\n if (!props[baseKey]) return '';\n const content = Array.isArray(props[baseKey]) ? props[baseKey][0] : props[baseKey];\n return content && content.url ? content.url : '';\n};\n\nexport default getLinkToPublishedContent;\n"],"mappings":"AAAA,MAAMA,yBAAyB,GAAGA,CAACC,GAAG,GAAG,EAAE,EAAEC,KAAK,GAAG,CAAC,CAAC,KAAK;EAC1D,MAAM,CAACC,OAAO,CAAC,GAAGF,GAAG,CAACG,KAAK,CAAC,GAAG,CAAC;EAChC,IAAI,CAACF,KAAK,CAACC,OAAO,CAAC,EAAE,OAAO,EAAE;EAC9B,MAAME,OAAO,GAAGC,KAAK,CAACC,OAAO,CAACL,KAAK,CAACC,OAAO,CAAC,CAAC,GAAGD,KAAK,CAACC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAGD,KAAK,CAACC,OAAO,CAAC;EAClF,OAAOE,OAAO,IAAIA,OAAO,CAACG,GAAG,GAAGH,OAAO,CAACG,GAAG,GAAG,EAAE;AAClD,CAAC;AAED,eAAeR,yBAAyB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blaze-cms/react-page-builder",
|
|
3
|
-
"version": "0.134.0-
|
|
3
|
+
"version": "0.134.0-alpha.0",
|
|
4
4
|
"description": "Blaze react page builder",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-es/index.js",
|
|
@@ -27,15 +27,15 @@
|
|
|
27
27
|
},
|
|
28
28
|
"license": "GPL-3.0",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@blaze-cms/core-auth-ui": "0.
|
|
31
|
-
"@blaze-cms/core-errors": "0.
|
|
32
|
-
"@blaze-cms/core-errors-ui": "0.
|
|
30
|
+
"@blaze-cms/core-auth-ui": "^0.131.0",
|
|
31
|
+
"@blaze-cms/core-errors": "^0.131.0",
|
|
32
|
+
"@blaze-cms/core-errors-ui": "^0.131.0",
|
|
33
33
|
"@blaze-cms/image-cdn-react": "0.3.0-alpha.6",
|
|
34
|
-
"@blaze-cms/nextjs-components": "0.134.0-
|
|
35
|
-
"@blaze-cms/plugin-search-ui": "0.134.0-
|
|
36
|
-
"@blaze-cms/setup-ui": "0.
|
|
37
|
-
"@blaze-cms/utils": "0.
|
|
38
|
-
"@blaze-cms/utils-handlebars": "0.134.0-
|
|
34
|
+
"@blaze-cms/nextjs-components": "0.134.0-alpha.0",
|
|
35
|
+
"@blaze-cms/plugin-search-ui": "0.134.0-alpha.0",
|
|
36
|
+
"@blaze-cms/setup-ui": "^0.131.0",
|
|
37
|
+
"@blaze-cms/utils": "^0.131.0",
|
|
38
|
+
"@blaze-cms/utils-handlebars": "0.134.0-alpha.0",
|
|
39
39
|
"@blaze-react/breadcrumb": "0.8.0-alpha.60",
|
|
40
40
|
"@blaze-react/button": "0.5.19",
|
|
41
41
|
"@blaze-react/checkboxes": "0.5.31",
|
|
@@ -89,5 +89,5 @@
|
|
|
89
89
|
"lib/*",
|
|
90
90
|
"lib-es/*"
|
|
91
91
|
],
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "12915c7990880884e5ddfb2cd910a4080ce6a3d6"
|
|
93
93
|
}
|
package/src/HOC/withTitle.js
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
import React, { Fragment } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
+
import { useStringTemplate } from '@blaze-cms/utils-handlebars';
|
|
3
4
|
|
|
4
5
|
const withTitle = Component => {
|
|
5
6
|
const InnerComponent = props => {
|
|
6
|
-
const { elementTitle, isHeroImg } = props;
|
|
7
|
+
const { elementTitle, isHeroImg, parent } = props;
|
|
8
|
+
|
|
7
9
|
const shouldDisplayTitle = elementTitle && !isHeroImg;
|
|
10
|
+
const {
|
|
11
|
+
loading,
|
|
12
|
+
data: [elementTitleToUse]
|
|
13
|
+
} = useStringTemplate(parent, [elementTitle]);
|
|
14
|
+
|
|
15
|
+
if (loading) return '';
|
|
8
16
|
|
|
9
17
|
return (
|
|
10
18
|
<Fragment>
|
|
11
|
-
{shouldDisplayTitle && <h2 className="heading heading--section">{
|
|
19
|
+
{shouldDisplayTitle && <h2 className="heading heading--section">{elementTitleToUse}</h2>}
|
|
12
20
|
<Component {...props} />
|
|
13
21
|
</Fragment>
|
|
14
22
|
);
|
|
@@ -21,10 +29,12 @@ const withTitle = Component => {
|
|
|
21
29
|
'Component'})`;
|
|
22
30
|
|
|
23
31
|
InnerComponent.propTypes = {
|
|
32
|
+
parent: PropTypes.object,
|
|
24
33
|
elementTitle: PropTypes.string,
|
|
25
34
|
isHeroImg: PropTypes.bool
|
|
26
35
|
};
|
|
27
36
|
InnerComponent.defaultProps = {
|
|
37
|
+
parent: {},
|
|
28
38
|
elementTitle: '',
|
|
29
39
|
isHeroImg: false
|
|
30
40
|
};
|
|
@@ -2,7 +2,6 @@ import React, { useState } from 'react';
|
|
|
2
2
|
import { AdSlot } from 'react-dfp';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { BANNER_LOADING, BANNER_EMPTY, BANNER_LOADED } from '../../constants';
|
|
5
|
-
import Wrapper from '../Wrapper';
|
|
6
5
|
|
|
7
6
|
const AdSlotRender = ({
|
|
8
7
|
shouldShowBanner,
|
|
@@ -10,7 +9,6 @@ const AdSlotRender = ({
|
|
|
10
9
|
sizeId,
|
|
11
10
|
parsedAdunit,
|
|
12
11
|
parsedSizes,
|
|
13
|
-
modifiers,
|
|
14
12
|
targetingArguments
|
|
15
13
|
}) => {
|
|
16
14
|
const [{ loadingStatus = BANNER_LOADING, minHeight }, setLoadingStatus] = useState({});
|
|
@@ -26,11 +24,11 @@ const AdSlotRender = ({
|
|
|
26
24
|
})
|
|
27
25
|
.sort();
|
|
28
26
|
const className = `ad-slot ad-slot-${loadingStatus} ${bannerClass}`;
|
|
29
|
-
|
|
27
|
+
|
|
30
28
|
return (
|
|
31
|
-
|
|
29
|
+
<>
|
|
32
30
|
{styles && <style>{styles.join('\n')}</style>}
|
|
33
|
-
<div className={className} style={{ minHeight }}
|
|
31
|
+
<div className={className} style={{ minHeight }}>
|
|
34
32
|
{shouldShowBanner && (
|
|
35
33
|
<AdSlot
|
|
36
34
|
adUnit={parsedAdunit}
|
|
@@ -48,7 +46,7 @@ const AdSlotRender = ({
|
|
|
48
46
|
/>
|
|
49
47
|
)}
|
|
50
48
|
</div>
|
|
51
|
-
|
|
49
|
+
</>
|
|
52
50
|
);
|
|
53
51
|
};
|
|
54
52
|
|
|
@@ -58,13 +56,11 @@ AdSlotRender.propTypes = {
|
|
|
58
56
|
sizeId: PropTypes.string.isRequired,
|
|
59
57
|
parsedAdunit: PropTypes.string.isRequired,
|
|
60
58
|
parsedSizes: PropTypes.array,
|
|
61
|
-
modifiers: PropTypes.string,
|
|
62
59
|
targetingArguments: PropTypes.object.isRequired
|
|
63
60
|
};
|
|
64
61
|
|
|
65
62
|
AdSlotRender.defaultProps = {
|
|
66
|
-
parsedSizes: null
|
|
67
|
-
modifiers: ''
|
|
63
|
+
parsedSizes: null
|
|
68
64
|
};
|
|
69
65
|
|
|
70
66
|
export default AdSlotRender;
|
|
@@ -7,6 +7,7 @@ import { useQuery } from '@apollo/client';
|
|
|
7
7
|
import { useRouter } from 'next/router';
|
|
8
8
|
import { buildUserQuery, buildPropsData } from './helpers';
|
|
9
9
|
import { getSingleEntitySchema, getUser } from '../../application/query';
|
|
10
|
+
import Wrapper from '../Wrapper';
|
|
10
11
|
import BannerRender from './BannerRender';
|
|
11
12
|
import buildPropsQuery from '../../helpers/build-props-query';
|
|
12
13
|
import { getClassModifiers } from '../../utils';
|
|
@@ -46,15 +47,16 @@ const Banner = ({ type, ...otherProps }) => {
|
|
|
46
47
|
const bannerKey = `${sizeId}${asPath}`;
|
|
47
48
|
|
|
48
49
|
return (
|
|
49
|
-
<
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
50
|
+
<Wrapper className={type} modifiers={modifiers}>
|
|
51
|
+
<BannerRender
|
|
52
|
+
key={bannerKey}
|
|
53
|
+
{...otherProps}
|
|
54
|
+
action={action}
|
|
55
|
+
actionKey={actionKey}
|
|
56
|
+
asPath={asPath}
|
|
57
|
+
userPropsData={userPropsData}
|
|
58
|
+
/>
|
|
59
|
+
</Wrapper>
|
|
58
60
|
);
|
|
59
61
|
};
|
|
60
62
|
|
|
@@ -34,7 +34,6 @@ const BannerRender = ({
|
|
|
34
34
|
actionKey,
|
|
35
35
|
renderCounter,
|
|
36
36
|
userPropsData,
|
|
37
|
-
modifiers,
|
|
38
37
|
...otherProps
|
|
39
38
|
}) => {
|
|
40
39
|
const { id } = otherProps;
|
|
@@ -91,7 +90,6 @@ const BannerRender = ({
|
|
|
91
90
|
sizeId={sizeId}
|
|
92
91
|
parsedAdunit={parsedAdunit}
|
|
93
92
|
parsedSizes={parsedSizes}
|
|
94
|
-
modifiers={modifiers}
|
|
95
93
|
targetingArguments={targetingArguments}
|
|
96
94
|
/>
|
|
97
95
|
);
|
|
@@ -110,7 +108,6 @@ BannerRender.propTypes = {
|
|
|
110
108
|
targetings: PropTypes.string,
|
|
111
109
|
sizes: PropTypes.string,
|
|
112
110
|
renderCounter: PropTypes.number,
|
|
113
|
-
modifiers: PropTypes.string,
|
|
114
111
|
userPropsData: PropTypes.object
|
|
115
112
|
};
|
|
116
113
|
|
|
@@ -123,7 +120,6 @@ BannerRender.defaultProps = {
|
|
|
123
120
|
targetings: '',
|
|
124
121
|
sizes: '',
|
|
125
122
|
renderCounter: null,
|
|
126
|
-
modifiers: '',
|
|
127
123
|
userPropsData: {}
|
|
128
124
|
};
|
|
129
125
|
|
|
@@ -45,12 +45,11 @@ const buildLoopPropsContent = (loopProps = [], propsToDisplay = [], limit = 0, d
|
|
|
45
45
|
|
|
46
46
|
return propertiesToDisplay.map(key => {
|
|
47
47
|
const loopValue = loopValues[key];
|
|
48
|
-
const
|
|
49
|
-
const propValue = loopValueItem ? getLoopValue(loopValueItem) : regularValues[key];
|
|
48
|
+
const propValue = loopValue ? getLoopValue(loopValue[i]) : regularValues[key];
|
|
50
49
|
if (!propValue) return null;
|
|
51
50
|
|
|
52
51
|
const processedValue = processDataSummaryValue(propValue, options);
|
|
53
|
-
const linkToPublishedContent = getLinkToPublishedContent(key, data
|
|
52
|
+
const linkToPublishedContent = getLinkToPublishedContent(key, data);
|
|
54
53
|
return [upperFirst(label), processedValue, linkToPublishedContent, modifier];
|
|
55
54
|
});
|
|
56
55
|
})
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
const getLinkToPublishedContent = (key = '', props = {}
|
|
1
|
+
const getLinkToPublishedContent = (key = '', props = {}) => {
|
|
2
2
|
const [baseKey] = key.split('.');
|
|
3
3
|
if (!props[baseKey]) return '';
|
|
4
|
-
|
|
5
|
-
if (currentValue && typeof currentValue.url !== 'undefined') return currentValue.url;
|
|
6
|
-
|
|
7
4
|
const content = Array.isArray(props[baseKey]) ? props[baseKey][0] : props[baseKey];
|
|
8
5
|
return content && content.url ? content.url : '';
|
|
9
6
|
};
|
|
@@ -6,13 +6,13 @@ import '@testing-library/jest-dom/extend-expect';
|
|
|
6
6
|
import { shallow } from 'enzyme';
|
|
7
7
|
import { withTitle } from '../../../../src/HOC';
|
|
8
8
|
|
|
9
|
+
jest.mock('@blaze-cms/utils-handlebars', () => ({
|
|
10
|
+
useStringTemplate: jest.fn((parent, [title]) => ({ loadig: false, data: [title] }))
|
|
11
|
+
}));
|
|
12
|
+
|
|
9
13
|
const MockComponent = () => <div>MockedComponent</div>;
|
|
10
14
|
|
|
11
15
|
describe('withTitle HOC', () => {
|
|
12
|
-
it('should be a function', () => {
|
|
13
|
-
expect(typeof withTitle).toEqual('function');
|
|
14
|
-
});
|
|
15
|
-
|
|
16
16
|
it('should return h2 based on elementTitle prop', () => {
|
|
17
17
|
const WrappedComponent = withTitle(MockComponent);
|
|
18
18
|
const shallowWrapper = shallow(<WrappedComponent />);
|
|
@@ -50,17 +50,17 @@ describe('Banner render component', () => {
|
|
|
50
50
|
<AdSlotRender {...defaultProps} shouldShowBanner={false} />
|
|
51
51
|
);
|
|
52
52
|
|
|
53
|
-
expect(container.childNodes[0].nodeName).toEqual('
|
|
54
|
-
expect(
|
|
53
|
+
expect(container.childNodes[0].nodeName).toEqual('STYLE');
|
|
54
|
+
expect(container.childNodes[1]).toHaveClass('ad-slot ad-slot-loading banner-sizeId');
|
|
55
55
|
expect(() => getByTestId(slotTestId)).toThrow();
|
|
56
56
|
expect(asFragment()).toMatchSnapshot();
|
|
57
57
|
});
|
|
58
58
|
|
|
59
59
|
describe('AdSlot loading', () => {
|
|
60
60
|
it('should render AdSlot', () => {
|
|
61
|
-
const { asFragment, getByTestId } = render(<AdSlotRender {...defaultProps} />);
|
|
61
|
+
const { asFragment, container, getByTestId } = render(<AdSlotRender {...defaultProps} />);
|
|
62
62
|
expect(getByTestId('adslot-test')).toBeDefined();
|
|
63
|
-
expect(
|
|
63
|
+
expect(container.childNodes[1]).toHaveClass('ad-slot ad-slot-loading banner-sizeId');
|
|
64
64
|
expect(asFragment()).toMatchSnapshot();
|
|
65
65
|
});
|
|
66
66
|
|
|
@@ -69,11 +69,16 @@ describe('Banner render component', () => {
|
|
|
69
69
|
const adSlot = getByTestId(slotTestId);
|
|
70
70
|
|
|
71
71
|
fireEvent.mouseOver(adSlot);
|
|
72
|
-
await waitFor(() =>
|
|
72
|
+
await waitFor(() =>
|
|
73
|
+
expect(container.childNodes[0]).toHaveClass('ad-slot ad-slot-loaded banner-sizeId')
|
|
74
|
+
);
|
|
75
|
+
expect(container.childNodes[0]).toHaveStyle('min-height: 250px');
|
|
73
76
|
expect(asFragment()).toMatchSnapshot();
|
|
74
77
|
|
|
75
78
|
fireEvent.mouseLeave(adSlot);
|
|
76
|
-
await waitFor(() =>
|
|
79
|
+
await waitFor(() =>
|
|
80
|
+
expect(container.childNodes[0]).toHaveClass('ad-slot ad-slot-empty banner-sizeId')
|
|
81
|
+
);
|
|
77
82
|
expect(asFragment()).toMatchSnapshot();
|
|
78
83
|
});
|
|
79
84
|
});
|
|
@@ -14,6 +14,10 @@ import {
|
|
|
14
14
|
PUBLISHED
|
|
15
15
|
} from '../../../../../src/constants';
|
|
16
16
|
|
|
17
|
+
jest.mock('@blaze-cms/utils-handlebars', () => ({
|
|
18
|
+
useStringTemplate: jest.fn((parent, [title]) => ({ loadig: false, data: [title] }))
|
|
19
|
+
}));
|
|
20
|
+
|
|
17
21
|
const actionKey = 'getPublishedPage';
|
|
18
22
|
const id = 'record id';
|
|
19
23
|
const action = getAction(actionKey, 'id, name');
|
|
@@ -3,18 +3,13 @@
|
|
|
3
3
|
exports[`Banner render component AdSlot loading should change class and remove responsive styles after loaded events 1`] = `
|
|
4
4
|
<DocumentFragment>
|
|
5
5
|
<div
|
|
6
|
-
class="banner
|
|
6
|
+
class="ad-slot ad-slot-loaded banner-sizeId"
|
|
7
|
+
style="min-height: 250px;"
|
|
7
8
|
>
|
|
8
9
|
<div
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
>
|
|
13
|
-
<div
|
|
14
|
-
data-testid="adslot-test"
|
|
15
|
-
role="button"
|
|
16
|
-
/>
|
|
17
|
-
</div>
|
|
10
|
+
data-testid="adslot-test"
|
|
11
|
+
role="button"
|
|
12
|
+
/>
|
|
18
13
|
</div>
|
|
19
14
|
</DocumentFragment>
|
|
20
15
|
`;
|
|
@@ -22,59 +17,44 @@ exports[`Banner render component AdSlot loading should change class and remove r
|
|
|
22
17
|
exports[`Banner render component AdSlot loading should change class and remove responsive styles after loaded events 2`] = `
|
|
23
18
|
<DocumentFragment>
|
|
24
19
|
<div
|
|
25
|
-
class="banner
|
|
20
|
+
class="ad-slot ad-slot-empty banner-sizeId"
|
|
21
|
+
style=""
|
|
26
22
|
>
|
|
27
23
|
<div
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
>
|
|
32
|
-
<div
|
|
33
|
-
data-testid="adslot-test"
|
|
34
|
-
role="button"
|
|
35
|
-
/>
|
|
36
|
-
</div>
|
|
24
|
+
data-testid="adslot-test"
|
|
25
|
+
role="button"
|
|
26
|
+
/>
|
|
37
27
|
</div>
|
|
38
28
|
</DocumentFragment>
|
|
39
29
|
`;
|
|
40
30
|
|
|
41
31
|
exports[`Banner render component AdSlot loading should render AdSlot 1`] = `
|
|
42
32
|
<DocumentFragment>
|
|
43
|
-
<
|
|
44
|
-
|
|
45
|
-
>
|
|
46
|
-
<style>
|
|
47
|
-
@media(min-width:320px){.banner-sizeId{min-height:100px;}
|
|
33
|
+
<style>
|
|
34
|
+
@media(min-width:320px){.banner-sizeId{min-height:100px;}
|
|
48
35
|
@media(min-width:728px){.banner-sizeId{min-height:100px;}
|
|
49
36
|
@media(min-width:970px){.banner-sizeId{min-height:250px;}
|
|
50
|
-
|
|
37
|
+
</style>
|
|
38
|
+
<div
|
|
39
|
+
class="ad-slot ad-slot-loading banner-sizeId"
|
|
40
|
+
>
|
|
51
41
|
<div
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
<div
|
|
56
|
-
data-testid="adslot-test"
|
|
57
|
-
role="button"
|
|
58
|
-
/>
|
|
59
|
-
</div>
|
|
42
|
+
data-testid="adslot-test"
|
|
43
|
+
role="button"
|
|
44
|
+
/>
|
|
60
45
|
</div>
|
|
61
46
|
</DocumentFragment>
|
|
62
47
|
`;
|
|
63
48
|
|
|
64
49
|
exports[`Banner render component should not render AdSlot if shouldShowBanner=false but should render styles and wrapper 1`] = `
|
|
65
50
|
<DocumentFragment>
|
|
66
|
-
<
|
|
67
|
-
|
|
68
|
-
>
|
|
69
|
-
<style>
|
|
70
|
-
@media(min-width:320px){.banner-sizeId{min-height:100px;}
|
|
51
|
+
<style>
|
|
52
|
+
@media(min-width:320px){.banner-sizeId{min-height:100px;}
|
|
71
53
|
@media(min-width:728px){.banner-sizeId{min-height:100px;}
|
|
72
54
|
@media(min-width:970px){.banner-sizeId{min-height:250px;}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
/>
|
|
78
|
-
</div>
|
|
55
|
+
</style>
|
|
56
|
+
<div
|
|
57
|
+
class="ad-slot ad-slot-loading banner-sizeId"
|
|
58
|
+
/>
|
|
79
59
|
</DocumentFragment>
|
|
80
60
|
`;
|
|
@@ -2,14 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`Banner render component should render 1`] = `
|
|
4
4
|
<DocumentFragment>
|
|
5
|
+
<style />
|
|
5
6
|
<div
|
|
6
|
-
class="banner
|
|
7
|
-
|
|
8
|
-
<style />
|
|
9
|
-
<div
|
|
10
|
-
class="ad-slot ad-slot-loading banner-sizeId"
|
|
11
|
-
data-testid="ad-slot"
|
|
12
|
-
/>
|
|
13
|
-
</div>
|
|
7
|
+
class="ad-slot ad-slot-loading banner-sizeId"
|
|
8
|
+
/>
|
|
14
9
|
</DocumentFragment>
|
|
15
10
|
`;
|
|
@@ -6,6 +6,10 @@ import { act, render, fireEvent, waitFor } from '@testing-library/react';
|
|
|
6
6
|
import '@testing-library/jest-dom/extend-expect';
|
|
7
7
|
import Button from '../../../../src/components/Button';
|
|
8
8
|
|
|
9
|
+
jest.mock('@blaze-cms/utils-handlebars', () => ({
|
|
10
|
+
useStringTemplate: jest.fn((parent, [title]) => ({ loadig: false, data: [title] }))
|
|
11
|
+
}));
|
|
12
|
+
|
|
9
13
|
jest.mock('@apollo/client', () => ({
|
|
10
14
|
...jest.requireActual('@apollo/client'),
|
|
11
15
|
useApolloClient: jest.fn(() => ({ resetStore: () => null }))
|
|
@@ -8,6 +8,10 @@ import '@testing-library/jest-dom/extend-expect';
|
|
|
8
8
|
import CardsContainer from '../../../../../src/components/Card/CardsContainer';
|
|
9
9
|
import { cardDataMockedOptions } from './mockData';
|
|
10
10
|
|
|
11
|
+
jest.mock('@blaze-cms/utils-handlebars', () => ({
|
|
12
|
+
useStringTemplate: jest.fn((parent, [title]) => ({ loadig: false, data: [title] }))
|
|
13
|
+
}));
|
|
14
|
+
|
|
11
15
|
// eslint-disable-next-line react/prop-types
|
|
12
16
|
jest.mock('../../../../../src/components/LazyImage', () => () => null);
|
|
13
17
|
|