<commit_before>import mapValues from 'lodash/mapValues'
import { SidebarContainerLogic } from './logic'
import {
    makeSingleDeviceUILogicTestFactory,
    UILogicTestDevice,
} from 'src/tests/ui-logic-tests'
import * as DATA from './logic.test.data'

function insertBackgroundFunctionTab(remoteFunctions, tab: any) {
    return mapValues(remoteFunctions, (f) => {
        return (...args: any[]) => {
            return f({ tab }, ...args)
        }
    })
}

const setupLogicHelper = async ({
    device,
    pageUrl = DATA.CURRENT_TAB_URL_1,
    initSearchType = 'pages',
}: {
    device: UILogicTestDevice
    pageUrl?: string
    initSearchType?: 'pageAnnots' | 'allAnnots' | 'pages'
}) => {
    const { backgroundModules } = device

    const annotations = {
        // ...insertBackgroundFunctionTab(
        //     backgroundModules.directLinking.remoteFunctions,
        //     currentTab,
        // ),
        editAnnotation: () => undefined,
        createAnnotation: () => undefined,
        addAnnotationTag: () => undefined,
        deleteAnnotation: () => undefined,
        toggleAnnotBookmark: () => undefined,
        updateAnnotationTags: () => undefined,
        getAllAnnotationsByUrl: () => undefined,
    } as any

    const sidebarLogic = new SidebarContainerLogic({
        pageUrl,
        tags: backgroundModules.tags.remoteFunctions,
        customLists: backgroundModules.customLists.remoteFunctions,
        annotations,
        // search: {
        //     ...backgroundModules.search.remoteFunctions.search,
        // },
        // bookmarks: backgroundModules.search.remoteFunctions.bookmarks,
        // inPageUI,
        // highlighter,
        initialState: 'hidden',
        env: 'inpage',
        searchResultLimit: 10,
    })

    let initSearchTypeMutation
    switch (initSearchType) {
        case 'allAnnots':
            initSearchTypeMutation = {
                searchType: { $set: 'notes' },
                pageType: { $set: 'all' },
            }
            break
        case 'pageAnnots':
            initSearchTypeMutation = {
                searchType: { $set: 'notes' },
                pageType: { $set: 'page' },
            }
            break
        case 'pages':
        default:
            initSearchTypeMutation = { searchType: { $set: 'page' } }
    }

    const sidebar = device.createElement(sidebarLogic)
    sidebar.processMutation(initSearchTypeMutation)
    await sidebar.init()<commit_msg>Remove `env` prop passed into test Logic setup<commit_after>import mapValues from 'lodash/mapValues'
import { SidebarContainerLogic } from './logic'
import {
    makeSingleDeviceUILogicTestFactory,
    UILogicTestDevice,
} from 'src/tests/ui-logic-tests'
import * as DATA from './logic.test.data'

function insertBackgroundFunctionTab(remoteFunctions, tab: any) {
    return mapValues(remoteFunctions, (f) => {
        return (...args: any[]) => {
            return f({ tab }, ...args)
        }
    })
}

const setupLogicHelper = async ({
    device,
    pageUrl = DATA.CURRENT_TAB_URL_1,
    initSearchType = 'pages',
}: {
    device: UILogicTestDevice
    pageUrl?: string
    initSearchType?: 'pageAnnots' | 'allAnnots' | 'pages'
}) => {
    const { backgroundModules } = device

    const annotations = {
        // ...insertBackgroundFunctionTab(
        //     backgroundModules.directLinking.remoteFunctions,
        //     currentTab,
        // ),
        editAnnotation: () => undefined,
        createAnnotation: () => undefined,
        addAnnotationTag: () => undefined,
        deleteAnnotation: () => undefined,
        toggleAnnotBookmark: () => undefined,
        updateAnnotationTags: () => undefined,
        getAllAnnotationsByUrl: () => undefined,
    } as any

    const sidebarLogic = new SidebarContainerLogic({
        pageUrl,
        tags: backgroundModules.tags.remoteFunctions,
        customLists: backgroundModules.customLists.remoteFunctions,
        annotations,
        // search: {
        //     ...backgroundModules.search.remoteFunctions.search,
        // },
        // bookmarks: backgroundModules.search.remoteFunctions.bookmarks,
        // inPageUI,
        // highlighter,
        initialState: 'hidden',
        searchResultLimit: 10,
    })

    let initSearchTypeMutation
    switch (initSearchType) {
        case 'allAnnots':
            initSearchTypeMutation = {
                searchType: { $set: 'notes' },
                pageType: { $set: 'all' },
            }
            break
        case 'pageAnnots':
            initSearchTypeMutation = {
                searchType: { $set: 'notes' },
                pageType: { $set: 'page' },
            }
            break
        case 'pages':
        default:
            initSearchTypeMutation = { searchType: { $set: 'page' } }
    }

    const sidebar = device.createElement(sidebarLogic)
    sidebar.processMutation(initSearchTypeMutation)
    await sidebar.init()
{'fraction_non_alphanumeric': 0.1166464155528554, 'fraction_numerical': 0.001215066828675577, 'mean_word_length': 2.1988341968911915, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7388556', 'n_tokens_mistral': 1387, 'n_tokens_neox': 1353, 'n_words': 266}