Created
November 16, 2013 01:14
-
-
Save swarut/7494523 to your computer and use it in GitHub Desktop.
Sign in view controller spec.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// SignInViewControllerSpecs.m | |
// Taskworld | |
// | |
// Created by Warut Surapat on 11/8/13. | |
// Copyright 2013 Taskworld. All rights reserved. | |
// | |
#import "Kiwi.h" | |
#import "KIFUITestActor+TWTester.h" | |
#import "TWTestConstants.h" | |
SPEC_BEGIN(SignInViewControllerSpecs) | |
describe(@"Login page", ^{ | |
__block NSString* invalidEmail = @"[email protected]"; | |
__block NSString* invalidPassword = @"asd1"; | |
beforeAll(^{ | |
[tester navigateToLoginPage]; | |
}); | |
it(@"has a correct page title", ^{ | |
[[[tester currentPageTitle] should] equal:T(@"sign_in_bar_sign_in")]; | |
}); | |
it(@"has the email field",^{ | |
[[tester waitForViewWithAccessibilityLabel:EmailTextFieldLabel] shouldNotBeNil]; | |
}); | |
it(@"has the password field", ^{ | |
[[tester waitForViewWithAccessibilityLabel:PasswordTextFieldLabel] shouldNotBeNil]; | |
}); | |
it(@"has the forgot password link", ^{ | |
[[tester waitForViewWithAccessibilityLabel:ForgotPasswordLabel] shouldNotBeNil]; | |
}); | |
describe(@"User authorization", ^{ | |
__block UIButton* loginButton = nil; | |
describe(@"Log in form", ^{ | |
beforeAll(^{ | |
loginButton = (UIButton*)[tester waitForViewWithAccessibilityLabel:LogInButtonLabel]; | |
}); | |
beforeEach(^{ | |
[tester clearTextFieldWithLabel:EmailTextFieldLabel]; | |
[tester clearTextFieldWithLabel:PasswordTextFieldLabel]; | |
}); | |
it(@"disables login button by default", ^{ | |
[[@(loginButton.isEnabled) should] equal:@(NO)]; | |
}); | |
context(@"with invalid email", ^{ | |
it(@"does not allow user to log in", ^{ | |
[tester enterText:invalidEmail intoViewWithAccessibilityLabel:EmailTextFieldLabel]; | |
[[theValue(loginButton.isEnabled) should] equal:theValue(NO)]; | |
}); | |
}); | |
context(@"with invalid password", ^{ | |
it(@"does not allow user to log in", ^{ | |
[tester enterText:invalidPassword intoViewWithAccessibilityLabel:PasswordTextFieldLabel]; | |
[[theValue(loginButton.isEnabled) should] equal:theValue(NO)]; | |
}); | |
}); | |
context(@"with invalid email and invalid password", ^{ | |
it(@"does not allow user to log in", ^{ | |
[tester enterText:invalidEmail intoViewWithAccessibilityLabel:EmailTextFieldLabel]; | |
[tester enterText:invalidPassword intoViewWithAccessibilityLabel:PasswordTextFieldLabel]; | |
[[theValue(loginButton.isEnabled) should] equal:theValue(NO)]; | |
}); | |
}); | |
context(@"with valid email and password", ^{ | |
it(@"allows user to login", ^{ | |
[tester enterText:TestUserEmail intoViewWithAccessibilityLabel:EmailTextFieldLabel]; | |
[tester enterText:TestUserPassword intoViewWithAccessibilityLabel:PasswordTextFieldLabel]; | |
[[theValue(loginButton.isEnabled) should] equal:theValue(YES)]; | |
}); | |
}); | |
context(@"with incorrect credential", ^{ | |
it(@"shows alert message", ^{ | |
// Pending | |
}); | |
}); | |
context(@"with correct credential" , ^{ | |
it(@"navigates user to task feed page", ^{ | |
[tester enterText:TestUserEmail intoViewWithAccessibilityLabel:EmailTextFieldLabel]; | |
[tester enterText:TestUserPassword intoViewWithAccessibilityLabel:PasswordTextFieldLabel]; | |
[tester tapViewWithAccessibilityLabel:LogInButtonLabel]; | |
[[[tester currentPageTitle] should] equal:T(@"task_feed_feed_nav_title")]; | |
// logout | |
[tester logout]; | |
}); | |
}); | |
}); | |
describe(@"Password recovery", ^{ | |
__block UITextField* forgotPasswordTextField = nil; | |
__block UIButton* submitButton = nil; | |
beforeAll(^{ | |
[tester navigateToLoginPage]; | |
[tester tapViewWithAccessibilityLabel:ForgotPasswordLabel]; | |
forgotPasswordTextField = (UITextField*)[tester | |
waitForViewWithAccessibilityLabel:ForgotPasswordTextFieldLabel]; | |
forgotPasswordTextField.text = @""; | |
}); | |
it(@"shows forgot password dialog", ^{ | |
[forgotPasswordTextField shouldNotBeNil]; | |
// With some reasons, uialertview instance can not be detected. | |
// UIAlertView* forgotPasswordAlertView = | |
// (UIAlertView*)[tester waitForViewWithAccessibilityLabel:@"forgot_password_alert_view"]; | |
// [forgotPasswordAlertView shouldNotBeNil]; | |
}); | |
describe(@"Password recovery form", ^{ | |
context(@"with invalid email", ^{ | |
it(@" does not allow user to submit", ^{ | |
// Pending | |
}); | |
}); | |
context(@"with valid email", ^{ | |
it(@"allows user to submit", ^{ | |
// Pending | |
}); | |
it(@"shows error message if email was not in the system", ^{ | |
// Pending | |
}); | |
it(@"shows successful message if email was in the system", ^{ | |
// Pending | |
}); | |
}); | |
}); | |
}); | |
}); | |
}); | |
SPEC_END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment