Skip to content

Commit 690838c

Browse files
committed
Make screenshot test more stable by waiting for ripple animation to finish
1 parent 5a8c8be commit 690838c

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

e2e/components/button/button.e2e.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {browser, by, element} from 'protractor';
1+
import {browser, by, element, ExpectedConditions} from 'protractor';
22
import {screenshot} from '../../screenshot';
33

44

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

1416
element(by.id('disable-toggle')).click();
1517
element(by.id('test-button')).click();
1618
expect(element(by.id('click-counter')).getText()).toEqual('1');
17-
screenshot('click disabled');
19+
browser.wait(ExpectedConditions.not(
20+
ExpectedConditions.presenceOf(element(by.css('div.mat-ripple-element')))))
21+
.then(() => screenshot('click disabled'));
1822
});
1923
});
20-
});
24+
});

e2e/components/checkbox/checkbox.e2e.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {browser, by, element, Key} from 'protractor';
1+
import {browser, by, element, Key, ExpectedConditions} from 'protractor';
22
import {screenshot} from '../../screenshot';
33

44
describe('checkbox', function () {
@@ -17,31 +17,39 @@ describe('checkbox', function () {
1717
checkboxEl.click();
1818
inputEl.getAttribute('checked').then((value: string) => {
1919
expect(value).toBeTruthy('Expect checkbox "checked" property to be true');
20+
browser.wait(ExpectedConditions.not(
21+
ExpectedConditions.presenceOf(element(by.css('div.mat-ripple-element')))))
22+
.then(() => screenshot('checked'));
2023
});
21-
screenshot('checked');
2224

2325
checkboxEl.click();
2426
inputEl.getAttribute('checked').then((value: string) => {
2527
expect(value).toBeFalsy('Expect checkbox "checked" property to be false');
28+
browser.wait(ExpectedConditions.not(
29+
ExpectedConditions.presenceOf(element(by.css('div.mat-ripple-element')))))
30+
.then(() => screenshot('unchecked'));
2631
});
27-
screenshot('unchecked');
2832
});
2933

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

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

3844
inputEl.sendKeys(Key.SPACE);
3945

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

4654
});
47-
});
55+
});

0 commit comments

Comments
 (0)