Skip to content

Commit 8a92f79

Browse files
committed
implemented basic test cases
1 parent cbead47 commit 8a92f79

File tree

12 files changed

+370
-25
lines changed

12 files changed

+370
-25
lines changed

src/app/register/register.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="col-md-4 col-md-offset-4">
33
<div class="panel panel-default">
44
<div class="panel-heading">
5-
<h3 class="panel-title" id="forgot-password-title">
5+
<h3 class="panel-title" id="register-title">
66
Register
77
</h3>
88
<div>

test/e2e/authentication/forgot-password/forgotPassword.page.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Promise = webdriver.promise.Promise;
44
export class ForgotPasswordPageObject {
55

66
private form;
7+
private title;
78
private emailInput;
89
private submitButton;
910
private goToLoginLink;
@@ -13,6 +14,7 @@ export class ForgotPasswordPageObject {
1314

1415
// get the relevant elements
1516
this.form = element(by.id('forgot-password-form'));
17+
this.title = element(by.id('forgot-password-title'));
1618
this.emailInput = this.form.element(by.id('forgot-password-email'));
1719
this.submitButton = this.form.element(by.id('forgot-password-submit'));
1820

@@ -25,6 +27,10 @@ export class ForgotPasswordPageObject {
2527
return this.emailInput.clear().sendKeys(value);
2628
}
2729

30+
getTitle(): Promise<string> {
31+
return this.title.getText();
32+
}
33+
2834
submitForm(): Promise<void> {
2935
return this.submitButton.sendKeys(protractor.Key.ENTER);
3036
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,55 @@
1+
import { ForgotPasswordPageObject } from './forgotPassword.page';
2+
import { AuthenticationPageObject } from '../authentication.page';
13

4+
let testData = [
5+
{
6+
input: {
7+
email: ''
8+
},
9+
result: {
10+
valid: false
11+
}
12+
},
13+
{
14+
input: {
15+
email: 'samkwerri.be'
16+
},
17+
result: {
18+
valid: false
19+
}
20+
},
21+
{
22+
input: {
23+
email: 'sam@kwerri.be'
24+
},
25+
result: {
26+
valid: true
27+
}
28+
}
29+
];
30+
31+
describe('forgot password page', function () {
32+
33+
let pageObject = new ForgotPasswordPageObject();
34+
let authPageObject = new AuthenticationPageObject();
35+
36+
beforeEach(() => {
37+
authPageObject.goToForgotPasswordPage();
38+
});
39+
40+
it('should get the forgot password page', () => {
41+
expect(pageObject.getTitle()).toEqual('Forgot password');
42+
});
43+
44+
testData.forEach((test) => {
45+
46+
it('should validate the forgot password form (' + test.input.email + ')', () => {
47+
pageObject.setEmail(test.input.email);
48+
pageObject.submitForm();
49+
expect(pageObject.formIsValid()).toEqual(test.result.valid);
50+
});
51+
52+
});
53+
54+
55+
});

test/e2e/authentication/forgot-password/forgotPassword.steps.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import { AuthenticationPageObject } from '../authentication.page';
1111
@binding()
1212
class ForgotPasswordSteps {
1313

14-
private authenticationModule: AuthenticationPageObject = new AuthenticationPageObject();
15-
private loginPageObject: LoginPageObject = new LoginPageObject();
16-
private forgotPasswordPageObject: ForgotPasswordPageObject = new ForgotPasswordPageObject();
14+
private authenticationModule = new AuthenticationPageObject();
15+
private loginPageObject = new LoginPageObject();
16+
private forgotPasswordPageObject = new ForgotPasswordPageObject();
1717

1818
@given(/^user clicks the forgot password link$/)
1919
private givenUserClicksTheForgotPasswordLink(callback: CallbackStepDefinition) {

test/e2e/authentication/login/login.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,26 +49,26 @@ let testData = [
4949
}
5050
];
5151

52-
describe('todo App', function () {
52+
describe('login page', function () {
5353

54-
let page = new LoginPageObject();
55-
let authPage = new AuthenticationPageObject();
54+
let pageObject = new LoginPageObject();
55+
let authPageObject = new AuthenticationPageObject();
5656

5757
beforeEach(() => {
58-
authPage.goToLoginPage();
58+
authPageObject.goToLoginPage();
5959
});
6060

6161
it('should get the login page', () => {
62-
expect(page.getTitle()).toEqual('Login');
62+
expect(pageObject.getTitle()).toEqual('Login');
6363
});
6464

6565
testData.forEach((test) => {
6666

6767
it('should validate the login form (' + test.input.email + ',' + test.input.password + ')', () => {
68-
page.setEmail(test.input.email);
69-
page.setPassword(test.input.password);
70-
page.submitForm();
71-
expect(page.formIsValid()).toEqual(test.result.valid);
68+
pageObject.setEmail(test.input.email);
69+
pageObject.setPassword(test.input.password);
70+
pageObject.submitForm();
71+
expect(pageObject.formIsValid()).toEqual(test.result.valid);
7272
});
7373

7474
});

test/e2e/authentication/login/login.steps.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import { AuthenticationPageObject } from '../authentication.page';
1010
@binding()
1111
class LoginSteps {
1212

13-
private authenticationModule: AuthenticationPageObject = new AuthenticationPageObject();
14-
private loginPageObject: LoginPageObject = new LoginPageObject();
13+
private authenticationModule = new AuthenticationPageObject();
14+
private loginPageObject = new LoginPageObject();
1515

1616
@given(/^user clicks the login link$/)
1717
private givenUserClicksTheLoginLink(callback: CallbackStepDefinition) {

test/e2e/authentication/register/register.page.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Promise = webdriver.promise.Promise;
44
export class RegisterPageObject {
55

66
private form;
7+
private title;
78
private nameInput;
89
private emailInput;
910
private passwordInput;
@@ -16,6 +17,7 @@ export class RegisterPageObject {
1617

1718
// get the relevant elements
1819
this.form = element(by.id('register-form'));
20+
this.title = element(by.id('register-title'));
1921
this.nameInput = this.form.element(by.id('register-name'));
2022
this.emailInput = this.form.element(by.id('register-email'));
2123
this.passwordInput = this.form.element(by.id('register-password'));
@@ -43,6 +45,10 @@ export class RegisterPageObject {
4345
return this.repeatPasswordInput.clear().sendKeys(value);
4446
}
4547

48+
getTitle(): Promise<string> {
49+
return this.title.getText();
50+
}
51+
4652
submitForm(): Promise<void> {
4753
return this.submitButton.sendKeys(protractor.Key.ENTER);
4854
}
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,133 @@
1+
import { RegisterPageObject } from './register.page';
2+
import { AuthenticationPageObject } from '../authentication.page';
13

4+
let testData = [
5+
{
6+
input: {
7+
name: '',
8+
email: '',
9+
password: '',
10+
repeatPassword: ''
11+
},
12+
result: {
13+
valid: false
14+
}
15+
},
16+
{
17+
input: {
18+
name: 'Sam Vloeberghs',
19+
email: '',
20+
password: '',
21+
repeatPassword: ''
22+
},
23+
result: {
24+
valid: false
25+
}
26+
},
27+
{
28+
input: {
29+
name: 'Sam Vloeberghs',
30+
email: 'samkwerri',
31+
password: '',
32+
repeatPassword: ''
33+
},
34+
result: {
35+
valid: false
36+
}
37+
},
38+
{
39+
input: {
40+
name: '',
41+
email: 'sam@kwerri.be',
42+
password: '',
43+
repeatPassword: ''
44+
},
45+
result: {
46+
valid: false
47+
}
48+
},
49+
{
50+
input: {
51+
name: 'Sam Vloeberghs',
52+
email: 'sam@kwerri.be',
53+
password: '',
54+
repeatPassword: ''
55+
},
56+
result: {
57+
valid: false
58+
}
59+
},
60+
{
61+
input: {
62+
name: 'Sam Vloeberghs',
63+
email: 'sam@kwerri.be',
64+
password: '1234567',
65+
repeatPassword: ''
66+
},
67+
result: {
68+
valid: false
69+
}
70+
},
71+
{
72+
input: {
73+
name: 'Sam Vloeberghs',
74+
email: 'sam@kwerri.be',
75+
password: '',
76+
repeatPassword: '1234567'
77+
},
78+
result: {
79+
valid: false
80+
}
81+
},
82+
{
83+
input: {
84+
name: 'Sam Vloeberghs',
85+
email: 'sam@kwerri.be',
86+
password: '1234567',
87+
repeatPassword: '7654321'
88+
},
89+
result: {
90+
valid: false
91+
}
92+
},
93+
{
94+
input: {
95+
name: 'Sam Vloeberghs',
96+
email: 'sam@kwerri.be',
97+
password: '1234567',
98+
repeatPassword: '1234567'
99+
},
100+
result: {
101+
valid: true
102+
}
103+
}
104+
];
105+
106+
describe('register page', function () {
107+
108+
let pageObject = new RegisterPageObject();
109+
let authPageObject = new AuthenticationPageObject();
110+
111+
beforeEach(() => {
112+
authPageObject.goToRegisterPage();
113+
});
114+
115+
it('should get the register page', () => {
116+
expect(pageObject.getTitle()).toEqual('Register');
117+
});
118+
119+
testData.forEach((test) => {
120+
121+
it('should validate the register form (' + test.input.name + ',' + test.input.email + ',' + test.input.password+ ',' + test.input.repeatPassword + ')', () => {
122+
pageObject.setName(test.input.name);
123+
pageObject.setEmail(test.input.email);
124+
pageObject.setPassword(test.input.password);
125+
pageObject.setRepeatPassword(test.input.repeatPassword);
126+
pageObject.submitForm();
127+
expect(pageObject.formIsValid()).toEqual(test.result.valid);
128+
});
129+
130+
});
131+
132+
133+
});

test/e2e/authentication/register/register.steps.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import { AuthenticationPageObject } from '../authentication.page';
1111
@binding()
1212
class RegisterSteps {
1313

14-
private authenticationModule: AuthenticationPageObject = new AuthenticationPageObject();
15-
private loginPageObject: LoginPageObject = new LoginPageObject();
16-
private registerPageObject: RegisterPageObject = new RegisterPageObject();
14+
private authenticationModule = new AuthenticationPageObject();
15+
private loginPageObject = new LoginPageObject();
16+
private registerPageObject = new RegisterPageObject();
1717

1818
@given(/^user clicks the register link$/)
1919
private givenUserClicksTheLoginLink(callback: CallbackStepDefinition) {

test/e2e/authentication/set-new-password/setNewPassword.page.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Promise = webdriver.promise.Promise;
44
export class SetNewPasswordPageObject {
55

66
private form;
7+
private title;
78
private passwordInput;
89
private repeatPasswordInput;
910
private submitButton;
@@ -14,6 +15,7 @@ export class SetNewPasswordPageObject {
1415

1516
// get the relevant elements
1617
this.form = element(by.id('set-new-password-form'));
18+
this.title = element(by.id('set-new-password-title'));
1719
this.passwordInput = this.form.element(by.id('set-new-password-password'));
1820
this.repeatPasswordInput = this.form.element(by.id('set-new-password-repeat-password'));
1921
this.submitButton = this.form.element(by.id('set-new-password-submit'));
@@ -23,10 +25,6 @@ export class SetNewPasswordPageObject {
2325

2426
}
2527

26-
getPage(id?: string, nonce?: string): Promise<void> {
27-
return browser.get(`set-new-password?id=${id}&nonce=${nonce}`);
28-
}
29-
3028
setPassword(value: string): Promise<void> {
3129
return this.passwordInput.clear().sendKeys(value);
3230
}
@@ -35,6 +33,10 @@ export class SetNewPasswordPageObject {
3533
return this.repeatPasswordInput.clear().sendKeys(value);
3634
}
3735

36+
getTitle(): Promise<string> {
37+
return this.title.getText();
38+
}
39+
3840
submitForm(): Promise<void> {
3941
return this.submitButton.sendKeys(protractor.Key.ENTER);
4042
}

0 commit comments

Comments
 (0)