Skip to content

Commit 4d05c39

Browse files
committed
Ensure fake-indexeddb isn't included in BG script
1 parent dc133b1 commit 4d05c39

File tree

5 files changed

+22
-26
lines changed

5 files changed

+22
-26
lines changed

src/content-sharing/background/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
import * as data from './index.test.data'
1212
import { BackgroundIntegrationTestSetupOpts } from 'src/tests/background-integration-tests'
1313
import { StorageHooksChangeWatcher } from '@worldbrain/memex-common/lib/storage/hooks'
14-
import { createMemoryServerStorage } from 'src/storage/server'
14+
import { createMemoryServerStorage } from 'src/storage/server.tests'
1515
import { FakeFetch } from 'src/util/tests/fake-fetch'
1616
import { AnnotationPrivacyLevels } from '@worldbrain/memex-common/lib/annotations/types'
1717
import { SharingTestHelper } from './index.tests'

src/discord/event-processor.test-setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import flatten from 'lodash/flatten'
22
import expect from 'expect'
33
import { createDiscordEventProcessor } from '@worldbrain/memex-common/lib/discord/event-processor'
44
import { DiscordChannelManager } from '@worldbrain/memex-common/lib/discord/channel-manager'
5-
import { createMemoryServerStorage } from 'src/storage/server'
5+
import { createMemoryServerStorage } from 'src/storage/server.tests'
66
import type { DiscordMessageCreateInfo } from '@worldbrain/memex-common/lib/discord/types'
77
import { extractListShareUrlParts } from 'src/content-sharing/utils'
88

src/storage/server.tests.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ import { FirestoreStorageBackend } from '@worldbrain/storex-backend-firestore'
44
import { initializeTestEnvironment } from '@firebase/rules-unit-testing'
55
import { documentId, Timestamp, serverTimestamp } from '@firebase/firestore'
66
import type { ServerStorage } from './types'
7-
import {
8-
createMemoryServerStorage,
9-
createStorageManager,
10-
createServerStorage,
11-
} from './server'
7+
import { createStorageManager, createServerStorage } from './server'
8+
import { DexieStorageBackend } from '@worldbrain/storex-backend-dexie'
9+
import inMemory from '@worldbrain/storex-backend-dexie/lib/in-memory'
1210

1311
async function createFirestoreEmulatorStorageBackend(options: {
1412
firebaseProjectId?: string
@@ -81,3 +79,19 @@ export async function createTestServerStorage(options: {
8179
return createMemoryServerStorage(options)
8280
}
8381
}
82+
83+
export function createMemoryServerStorage(options?: {
84+
setupMiddleware?(manager: StorageManager): StorageMiddleware[]
85+
}): Promise<ServerStorage> {
86+
const backend = new DexieStorageBackend({
87+
dbName: 'server',
88+
idbImplementation: inMemory(),
89+
legacyMemexCompatibility: true,
90+
})
91+
const storageManager = createStorageManager(backend, options)
92+
93+
return createServerStorage(storageManager, {
94+
autoPkType: 'number',
95+
skipApplicationLayer: true,
96+
})
97+
}

src/storage/server.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ import { SharedSyncLogStorage } from '@worldbrain/storex-sync/lib/shared-sync-lo
1212
import UserStorage from '@worldbrain/memex-common/lib/user-management/storage'
1313
import { ALLOWED_STORAGE_MODULE_OPERATIONS } from '@worldbrain/memex-common/lib/firebase-backend/app-layer/allowed-operations'
1414
import { createClientApplicationLayer } from '@worldbrain/memex-common/lib/firebase-backend/app-layer/client'
15-
import { DexieStorageBackend } from '@worldbrain/storex-backend-dexie'
16-
import inMemory from '@worldbrain/storex-backend-dexie/lib/in-memory'
1715
import { ContentSharingStorage } from 'src/content-sharing/background/storage'
1816
import type { ServerStorage } from './types'
1917
import ContentConversationStorage from '@worldbrain/memex-common/lib/content-conversations/storage'
@@ -144,22 +142,6 @@ export async function createServerStorage(
144142
return serverStorage
145143
}
146144

147-
export function createMemoryServerStorage(options?: {
148-
setupMiddleware?(manager: StorageManager): StorageMiddleware[]
149-
}): Promise<ServerStorage> {
150-
const backend = new DexieStorageBackend({
151-
dbName: 'server',
152-
idbImplementation: inMemory(),
153-
legacyMemexCompatibility: true,
154-
})
155-
const storageManager = createStorageManager(backend, options)
156-
157-
return createServerStorage(storageManager, {
158-
autoPkType: 'number',
159-
skipApplicationLayer: true,
160-
})
161-
}
162-
163145
export function createStorageManager(
164146
backend: StorageBackend,
165147
options?: {

src/tests/background-integration-tests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { MemorySubscriptionsService } from '@worldbrain/memex-common/lib/subscri
2424
import { FakeAnalytics } from 'src/analytics/mock'
2525
import AnalyticsManager from 'src/analytics/analytics'
2626
import { setStorageMiddleware } from 'src/storage/middleware'
27-
import { createMemoryServerStorage } from 'src/storage/server'
27+
import { createMemoryServerStorage } from 'src/storage/server.tests'
2828
import { ServerStorage } from 'src/storage/types'
2929
import { Browser } from 'webextension-polyfill'
3030
import { createServices } from 'src/services'

0 commit comments

Comments
 (0)