Skip to content

Commit 22caf9f

Browse files
Fix Spec tests 'Limbo documents stay consistent' (#1994)
1 parent 6196a50 commit 22caf9f

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

packages/firestore/test/unit/specs/describe_spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const NO_ANDROID_TAG = 'no-android';
3333
const NO_IOS_TAG = 'no-ios';
3434
// The remaining tags specify features that must be present to run a given test
3535
// Multi-client related tests (which imply persistence).
36-
const MULTI_CLIENT_TAG = 'multi-client';
36+
export const MULTI_CLIENT_TAG = 'multi-client';
3737
const EAGER_GC_TAG = 'eager-gc';
3838
const DURABLE_PERSISTENCE_TAG = 'durable-persistence';
3939
const BENCHMARK_TAG = 'benchmark';
@@ -173,7 +173,7 @@ export function specTest(
173173
const fullName = `${mode} ${name}`;
174174
const queuedTest = runner(fullName, async () => {
175175
const start = Date.now();
176-
await spec.runAsTest(fullName, usePersistence);
176+
await spec.runAsTest(fullName, tags, usePersistence);
177177
const end = Date.now();
178178
if (tags.indexOf(BENCHMARK_TAG) >= 0) {
179179
// eslint-disable-next-line no-console

packages/firestore/test/unit/specs/limbo_spec.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,8 @@ describeSpec('Limbo Documents:', [], () => {
458458
);
459459

460460
return (
461-
client(0)
461+
spec()
462+
.withGCEnabled(false)
462463
.userSets('collection/a', { matches: true })
463464
.userSets('collection/b', { matches: true })
464465
.writeAcks('collection/a', 1000)

packages/firestore/test/unit/specs/spec_builder.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,13 @@ export class SpecBuilder {
195195
* Run the spec as a test. If persistence is available it will run it with and
196196
* without persistence enabled.
197197
*/
198-
runAsTest(name: string, usePersistence: boolean): Promise<void> {
198+
runAsTest(
199+
name: string,
200+
tags: string[],
201+
usePersistence: boolean
202+
): Promise<void> {
199203
this.nextStep();
200-
return runSpec(name, usePersistence, this.config, this.steps);
204+
return runSpec(name, tags, usePersistence, this.config, this.steps);
201205
}
202206

203207
// Configures Garbage Collection behavior (on or off). Default is on.

packages/firestore/test/unit/specs/spec_test_runner.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ import {
109109
TEST_PERSISTENCE_PREFIX,
110110
TEST_SERIALIZER
111111
} from '../local/persistence_test_helpers';
112+
import { MULTI_CLIENT_TAG } from './describe_spec';
112113

113114
const ARBITRARY_SEQUENCE_NUMBER = 2;
114115

@@ -1236,6 +1237,7 @@ class IndexedDbTestRunner extends TestRunner {
12361237
*/
12371238
export async function runSpec(
12381239
name: string,
1240+
tags: string[],
12391241
usePersistence: boolean,
12401242
config: SpecConfig,
12411243
steps: SpecStep[]
@@ -1279,6 +1281,12 @@ export async function runSpec(
12791281
let count = 0;
12801282
try {
12811283
await sequence(steps, async step => {
1284+
assert(
1285+
step.clientIndex === undefined || tags.indexOf(MULTI_CLIENT_TAG) !== -1,
1286+
"Cannot use 'client()' to initialize a test that is not tagged with " +
1287+
"'multi-client'. Did you mean to use 'spec()'?"
1288+
);
1289+
12821290
++count;
12831291
lastStep = step;
12841292
return ensureRunner(step.clientIndex || 0).then(runner =>

0 commit comments

Comments
 (0)