Skip to content

Commit

Permalink
Added visual tests for Material theme.
Browse files Browse the repository at this point in the history
  • Loading branch information
sohrabtaee authored and tomivirkki committed Sep 3, 2018
1 parent e0d1949 commit 9a02fc8
Show file tree
Hide file tree
Showing 23 changed files with 59 additions and 44 deletions.
7 changes: 5 additions & 2 deletions test/visual/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
<meta charset="UTF-8">

<script src="../../../webcomponentsjs/webcomponents-lite.js"></script>
<link href="../../vaadin-date-picker.html" rel="import">
<script>
const theme = window.location.search.replace(/.*theme=(\w+).*/, '$1') || 'lumo';
document.write(`<link rel="import" href="../../theme/${theme}/vaadin-date-picker.html">`);
</script>
</head>

<body>
Expand All @@ -29,4 +32,4 @@
<vaadin-date-picker value="1991-12-20"></vaadin-date-picker>
</div>

</body>
</body>
26 changes: 18 additions & 8 deletions test/visual/dropdown.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
</template>
</dom-module>

<link href="../../vaadin-date-picker.html" rel="import">
<script>
const theme = window.location.search.replace(/.*theme=(\w+).*/, '$1') || 'lumo';
document.write(`<link rel="import" href="../../theme/${theme}/vaadin-date-picker.html">`);
</script>
</head>

<body style="height: 100vh;">
Expand All @@ -43,22 +46,29 @@
<vaadin-date-picker min="2017-06-10" max="2017-06-29" initial-position="2017-06-15" id="date-limit"></vaadin-date-picker>

<br>Week numbers
<vaadin-date-picker show-week-numbers id="weeks" initial-position="2018-04-28"></vaadin-date-picker>
<vaadin-date-picker show-week-numbers id="weeks" initial-position="2018-04-28"></vaadin-date-picker>
</div>

<script>
var datePickers = document.querySelectorAll('vaadin-date-picker');

window.addEventListener('WebComponentsReady', function() {
var datepicker = document.querySelector('vaadin-date-picker#weeks');
datepicker.set('i18n.firstDayOfWeek', 1);
const weeksDatepicker = document.querySelector('vaadin-date-picker#weeks');
weeksDatepicker.set('i18n.firstDayOfWeek', 1);

[].forEach.call(datePickers, function(datePicker) {
datePicker.$.input.addEventListener('focus', function(e) {
// Make sure the input doesn't have a blinking caret that might fail the test
e.target.blur();
});
});
});

function closeDatePickers() {
var datePickers = document.querySelectorAll('vaadin-date-picker');

[].forEach.call(datePickers, function(datePicker) {
datePicker.close();
datePicker.close && datePicker.close();
});
}
</script>

</body>
</body>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 36 additions & 34 deletions test/visual/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,43 @@ gemini.suite('vaadin-date-picker', function(rootSuite) {
.before(wait)
.after(goToAboutBlank);

gemini.suite('default-tests', function(suite) {
suite
.setUrl('default.html')
.setCaptureElements('#default-tests')
.capture('default');
});
['lumo', 'material'].forEach(theme => {
gemini.suite(`default-tests-${theme}`, function(suite) {
suite
.setUrl(`default.html?theme=${theme}`)
.setCaptureElements('#default-tests')
.capture('default');
});

gemini.suite('dropdown', function(suite) {
suite
.setUrl('dropdown.html')
.setCaptureElements('body')
.capture('default', function(actions) {
actions.executeJS(function(window) {
window.closeDatePickers();
window.document.querySelector('#plain').open();
});
})
.capture('selected-value', function(actions) {
actions.executeJS(function(window) {
window.closeDatePickers();
window.document.querySelector('#selected-value').open();
gemini.suite(`dropdown-${theme}`, function(suite) {
suite
.setUrl(`dropdown.html?theme=${theme}`)
.setCaptureElements('body')
.capture('default', function(actions) {
actions.executeJS(function(window) {
window.closeDatePickers();
window.document.querySelector('#plain').open();
});
})
.capture('selected-value', function(actions) {
actions.executeJS(function(window) {
window.closeDatePickers();
window.document.querySelector('#selected-value').open();
});
})
.capture('date-limit', function(actions) {
actions.executeJS(function(window) {
window.closeDatePickers();
window.document.querySelector('#date-limit').open();
});
})
.capture('week-numbers', function(actions) {
actions.executeJS(function(window) {
window.closeDatePickers();
window.document.querySelector('#weeks').open();
});
});
})
.capture('date-limit', function(actions) {
actions.executeJS(function(window) {
window.closeDatePickers();
window.document.querySelector('#date-limit').open();
});
})
.capture('week-numbers', function(actions) {
actions.executeJS(function(window) {
window.closeDatePickers();
window.document.querySelector('#weeks').open();
});
});
});
});

});
});

0 comments on commit 9a02fc8

Please sign in to comment.