Skip to content

Commit

Permalink
Make screenshot test more stable by waiting for ripple animation to f…
Browse files Browse the repository at this point in the history
…inish
  • Loading branch information
tinayuangao committed Feb 15, 2017
1 parent 5a8c8be commit 37fcfe1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
10 changes: 7 additions & 3 deletions e2e/components/button/button.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {browser, by, element} from 'protractor';
import {browser, by, element, ExpectedConditions} from 'protractor';
import {screenshot} from '../../screenshot';


Expand All @@ -9,12 +9,16 @@ describe('button', () => {
it('should prevent click handlers from executing when disabled', () => {
element(by.id('test-button')).click();
expect(element(by.id('click-counter')).getText()).toEqual('1');
screenshot('clicked once');
browser.wait(ExpectedConditions.not(
ExpectedConditions.presenceOf(element(by.css('div.mat-ripple-element')))))
.then(() => screenshot('clicked once'));

element(by.id('disable-toggle')).click();
element(by.id('test-button')).click();
expect(element(by.id('click-counter')).getText()).toEqual('1');
screenshot('click disabled');
browser.wait(ExpectedConditions.not(
ExpectedConditions.presenceOf(element(by.css('div.mat-ripple-element')))))
.then(() => screenshot('click disabled'));
});
});
});
18 changes: 13 additions & 5 deletions e2e/components/checkbox/checkbox.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {browser, by, element, Key} from 'protractor';
import {browser, by, element, Key, ExpectedConditions} from 'protractor';
import {screenshot} from '../../screenshot';

describe('checkbox', function () {
Expand All @@ -17,29 +17,37 @@ describe('checkbox', function () {
checkboxEl.click();
inputEl.getAttribute('checked').then((value: string) => {
expect(value).toBeTruthy('Expect checkbox "checked" property to be true');
browser.wait(ExpectedConditions.not(
ExpectedConditions.presenceOf(element(by.css('div.mat-ripple-element')))))
.then(() => screenshot('checked'));
});
screenshot('checked');

checkboxEl.click();
inputEl.getAttribute('checked').then((value: string) => {
expect(value).toBeFalsy('Expect checkbox "checked" property to be false');
browser.wait(ExpectedConditions.not(
ExpectedConditions.presenceOf(element(by.css('div.mat-ripple-element')))))
.then(() => screenshot('unchecked'));
});
screenshot('unchecked');
});

it('should toggle the checkbox when pressing space', () => {
let inputEl = element(by.css('input[id=input-test-checkbox]'));

inputEl.getAttribute('checked').then((value: string) => {
expect(value).toBeFalsy('Expect checkbox "checked" property to be false');
screenshot('start');
browser.wait(ExpectedConditions.not(
ExpectedConditions.presenceOf(element(by.css('div.mat-ripple-element')))))
.then(() => screenshot('start'));
});

inputEl.sendKeys(Key.SPACE);

inputEl.getAttribute('checked').then((value: string) => {
expect(value).toBeTruthy('Expect checkbox "checked" property to be true');
screenshot('pressed space');
browser.wait(ExpectedConditions.not(
ExpectedConditions.presenceOf(element(by.css('div.mat-ripple-element')))))
.then(() => screenshot('pressed space'));
});
});

Expand Down

0 comments on commit 37fcfe1

Please sign in to comment.