4
4
using System ;
5
5
using System . Collections . Generic ;
6
6
using System . IO ;
7
+ using System . Linq ;
7
8
using System . Runtime . Versioning ;
8
9
using System . Text ;
9
10
using System . Threading . Tasks ;
14
15
using Xunit . Abstractions ;
15
16
using Process = System . Diagnostics . Process ;
16
17
using TC = Common . TestConstants ;
17
- using TH = Common . UiTestHelpers ;
18
18
19
19
namespace MultipleApiUiTest
20
20
{
21
- public class MultiApiTest : IClassFixture < InstallPlaywrightBrowserFixture >
21
+ public class AnyOrgOrPersonalTest : IClassFixture < InstallPlaywrightBrowserFixture >
22
22
{
23
23
private const string SignOutPageUriPath = @"/MicrosoftIdentity/Account/SignedOut" ;
24
24
private const uint ClientPort = 44321 ;
25
25
private const string TraceFileClassName = "OpenIDConnect" ;
26
26
private const uint NumProcessRetries = 3 ;
27
- private readonly LocatorAssertionsToBeVisibleOptions _assertVisibleOptions = new ( ) { Timeout = 15000 } ;
28
- private readonly string _sampleAppPath = "3 -WebApp-multi-APIs " + Path . DirectorySeparatorChar . ToString ( ) ;
29
- private readonly string _testAssemblyLocation = typeof ( MultiApiTest ) . Assembly . Location ;
27
+ private readonly LocatorAssertionsToBeVisibleOptions _assertVisibleOptions = new ( ) { Timeout = 25000 } ;
28
+ private readonly string _sampleAppPath = "1 -WebApp-OIDC" + Path . DirectorySeparatorChar + "1-3-AnyOrgOrPersonal " + Path . DirectorySeparatorChar . ToString ( ) ;
29
+ private readonly string _testAssemblyLocation = typeof ( AnyOrgOrPersonalTest ) . Assembly . Location ;
30
30
private readonly ITestOutputHelper _output ;
31
31
32
- public MultiApiTest ( ITestOutputHelper output )
32
+ public AnyOrgOrPersonalTest ( ITestOutputHelper output )
33
33
{
34
34
_output = output ;
35
35
}
@@ -62,7 +62,7 @@ public async Task ChallengeUser_MicrosoftIdFlow_LocalApp_ValidEmailPasswordCreds
62
62
// The delay before starting client prevents transient devbox issue where the client fails to load the first time after rebuilding
63
63
var clientProcessOptions = new ProcessStartOptions ( _testAssemblyLocation , _sampleAppPath , TC . s_oidcWebAppExe , clientEnvVars ) ;
64
64
65
- bool areProcessesRunning = TH . StartAndVerifyProcessesAreRunning ( [ clientProcessOptions ] , out processes , NumProcessRetries ) ;
65
+ bool areProcessesRunning = UiTestHelpers . StartAndVerifyProcessesAreRunning ( [ clientProcessOptions ] , out processes , NumProcessRetries ) ;
66
66
67
67
if ( ! areProcessesRunning )
68
68
{
@@ -71,7 +71,7 @@ public async Task ChallengeUser_MicrosoftIdFlow_LocalApp_ValidEmailPasswordCreds
71
71
foreach ( var process in processes )
72
72
{
73
73
#pragma warning disable CA1305 // Specify IFormatProvider
74
- runningProcesses . AppendLine ( $ "Is { process . Key } running: { TH . ProcessIsAlive ( process . Value ) } ") ;
74
+ runningProcesses . AppendLine ( $ "Is { process . Key } running: { UiTestHelpers . ProcessIsAlive ( process . Value ) } ") ;
75
75
#pragma warning restore CA1305 // Specify IFormatProvider
76
76
}
77
77
Assert . Fail ( TC . WebAppCrashedString + " " + runningProcesses . ToString ( ) ) ;
@@ -82,17 +82,17 @@ public async Task ChallengeUser_MicrosoftIdFlow_LocalApp_ValidEmailPasswordCreds
82
82
// Initial sign in
83
83
_output . WriteLine ( "Starting web app sign-in flow." ) ;
84
84
string email = labResponse . User . Upn ;
85
- await TH . NavigateToWebApp ( uriWithPort , page ) ;
86
- await TH . EnterEmailAsync ( page , email , _output ) ;
87
- await TH . EnterPasswordAsync ( page , labResponse . User . GetOrFetchPassword ( ) , _output ) ;
85
+ await UiTestHelpers . NavigateToWebApp ( uriWithPort , page ) ;
86
+ await UiTestHelpers . EnterEmailAsync ( page , email , _output ) ;
87
+ await UiTestHelpers . EnterPasswordAsync ( page , labResponse . User . GetOrFetchPassword ( ) , _output ) ;
88
88
await Assertions . Expect ( page . GetByText ( "Integrating Azure AD V2" ) ) . ToBeVisibleAsync ( _assertVisibleOptions ) ;
89
89
await Assertions . Expect ( page . GetByText ( email ) ) . ToBeVisibleAsync ( _assertVisibleOptions ) ;
90
90
_output . WriteLine ( "Web app sign-in flow successful." ) ;
91
91
92
92
// Sign out
93
93
_output . WriteLine ( "Starting web app sign-out flow." ) ;
94
94
await page . GetByRole ( AriaRole . Link , new ( ) { Name = "Sign out" } ) . ClickAsync ( ) ;
95
- await TH . PerformSignOut_MicrosoftIdFlow ( page , email , TC . LocalhostUrl + ClientPort + SignOutPageUriPath , _output ) ;
95
+ await UiTestHelpers . PerformSignOut_MicrosoftIdFlow ( page , email , TC . LocalhostUrl + ClientPort + SignOutPageUriPath , _output ) ;
96
96
_output . WriteLine ( "Web app sign out successful." ) ;
97
97
}
98
98
catch ( Exception ex )
@@ -111,16 +111,16 @@ public async Task ChallengeUser_MicrosoftIdFlow_LocalApp_ValidEmailPasswordCreds
111
111
_output . WriteLine ( "No Screenshot." ) ;
112
112
}
113
113
114
- string runningProcesses = TH . GetRunningProcessAsString ( processes ) ;
114
+ string runningProcesses = UiTestHelpers . GetRunningProcessAsString ( processes ) ;
115
115
Assert . Fail ( $ "the UI automation failed: { ex } output: { ex . Message } .\n { runningProcesses } \n Test run: { guid } ") ;
116
116
}
117
117
finally
118
118
{
119
119
// Add the following to make sure all processes and their children are stopped.
120
- TH . EndProcesses ( processes ) ;
120
+ UiTestHelpers . EndProcesses ( processes ) ;
121
121
122
122
// Stop tracing and export it into a zip archive.
123
- string path = TH . GetTracePath ( _testAssemblyLocation , TraceFileName ) ;
123
+ string path = UiTestHelpers . GetTracePath ( _testAssemblyLocation , TraceFileName ) ;
124
124
await context . Tracing . StopAsync ( new ( ) { Path = path } ) ;
125
125
_output . WriteLine ( $ "Trace data for { TraceFileName } recorded to { path } .") ;
126
126
0 commit comments