Skip to content

Commit 56113b0

Browse files
authored
Minor cleanup (#804)
* Minor cleanup * fix trace filename
1 parent 82236f0 commit 56113b0

File tree

7 files changed

+31
-81
lines changed

7 files changed

+31
-81
lines changed

Diff for: UiTests/AnyOrgOrPersonalUiTest/AnyOrgOrPersonalTest.cs

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,32 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4+
using Common;
5+
using Microsoft.Identity.Lab.Api;
6+
using Microsoft.Playwright;
47
using System;
58
using System.Collections.Generic;
69
using System.IO;
7-
using System.Linq;
810
using System.Runtime.Versioning;
911
using System.Text;
1012
using System.Threading.Tasks;
11-
using Common;
12-
using Microsoft.Identity.Lab.Api;
13-
using Microsoft.Playwright;
1413
using Xunit;
1514
using Xunit.Abstractions;
1615
using Process = System.Diagnostics.Process;
1716
using TC = Common.TestConstants;
1817

19-
namespace MultipleApiUiTest
18+
namespace AnyOrgOrPersonalUiTest
2019
{
2120
public class AnyOrgOrPersonalTest : IClassFixture<InstallPlaywrightBrowserFixture>
2221
{
2322
private const string SignOutPageUriPath = @"/MicrosoftIdentity/Account/SignedOut";
2423
private const uint ClientPort = 44321;
25-
private const string TraceFileClassName = "OpenIDConnect";
24+
private const string TraceFileClassName = "AnyOrgOrPersonal";
2625
private const uint NumProcessRetries = 3;
2726
private const string SampleSlnFileName = "1-3-AnyOrgOrPersonal.sln";
2827
private readonly LocatorAssertionsToBeVisibleOptions _assertVisibleOptions = new() { Timeout = 25000 };
29-
private readonly string _sampleAppPath = "1-WebApp-OIDC" + Path.DirectorySeparatorChar + "1-3-AnyOrgOrPersonal" + Path.DirectorySeparatorChar.ToString();
30-
private readonly string _testAppsettingsPath = "UiTests" + Path.DirectorySeparatorChar + "AnyOrgOrPersonalUiTest" + Path.DirectorySeparatorChar.ToString() + TC.AppSetttingsDotJson;
28+
private readonly string _sampleAppPath = "1-WebApp-OIDC" + Path.DirectorySeparatorChar + "1-3-AnyOrgOrPersonal" + Path.DirectorySeparatorChar;
29+
private readonly string _testAppsettingsPath = "UiTests" + Path.DirectorySeparatorChar + "AnyOrgOrPersonalUiTest" + Path.DirectorySeparatorChar + TC.AppSetttingsDotJson;
3130
private readonly string _testAssemblyLocation = typeof(AnyOrgOrPersonalTest).Assembly.Location;
3231
private readonly ITestOutputHelper _output;
3332

@@ -38,7 +37,7 @@ public AnyOrgOrPersonalTest(ITestOutputHelper output)
3837

3938
[Fact]
4039
[SupportedOSPlatform("windows")]
41-
public async Task ChallengeUser_MicrosoftIdFlow_LocalApp_ValidEmailPasswordCreds_LoginLogout()
40+
public async Task LocalApp_ValidEmailPasswordCreds_LoginLogout()
4241
{
4342
// Setup web app and api environmental variables.
4443
var clientEnvVars = new Dictionary<string, string>

Diff for: UiTests/B2CUiTest/B2CUiTest.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class B2CUiTest : IClassFixture<InstallPlaywrightBrowserFixture>
2727
private const string SampleSolutionFileName = "4-2-B2C-Secured-API.sln";
2828
private const uint TodoListClientPort = 5000;
2929
private const uint TodoListServicePort = 44332;
30-
private const string TraceClassName = "B2C-Login";
30+
private const string TraceClassName = "B2C";
3131

3232
private readonly LocatorAssertionsToBeVisibleOptions _assertVisibleOptions = new() { Timeout = 25000 };
3333
private readonly string _sampleClientAppPath;
@@ -46,7 +46,7 @@ public B2CUiTest(ITestOutputHelper output)
4646

4747
[Fact]
4848
[SupportedOSPlatform("windows")]
49-
public async Task B2C_ValidCreds_LoginLogout()
49+
public async Task LocalApp_ValidEmailPasswordCreds_LoginLogout()
5050
{
5151
// Web app and api environmental variable setup.
5252
Dictionary<string, Process>? processes = null;

Diff for: UiTests/Common/TestConstants.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ public static class TestConstants
2828
public const string TodoTitle2 = "Testing edit todo item";
2929
public const string WebAppCrashedString = $"The web app process has exited prematurely.";
3030

31-
public static readonly string s_oidcWebAppExe = Path.DirectorySeparatorChar.ToString() + "WebApp-OpenIDConnect-DotNet.exe";
32-
public static readonly string s_oidcWebAppPath = Path.DirectorySeparatorChar.ToString() + "WebApp-OpenIDConnect";
33-
public static readonly string s_todoListClientExe = Path.DirectorySeparatorChar.ToString() + "TodoListClient.exe";
34-
public static readonly string s_todoListClientPath = Path.DirectorySeparatorChar.ToString() + "Client";
35-
public static readonly string s_todoListServiceExe = Path.DirectorySeparatorChar.ToString() + "TodoListService.exe";
36-
public static readonly string s_todoListServicePath = Path.DirectorySeparatorChar.ToString() + "TodoListService";
31+
public static readonly string s_oidcWebAppExe = Path.DirectorySeparatorChar + "WebApp-OpenIDConnect-DotNet.exe";
32+
public static readonly string s_oidcWebAppPath = Path.DirectorySeparatorChar + "WebApp-OpenIDConnect";
33+
public static readonly string s_todoListClientExe = Path.DirectorySeparatorChar + "TodoListClient.exe";
34+
public static readonly string s_todoListClientPath = Path.DirectorySeparatorChar + "Client";
35+
public static readonly string s_todoListServiceExe = Path.DirectorySeparatorChar + "TodoListService.exe";
36+
public static readonly string s_todoListServicePath = Path.DirectorySeparatorChar + "TodoListService";
3737
}
3838
}

Diff for: UiTests/Common/UiTestHelpers.cs

+2-55
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
using Microsoft.Data.SqlClient;
77
using Microsoft.Playwright;
88
using System.Diagnostics;
9-
using System.Management;
10-
using System.Runtime.Versioning;
119
using System.Text;
1210
using Xunit.Abstractions;
1311

@@ -56,24 +54,6 @@ public static async Task FirstLogin_MicrosoftIdFlow_ValidEmailPassword(IPage pag
5654
await StaySignedIn_MicrosoftIdFlow(page, staySignedInText, output);
5755
}
5856

59-
/// <summary>
60-
/// Login flow for anytime after the first time in a given browsing session.
61-
/// </summary>
62-
/// <param name="page">Playwright Page object the web app is accessed from</param>
63-
/// <param name="email">email of the user to sign in</param>
64-
/// <param name="password">password for sign in</param>
65-
/// <param name="output">Used to communicate output to the test's Standard Output</param>
66-
/// <param name="staySignedIn">Whether to select "stay signed in" on login</param>
67-
public static async Task SuccessiveLogin_MicrosoftIdFlow_ValidEmailPassword(IPage page, string email, string password, ITestOutputHelper? output = null, bool staySignedIn = false)
68-
{
69-
string staySignedInText = staySignedIn ? "Yes" : "No";
70-
71-
WriteLine(output, $"Logging in again in this browsing session... selecting user via email: {email}.");
72-
await SelectKnownAccountByEmail_MicrosoftIdFlow(page, email);
73-
await EnterPasswordAsync(page, password, output);
74-
await StaySignedIn_MicrosoftIdFlow(page, staySignedInText, output);
75-
}
76-
7757
/// <summary>
7858
/// Enters the email of the user to sign in.
7959
/// </summary>
@@ -155,21 +135,6 @@ private static void WriteLine(ITestOutputHelper? output, string message)
155135
}
156136
}
157137

158-
/// <summary>
159-
/// This starts the recording of playwright trace files. The corresponding EndAndWritePlaywrightTrace method will also need to be used.
160-
/// This is not used anywhere by default and will need to be added to the code if desired.
161-
/// </summary>
162-
/// <param name="page">The page object whose context the trace will record.</param>
163-
public static async Task StartPlaywrightTrace(IPage page)
164-
{
165-
await page.Context.Tracing.StartAsync(new()
166-
{
167-
Screenshots = true,
168-
Snapshots = true,
169-
Sources = true
170-
});
171-
}
172-
173138
/// <summary>
174139
/// Starts a process from an executable, sets its working directory, and redirects its output to the test's output.
175140
/// </summary>
@@ -179,7 +144,7 @@ await page.Context.Tracing.StartAsync(new()
179144
/// <param name="portNumber">The port for the process to listen on.</param>
180145
/// <param name="isHttp">If the launch URL is http or https. Default is https.</param>
181146
/// <returns>The started process.</returns>
182-
public static Process StartProcessLocally(string testAssemblyLocation, string appLocation, string executableName, Dictionary<string, string>? environmentVariables = null)
147+
private static Process StartProcessLocally(string testAssemblyLocation, string appLocation, string executableName, Dictionary<string, string>? environmentVariables = null)
183148
{
184149
string applicationWorkingDirectory = GetApplicationWorkingDirectory(testAssemblyLocation, appLocation);
185150
ProcessStartInfo processStartInfo = new ProcessStartInfo(applicationWorkingDirectory + executableName)
@@ -258,7 +223,7 @@ private static string GetAbsoluteAppDirectory(string testAssemblyLocation, strin
258223
/// <returns>An absolute path to a Playwright Trace zip folder</returns>
259224
public static string GetTracePath(string testAssemblyLocation, string traceName)
260225
{
261-
const string traceParentFolder = "E2E Tests";
226+
const string traceParentFolder = "UiTests";
262227
const string traceFolder = "PlaywrightTraces";
263228
const string zipExtension = ".zip";
264229
const int netVersionNumberLength = 3;
@@ -323,24 +288,6 @@ private static void KillProcessTrees(Queue<Process> processQueue)
323288
#endif
324289
}
325290

326-
/// <summary>
327-
/// Gets the child processes of a process on Windows
328-
/// </summary>
329-
/// <param name="process">The parent process</param>
330-
/// <returns>A list of child processes</returns>
331-
[SupportedOSPlatform("windows")]
332-
public static IList<Process> GetChildProcesses(this Process process)
333-
{
334-
ManagementObjectSearcher processSearch = new ManagementObjectSearcher($"Select * From Win32_Process Where ParentProcessID={process.Id}");
335-
IList<Process> processList = processSearch.Get()
336-
.Cast<ManagementObject>()
337-
.Select(mo =>
338-
Process.GetProcessById(Convert.ToInt32(mo["ProcessID"], System.Globalization.CultureInfo.InvariantCulture)))
339-
.ToList();
340-
processSearch.Dispose();
341-
return processList;
342-
}
343-
344291
/// <summary>
345292
/// Checks if all processes in a list are alive
346293
/// </summary>

Diff for: UiTests/GraphUserTokenCache/GraphUserTokenCacheTest.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ public class GraphUserTokenCacheTest
2222
private const string SqlDbName = "MY_TOKEN_CACHE_DATABASE";
2323
private const string SqlServerConnectionString = "Server=(localdb)\\mssqllocaldb;Integrated Security=true";
2424
private const string SqlTableName = "TokenCache";
25-
private const string TraceFileClassName = "GraphUserTokenCacheTest";
25+
private const string TraceFileClassName = "GraphUserTokenCache";
2626
private readonly LocatorAssertionsToBeVisibleOptions _assertVisibleOptions = new() { Timeout = 25000 };
2727
private readonly ITestOutputHelper _output;
28-
private readonly string _sampleAppPath = "2-WebApp-graph-user" + Path.DirectorySeparatorChar + "2-2-TokenCache" + Path.DirectorySeparatorChar.ToString();
29-
private readonly string _testAppsettingsPath = "UiTests" + Path.DirectorySeparatorChar + "GraphUserTokenCache" + Path.DirectorySeparatorChar.ToString() + TC.AppSetttingsDotJson;
28+
private readonly string _sampleAppPath = "2-WebApp-graph-user" + Path.DirectorySeparatorChar + "2-2-TokenCache" + Path.DirectorySeparatorChar;
29+
private readonly string _testAppsettingsPath = "UiTests" + Path.DirectorySeparatorChar + "GraphUserTokenCache" + Path.DirectorySeparatorChar + TC.AppSetttingsDotJson;
3030
private readonly string _testAssemblyLocation = typeof(GraphUserTokenCacheTest).Assembly.Location;
3131

3232
public GraphUserTokenCacheTest(ITestOutputHelper output)
@@ -35,7 +35,7 @@ public GraphUserTokenCacheTest(ITestOutputHelper output)
3535
}
3636

3737
[Fact]
38-
public async Task ChallengeUser_MicrosoftIdFlow_LocalApp_ValidEmailPasswordCreds_LoginLogoutAsync()
38+
public async Task LocalApp_ValidEmailPasswordCreds_LoginLogout()
3939
{
4040
// Setup web app and api environmental variables.
4141
var clientEnvVars = new Dictionary<string, string>

Diff for: UiTests/HybridFlowUiTest/HybridFlowTest.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ public class HybridFlowTest : IClassFixture<InstallPlaywrightBrowserFixture>
2121
{
2222
private const string SignOutPageUriPath = @"/MicrosoftIdentity/Account/SignedOut";
2323
private const uint ClientPort = 44321;
24-
private const string TraceFileClassName = "OpenIDConnect-HybridFlow";
24+
private const string TraceFileClassName = "HybridFlow";
2525
private const uint NumProcessRetries = 3;
2626
private const string SampleSlnFileName = "2-5-HybridFlow.sln";
2727
private const string SampleExeFileName = "2-5-HybridFlow.exe";
2828
private readonly LocatorAssertionsToBeVisibleOptions _assertVisibleOptions = new() { Timeout = 25000 };
29-
private readonly string _sampleAppPath = "2-WebApp-graph-user" + Path.DirectorySeparatorChar + "2-5-HybridFlow" + Path.DirectorySeparatorChar.ToString();
30-
private readonly string _testAppsettingsPath = "UiTests" + Path.DirectorySeparatorChar + "HybridFlowUiTest" + Path.DirectorySeparatorChar.ToString() + TC.AppSetttingsDotJson;
29+
private readonly string _sampleAppPath = "2-WebApp-graph-user" + Path.DirectorySeparatorChar + "2-5-HybridFlow" + Path.DirectorySeparatorChar;
30+
private readonly string _testAppsettingsPath = "UiTests" + Path.DirectorySeparatorChar + "HybridFlowUiTest" + Path.DirectorySeparatorChar + TC.AppSetttingsDotJson;
3131
private readonly string _testAssemblyLocation = typeof(HybridFlowTest).Assembly.Location;
3232
private readonly ITestOutputHelper _output;
3333

@@ -38,7 +38,7 @@ public HybridFlowTest(ITestOutputHelper output)
3838

3939
[Fact]
4040
[SupportedOSPlatform("windows")]
41-
public async Task ChallengeUser_MicrosoftIdFlow_LocalApp_ValidEmailPasswordCreds_LoginLogout()
41+
public async Task LocalApp_ValidEmailPasswordCreds_LoginLogout()
4242
{
4343
// Setup web app and api environmental variables.
4444
var clientEnvVars = new Dictionary<string, string>
@@ -68,7 +68,7 @@ public async Task ChallengeUser_MicrosoftIdFlow_LocalApp_ValidEmailPasswordCreds
6868
var clientProcessOptions = new ProcessStartOptions(
6969
_testAssemblyLocation,
7070
_sampleAppPath,
71-
Path.DirectorySeparatorChar.ToString() + SampleExeFileName,
71+
Path.DirectorySeparatorChar + SampleExeFileName,
7272
clientEnvVars
7373
);
7474

Diff for: UiTests/PlaywrightTraces/.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Ignore all files in this directory, which is needed for PR pipeline test traces
2+
*
3+
# Except this file
4+
!.gitignore

0 commit comments

Comments
 (0)