Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

Commit

Permalink
add e2e test for reset functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
raychenfj committed Jul 29, 2017
1 parent ab0d037 commit 40eddf5
Show file tree
Hide file tree
Showing 3 changed files with 156 additions and 121 deletions.
12 changes: 11 additions & 1 deletion config/protractor.conf.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const SpecReporter = require('jasmine-spec-reporter').SpecReporter;

//jshint strict: false
exports.config = {
directConnect: true,
Expand All @@ -18,7 +20,15 @@ exports.config = {
useAllAngular2AppRoots: true,

jasmineNodeOpts: {
defaultTimeoutInterval: 30000
defaultTimeoutInterval: 30000,
print () {}
},
onPrepare() {
jasmine.getEnv().addReporter(new SpecReporter({
spec: {
displayStacktrace: true
}
}));
}

};
262 changes: 142 additions & 120 deletions e2e/multi-picker.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,139 +1,161 @@
import {element, by, browser} from 'protractor';
import { element, by, browser } from 'protractor';

const SLEEP = 1000;
/**
* Multi Picker E2E Test
*/
describe('MultiPicker', () => {
beforeAll(() => {
{
browser.get('http://localhost:8100/');
}
});
beforeAll(() => {
{
browser.get('http://localhost:8100/');
}
});

/**
* Simple
*/
describe('Simple', () => {
it('should open picker', () => {
browser.sleep(SLEEP);
element(by.id('simple')).click();
})
/**
* Simple
*/
describe('Simple', () => {
it('should open picker', () => {
browser.sleep(SLEEP);
element(by.id('simple')).click();
})

it('should close picker', () => {
browser.sleep(SLEEP);
element.all(by.className('picker-button')).get(0).click();
})
it('should close picker', () => {
browser.sleep(SLEEP);
element.all(by.className('picker-button')).get(0).click();
})

it('should pick 2 1-2 1-1-2', () => {
browser.sleep(SLEEP);
element(by.id('simple')).click();
browser.sleep(SLEEP);
// Pick 2
element.all(by.className('picker-col')).get(0).all(by.className('picker-opt')).get(1).click();
// Pick 1-2
element.all(by.className('picker-col')).get(1).all(by.className('picker-opt')).get(1).click();
// Pick 1-1-2
element.all(by.className('picker-col')).get(2).all(by.className('picker-opt')).get(1).click();
browser.sleep(SLEEP);
// Click Done
element.all(by.className('picker-button')).get(1).click();
browser.sleep(SLEEP);
expect<any>(element(by.id('simple')).element(by.className('multi-picker-text')).getText()).toEqual('2 1-2 1-1-2');
});
it('should pick 2 1-2 1-1-2', () => {
browser.sleep(SLEEP);
element(by.id('simple')).click();
browser.sleep(SLEEP);
// Pick 2
element.all(by.className('picker-col')).get(0).all(by.className('picker-opt')).get(1).click();
// Pick 1-2
element.all(by.className('picker-col')).get(1).all(by.className('picker-opt')).get(1).click();
// Pick 1-1-2
element.all(by.className('picker-col')).get(2).all(by.className('picker-opt')).get(1).click();
browser.sleep(SLEEP);
// Click Done
element.all(by.className('picker-button')).get(1).click();
browser.sleep(SLEEP);
expect<any>(element(by.id('simple')).element(by.className('multi-picker-text')).getText()).toEqual('2 1-2 1-1-2');
});
});

/**
* Advanced
*/
describe('Advanced', () => {
it('should navigate to advanced', () => {
browser.sleep(SLEEP);
element.all(by.className('tab-button')).get(1).click();
})

it('should pick 2 2-2 2-2-2', () => {
browser.sleep(SLEEP);
element.all(by.id('advanced')).click();
browser.sleep(SLEEP);
//Pick 2
element.all(by.className('picker-col')).get(0).all(by.className('picker-opt')).get(1).click();
browser.sleep(SLEEP);
//Pick 2-2
element.all(by.className('picker-col')).get(1).all(by.className('picker-opt')).get(1).click();
browser.sleep(SLEEP);
//Pick 2-2-2
element.all(by.className('picker-col')).get(2).all(by.className('picker-opt')).get(1).click();
browser.sleep(SLEEP);
// Click Done
element.all(by.className('picker-button')).get(1).click();
browser.sleep(SLEEP);
expect<any>(element(by.id('advanced')).element(by.className('multi-picker-text')).getText()).toEqual('2 2-2 2-2-2');
})
/**
* Advanced
*/
describe('Advanced', () => {
it('should navigate to advanced', () => {
browser.sleep(SLEEP);
element.all(by.className('tab-button')).get(1).click();
})

it('should be disabled', () => {
browser.sleep(SLEEP);
element(by.className('multi-picke-disabled')).element(by.tagName('button')).click();
});
it('should pick 2 2-2 2-2-2', () => {
browser.sleep(SLEEP);
element.all(by.id('advanced')).click();
browser.sleep(SLEEP);
//Pick 2
element.all(by.className('picker-col')).get(0).all(by.className('picker-opt')).get(1).click();
browser.sleep(SLEEP);
//Pick 2-2
element.all(by.className('picker-col')).get(1).all(by.className('picker-opt')).get(1).click();
browser.sleep(SLEEP);
//Pick 2-2-2
element.all(by.className('picker-col')).get(2).all(by.className('picker-opt')).get(1).click();
browser.sleep(SLEEP);
// Click Done
element.all(by.className('picker-button')).get(1).click();
browser.sleep(SLEEP);
expect<any>(element(by.id('advanced')).element(by.className('multi-picker-text')).getText()).toEqual('2 2-2 2-2-2');
})

it('should have default value 1 1-2 1-2-2', () => {
browser.sleep(SLEEP);
expect<any>(element(by.id('default')).element(by.className('multi-picker-text')).getText()).toEqual('1 1-2 1-2-2');
});
it('should be disabled', () => {
browser.sleep(SLEEP);
element(by.className('multi-picke-disabled')).element(by.tagName('button')).click();
});

it('should have default value Melon', () => {
browser.sleep(SLEEP);
expect<any>(element(by.id('fruit')).element(by.className('multi-picker-text')).getText()).toEqual('Melon');
});
it('should have default value 1 1-2 1-2-2', () => {
browser.sleep(SLEEP);
expect<any>(element(by.id('default')).element(by.className('multi-picker-text')).getText()).toEqual('1 1-2 1-2-2');
});

it('should pick Banana', () => {
browser.sleep(SLEEP);
element(by.id('fruit')).click();
browser.sleep(SLEEP);
// Pick Banana
element.all(by.className('picker-col')).get(0).all(by.className('picker-opt')).get(3).click();
browser.sleep(SLEEP);
// Click Done
element.all(by.className('picker-button')).get(1).click();
browser.sleep(SLEEP);
expect<any>(element(by.id('fruit')).element(by.className('multi-picker-text')).getText()).toEqual('Banana');
});
it('should have default value Melon', () => {
browser.sleep(SLEEP);
expect<any>(element(by.id('fruit')).element(by.className('multi-picker-text')).getText()).toEqual('Melon');
});

it('should pick 2 2-1 1-2-2',()=>{
browser.sleep(SLEEP);
// Default value
expect<any>(element(by.id('separator')).element(by.className('multi-picker-text')).getText()).toEqual('1_1-2_1-2-1');
element(by.id('separator')).click();
browser.sleep(SLEEP);
// Pick 2
element.all(by.className('picker-col')).get(0).all(by.className('picker-opt')).get(1).click();
// Pick 2-1
element.all(by.className('picker-col')).get(1).all(by.className('picker-opt')).get(2).click();
// Pick 1-2-2
element.all(by.className('picker-col')).get(2).all(by.className('picker-opt')).get(3).click();
// Pick Done
element.all(by.className('picker-button')).get(1).click();
browser.sleep(SLEEP);
expect<any>(element(by.id('separator')).element(by.className('multi-picker-text')).getText()).toEqual('2_2-1_1-2-2');
});
it('should pick Banana', () => {
browser.sleep(SLEEP);
element(by.id('fruit')).click();
browser.sleep(SLEEP);
// Pick Banana
element.all(by.className('picker-col')).get(0).all(by.className('picker-opt')).get(3).click();
browser.sleep(SLEEP);
// Click Done
element.all(by.className('picker-button')).get(1).click();
browser.sleep(SLEEP);
expect<any>(element(by.id('fruit')).element(by.className('multi-picker-text')).getText()).toEqual('Banana');
});

it('should pick 2-2-2 2-2 2', () => {
browser.sleep(SLEEP);
element(by.id('parent')).click();
browser.sleep(SLEEP);
// Pick 2
element.all(by.className('picker-col')).get(2).all(by.className('picker-opt')).get(1).click();
browser.sleep(SLEEP);
// Pick 2-2
element.all(by.className('picker-col')).get(1).all(by.className('picker-opt')).get(1).click();
browser.sleep(SLEEP);
// Pick 2-2-2
element.all(by.className('picker-col')).get(0).all(by.className('picker-opt')).get(1).click();
browser.sleep(SLEEP);
// Pick Done
element.all(by.className('picker-button')).get(1).click();
browser.sleep(SLEEP);
expect<any>(element(by.id('parent')).element(by.className('multi-picker-text')).getText()).toEqual('2-2-2 2-2 2');
})
it('should pick 2 2-1 1-2-2', () => {
browser.sleep(SLEEP);
// Default value
expect<any>(element(by.id('separator')).element(by.className('multi-picker-text')).getText()).toEqual('1_1-2_1-2-1');
element(by.id('separator')).click();
browser.sleep(SLEEP);
// Pick 2
element.all(by.className('picker-col')).get(0).all(by.className('picker-opt')).get(1).click();
// Pick 2-1
element.all(by.className('picker-col')).get(1).all(by.className('picker-opt')).get(2).click();
// Pick 1-2-2
element.all(by.className('picker-col')).get(2).all(by.className('picker-opt')).get(3).click();
// Click Done
element.all(by.className('picker-button')).get(1).click();
browser.sleep(SLEEP);
expect<any>(element(by.id('separator')).element(by.className('multi-picker-text')).getText()).toEqual('2_2-1_1-2-2');
});

it('should pick 2-2-2 2-2 2', () => {
browser.sleep(SLEEP);
element(by.id('parent')).click();
browser.sleep(SLEEP);
// Pick 2
element.all(by.className('picker-col')).get(2).all(by.className('picker-opt')).get(1).click();
browser.sleep(SLEEP);
// Pick 2-2
element.all(by.className('picker-col')).get(1).all(by.className('picker-opt')).get(1).click();
browser.sleep(SLEEP);
// Pick 2-2-2
element.all(by.className('picker-col')).get(0).all(by.className('picker-opt')).get(1).click();
browser.sleep(SLEEP);
// Click Done
element.all(by.className('picker-button')).get(2).click();
browser.sleep(SLEEP);
expect<any>(element(by.id('parent')).element(by.className('multi-picker-text')).getText()).toEqual('2-2-2 2-2 2');
})

it('should reset picker', () => {
browser.sleep(SLEEP);
element(by.id('parent')).click();
browser.sleep(SLEEP);
// Pick 1
element.all(by.className('picker-col')).get(2).all(by.className('picker-opt')).get(0).click();
browser.sleep(SLEEP);
// Pick 1-1
element.all(by.className('picker-col')).get(1).all(by.className('picker-opt')).get(0).click();
browser.sleep(SLEEP);
// Pick 1-1-1
element.all(by.className('picker-col')).get(0).all(by.className('picker-opt')).get(0).click();
browser.sleep(SLEEP);
// Click Reset
element.all(by.className('picker-toolbar-multi-picker-reset')).get(0).click()
browser.sleep(SLEEP);
// Click Done
element.all(by.className('picker-button')).get(2).click();
browser.sleep(SLEEP);
expect<any>(element(by.id('parent')).element(by.className('multi-picker-text')).getText()).toEqual('2-2-2 2-2 2');
})
});
});
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@
"gulp-watch": "4.3.11",
"html-loader": "^0.4.0",
"html-webpack-plugin": "^2.8.1",
"install": "^0.10.1",
"ionic-angular": "3.0.1",
"ionicons": "3.0.0",
"istanbul-instrumenter-loader": "^0.2.0",
"jasmine": "^2.5.2",
"jasmine-spec-reporter": "^4.1.1",
"json-loader": "^0.5.3",
"karma": "^1.3.0",
"karma-chrome-launcher": "^2.0.0",
Expand All @@ -58,6 +60,7 @@
"karma-spec-reporter": "0.0.26",
"karma-webpack": "1.8.0",
"node-sass": "^4.5.2",
"npm": "^5.3.0",
"null-loader": "^0.1.1",
"phantomjs-prebuilt": "^2.1.13",
"postcss-loader": "^1.1.0",
Expand Down

0 comments on commit 40eddf5

Please sign in to comment.