Skip to content

Adds automated test for manual phone sign-in #376

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 4 commits into from
Oct 17, 2017

Conversation

Ivan164
Copy link
Contributor

@Ivan164 Ivan164 commented Oct 13, 2017

Added automation for phone manual test.

@@ -428,6 +428,11 @@
*/
static NSString *const kAutoAccountLinking = @"Link with Google";

/** @var kAutoPhoneNumberSignIn
@brief The button title for automated account linking.
Copy link
Contributor Author

@Ivan164 Ivan164 Oct 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix indentation on next push.

@@ -680,7 +685,7 @@ - (void)updateTable {
action:^{ [weakSelf linkPhoneNumber]; }],
[StaticContentTableViewCell cellWithTitle:kUnlinkPhoneNumber
action:^{
[weakSelf unlinkFromProvider:FIRPhoneAuthProviderID];
[weakSelf unlinkFromProvider:FIRPhoneAuthProviderID completion:nil];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no indentation is needed here.

@@ -428,6 +428,11 @@
*/
static NSString *const kAutoAccountLinking = @"Link with Google";

/** @var kAutoPhoneNumberSignIn
@brief The button title for automated account linking.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "brief" should be related to Phone Number Sign In and not account linking.

[self logFailedTest:@"Could not update phone number."];
}
[self logSuccess:@"update phone number test succeeded."];
[self unlinkFromProvider:FIRPhoneAuthProviderID completion:^ {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove space after "^"

@@ -2050,14 +2107,15 @@ - (void)showEmailPasswordDialogWithCompletion:(ShowEmailPasswordDialogCompletion
@brief Unlinks the current user from the provider with the specified provider ID.
@param provider The provider ID of the provider to unlink the current user's account from.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add "completion" parameter to this comment block, please make sure this is added to all the functions where you added a completion.

Example:
@param completion A completion block to be executed after the provider is unlinked.

@param phoneNumber Number pass in string for automation.
*/
- (void)signInWithPhoneNumberRecaptchaWithString:(NSString *_Nullable)phoneNumber
completion:(void(^)(NSError *_Nullable))completion {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please align ":" by indenting this line.

@brief Allows sign in with phone number using reCAPTCHA and completion.
@param phoneNumber Number pass in string for automation.
*/
- (void)signInWithPhoneNumberRecaptchaWithString:(NSString *_Nullable)phoneNumber
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer the name signInWithPhoneNumber:(NSString *_Nullable)phoneNumber
completion:(void(^)(NSError *_Nullable))completion...

The reasons are:

  • ReCAPTCHA is now the correct way to sign in with phone number so it is no longer a special case.
  • We try out best to make sure the last part of the function name is the name of the actual variable (starting with a lowercase character);
    Example:
    - (void) doSomethingWithSomethingElse:(NSString *)somethingElse;

Notice that the SomethingElse at the end of the function name matches the "somethingelse" which is the variable name.

Same for other functions (update, link).

@param phoneNumber Number pass in string for automation.
*/
- (void)linkPhoneNumberWithString:(NSString *_Nullable)phoneNumber
completion:(void(^)(void))completion{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

align ":"

@@ -2653,13 +2725,27 @@ - (void)linkPhoneNumber {
return;
}
[self logSuccess:@"link phone number succeeded."];
if (completion) completion();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As convention we use curly braces for conditionals even when unnecessary.

if (completion) {
  completion();
}

@param phoneNumber Number pass in string for automation.
*/
- (void)linkPhoneNumberWithString:(NSString *_Nullable)phoneNumber
completion:(void(^)(void))completion{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The completion should take an error parameter just like signInWithPhoneNumberRecaptchaWithString.

[self hideSpinner:^{
if (error) {
[self logFailure:@"failed to send verification code" error:error];
[self showMessagePrompt:error.localizedDescription];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case of error, you need to call the completion block with the error before returning.

Example:

completion(error);
return;

Copy link
Contributor

@protocol86 protocol86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future please reply to comment indicating that they are addressed, just the word "Done" is usually enough. :)

/** @fn signInWithPhoneNumberPrompt
@brief Allows sign in with phone number via popup prompt.
*/
- (void)signInWithPhoneNumberPrompt {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

signInWithPhoneNumberWithPrompt sounds better. The current name makes the method sound like a it only shows a prompt for signing in with phone number but not actually doing the sign in. Same for other methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@Ivan164 Ivan164 merged commit bb681a0 into master Oct 17, 2017
@paulb777 paulb777 deleted the automate-phonenumber-signin branch November 8, 2017 20:27
minafarid pushed a commit to minafarid/firebase-ios-sdk that referenced this pull request Jun 6, 2018
…gnin

Adds automated test for manual phone sign-in.
@firebase firebase locked and limited conversation to collaborators Nov 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants