Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit fb11b21

Browse files
committed
Merge branch 'master' into feature/pr/views
2 parents 144359f + b028aa6 commit fb11b21

File tree

6 files changed

+56
-4
lines changed

6 files changed

+56
-4
lines changed

src/GitHub.App/ViewModels/LoginControlViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public LoginControlViewModel(
4545

4646
}).ToProperty(this, x => x.LoginMode);
4747

48-
AuthenticationResults = Observable.Amb(
48+
AuthenticationResults = Observable.Merge(
4949
loginToGitHubViewModel.Login,
5050
EnterpriseLogin.Login);
5151
CancelCommand = ReactiveCommand.Create();

src/GitHub.UI.Reactive/Assets/Controls/Validation/ValidationMessage.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@
6868
<Grid
6969
ToolTip="{Binding ElementName=adornerPlaceholder, Path=AdornedElement.(Validation.Errors).CurrentItem.ErrorContent}"
7070
Background="Transparent"
71-
Cursor="IBeam">
71+
Cursor="IBeam"
72+
IsHitTestVisible="False">
7273

7374
<AdornedElementPlaceholder
7475
Name="adornerPlaceholder"

src/GitHub.UI.Reactive/Controls/SimpleViewUserControl.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ protected void NotifyCancel()
5656
return;
5757

5858
cancel.OnNext(null);
59-
cancel.OnCompleted();
6059
}
6160

6261
protected void NotifyIsBusy(bool busy)

src/GitHub.UI.Reactive/Controls/Validation/ValidationMessage.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ namespace GitHub.UI
1717
public class ValidationMessage : UserControl
1818
{
1919
const double defaultTextChangeThrottle = 0.2;
20+
bool userHasInteracted;
2021

2122
public ValidationMessage()
2223
{
@@ -33,7 +34,7 @@ public ValidationMessage()
3334
.Do(CreateBinding)
3435
.Select(control =>
3536
Observable.Merge(
36-
this.WhenAnyValue(x => x.ShowError),
37+
this.WhenAnyValue(x => x.ShowError).Where(x => userHasInteracted),
3738
control.Events().TextChanged
3839
.Throttle(TimeSpan.FromSeconds(ShowError ? defaultTextChangeThrottle : TextChangeThrottle),
3940
RxApp.MainThreadScheduler)
@@ -121,6 +122,7 @@ public string ErrorAdornerTemplate
121122
void ShowValidateError(bool showError)
122123
{
123124
IsShowingMessage = showError;
125+
userHasInteracted = true;
124126

125127
if (ValidatesControl == null || !IsAdornerEnabled()) return;
126128

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using System;
2+
using System.Net;
3+
using System.Reactive.Linq;
4+
using System.Reactive.Subjects;
5+
using GitHub.Authentication;
6+
using GitHub.Info;
7+
using GitHub.Models;
8+
using GitHub.Primitives;
9+
using GitHub.Services;
10+
using GitHub.ViewModels;
11+
using NSubstitute;
12+
using Octokit;
13+
using ReactiveUI;
14+
using Xunit;
15+
16+
public class LoginControlViewModelTests
17+
{
18+
public class TheAuthenticationResultsCommand : TestBaseClass
19+
{
20+
[Fact]
21+
public async void AllowsLoginFromEnterpriseAfterGitHubLoginHasFailed()
22+
{
23+
var repositoryHosts = Substitute.For<IRepositoryHosts>();
24+
25+
var gitHubLogin = Substitute.For<ILoginToGitHubViewModel>();
26+
var gitHubLoginCommand = ReactiveCommand.CreateAsyncObservable(_ =>
27+
Observable.Return(AuthenticationResult.CredentialFailure));
28+
gitHubLogin.Login.Returns(gitHubLoginCommand);
29+
30+
var enterpriseLogin = Substitute.For<ILoginToGitHubForEnterpriseViewModel>();
31+
var enterpriseLoginCommand = ReactiveCommand.CreateAsyncObservable(_ =>
32+
Observable.Return(AuthenticationResult.Success));
33+
enterpriseLogin.Login.Returns(enterpriseLoginCommand);
34+
35+
var loginViewModel = new LoginControlViewModel(repositoryHosts, gitHubLogin, enterpriseLogin);
36+
var success = false;
37+
38+
loginViewModel.AuthenticationResults
39+
.Where(x => x == AuthenticationResult.Success)
40+
.Subscribe(_ => success = true);
41+
42+
await gitHubLoginCommand.ExecuteAsync();
43+
await enterpriseLoginCommand.ExecuteAsync();
44+
45+
Assert.True(success);
46+
}
47+
}
48+
}
49+

src/UnitTests/UnitTests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@
163163
<Compile Include="GitHub.App\Services\GitClientTests.cs" />
164164
<Compile Include="GitHub.App\Services\RepositoryCloneServiceTests.cs" />
165165
<Compile Include="GitHub.App\Services\RepositoryCreationServiceTests.cs" />
166+
<Compile Include="GitHub.App\ViewModels\LoginControlViewModelTests.cs" />
166167
<Compile Include="GitHub.App\ViewModels\LoginToGitHubViewModelTests.cs" />
167168
<Compile Include="GitHub.App\ViewModels\RepositoryCloneViewModelTests.cs" />
168169
<Compile Include="GitHub.App\ViewModels\RepositoryCreationViewModelTests.cs" />

0 commit comments

Comments
 (0)