import { type FirestoreAccessorDriver, type FirestoreContext, type FirestoreDrivers } from '@dereekb/firebase'; /** * Used to override/extend a FirestoreAccessorDriver to provide better isolation between tests. */ export interface TestingFirestoreAccessorDriver extends FirestoreAccessorDriver { /** * Gets the fuzzed path names map. */ getFuzzedCollectionsNameMap(): Map; /** * Initializes fuzzed path names for the input collections. Returns the result of getFuzzedCollectionsNameMap(). * * This initialization step is useful for the client, where the rules file needs to be updated to reflect the collection names properly in order to ensure rules are correct. * * @param collectionNames */ initWithCollectionNames(collectionNames: string[]): Map; } /** * Creates a {@link TestingFirestoreAccessorDriver} that wraps the given driver with collection name fuzzing. * * Each collection/subcollection/collectionGroup path is replaced with a unique fuzzed name * (incorporating a timestamp and random component) so that parallel tests never read or write * each other's documents. The mapping from original to fuzzed names is retrievable via * {@link TestingFirestoreAccessorDriver.getFuzzedCollectionsNameMap}. * * @example * ```ts * const testDriver = makeTestingFirestoreAccesorDriver(productionDriver); * // "mockItems" -> "1678901234_42_mockItems_1" * ``` * * @param driver - The base driver to wrap with fuzzing behavior. */ export declare function makeTestingFirestoreAccesorDriver(driver: FirestoreAccessorDriver): TestingFirestoreAccessorDriver; /** * Drivers used for testing. Provides additional functionality for controlling collection access to prevent cross-test contamination. */ export interface TestingFirestoreDrivers extends FirestoreDrivers { firestoreDriverType: 'testing'; firestoreAccessorDriver: TestingFirestoreAccessorDriver; } /** * Extends the input drivers to generate new drivers for a testing environment. * * @param drivers * @returns */ export declare function makeTestingFirestoreDrivers(drivers: FirestoreDrivers): TestingFirestoreDrivers; /** * Extension applied to a {@link FirestoreContext} to expose the testing-specific drivers. * * This is mixed into the base context type via {@link TestFirestoreContext} so that * test code can access the fuzzed driver and its collection name map. */ export interface TestingFirestoreContextExtension { drivers: TestingFirestoreDrivers; } /** * A {@link FirestoreContext} augmented with {@link TestingFirestoreContextExtension}, * giving tests access to fuzzed collection drivers for isolation. */ export type TestFirestoreContext = C & TestingFirestoreContextExtension; /** * Function that clears a single Firestore collection used during testing. * * @param collectionName - The original (un-fuzzed) collection name. * @param realCollectionName - The fuzzed collection name that actually exists in Firestore. */ export type ClearTestFirestoreCollectionFunction = (collectionName: string, realCollectionName: string) => Promise; /** * Iterates over every fuzzed collection in the given test context and invokes the * provided cleanup function for each one. Use this in `afterAll`/`afterEach` hooks * to remove test data and avoid cross-test contamination. * * @param context - The test context whose fuzzed collections should be cleared. * @param clearCollection - Callback that performs the actual deletion for a single collection. */ export declare function clearTestFirestoreContextCollections(context: TestFirestoreContext, clearCollection: ClearTestFirestoreCollectionFunction): Promise;