Skip to content

test: fix slide-toggle e2e failures #12699

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 16, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 9 additions & 19 deletions e2e/components/slide-toggle-e2e.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {browser, element, by, Key, ExpectedConditions} from 'protractor';
import {browser, element, by, Key} from 'protractor';
import {expectToExist} from '../util/index';


Expand All @@ -13,59 +13,49 @@ describe('slide-toggle', () => {
});

it('should change the checked state on click', async () => {
let inputEl = getInput();
const inputEl = getInput();

expect(inputEl.getAttribute('checked')).toBeFalsy('Expect slide-toggle to be unchecked');

getNormalToggle().click();

expect(inputEl.getAttribute('checked')).toBeTruthy('Expect slide-toggle to be checked');

await browser.wait(ExpectedConditions.not(
ExpectedConditions.presenceOf(element(by.css('div.mat-ripple-element')))));
});

it('should change the checked state on click', async () => {
let inputEl = getInput();
const inputEl = getInput();

expect(inputEl.getAttribute('checked')).toBeFalsy('Expect slide-toggle to be unchecked');

getNormalToggle().click();

expect(inputEl.getAttribute('checked')).toBeTruthy('Expect slide-toggle to be checked');
await browser.wait(ExpectedConditions.not(
ExpectedConditions.presenceOf(element(by.css('div.mat-ripple-element')))));
});

it('should not change the checked state on click when disabled', async () => {
let inputEl = getInput();
const inputEl = getInput();

expect(inputEl.getAttribute('checked')).toBeFalsy('Expect slide-toggle to be unchecked');

element(by.css('#disabled-slide-toggle')).click();

expect(inputEl.getAttribute('checked')).toBeFalsy('Expect slide-toggle to be unchecked');
await browser.wait(ExpectedConditions.not(
ExpectedConditions.presenceOf(element(by.css('div.mat-ripple-element')))));
});

it('should move the thumb on state change', async () => {
let slideToggleEl = getNormalToggle();
let thumbEl = element(by.css('#normal-slide-toggle .mat-slide-toggle-thumb-container'));
let previousPosition = await thumbEl.getLocation();
const slideToggleEl = getNormalToggle();
const thumbEl = element(by.css('#normal-slide-toggle .mat-slide-toggle-thumb-container'));
const previousPosition = await thumbEl.getLocation();

slideToggleEl.click();

let position = await thumbEl.getLocation();
const position = await thumbEl.getLocation();

expect(position.x).not.toBe(previousPosition.x);

await browser.wait(ExpectedConditions.not(
ExpectedConditions.presenceOf(element(by.css('div.mat-ripple-element')))));
});

it('should toggle the slide-toggle on space key', () => {
let inputEl = getInput();
const inputEl = getInput();

expect(inputEl.getAttribute('checked')).toBeFalsy('Expect slide-toggle to be unchecked');

Expand Down