Skip to content

Commit 0a2336b

Browse files
committed
First webdriver
1 parent fdadf71 commit 0a2336b

File tree

7 files changed

+142
-3
lines changed

7 files changed

+142
-3
lines changed

packages-exp/auth-compat-exp/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
"test:browser:integration": "karma start --single-run --integration",
2626
"test:node": "ts-node -O '{\"module\": \"commonjs\", \"target\": \"es6\"}' scripts/run_node_tests.ts",
2727
"test:node:integration": "ts-node -O '{\"module\": \"commonjs\", \"target\": \"es6\"}' scripts/run_node_tests.ts --integration",
28-
"test:integration": "run-s test:browser:integration test:node:integration"
28+
"test:webdriver": "rollup -c test/integration/webdriver/static/rollup.config.js && ts-node -O '{\"module\": \"commonjs\", \"target\": \"es6\"}' scripts/run_node_tests.ts --webdriver",
29+
"test:integration": "run-s test:browser:integration test:node:integration test:webdriver"
2930
},
3031
"peerDependencies": {
3132
"@firebase/app-compat": "0.x"
@@ -41,8 +42,8 @@
4142
"license": "Apache-2.0",
4243
"devDependencies": {
4344
"@firebase/app-compat": "0.x",
44-
"rollup": "2.35.1",
4545
"@rollup/plugin-json": "4.1.0",
46+
"rollup": "^2.35.1",
4647
"rollup-plugin-replace": "2.2.0",
4748
"rollup-plugin-typescript2": "0.29.0",
4849
"typescript": "4.2.2"

packages-exp/auth-compat-exp/scripts/run_node_tests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ let testConfig = ['src/**/*.test.ts'];
3939
if (argv.integration) {
4040
testConfig = ['test/integration/flows/**.test.ts'];
4141
} else if (argv.webdriver) {
42-
testConfig = ['test/integration/webdriver/**.test.ts', '--delay'];
42+
testConfig = ['../auth-exp/test/integration/webdriver/anonymous.test.ts', '--delay'];
4343
}
4444

4545
let args = [
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
export async function anonymousSignIn() {
19+
console.error('hi');
20+
return firebase.auth().signInAnonymously();
21+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
import { clearPersistence } from './persistence';
18+
19+
export function reset() {
20+
return clearPersistence();
21+
}
22+
23+
export function authInit() {
24+
return new Promise(resolve => {
25+
firebase.auth().onAuthStateChanged(user => {
26+
console.error('Init resolution', user);
27+
resolve();
28+
});
29+
});
30+
}
31+
32+
export async function userSnap() {
33+
console.error('User snap', firebase.auth().currentUser);
34+
return firebase.auth().currentUser;
35+
}
36+
37+
export async function authSnap() {
38+
return firebase.auth();
39+
}
40+
41+
export function signOut() {
42+
return firebase.auth().signOut();
43+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
const TEST_PASSWORD = 'password';
19+
20+
export function createUser(email) {
21+
return firebase.auth().createUserWithEmailAndPassword(email, TEST_PASSWORD);
22+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<!DOCTYPE html>
2+
<!--
3+
type=module makes browers treat it as an ES6 module and enforces strict mode. This helps catch
4+
some errors in the test (e.g. extending frozen objects or accidentally creating global variables).
5+
-->
6+
<script type="module" src="dist/bundle.js"></script>
7+
<h1>Compatibility layer tests</h1>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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 redirect from './redirect';
19+
import firebase from '@firebase/app-compat';
20+
import '@firebase/auth-compat';
21+
import * as anonymous from './anonymous';
22+
import * as core from './core';
23+
// import * as popup from './popup';
24+
import * as email from './email';
25+
// import * as persistence from './persistence';
26+
// import { initializeApp } from '@firebase/app-exp';
27+
// import { getAuth, useAuthEmulator } from '@firebase/auth-exp';
28+
29+
window.core = core;
30+
window.anonymous = anonymous;
31+
// window.redirect = redirect;
32+
// window.popup = popup;
33+
window.email = email;
34+
// window.persistence = persistence;
35+
36+
// window.auth = null;
37+
38+
// The config and emulator URL are injected by the test. The test framework
39+
// calls this function after that injection.
40+
window.startAuth = async () => {
41+
console.warn('Starting auth...');
42+
firebase.initializeApp(firebaseConfig);
43+
firebase.auth().useEmulator(emulatorUrl);
44+
window.firebase = firebase;
45+
};

0 commit comments

Comments
 (0)