import { configureStore } from '@reduxjs/toolkit'; import { render } from '@testing-library/react'; import { Provider } from 'react-redux'; import { HashRouter } from 'react-router'; import { apiSlice } from '../features/api/apiSlice'; import discountReducer from '../features/discount/discountSlice'; import interactionReducer from '../features/interaction/interactionSlice'; import campaignReducer from './../features/campaigns/campaignSlice'; export function renderWithProviders( ui, { preloadedState = {}, store = configureStore({ reducer: { [apiSlice.reducerPath]: apiSlice.reducer, discount: discountReducer, interaction: interactionReducer, campaignState: campaignReducer, }, preloadedState, middleware: (getDefaultMiddleware) => getDefaultMiddleware().concat(apiSlice.middleware), }), ...renderOptions } = {} ) { function Wrapper({ children }) { return ( {children} ); } return { store, ...render(ui, { wrapper: Wrapper, ...renderOptions }) }; } export const testCampaigns = [ { id: '408', name: '50% Off', priority: 1, status: '1', discount_intent: 'Product', products: ['all'], conditions: [], discount_rules: [ { id: '83fd0cd4-0783-466a-82ec-9aafbc8581d3', min: '', max: '', get_quantity: '', get_ids: [], discount_type: 'percent', discount_value: '50', discount_label: '', recursive: 'no', }, ], created_by: 1, created_date: '2023-11-01T05:05:26+00:00', modified_by: 1, modified_date: '2023-11-01T05:05:26+00:00', discount_valid_from: '2023-11-01T05:05:00+00:00', discount_valid_to: '2023-11-10T05:05:00+00:00', discount_method: 'automated', discount_coupon: '', discount_max_user: '0', discount_based_on: 'item_quantity', bogo_type: 'all', ui: [0, 0], _links: { self: [ { href: 'http://localhost/quasar/wp-json/disco/v1/campaigns/408', }, ], collection: [ { href: 'http://localhost/quasar/wp-json/disco/v1/campaigns', }, ], }, }, { id: '409', name: 'Winter Sale', priority: 2, status: '1', discount_intent: 'Product', products: ['all'], conditions: [], discount_rules: [ { id: '83fd0cd4-0783-466a-82ec-9aafbc8581d3', min: '', max: '', get_quantity: '', get_ids: [], discount_type: 'fixed', discount_value: '100', discount_label: '', recursive: 'no', }, ], created_by: 1, created_date: '2023-11-01T05:05:56+00:00', modified_by: 1, modified_date: '2023-11-01T05:05:56+00:00', discount_valid_from: '2023-11-01T05:05:00+00:00', discount_valid_to: '2023-11-30T05:05:00+00:00', discount_method: 'automated', discount_coupon: '', discount_max_user: '500', discount_based_on: 'item_quantity', bogo_type: 'all', ui: [0, 0], _links: { self: [ { href: 'http://localhost/quasar/wp-json/disco/v1/campaigns/409', }, ], collection: [ { href: 'http://localhost/quasar/wp-json/disco/v1/campaigns', }, ], }, }, ]; export const filters = { name: 'filters', values: [ { optionGroup: 'Product / Cart Item', options: { id: { title: 'ID', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', quantity: 1, }, }, parent_id: { title: 'Parent Id', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, sku: { title: 'SKU', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, parent_sku: { title: 'Parent SKU', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, title: { title: 'Title', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, parent_title: { title: 'Parent Title', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, description: { title: 'Description', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, short_description: { title: 'Short Description', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, attribute: { title: 'Attributes', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, category: { title: 'Categories', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, tags: { title: 'Tags', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, link: { title: 'URL', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, add_to_cart_link: { title: 'Add to Cart URL', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, availability: { title: 'Availability', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, quantity: { title: 'Quantity', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, weight: { title: 'Weight', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, weight_unit: { title: 'Weight Unit', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, width: { title: 'Width', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, height: { title: 'Height', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, length: { title: 'Length', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, type: { title: 'Product Type', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, visibility: { title: 'Visibility', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, rating_total: { title: 'Total Rating', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, rating_average: { title: 'Average Rating', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, author_name: { title: 'Author Name', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, author_email: { title: 'Author Email', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, date_created: { title: 'Date Created', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, date_updated: { title: 'Date Updated', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, product_status: { title: 'Status', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, featured_status: { title: 'Featured Status', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, }, }, { optionGroup: 'Price', options: { currency: { title: 'Currency', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, regular_price: { title: 'Regular Price', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, price: { title: 'Price', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, sale_price: { title: 'Sale Price', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, regular_price_with_tax: { title: 'Regular Price With Tax', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, price_with_tax: { title: 'Price With Tax', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, sale_price_with_tax: { title: 'Sale Price With Tax', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, sale_price_sdate: { title: 'Sale Start Date', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, sale_price_edate: { title: 'Sale End Date', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, }, }, { optionGroup: 'Cart', options: { line_items_count: { title: 'Cart Items Count', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, cart_items_quantity: { title: 'Cart Items Quantity', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, cart_total_weight: { title: 'Cart Items Total Weight', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, cart_subtotal: { title: 'Cart Subtotal', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, cart_payment_method: { title: 'Payment Method', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, cart_coupons: { title: 'Cart Coupons', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, }, }, { optionGroup: 'Product Purchase History', options: { product_history_last_order_date: { title: 'Last Order Date', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, product_history_total_order_made: { title: 'Number of Order Made with Following Products', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, product_history_total_amount_sold: { title: 'Number of Amount Sold with Following Products', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, product_history_total_quantity_sold: { title: 'Number of Quantities Sold with Following Products', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, }, }, { optionGroup: 'Customer', options: { customer_email: { title: 'Email', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, customer_user: { title: 'User', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, customer_is_logged_in: { title: 'Is Logged In', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, customer_user_role: { title: 'User Role', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, customer_country: { title: 'Country', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, customer_city: { title: 'City', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, customer_state: { title: 'State', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, customer_zip: { title: 'Zip', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, }, }, { optionGroup: 'Customer Purchase History', options: { customer_history_first_order: { title: 'Is First Order', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, customer_history_last_order_date: { title: 'Last Order Date', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, customer_history_last_order_amount: { title: 'Last Order Amount', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, customer_history_total_order_made: { title: 'Number of Order Made By Customer', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, customer_history_total_amount_sold: { title: 'Number of Amount Spent By Customer', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, customer_history_total_quantity_sold: { title: 'Number of Quantities Bought By Customer', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, customer_history_total_order_made_by_ids: { title: 'Number of Order Made with Following Products', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, customer_history_total_amount_sold_by_ids: { title: 'Number of Amount Sold with Following Products', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, customer_history_total_quantity_sold_by_ids: { title: 'Number of Quantities Sold with Following Products', component: 'string', condition: { in_list: 'In List', not_in_list: 'Not In List', contain: 'Contain', not_contain: 'Does Not Contain', equal: 'Equal', not_equal: 'Not Equal', }, compare: 'text', fields: { filter: '', condition: '', compare: '', }, }, }, }, ], };