Skip to content

Commit

Permalink
Merge pull request #267 from Neovici/feature/NEOV-295-chrome-74-tests
Browse files Browse the repository at this point in the history
Feature/neov 295 chrome 74 tests
  • Loading branch information
nomego authored Mar 16, 2019
2 parents 70516cf + 698191c commit 6f32844
Show file tree
Hide file tree
Showing 31 changed files with 1,254 additions and 1,219 deletions.
13 changes: 9 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ addons:
sources:
- google-chrome
packages:
- google-chrome-stable
- google-chrome-unstable

cache:
yarn: true
Expand All @@ -22,16 +22,21 @@ cache:
env:
global:
- CC_TEST_REPORTER_ID=a061a568c2b58fab68f6fad8d19fa398b5ea29d701348e69716e4f48132fc4c3
- NEO_CC_URL=https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64
- NEO_CC=$HOME/cc/cc-test-reporter
- SAUCE_USERNAME=nomego
- secure: UBpSMi2Omci2y1vCF05pwG6QSDz1YkQDzxcW01SRk8auNegwEXW7O9Sclhipz+hRTt3x6yl+P3/rIimc5N2NHEfujjImz8SAP8pdD70CJyNBqQ+96JYY6MpqbmIwq5A7EfcmErzhkVt9/85APqWIGirtoc4oIF3g+OL05tY5L4CKvjs04wBT+J25aX6MlDukm7aVL7jy5byMU6U3IjuP8HzeHvzjG4o6gpWYqIRE4KG+W6swLsI4IWApO2PJZrIsUB4662XGMYO+ElowgnoVlYMtL9BxVxPymJUguivHtEhA5FO9BjW6ah/dOov7P55Ca0mALLACqKwJNk5ub4uHvD4VbMx10T5V6s5vXHoJ1fdGJ9R5JLQjhoeDO6S6v/hhSkK3sUqa8AUpymvmys3tjlh4iglGrsYzTtku9TmgEC1l0t8kEhrA7oedCH199LHZ5616hJHjWY5xZwmYrObakmyuB/xBa88qOzpfJvCX1XUDQfano6Vds1mODDAIUr1pQmoBjoGD5k4PSrKquAIVXHgbIlBlpgttNeLlq5TyPsXxigSNRtenr4c92WQAo8dboFfREbJ6WxE7QUaJ2j6HMFtbwCuA0Cag+EmjvZwWoI28vE0vpCePbSBsk+g88vbzI0v0ovKx4F8k+F55zMkukNgDAV7eASiNhFGAVOrQzgo=
- NEO_CC_URL=https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64
- NEO_CC=$HOME/cc/cc-test-reporter
- SELENIUM_OVERRIDES_CONFIG=$TRAVIS_BUILD_DIR/selenium-overrides.js
- LAUNCHPAD_CHROME=/usr/bin/google-chrome-unstable
- TZ=Europe/Stockholm

before_script:
- yarn lint
- ([[ -e $NEO_CC ]] || curl -L $NEO_CC_URL > $NEO_CC) && chmod +x $NEO_CC
- $NEO_CC before-build

script:
- yarn test
- yarn test $([ -z "$SAUCE_ACCESS_KEY"] && echo "--skip-plugin sauce")
- $NEO_CC after-build --exit-code $TRAVIS_TEST_RESULT

notifications:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cosmoz-omnitable
=================

