diff --git a/models/custom-view/src/custom-view/constants.ts b/models/custom-view/src/custom-view/constants.ts new file mode 100644 index 000000000..eb62d14f3 --- /dev/null +++ b/models/custom-view/src/custom-view/constants.ts @@ -0,0 +1,10 @@ +export const defaultLocators = [ + 'products.product_details.general', + 'products.product_variant_details.general', + 'categories.category_details.external_search', + 'customers.customer_addresses.edit_address', + 'orders.order_details.custom_field', + 'standalone_prices.standalone_price_details', + 'discounts.product_discount_details.custom_fields', + 'operations.import_log_details', +]; diff --git a/models/custom-view/src/custom-view/generator.ts b/models/custom-view/src/custom-view/generator.ts index ee0d103e2..f19882b4c 100644 --- a/models/custom-view/src/custom-view/generator.ts +++ b/models/custom-view/src/custom-view/generator.ts @@ -3,8 +3,8 @@ import { fake, Generator } from '@commercetools-test-data/core'; import { createRelatedDates } from '@commercetools-test-data/utils'; import * as CustomViewPermission from '../custom-view-permission'; import * as CustomViewTypeSettingsForCustomPanel from '../custom-view-type-settings-for-custom-panel'; +import { defaultLocators } from './constants'; import { TCustomView } from './types'; -import { defaultLocators } from './utils'; const [getOlderDate, getNewerDate] = createRelatedDates(); @@ -19,7 +19,7 @@ const generator = Generator({ locators: fake((f) => f.helpers.arrayElements(defaultLocators, { min: 1, - max: defaultLocators.length, + max: 4, }) ), permissions: fake(() => [ diff --git a/models/custom-view/src/custom-view/utils.ts b/models/custom-view/src/custom-view/utils.ts deleted file mode 100644 index 193bd4b68..000000000 --- a/models/custom-view/src/custom-view/utils.ts +++ /dev/null @@ -1,35 +0,0 @@ -const upperFirst = (word: string) => word[0].toUpperCase() + word.slice(1); - -export const formatCustomViewIdToResourceAccessKey = ( - entryPointUriPath: string -) => - entryPointUriPath - // Splits the string by underscore. - .split('_') - // Uppercase the first character of each word split. - .map(upperFirst) - // Join the words by an underscore. - .join('_') - // Each word is split by a hyphen. - .split('-') - .map((word, i) => { - // Regex below checking if the character is numeric. - // If the word after the hyphen is numeric, replace the hyphen with a forward slash. - // If not, omit the hyphen and uppercase the first character - if (i > 0 && /^-?\d+$/.test(word[0])) { - return `/${word}`; - } - return upperFirst(word); - }) - .join(''); - -export const defaultLocators = [ - 'products.product_details.general', - 'products.product_variant_details.general', - 'categories.category_details.external_search', - 'customers.customer_addresses.edit_address', - 'orders.order_details.custom_field', - 'standalone_prices.standalone_price_details', - 'discounts.product_discount_details.custom_fields', - 'operations.import_log_details', -];