Skip to content

Commit bcf91c6

Browse files
Shared Integration Tests
1 parent 0b14a8c commit bcf91c6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+960
-849
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import * as firebase from 'firebase';
19+
20+
// This file replaces "packages/firestore/test/integration/util/firebase_export"
21+
// and depends on the minified sources.
22+
23+
let appCount = 0;
24+
25+
export function newTestFirestore(
26+
projectId: string,
27+
nameOrApp?: string | firebase.app.App,
28+
settings?: firebase.firestore.Settings
29+
): firebase.firestore.Firestore {
30+
if (nameOrApp === undefined) {
31+
nameOrApp = 'test-app-' + appCount++;
32+
}
33+
const app =
34+
typeof nameOrApp === 'string'
35+
? firebase.initializeApp({ apiKey: 'fake-api-key', projectId }, nameOrApp)
36+
: nameOrApp;
37+
38+
const firestore = firebase.firestore(app);
39+
if (settings) {
40+
firestore.settings(settings);
41+
}
42+
return firestore;
43+
}
44+
45+
export function usesModularApi(): false {
46+
return false;
47+
}
48+
49+
const Firestore = firebase.firestore.Firestore;
50+
const FieldPath = firebase.firestore.FieldPath;
51+
const Timestamp = firebase.firestore.Timestamp;
52+
const GeoPoint = firebase.firestore.GeoPoint;
53+
const FieldValue = firebase.firestore.FieldValue;
54+
const Blob = firebase.firestore.Blob;
55+
56+
export { Firestore, FieldValue, FieldPath, Timestamp, Blob, GeoPoint };

integration/firestore/gulpfile.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ function copyTests() {
4848
return gulp
4949
.src(
5050
[
51+
'firebase_export.ts',
5152
testBase + '/integration/api/*.ts',
5253
testBase + '/integration/util/events_accumulator.ts',
5354
testBase + '/integration/util/helpers.ts',
@@ -63,21 +64,29 @@ function copyTests() {
6364
* This regex is designed to match the following statement used in our
6465
* firestore integration test suites:
6566
*
66-
* import firebase from '../../util/firebase_export';
67+
* import * as firebaseExport from '../../util/firebase_export';
6768
*
6869
* It will handle variations in whitespace, single/double quote
6970
* differences, as well as different paths to a valid firebase_export
7071
*/
71-
/import\s+firebase\s+from\s+('|")[^\1]+firebase_export\1;?/,
72-
`import firebase from '${firebaseAppSdk}';
73-
import '${firebaseFirestoreSdk}';
74-
72+
/import\s+\* as firebaseExport\s+from\s+('|")[^\1]+firebase_export\1;?/,
73+
`import * as firebaseExport from '${resolve(
74+
__dirname,
75+
'./firebase_export'
76+
)}';
77+
7578
if (typeof process === 'undefined') {
7679
process = { env: { INCLUDE_FIRESTORE_PERSISTENCE: '${isPersistenceEnabled()}' } } as any;
7780
} else {
7881
process.env.INCLUDE_FIRESTORE_PERSISTENCE = '${isPersistenceEnabled()}';
79-
}
80-
`
82+
}`
83+
)
84+
)
85+
.pipe(
86+
replace(
87+
'import * as firebase from "firebase";',
88+
`import firebase from '${firebaseAppSdk}';
89+
import '${firebaseFirestoreSdk}';`
8190
)
8291
)
8392
.pipe(

packages/firestore/.idea/runConfigurations/firestore_exp_Tests__Emulator__.xml

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/firestore/.idea/runConfigurations/firestore_exp_Tests__Emulator_w__Mock_Persistence_.xml

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/firestore/exp/src/api/database.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ export function disableNetwork(
291291
export function terminate(
292292
firestore: firestore.FirebaseFirestore
293293
): Promise<void> {
294-
_removeServiceInstance(firestore.app, 'firestore/lite');
294+
_removeServiceInstance(firestore.app, 'firestore-exp');
295295
const firestoreImpl = cast(firestore, Firestore);
296296
return firestoreImpl._terminate();
297297
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import '../../test/integration/api/array_transforms.test';
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import '../../test/integration/api/batch_writes.test';
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import '../../test/integration/api/cursor.test';
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import '../../test/integration/api/database.test';

packages/firestore/exp/test/deps/verify_dependencies.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ import * as dependencies from './dependencies.json';
2424
import * as pkg from '../../package.json';
2525
import { forEach } from '../../../src/util/obj';
2626

27-
describe('Dependencies', () => {
27+
// TODO(firestoreexp): Enable once the dependencies are stable
28+
// eslint-disable-next-line no-restricted-properties
29+
describe.skip('Dependencies', () => {
2830
forEach(dependencies, (api, { dependencies }) => {
2931
it(api, () => {
3032
return extractDependencies(api, resolve('exp', pkg.main)).then(
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import '../../test/integration/api/fields.test';
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import '../../test/integration/api/get_options.test';

packages/firestore/exp/test/helpers.ts

Lines changed: 0 additions & 77 deletions
This file was deleted.

0 commit comments

Comments
 (0)