Skip to content

Commit

Permalink
[test] Omit firebase storage for non-Firebase tests and make them rec…
Browse files Browse the repository at this point in the history
…onnectable
  • Loading branch information
t2ym committed Jun 22, 2017
1 parent 826ea30 commit 7349cf4
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 4 deletions.
11 changes: 8 additions & 3 deletions test/src/common-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Copyright (c) 2016, Tetsuya Mori <t2y3141592@gmail.com>. All rights reserved.
common.htmlSuite = '*'; // Only inherited scopes are executed
// common test classes
common.test = class LiveLocalizerSuite extends Suite {
static get reconnectable() { return false; }
static get reconnectable() { return true; }
get currentPhase() {
this.href = this.href || window.location.href;
let match = this.href.match(/^[^#]*#TestSuites=[^&]*&Scope=[a-zA-Z0-9_-]*&Phase=([0-9]*).*$/);
Expand All @@ -29,9 +29,13 @@ Copyright (c) 2016, Tetsuya Mori <t2y3141592@gmail.com>. All rights reserved.
await super.setup();
if (!HTMLImports.useNative) {
let count = 1;
await this.checkInterval(() => count-- === 0, 1000, 2);
await this.checkInterval(() => count-- === 0, 100, 2);
}
this.fixture = document.querySelector(this.target);
if (!HTMLImports.useNative) {
let count = 1;
await this.checkInterval(() => count-- === 0, 100, 2);
}
}
async teardown() {
let self = this;
Expand Down Expand Up @@ -190,11 +194,12 @@ Copyright (c) 2016, Tetsuya Mori <t2y3141592@gmail.com>. All rights reserved.
assert.equal(self.listView.is, 'live-localizer-list-view');
assert.equal(self.storageView.is, 'live-localizer-storage-view');
assert.equal(self.browserStorage.is, 'live-localizer-browser-storage');
assert.equal(self.firebaseStorage.is, 'live-localizer-firebase-storage');
if (self.firebaseStorage) { assert.equal(self.firebaseStorage.is, 'live-localizer-firebase-storage'); }
assert.equal(self.fileStorage.is, 'live-localizer-local-file-storage');
}
}
common.test = (base) => class Reload extends base {
static get reconnectable() { return false; }
async operation() {
this.stepPhase();
}
Expand Down
1 change: 1 addition & 0 deletions test/src/dialog-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ Copyright (c) 2016, Tetsuya Mori <t2y3141592@gmail.com>. All rights reserved.
}
}
dialog.test = (base) => class LoadFailureTest extends base {
static get reconnectable() { return false; }
async operation() {
let self = this;
let mainLink = Array.prototype.filter.call(document.querySelectorAll('link[rel=import]'), (link) => link.href.match(/live-localizer-lazy[.]html/));
Expand Down
4 changes: 4 additions & 0 deletions test/src/filestorage-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ Copyright (c) 2017, Tetsuya Mori <t2y3141592@gmail.com>. All rights reserved.
}
}
filestorage.test = (base) => class MockFileStorageSaveTest extends base {
static get reconnectable() { return false; }
async operation() {
if (this.hasToSkip) { return; }
let self = this;
Expand All @@ -166,6 +167,7 @@ Copyright (c) 2017, Tetsuya Mori <t2y3141592@gmail.com>. All rights reserved.
}
}
filestorage.test = (base) => class MockFileStorageSaveTest2 extends base {
static get reconnectable() { return false; }
async operation() {
if (this.hasToSkip) { return; }
let self = this;
Expand Down Expand Up @@ -229,6 +231,7 @@ Copyright (c) 2017, Tetsuya Mori <t2y3141592@gmail.com>. All rights reserved.
}
}
filestorage.test = (base) => class MockFileStorageUploadTest extends base {
static get reconnectable() { return false; }
async operation() {
if (this.hasToSkip) { return; }
let self = this;
Expand Down Expand Up @@ -295,6 +298,7 @@ Copyright (c) 2017, Tetsuya Mori <t2y3141592@gmail.com>. All rights reserved.
}
}
filestorage.test = (base) => class MockFileStorageDropTest extends base {
static get reconnectable() { return false; }
async operation() {
if (this.hasToSkip) { return; }
let self = this;
Expand Down
6 changes: 5 additions & 1 deletion test/src/firebasestorage-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ Copyright (c) 2017, Tetsuya Mori <t2y3141592@gmail.com>. All rights reserved.
// firebasestorage scope (subscope of storageview)
let scope = 'firebasestorage';
let firebasestorage = new Suite(scope, 'live-localizer firebasestorage tests');
firebasestorage.htmlSuite = 'live-localizer';
firebasestorage.htmlSuite = 'live-localizer-firebase';
firebasestorage.test = Suite.scopes.storageview.classes.SelectStorageView;
firebasestorage.test = Suite.scopes.panel.classes.SelectIconView;
firebasestorage.test = Suite.scopes.panel.mixins.SelectStorageView;
firebasestorage.test = Suite.scopes.browserstorage.mixins.SelectLocaleIcon;
firebasestorage.test = Suite.scopes.common.mixins.Reload;
firebasestorage.test = (base) => class CleanupFirebaseAuthSuite extends base {
static get reconnectable() { return false; }
async setup() {
await super.setup();
if (this.hasToSkip) { return; }
Expand Down Expand Up @@ -353,6 +354,8 @@ Copyright (c) 2017, Tetsuya Mori <t2y3141592@gmail.com>. All rights reserved.
async operation() {
if (this.hasToSkip) { return; }
let self = this;
await self.checkInterval(() => self.firebaseStorage.isSettingsInitialized, 200, 100);
await self.checkInterval(() => self.storageIcon.label === 'bundle.de.xlf', 200, 100);
await self.showTooltip(self.storageIcon.$.card, self.iconTooltip);
}
async checkpoint() {
Expand Down Expand Up @@ -398,6 +401,7 @@ Copyright (c) 2017, Tetsuya Mori <t2y3141592@gmail.com>. All rights reserved.
}
}
firebasestorage.test = (base) => class MockSignInTest extends base {
static get reconnectable() { return false; }
* iteration() {
yield *[
{
Expand Down
2 changes: 2 additions & 0 deletions test/src/iconview-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Copyright (c) 2017, Tetsuya Mori <t2y3141592@gmail.com>. All rights reserved.
}
// Must be after SelectLocaleIconTest
iconview.test = (base) => class MockSaveFileTest extends base {
static get reconnectable() { return false; }
async operation() {
let self = this;
let droparea = self.iconView.$.droparea;
Expand Down Expand Up @@ -107,6 +108,7 @@ Copyright (c) 2017, Tetsuya Mori <t2y3141592@gmail.com>. All rights reserved.
}
}
iconview.test = (base) => class IconTooltipTest extends base {
static get reconnectable() { return false; }
* iteration() {
yield *[
{ icon: 'en', tooltip: 'Save XLIFF' },
Expand Down
75 changes: 75 additions & 0 deletions test/src/live-localizer-firebase-test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<!--
@license
Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<!--
@license https://github.com/t2ym/live-localizer/blob/master/LICENSE.md
Copyright (c) 2016, Tetsuya Mori <t2y3141592@gmail.com>. All rights reserved.
-->

<!doctype html>
<html lang="en" preferred>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">

<title>Live Localizer Basic Test</title>

<meta name="theme-color" content="#fff">

<script src="../../../web-component-tester/browser.js"></script>
<script src="../../../webcomponentsjs/webcomponents-lite.js"></script>

<link rel="import" href="../../../iron-test-helpers/iron-test-helpers.html">
<link rel="import" href="my-app.html">
<link rel="import" href="../../live-localizer.html">

<style>

body {
margin: 0;
font-family: 'Roboto', 'Noto', sans-serif;
line-height: 1.5;
min-height: 100vh;
background-color: #eee;
}

</style>

</head>
<body>

<my-app></my-app>

<test-fixture id="fixture">
<template>
<live-localizer>
<live-localizer-firebase-storage id="firebase-storage" class="storage cloud"
auth-provider="google"
auth-domain="live-localizer-demo.firebaseapp.com"
database-url="https://live-localizer-demo.firebaseio.com"
api-key="AIzaSyCjrlPhl0cLSZVRsDvuajq16vkerhcu_UM">
</live-localizer-firebase-storage>
</live-localizer>
</template>
</test-fixture>

<!-- <script src="../../node_modules/babel-polyfill/browser.js"></script> -->
<link rel="import" href="import-suites.html">
<script>
addEventListener('WebComponentsReady', function () {
let match = decodeURIComponent(window.location.href).match(/^.*[^_a-zA-Z0-9]TestSuites=([_a-zA-Z0-9,]*)&Scope=([_a-zA-Z0-9-]*).*$/);

if (match) {
// Runner
Suite.scopes[match[2]].run(match[1], '#fixture');
}
});
</script>
</body>
</html>
2 changes: 2 additions & 0 deletions test/src/live-localizer-lazy-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@
<test-fixture id="fixture">
<template>
<live-localizer>
<!--
<live-localizer-firebase-storage id="firebase-storage" class="storage cloud"
auth-provider="google"
auth-domain="live-localizer-demo.firebaseapp.com"
database-url="https://live-localizer-demo.firebaseio.com"
api-key="AIzaSyCjrlPhl0cLSZVRsDvuajq16vkerhcu_UM">
</live-localizer-firebase-storage>
-->
</live-localizer>
</template>
</test-fixture>
Expand Down
2 changes: 2 additions & 0 deletions test/src/live-localizer-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@
<test-fixture id="fixture">
<template>
<live-localizer>
<!--
<live-localizer-firebase-storage id="firebase-storage" class="storage cloud"
auth-provider="google"
auth-domain="live-localizer-demo.firebaseapp.com"
database-url="https://live-localizer-demo.firebaseio.com"
api-key="AIzaSyCjrlPhl0cLSZVRsDvuajq16vkerhcu_UM">
</live-localizer-firebase-storage>
-->
</live-localizer>
</template>
</test-fixture>
Expand Down
4 changes: 4 additions & 0 deletions test/src/panel-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Copyright (c) 2016, Tetsuya Mori <t2y3141592@gmail.com>. All rights reserved.
panel.test = Suite.scopes.common.classes.InstantiateTest;
panel.test = Suite.scopes.dialog.classes.OpenDialogTest;
panel.test = (base) => class PanelTooltipTest extends base {
static get reconnectable() { return false; }
* iteration() {
yield *[
{ button: 'iconview-button', tooltip: 'Show Icons' },
Expand Down Expand Up @@ -135,6 +136,7 @@ Copyright (c) 2016, Tetsuya Mori <t2y3141592@gmail.com>. All rights reserved.
}
}
panel.test = (base) => class FileLoadButtonTest extends base {
static get reconnectable() { return false; }
async operation() {
let self = this;
let button = self.panel.$.load;
Expand All @@ -150,6 +152,7 @@ Copyright (c) 2016, Tetsuya Mori <t2y3141592@gmail.com>. All rights reserved.
}
}
panel.test = (base) => class LocalesButtonTest extends base {
static get reconnectable() { return false; }
async operation() {
let self = this;
let button = Polymer.dom(self.panel.root).querySelector('paper-icon-button#locales');
Expand Down Expand Up @@ -193,6 +196,7 @@ Copyright (c) 2016, Tetsuya Mori <t2y3141592@gmail.com>. All rights reserved.
}
}
panel.test = (base) => class ReloadButtonTest extends base {
static get reconnectable() { return false; }
async operation() {
if (this.hasToSkip) { return; }
let self = this;
Expand Down

0 comments on commit 7349cf4

Please sign in to comment.