Skip to content

Commit

Permalink
some integration tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
a-type committed Oct 18, 2024
1 parent 27fad38 commit 1b101a1
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 118 deletions.
1 change: 1 addition & 0 deletions packages/store/src/entities/Entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,7 @@ export class Entity<
}
const file = this.files.get(child.id, {
downloadRemote: !!fieldSchema.downloadRemote,
ctx: this.ctx,
});

// FIXME: this seems bad and inconsistent
Expand Down
9 changes: 0 additions & 9 deletions packages/store/src/entities/EntityCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,6 @@ export class EntityCache {
return this.cache.has(oid);
};

getFile = (id: string, options: { downloadRemote: boolean }): EntityFile => {
if (this.cache.has(id)) {
return this.cache.get(id)! as EntityFile;
}
const file = new EntityFile(id, options);
this.cache.set(id, file);
return file;
};

getCached = (oid: string) => {
return this.cache.get(oid);
};
Expand Down
12 changes: 7 additions & 5 deletions packages/store/src/persistence/idb/metadata/IdbMetadataDb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export class IdbMetadataDb extends IdbService implements PersistenceMetadataDb {

updateLocalReplica = async (
data: Partial<LocalReplicaInfo>,
opts?: CommonQueryOptions,
opts: CommonQueryOptions = writeOpts,
): Promise<void> => {
const localReplicaInfo = await this.getLocalReplica(opts);
Object.assign(localReplicaInfo, data);
Expand Down Expand Up @@ -199,7 +199,7 @@ export class IdbMetadataDb extends IdbService implements PersistenceMetadataDb {

setBaselines = async (
baselines: DocumentBaseline[],
opts?: CommonQueryOptions,
opts: CommonQueryOptions = writeOpts,
): Promise<void> => {
await this.runAll<any>(
'baselines',
Expand All @@ -210,7 +210,7 @@ export class IdbMetadataDb extends IdbService implements PersistenceMetadataDb {

deleteBaseline = async (
oid: string,
opts?: CommonQueryOptions,
opts: CommonQueryOptions = writeOpts,
): Promise<void> => {
await this.run(
'baselines',
Expand Down Expand Up @@ -269,7 +269,7 @@ export class IdbMetadataDb extends IdbService implements PersistenceMetadataDb {
consumeEntityOperations = (
oid: string,
iterator: Iterator<ClientOperation>,
opts?: CommonQueryOptions & { to?: string | null },
opts: CommonQueryOptions & { to?: string | null } = writeOpts,
): Promise<void> => {
return this.iterate<StoredClientOperation>(
'operations',
Expand Down Expand Up @@ -363,7 +363,7 @@ export class IdbMetadataDb extends IdbService implements PersistenceMetadataDb {

addOperations = async (
ops: StoredClientOperation[],
opts?: CommonQueryOptions,
opts: CommonQueryOptions = writeOpts,
): Promise<ObjectIdentifier[]> => {
let affected = new Set<ObjectIdentifier>();
await this.runAll(
Expand Down Expand Up @@ -454,3 +454,5 @@ export class IdbMetadataDb extends IdbService implements PersistenceMetadataDb {
};
};
}

const writeOpts = { mode: 'readwrite' } as const;

This file was deleted.

4 changes: 3 additions & 1 deletion packages/store/src/sync/Sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,9 @@ export class ServerSync<Presence = any, Profile = any>
this.ctx.log(
'error',
'Failed to upload unsynced files',
results.filter((r) => r.status === 'rejected').map((r) => r.reason),
results
.filter((r): r is PromiseRejectedResult => r.status === 'rejected')
.map((r) => r.reason),
);
}
}
Expand Down
8 changes: 5 additions & 3 deletions test/client/schemaVersions/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { StorageSchema } from '@verdant-web/common';
declare const versions: StorageSchema[];
export default versions;

import { StorageSchema } from '@verdant-web/common';
declare const versions: StorageSchema[];
export default versions;

3 changes: 0 additions & 3 deletions test/tests/fuzz.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { ReplicaType, Server } from '@verdant-web/server';
import {
ClientWithCollections,
collection,
createMigration,
Entity,
migrate,
schema,
StorageDescriptor,
} from '@verdant-web/store';
Expand Down Expand Up @@ -222,7 +220,6 @@ async function waitForConsistency(
const fuzz2 = await getFuzz(client2);
const fuzz1Pending = fuzz1.metadata.pendingOperations;
const fuzz2Pending = fuzz2.metadata.pendingOperations;
debugger;
return `[${debugTag}] consistency (${attempts} attempts):
${snap1}
Expand Down

0 comments on commit 1b101a1

Please sign in to comment.