<commit_before>import StorageManager from '@worldbrain/storex'
import normalize from 'src/util/encode-url-for-id'
import * as DATA from './index.test.data'
import { PageUrlsByDay } from './types'
import { setupBackgroundIntegrationTest } from 'src/tests/background-integration-tests'
import { BackgroundModules } from 'src/background-script/setup'

const mockEvent = { addListener: () => undefined }

const countAnnots = res => {
    const results: any = res.docs[0]

    // let count = 0
    // for (const annotation of results.annotations) {
    //     count += Object.keys(results[day]).length
    // }

    return results.annotations.length
}

// TODO: Make this work somehow...
describe('Annotations search', () => {
    async function insertTestData({
        storageManager,
        backgroundModules,
    }: {
        storageManager: StorageManager
        backgroundModules: BackgroundModules
    }) {
        const annotsStorage = backgroundModules.directLinking.annotationStorage
        const customListsBg = backgroundModules.customLists

        for (const annot of [
            DATA.directLink,
            DATA.highlight,
            DATA.annotation,<commit_msg>Ensure `countAnnots` sums annots counts for all days<commit_after>import StorageManager from '@worldbrain/storex'
import normalize from 'src/util/encode-url-for-id'
import * as DATA from './index.test.data'
import { PageUrlsByDay } from './types'
import { setupBackgroundIntegrationTest } from 'src/tests/background-integration-tests'
import { BackgroundModules } from 'src/background-script/setup'

const mockEvent = { addListener: () => undefined }

const countAnnots = res => {
    return res.docs.reduce(
        (count, result) => count + result.annotations.length,
        0,
    )
}

describe('Annotations search', () => {
    async function insertTestData({
        storageManager,
        backgroundModules,
    }: {
        storageManager: StorageManager
        backgroundModules: BackgroundModules
    }) {
        const annotsStorage = backgroundModules.directLinking.annotationStorage
        const customListsBg = backgroundModules.customLists

        for (const annot of [
            DATA.directLink,
            DATA.highlight,
            DATA.annotation,
{'fraction_non_alphanumeric': 0.10159716060337179, 'fraction_numerical': 0.0013309671694764862, 'mean_word_length': 3.0703971119133575, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, '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': '6870119', 'n_tokens_mistral': 610, 'n_tokens_neox': 592, 'n_words': 146}