-
Notifications
You must be signed in to change notification settings - Fork 900
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
7,869 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: E2E Smoke Tests | ||
|
||
on: workflow_dispatch | ||
|
||
jobs: | ||
test: | ||
name: Run E2E Smoke Tests | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
# Run any command steps in the /e2e subdir | ||
working-directory: './e2e' | ||
|
||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@master | ||
- name: Set up Node (12) | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 12.x | ||
- name: install Chrome stable | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install google-chrome-stable | ||
- name: Bump Node memory limit | ||
run: echo "NODE_OPTIONS=--max_old_space_size=4096" >> $GITHUB_ENV | ||
- name: Write project config | ||
env: | ||
PROJECT_CONFIG: ${{ secrets.TEST_PROJECT_CONFIG }} | ||
TEST_ACCOUNT: ${{ secrets.TEST_ACCOUNT }} | ||
run: | | ||
echo "export const config = $PROJECT_CONFIG; export const testAccount = $TEST_ACCOUNT" > firebase-config.js | ||
- name: Yarn install | ||
run: | | ||
yarn add firebase | ||
yarn | ||
- name: Deploy "callTest" cloud function | ||
run: | | ||
pushd functions | ||
npm install | ||
popd | ||
npx firebase-tools deploy --only functions:callTest --project jscore-sandbox-141b5 --token $FIREBASE_CLI_TOKEN | ||
working-directory: ./config | ||
env: | ||
FIREBASE_CLI_TOKEN: ${{ secrets.FIREBASE_CLI_TOKEN }} | ||
- name: Run modular tests | ||
env: | ||
APP_CHECK_DEBUG_TOKEN: ${{ secrets.APP_CHECK_DEBUG_TOKEN }} | ||
run: xvfb-run yarn test:modular | ||
- name: Run compat tests | ||
env: | ||
APP_CHECK_DEBUG_TOKEN: ${{ secrets.APP_CHECK_DEBUG_TOKEN }} | ||
run: xvfb-run yarn test:compat |
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,3 @@ | ||
build/*.js | ||
firebase-config.js | ||
context.html |
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,92 @@ | ||
# Firebase JS SDK E2E Tests | ||
|
||
This directory contains end-to-end tests for the Firebase JS SDK package as well as minimal quick start sample apps for debugging and development. | ||
|
||
## E2E Tests | ||
|
||
### Setup | ||
|
||
Before running the tests, you will need: | ||
|
||
- a project config | ||
- a test user with an email/password login which has read/write privileges for Storage, Realtime Database, and Firestore | ||
- an App Check debug token | ||
- to deploy the `callTest` Cloud Function | ||
|
||
#### Project Config and Test User | ||
|
||
Create a file named `firebase-config.js` in the top level of this `e2e/` directory. The contents of the file should be: | ||
|
||
```javascript | ||
// A config for a project | ||
export const config = { | ||
apiKey: ************, | ||
authDomain: ************, | ||
databaseURL: ************, | ||
projectId: ************, | ||
storageBucket: ************, | ||
messagingSenderId: ************, | ||
appId: ************, | ||
measurementId: ************ | ||
}; | ||
* | ||
// A user account with read/write privileges in that project | ||
// for storage, database, firestore | ||
export const testAccount = { | ||
email: ************, | ||
password: ************ | ||
} | ||
``` | ||
|
||
#### App Check Debug Token | ||
|
||
Create an App Check debug token in the Firebase Console. Assign it to an environment variable in your shell named `APP_CHECK_DEBUG_TOKEN`. | ||
|
||
#### Deploy `callTest` Cloud Function | ||
|
||
From the top level of the firebase repo, ensure you have the Firebase CLI (`firebase-tools`) installed (if not, `npm install -g firebase-tools`). | ||
|
||
Ensure you are logged in using the CLI (`firebase login`); | ||
|
||
Then deploy the function with: | ||
`firebase deploy --only functions:callTest --project YOUR_PROJECT_ID` | ||
|
||
### Running the Tests | ||
|
||
To run the tests on the default modular API: | ||
|
||
``` | ||
yarn test:modular | ||
``` | ||
|
||
To run the tests on the compat API: | ||
|
||
``` | ||
yarn test:compat | ||
``` | ||
|
||
## Sample Apps | ||
|
||
Two minimal sample apps are provided for quick debugging and development. These apps import and initialize every product in the SDK and call some basic methods. Products can easily be commented out to focus on one or more products you are interested in looking at. | ||
|
||
### Setup | ||
|
||
The setup is the same as for the E2E tests above. Certain tests can be skipped if you are commenting out that product (e.g, no need to deploy the Cloud Function if you are commenting out the `callFunctions()` line in the sample app, and no need to set the App Check debug token env variable if not using App Check). | ||
|
||
### Running Sample Apps | ||
|
||
To run the modular sample app (uses current default version of the API): | ||
|
||
``` | ||
yarn start:modular | ||
``` | ||
|
||
Then open `localhost:8080` in a browser. | ||
|
||
To run the compat sample app (uses current compat version of the API): | ||
|
||
``` | ||
yarn start:compat | ||
``` | ||
|
||
Then open `localhost:8080` in a browser. |
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,3 @@ | ||
<body> | ||
<script src="./app.bundle.js"></script> | ||
</body> |
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,43 @@ | ||
<!DOCTYPE html> | ||
<!-- | ||
NOTE: This file is identical to karma's default except for the | ||
FIREBASE_APPCHECK_DEBUG_TOKEN line. | ||
This is the execution context. | ||
Loaded within the iframe. | ||
Reloaded before every execution run. | ||
--> | ||
<html> | ||
<head> | ||
<title></title> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" /> | ||
</head> | ||
<body> | ||
<!-- The scripts need to be in the body DOM element, as some test running frameworks need the body | ||
to have already been created so they can insert their magic into it. For example, if loaded | ||
before body, Angular Scenario test framework fails to find the body and crashes and burns in | ||
an epic manner. --> | ||
<script src="context.js"></script> | ||
<script type="text/javascript"> | ||
// test-setup.js will replace with token pulled from process.env.APP_CHECK_DEBUG_TOKEN | ||
self.FIREBASE_APPCHECK_DEBUG_TOKEN = 'APP_CHECK_DEBUG_TOKEN'; | ||
// Configure our Karma and set up bindings | ||
%CLIENT_CONFIG% | ||
window.__karma__.setupContext(window); | ||
|
||
// All served files with the latest timestamps | ||
%MAPPINGS% | ||
</script> | ||
<!-- Dynamically replaced with <script> tags --> | ||
%SCRIPTS% | ||
<!-- Since %SCRIPTS% might include modules, the `loaded()` call needs to be in a module too. | ||
This ensures all the tests will have been declared before karma tries to run them. --> | ||
<script type="module"> | ||
window.__karma__.loaded(); | ||
</script> | ||
<script nomodule> | ||
window.__karma__.loaded(); | ||
</script> | ||
</body> | ||
</html> |
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,90 @@ | ||
/** | ||
* @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. | ||
*/ | ||
|
||
function getTestFiles(argv) { | ||
const files = []; | ||
if (argv.includes('--compat')) { | ||
files.push('./tests/compat.test.ts'); | ||
} | ||
if (argv.includes('--modular')) { | ||
files.push('./tests/modular.test.ts'); | ||
} | ||
return files; | ||
} | ||
const karma = require('karma'); | ||
|
||
module.exports = function (config) { | ||
config.set({ | ||
frameworks: ['karma-typescript', 'mocha'], | ||
files: getTestFiles(process.argv), | ||
preprocessors: { | ||
'./tests/*.test.ts': ['karma-typescript'] | ||
}, | ||
browsers: ['Chrome'], | ||
singleRun: true, | ||
client: { | ||
mocha: { | ||
timeout: 10000 | ||
} | ||
}, | ||
customContextFile: './context.html', | ||
reporters: ['spec'], | ||
specReporter: { | ||
maxLogLines: 5, // limit number of lines logged per test | ||
suppressErrorSummary: true, // do not print error summary | ||
suppressFailed: false, // do not print information about failed tests | ||
suppressPassed: false, // do not print information about passed tests | ||
suppressSkipped: true, // do not print information about skipped tests | ||
showSpecTiming: false // print the time elapsed for each spec | ||
}, | ||
concurrency: 1, | ||
karmaTypescriptConfig: { | ||
bundlerOptions: { | ||
resolve: { | ||
directories: ['./node_modules'], | ||
alias: { | ||
'@firebase/messaging/sw': | ||
'node_modules/@firebase/messaging/dist/index.sw.esm2017.js' | ||
} | ||
}, | ||
transforms: [ | ||
require('karma-typescript-es6-transform')({ | ||
presets: [ | ||
[ | ||
'@babel/preset-env', | ||
{ | ||
targets: { | ||
browsers: ['last 2 Chrome versions'] | ||
} | ||
} | ||
] | ||
] | ||
}) | ||
] | ||
}, | ||
compilerOptions: { | ||
allowJs: true | ||
} | ||
}, | ||
plugins: [ | ||
'karma-typescript', | ||
'karma-mocha', | ||
'karma-chrome-launcher', | ||
'karma-spec-reporter' | ||
] | ||
}); | ||
}; |
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,40 @@ | ||
{ | ||
"name": "firebase-smoke-test", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"setup": "node test-setup.js", | ||
"test": "yarn setup && karma start --compat --modular", | ||
"test:compat": "yarn setup && yarn karma start --compat", | ||
"test:modular": "yarn setup && karma start --modular", | ||
"watch": "webpack --watch", | ||
"build": "webpack", | ||
"start:modular": "webpack serve --config-name modular", | ||
"start:compat": "webpack serve --config-name compat" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"firebase": "9.0.2" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "7.14.6", | ||
"@babel/preset-env": "7.14.4", | ||
"@types/chai": "4.2.18", | ||
"@types/mocha": "8.2.2", | ||
"babel-loader": "8.0.5", | ||
"chai": "4.3.4", | ||
"karma": "6.3.4", | ||
"karma-chrome-launcher": "3.1.0", | ||
"karma-mocha": "2.0.1", | ||
"karma-spec-reporter": "0.0.32", | ||
"karma-typescript": "5.5.1", | ||
"karma-typescript-es6-transform": "5.5.1", | ||
"mocha": "9.0.0", | ||
"typescript": "4.3.4", | ||
"webpack": "5.41.1", | ||
"webpack-cli": "4.7.2", | ||
"webpack-dev-server": "3.10.1" | ||
} | ||
} |
Oops, something went wrong.