-
Notifications
You must be signed in to change notification settings - Fork 895
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integration tests for v9 & v9 compat interop (#4911)
* auth compat interop test * add compat interop integration tests * use scoped packages for integration tests * fix package name * ignore firebase-compat-interop-test in changeset * better handling of input * Create fuzzy-teachers-guess.md
- Loading branch information
Showing
18 changed files
with
439 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@firebase/component": patch | ||
--- | ||
|
||
handle `undefined` correctly from input. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* @license | ||
* Copyright 2021 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { getModularInstance } from '@firebase/util'; | ||
import { expect } from 'chai'; | ||
import { getAnalytics } from '@firebase/analytics-exp'; | ||
import firebase from '@firebase/app-compat'; | ||
import '@firebase/analytics-compat'; | ||
|
||
import { TEST_PROJECT_CONFIG } from './util'; | ||
|
||
firebase.initializeApp(TEST_PROJECT_CONFIG); | ||
|
||
const compatAnalytics = firebase.analytics(); | ||
const modularAnalytics = getAnalytics(); | ||
|
||
describe('Analytics compat interop', () => { | ||
it('Analytics compat instance references modular Analytics instance', () => { | ||
expect(getModularInstance(compatAnalytics)).to.equal(modularAnalytics); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* @license | ||
* Copyright 2021 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { getModularInstance } from '@firebase/util'; | ||
import { expect } from 'chai'; | ||
import { getApp, getApps } from '@firebase/app-exp'; | ||
import firebase from '@firebase/app-compat'; | ||
|
||
import { TEST_PROJECT_CONFIG } from './util'; | ||
//TODO: add Storage, Firestore and Database tests once v8 is removed. Currently it's too difficult to set them up in integration tests. | ||
describe('App compat interop', () => { | ||
afterEach(() => { | ||
const deletePromises = []; | ||
for (const app of firebase.apps) { | ||
deletePromises.push(app.delete()); | ||
} | ||
|
||
return Promise.all(deletePromises); | ||
}); | ||
|
||
it('App compat instance references modular App instance', () => { | ||
const compatApp = firebase.initializeApp(TEST_PROJECT_CONFIG); | ||
const modularApp = getApp(); | ||
expect(getModularInstance(compatApp)).to.equal(modularApp); | ||
}); | ||
|
||
it('deleting compat app deletes modular app', async () => { | ||
const compatApp = firebase.initializeApp(TEST_PROJECT_CONFIG); | ||
expect(firebase.apps.length).to.equal(1); | ||
expect(getApps().length).to.equal(1); | ||
|
||
await compatApp.delete(); | ||
expect(firebase.apps.length).to.equal(0); | ||
expect(getApps().length).to.equal(0); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* @license | ||
* Copyright 2021 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { getModularInstance } from '@firebase/util'; | ||
import { expect } from 'chai'; | ||
import { getAuth, signOut } from '@firebase/auth-exp'; | ||
import firebase from '@firebase/app-compat'; | ||
import '@firebase/auth-compat'; | ||
|
||
import { TEST_PROJECT_CONFIG } from './util'; | ||
|
||
firebase.initializeApp(TEST_PROJECT_CONFIG); | ||
|
||
const compatAuth = firebase.auth(); | ||
const modularAuth = getAuth(); | ||
|
||
describe('Auth compat interop', () => { | ||
it('Auth compat instance references modular Auth instance', () => { | ||
expect(getModularInstance(compatAuth)).to.equal(modularAuth); | ||
}); | ||
|
||
it('Auth compat and modular Auth share the same user state', async () => { | ||
expect(compatAuth.currentUser).to.equal(null); | ||
expect(modularAuth.currentUser).to.equal(null); | ||
const userCred = await compatAuth.signInAnonymously(); | ||
expect(userCred.user?.uid).to.equal(modularAuth.currentUser?.uid); | ||
expect(await userCred.user?.getIdToken()).to.equal( | ||
await modularAuth.currentUser?.getIdToken() | ||
); | ||
|
||
await signOut(modularAuth); | ||
expect(compatAuth.currentUser).to.equal(null); | ||
expect(modularAuth.currentUser).to.equal(null); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* @license | ||
* Copyright 2021 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { getModularInstance } from '@firebase/util'; | ||
import { expect } from 'chai'; | ||
import { getFunctions } from '@firebase/functions-exp'; | ||
import firebase from '@firebase/app-compat'; | ||
import '@firebase/functions-compat'; | ||
|
||
import { TEST_PROJECT_CONFIG } from './util'; | ||
|
||
firebase.initializeApp(TEST_PROJECT_CONFIG); | ||
|
||
const compatFunction = firebase.functions(); | ||
const modularFunctions = getFunctions(); | ||
|
||
describe('Functions compat interop', () => { | ||
it('Functions compat instance references modular Functions instance', () => { | ||
expect(getModularInstance(compatFunction)).to.equal(modularFunctions); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
const karma = require('karma'); | ||
const karmaBase = require('../../config/karma.base'); | ||
|
||
const files = ['*.test.*']; | ||
|
||
module.exports = function (config) { | ||
const karmaConfig = Object.assign({}, karmaBase, { | ||
// files to load into karma | ||
files: files, | ||
preprocessors: { '**/*.ts': ['webpack', 'sourcemap'] }, | ||
// frameworks to use | ||
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter | ||
frameworks: ['mocha'] | ||
}); | ||
|
||
config.set(karmaConfig); | ||
}; | ||
|
||
module.exports.files = files; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* @license | ||
* Copyright 2021 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { getModularInstance } from '@firebase/util'; | ||
import { expect } from 'chai'; | ||
import { getMessaging } from '@firebase/messaging-exp'; | ||
import firebase from '@firebase/app-compat'; | ||
import '@firebase/messaging-compat'; | ||
|
||
import { TEST_PROJECT_CONFIG } from './util'; | ||
|
||
firebase.initializeApp(TEST_PROJECT_CONFIG); | ||
|
||
const compatMessaging = firebase.messaging(); | ||
const modularMessaging = getMessaging(); | ||
|
||
describe('Messaging compat interop', () => { | ||
it('Messaging compat instance references modular Messaging instance', () => { | ||
expect(getModularInstance(compatMessaging)).to.equal(modularMessaging); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "firebase-compat-interop-test", | ||
"private": true, | ||
"version": "0.1.0", | ||
"scripts": { | ||
"test": "karma start --single-run", | ||
"test:ci": "node ../../scripts/run_tests_in_ci.js -s test", | ||
"test:debug": "karma start --browsers Chrome --auto-watch" | ||
}, | ||
"dependencies": { | ||
"@firebase/app-exp": "0.0.900", | ||
"@firebase/app-compat": "0.0.900", | ||
"@firebase/analytics-exp": "0.0.900", | ||
"@firebase/analytics-compat": "0.0.900", | ||
"@firebase/auth-exp": "0.0.900", | ||
"@firebase/auth-compat": "0.0.900", | ||
"@firebase/functions-exp": "0.0.900", | ||
"@firebase/functions-compat": "0.0.900", | ||
"@firebase/messaging-exp": "0.0.900", | ||
"@firebase/messaging-compat": "0.0.900", | ||
"@firebase/performance-exp": "0.0.900", | ||
"@firebase/performance-compat": "0.0.900", | ||
"@firebase/remote-config-exp": "0.0.900", | ||
"@firebase/remote-config-compat": "0.0.900" | ||
}, | ||
"devDependencies": { | ||
"typescript": "4.2.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* @license | ||
* Copyright 2021 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { getModularInstance } from '@firebase/util'; | ||
import { expect } from 'chai'; | ||
import { getPerformance } from '@firebase/performance-exp'; | ||
import firebase from '@firebase/app-compat'; | ||
import '@firebase/performance-compat'; | ||
|
||
import { TEST_PROJECT_CONFIG } from './util'; | ||
|
||
firebase.initializeApp(TEST_PROJECT_CONFIG); | ||
|
||
const compatPerf = firebase.performance(); | ||
const modularPerf = getPerformance(); | ||
|
||
describe('Performance compat interop', () => { | ||
it('Performance compat instance references modular Performance instance', () => { | ||
expect(getModularInstance(compatPerf)).to.equal(modularPerf); | ||
}); | ||
|
||
it('Performance compat and modular Performance instance share the same configuration', () => { | ||
expect(compatPerf.dataCollectionEnabled).to.equal(true); | ||
expect(compatPerf.instrumentationEnabled).to.equal(true); | ||
expect(modularPerf.dataCollectionEnabled).to.equal(true); | ||
expect(modularPerf.instrumentationEnabled).to.equal(true); | ||
|
||
// change settings on the compat instance | ||
compatPerf.dataCollectionEnabled = false; | ||
compatPerf.instrumentationEnabled = false; | ||
|
||
expect(compatPerf.dataCollectionEnabled).to.equal(false); | ||
expect(compatPerf.instrumentationEnabled).to.equal(false); | ||
expect(modularPerf.dataCollectionEnabled).to.equal(false); | ||
expect(modularPerf.instrumentationEnabled).to.equal(false); | ||
|
||
// change settings on the modular instance | ||
modularPerf.dataCollectionEnabled = true; | ||
modularPerf.instrumentationEnabled = true; | ||
|
||
expect(compatPerf.dataCollectionEnabled).to.equal(true); | ||
expect(compatPerf.instrumentationEnabled).to.equal(true); | ||
expect(modularPerf.dataCollectionEnabled).to.equal(true); | ||
expect(modularPerf.instrumentationEnabled).to.equal(true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* @license | ||
* Copyright 2021 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { getModularInstance } from '@firebase/util'; | ||
import { expect } from 'chai'; | ||
import { getRemoteConfig } from '@firebase/remote-config-exp'; | ||
import firebase from '@firebase/app-compat'; | ||
import '@firebase/remote-config-compat'; | ||
|
||
import { TEST_PROJECT_CONFIG } from './util'; | ||
|
||
firebase.initializeApp(TEST_PROJECT_CONFIG); | ||
|
||
const compatRC = firebase.remoteConfig(); | ||
const modularRC = getRemoteConfig(); | ||
|
||
describe('RC compat interop', () => { | ||
it('RC compat instance references modular RC instance', () => { | ||
expect(getModularInstance(compatRC)).to.equal(modularRC); | ||
}); | ||
}); |
Oops, something went wrong.