Skip to content

Fix Saucelabs tests in analytics and functions #2845

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/cross-browser-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ jobs:
cross-browser-test:
name: Cross-Browser (Saucelabs) Tests
runs-on: ubuntu-latest
if: github.event.pull_request.merged
env:
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
Expand Down
4 changes: 2 additions & 2 deletions config/karma.saucelabs.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @license
* Copyright 2017 Google Inc.
* 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.
Expand Down Expand Up @@ -201,7 +201,7 @@ module.exports = function(config) {
maxLogLines: 5,
suppressErrorSummary: false,
suppressFailed: false,
suppressPassed: true,
suppressPassed: false,
suppressSkipped: true,
showSpecTiming: true,
failFast: false
Expand Down
16 changes: 12 additions & 4 deletions packages/analytics/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @license
* Copyright 2019 Google Inc.
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -88,7 +88,9 @@ describe('FirebaseAnalytics instance tests', () => {
currency: 'USD'
});
// Clear event stack of async FID call.
await fidDeferred.promise;
// For IE: Need then() or else "expect" runs immediately on FID resolve
// before the other statements in initializeGAId.
await fidDeferred.promise.then();
expect(gtagStub).to.have.been.calledWith('js');
expect(gtagStub).to.have.been.calledWith(
GtagCommand.CONFIG,
Expand Down Expand Up @@ -158,7 +160,9 @@ describe('FirebaseAnalytics instance tests', () => {
currency: 'USD'
});
// Clear event stack of async FID call.
await fidDeferred.promise;
// For IE: Need then() or else "expect" runs immediately on FID resolve
// before the other statements in initializeGAId.
await fidDeferred.promise.then();
expect(gtagStub).to.have.been.calledWith('js');
expect(gtagStub).to.have.been.calledWith(
GtagCommand.CONFIG,
Expand Down Expand Up @@ -195,8 +199,12 @@ describe('FirebaseAnalytics instance tests', () => {
delete window['dataLayer'];
removeGtagScript();
});
it('Adds the script tag to the page', () => {
it('Adds the script tag to the page', async () => {
const { initializedIdPromisesMap } = getGlobalVars();
await initializedIdPromisesMap[analyticsId];
expect(findGtagScriptOnPage()).to.not.be.null;
expect(typeof window['gtag']).to.equal('function');
expect(Array.isArray(window['dataLayer'])).to.be.true;
});
});
});
6 changes: 2 additions & 4 deletions packages/functions/karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @license
* Copyright 2017 Google Inc.
* 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.
Expand All @@ -15,16 +15,14 @@
* limitations under the License.
*/

const karma = require('karma');
const path = require('path');
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,
files,
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['mocha']
Expand Down
6 changes: 5 additions & 1 deletion packages/functions/test/browser/callable.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @license
* Copyright 2017 Google Inc.
* 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.
Expand Down Expand Up @@ -43,6 +43,10 @@ describe('Firebase Functions > Call', () => {
// TODO(klimt): Move this to the cross-platform tests and delete this file,
// once instance id works there.
it('instance id', async () => {
if (!('Notification' in self)) {
console.log('No Notification API: skipping instance id test.');
return;
}
// mock firebase messaging
const messagingMock: FirebaseMessaging = ({
getToken: async () => 'iid'
Expand Down