[![Build Status](https://travis-ci.org/Neovici/cosmoz-omnitable.svg?branch=master)](https://travis-ci.org/Neovici/cosmoz-omnitable)
[![Build Status](https://travis-ci.com/Neovici/cosmoz-omnitable.svg?branch=master)](https://travis-ci.com/Neovici/cosmoz-omnitable)
[![Maintainability](https://api.codeclimate.com/v1/badges/6b16292868f47977eee2/maintainability)](https://codeclimate.com/github/Neovici/cosmoz-omnitable/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/6b16292868f47977eee2/test_coverage)](https://codeclimate.com/github/Neovici/cosmoz-omnitable/test_coverage)
43 changes: 41 additions & 2 deletions cosmoz-omnitable-column-date-mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,31 @@
if (value == null || value === '') {
return;
}
const date = value instanceof Date ? value : new Date(value);

// convert value to Date
let date = value;
if (!(date instanceof Date)) {
// if the value is an ISO string, make sure that it has an explicit timezone
if (typeof value === 'string') {
date = this.getAbsoluteISOString(date);
}

date = new Date(date);
}

if (Number.isNaN(date.getTime())) {
return null;
}

if (limitFunc == null || limit == null) {
return date;
}
let lDate = this.toDate(limit);

const lDate = this.toDate(limit);
if (lDate == null) {
return date;
}

const comparableDate = this.getComparableValue(date),
comparableLDate = this.getComparableValue(lDate),
limitedValue = limitFunc(comparableDate, comparableLDate);
Expand Down Expand Up @@ -128,6 +142,31 @@
return this.renderValue(value, formatter);
}

/**
* Computes the local timezone and adds it to a local ISO string
* @param {String} localISOString an ISO date string, without timezone info
* @return {String} an ISO date string, with timezone info
*/
getAbsoluteISOString(localISOString) {
// Most browsers use local timezone when no timezone is specified
// but Safari uses UTC, so we set it implicitly
// TODO: Consider removing this when/if Safari handles local timezone correctly
if (localISOString.length === 19) {
return localISOString + this._getTimezoneString(localISOString);
}
return localISOString;
}

/**
* Calculates the local timezone offset and formats it to ISO Timezone string.
* @param {String} localISOString an ISO date string
* @return {String} the ISO timezone
*/
_getTimezoneString(localISOString) {
const off = -new Date(localISOString).getTimezoneOffset() / 60;
return (off < 0 ? '-' : '+') + ['0', Math.abs(off)].join('').substr(-2) + ':00';
}

renderValue(value, formatter = this.formatter) {
if (formatter == null) {
return;
Expand Down
7 changes: 5 additions & 2 deletions cosmoz-omnitable-column-time.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,11 @@ <h3 style="margin: 0;">[[ title ]]</h3>
* @returns {Date|void} Value converted to date optionaly limitated
*/
toDate(value, limit, limitFunc) {
// Most browsers use local timezone when no timezone is specified
// but Safari uses UTC, so we set it implicitly
// TODO: Consider removing this when/if Safari handles local timezone correctly
const date = typeof value === 'string' && value.length > 3 && value.length <= 9
? this._fixedDate + 'T' + value
? this.getAbsoluteISOString(this._fixedDate + 'T' + value)
: value;
return super.toDate(date, limit, limitFunc);
}
Expand Down Expand Up @@ -142,7 +145,7 @@ <h3 style="margin: 0;">[[ title ]]</h3>
if (value == null) {
return;
}
value = this.toValue(this._fixedDate + 'T' + value);
value = this.toValue(this.getAbsoluteISOString(this._fixedDate + 'T' + value));
if (value == null) {
return;
}
Expand Down
31 changes: 15 additions & 16 deletions demo/ajax-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,26 +74,25 @@ <h3>Cosmoz omnitable demo</h3>
</template>

<script type="text/javascript">
/*global window */
(function () {
'use strict';
var t = document.getElementById('t');
(function () {
'use strict';
var t = document.getElementById('t');

t.getEyeColorSearch = function (query) {
return {
q: query
t.getEyeColorSearch = function (query) {
return {
q: query
};
};
};

t.getSearchParams = function (filterSplice) {
if (!filterSplice) {
return;
}
return {
eyeColor: filterSplice.indexSplices[0].object
t.getSearchParams = function (filterSplice) {
if (!filterSplice) {
return;
}
return {
eyeColor: filterSplice.indexSplices[0].object
};
};
};
}());
}());
</script>
</body>
</html>
96 changes: 47 additions & 49 deletions demo/custom-template-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,65 +87,63 @@ <h3>Cosmoz omnitable templates demo</h3>
</x-page>

<script type="text/javascript">
/*global document, window, Cosmoz, Polymer */
(function () {
'use strict';


Polymer({
is: 'x-page',

properties: {
data: {
type: Array
},
selectedItems: {
type: Array
},
locale: {
type: String,
value: null
(function () {
'use strict';

Polymer({
is: 'x-page',

properties: {
data: {
type: Array
},
selectedItems: {
type: Array
},
locale: {
type: String,
value: null
},
customDataTemplate: {
type: Object
}
},
customDataTemplate: {
type: Object
}
},

behaviors: [
Cosmoz.TableDemoBehavior
],
behaviors: [
Cosmoz.TableDemoBehavior
],

ready() {
//this.changeData();
},
ready() {
//this.changeData();
},

attached() {
var data = this.generateTableDemoData(10, 11, 25);
this.async(() => {
this.data = data;
}, 100);
this.customDataTemplate = Polymer.dom(this).querySelector('#customDataTemplate');
attached() {
var data = this.generateTableDemoData(10, 11, 25);
this.async(() => {
this.data = data;
}, 100);
this.customDataTemplate = Polymer.dom(this).querySelector('#customDataTemplate');

},
},

changeData() {
this.data = this.generateTableDemoData(10, 11, 10);
},
changeData() {
this.data = this.generateTableDemoData(10, 11, 10);
},

emptyData() {
this.data = [];
},
emptyData() {
this.data = [];
},

onTap(event) {
console.log('onTap', event);
},
onTap(event) {
console.log('onTap', event);
},

_customFunction(item) {
return 'bla ' + item.id + ' bla';
}
_customFunction(item) {
return 'bla ' + item.id + ' bla';
}

});
}());
});
}());

</script>
</body>
Expand Down
Loading

0 comments on commit 6f32844

Please sign in to comment.