diff --git a/integration/firestore/firebase_export.ts b/integration/firestore/firebase_export.ts index f651bdaf839..31371b34552 100644 --- a/integration/firestore/firebase_export.ts +++ b/integration/firestore/firebase_export.ts @@ -15,10 +15,12 @@ * limitations under the License. */ -import firebase from '@firebase/app-compat'; -import '@firebase/firestore-compat'; -import { FirebaseApp } from '@firebase/app-types'; -import { Settings, FirebaseFirestore } from '@firebase/firestore-types'; +import { FirebaseApp, initializeApp } from '@firebase/app'; +import { + Firestore, + FirestoreSettings, + initializeFirestore +} from '@firebase/firestore'; // This file replaces "packages/firestore/test/integration/util/firebase_export" // and depends on the minified sources. @@ -28,43 +30,18 @@ let appCount = 0; export function newTestFirestore( projectId: string, nameOrApp?: string | FirebaseApp, - settings?: Settings -): FirebaseFirestore { + settings?: FirestoreSettings +): Firestore { if (nameOrApp === undefined) { nameOrApp = 'test-app-' + appCount++; } const app = typeof nameOrApp === 'string' - ? firebase.initializeApp({ apiKey: 'fake-api-key', projectId }, nameOrApp) + ? initializeApp({ apiKey: 'fake-api-key', projectId }, nameOrApp) : nameOrApp; - - const firestore = firebase.firestore(app); - if (settings) { - firestore.settings(settings); - } - return firestore; + return initializeFirestore(app, settings || {}); } -export function usesFunctionalApi(): false { - return false; -} - -const Blob = firebase.firestore.Blob; -const DocumentReference = firebase.firestore.DocumentReference; -const FieldPath = firebase.firestore.FieldPath; -const FieldValue = firebase.firestore.FieldValue; -const Firestore = firebase.firestore.Firestore; -const GeoPoint = firebase.firestore.GeoPoint; -const QueryDocumentSnapshot = firebase.firestore.QueryDocumentSnapshot; -const Timestamp = firebase.firestore.Timestamp; +export * from '@firebase/firestore'; -export { - Blob, - DocumentReference, - FieldPath, - FieldValue, - Firestore, - GeoPoint, - QueryDocumentSnapshot, - Timestamp -}; +export type PrivateSettings = Record; diff --git a/integration/firestore/gulpfile.js b/integration/firestore/gulpfile.js index 33694dc6a10..6e1cf0490c3 100644 --- a/integration/firestore/gulpfile.js +++ b/integration/firestore/gulpfile.js @@ -53,25 +53,18 @@ function copyTests() { .pipe( replace( /** - * This regex is designed to match the following statement used in our - * firestore integration test suites: - * - * import * as firebaseExport from '../../util/firebase_export'; - * - * It will handle variations in whitespace, single/double quote - * differences, as well as different paths to a valid firebase_export + * This regex is designed to match the Firebase import in our + * integration tests. */ - /import\s+\* as firebaseExport\s+from\s+('|")[^\1]+firebase_export\1;?/, - `import * as firebaseExport from '${resolve( - __dirname, - './firebase_export' - )}'; + /\s+from '\.(\.\/util)?\/firebase_export';/, + ` from '${resolve(__dirname, './firebase_export')}'; - if (typeof process === 'undefined') { - process = { env: { INCLUDE_FIRESTORE_PERSISTENCE: '${isPersistenceEnabled()}' } } as any; - } else { - process.env.INCLUDE_FIRESTORE_PERSISTENCE = '${isPersistenceEnabled()}'; - }` +if (typeof process === 'undefined') { + process = { env: { INCLUDE_FIRESTORE_PERSISTENCE: '${isPersistenceEnabled()}' } } as any; +} else { + process.env.INCLUDE_FIRESTORE_PERSISTENCE = '${isPersistenceEnabled()}'; +} +` ) ) .pipe( diff --git a/integration/firestore/package.json b/integration/firestore/package.json index 18ca2f03c73..0058ea7ef8e 100644 --- a/integration/firestore/package.json +++ b/integration/firestore/package.json @@ -6,6 +6,7 @@ "build:deps": "lerna run --scope @firebase/'{app,firestore}' --include-dependencies build", "build:persistence": "INCLUDE_FIRESTORE_PERSISTENCE=true gulp compile-tests", "build:memory": "INCLUDE_FIRESTORE_PERSISTENCE=false gulp compile-tests", + "prettier": "prettier --write '*.js' '*.ts'", "test": "yarn build:memory; karma start --single-run; yarn build:persistence; karma start --single-run;", "test:ci": "node ../../scripts/run_tests_in_ci.js -s test", "test:persistence": " yarn build:persistence; karma start --single-run", @@ -15,7 +16,7 @@ }, "devDependencies": { "@firebase/app": "0.7.11", - "@firebase/firestore-compat": "0.1.10", + "@firebase/firestore": "3.4.1", "@types/mocha": "9.0.0", "gulp": "4.0.2", "gulp-filter": "7.0.0", diff --git a/packages/firestore/test/integration/util/events_accumulator.ts b/packages/firestore/test/integration/util/events_accumulator.ts index 64697a88d1a..2017ae4bba0 100644 --- a/packages/firestore/test/integration/util/events_accumulator.ts +++ b/packages/firestore/test/integration/util/events_accumulator.ts @@ -17,7 +17,7 @@ import { expect } from 'chai'; -import { DocumentSnapshot, QuerySnapshot } from '../../../src'; +import { DocumentSnapshot, QuerySnapshot } from './firebase_export'; import { Deferred } from '../../util/promise'; /** diff --git a/packages/firestore/test/integration/util/firebase_export.ts b/packages/firestore/test/integration/util/firebase_export.ts index 5a54f53c133..ab52cb2e1db 100644 --- a/packages/firestore/test/integration/util/firebase_export.ts +++ b/packages/firestore/test/integration/util/firebase_export.ts @@ -53,3 +53,4 @@ export function newTestFirestore( } export * from '../../../src'; +export { PrivateSettings }; diff --git a/packages/firestore/test/integration/util/helpers.ts b/packages/firestore/test/integration/util/helpers.ts index 87f2ea31ad9..c1eab271f48 100644 --- a/packages/firestore/test/integration/util/helpers.ts +++ b/packages/firestore/test/integration/util/helpers.ts @@ -17,7 +17,6 @@ import { isIndexedDBAvailable } from '@firebase/util'; -import * as firebaseExport from './firebase_export'; import { collection, doc, @@ -26,12 +25,13 @@ import { terminate, clearIndexedDbPersistence, enableIndexedDbPersistence, - Settings, CollectionReference, DocumentData, QuerySnapshot, setDoc, - SnapshotListenOptions + PrivateSettings, + SnapshotListenOptions, + newTestFirestore } from './firebase_export'; import { ALT_PROJECT_ID, @@ -39,8 +39,6 @@ import { DEFAULT_SETTINGS } from './settings'; -const newTestFirestore = firebaseExport.newTestFirestore; - /* eslint-disable no-restricted-globals */ function isIeOrEdge(): boolean { @@ -173,7 +171,7 @@ export function withTestDbs( export async function withTestDbsSettings( persistence: boolean, projectId: string, - settings: Settings, + settings: PrivateSettings, numDbs: number, fn: (db: Firestore[]) => Promise ): Promise { @@ -214,7 +212,7 @@ export function withTestDoc( export function withTestDocAndSettings( persistence: boolean, - settings: Settings, + settings: PrivateSettings, fn: (doc: DocumentReference) => Promise ): Promise { return withTestDbsSettings( @@ -260,7 +258,7 @@ export function withTestCollection( // return the same collection every time. export function withTestCollectionSettings( persistence: boolean, - settings: Settings, + settings: PrivateSettings, docs: { [key: string]: DocumentData }, fn: (collection: CollectionReference, db: Firestore) => Promise ): Promise { diff --git a/packages/firestore/test/integration/util/settings.ts b/packages/firestore/test/integration/util/settings.ts index 5457417f273..9eb32460178 100644 --- a/packages/firestore/test/integration/util/settings.ts +++ b/packages/firestore/test/integration/util/settings.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { PrivateSettings } from '../../../src/lite-api/settings'; +import { PrivateSettings } from './firebase_export'; /** * NOTE: These helpers are used by api/ tests and therefore may not have any