Skip to content

Commit d9e0d05

Browse files
authored
fix(playwrighttesting): no auth error when scalable scenario is disabled (Azure#47050)
Co-authored-by: Siddharth Singha Roy <[email protected]>
1 parent 94939dc commit d9e0d05

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

sdk/playwrighttesting/Azure.Developer.MicrosoftPlaywrightTesting.NUnit/src/PlaywrightServiceNUnit.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using NUnit.Framework;
66
using System.Threading.Tasks;
77
using System.Runtime.InteropServices;
8-
using System.Threading;
8+
using System;
99
using Azure.Developer.MicrosoftPlaywrightTesting.TestLogger;
1010

1111
namespace Azure.Developer.MicrosoftPlaywrightTesting.NUnit;
@@ -45,6 +45,10 @@ public PlaywrightServiceNUnit(TokenCredential? credential = null)
4545
[OneTimeSetUp]
4646
public async Task SetupAsync()
4747
{
48+
if (!UseCloudHostedBrowsers)
49+
return;
50+
TestContext.Progress.WriteLine("\nRunning tests using Microsoft Playwright Testing service.\n");
51+
4852
await InitializeAsync().ConfigureAwait(false);
4953
}
5054

sdk/playwrighttesting/Azure.Developer.MicrosoftPlaywrightTesting.TestLogger/src/PlaywrightService.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ public async Task InitializeAsync(CancellationToken cancellationToken = default)
145145
// Since playwright-dotnet checks PLAYWRIGHT_SERVICE_ACCESS_TOKEN and PLAYWRIGHT_SERVICE_URL to be set, remove PLAYWRIGHT_SERVICE_URL so that tests are run locally.
146146
// If customers use GetConnectOptionsAsync, after setting disableScalableExecution, an error will be thrown.
147147
Environment.SetEnvironmentVariable(ServiceEnvironmentVariable.PlaywrightServiceUri, null);
148+
return;
148149
}
149150
// If default auth mechanism is Access token and token is available in the environment variable, no need to setup rotation handler
150151
if (ServiceAuth == ServiceAuthType.AccessToken)

sdk/playwrighttesting/Azure.Developer.MicrosoftPlaywrightTesting.TestLogger/tests/PlaywrightServiceTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,9 @@ public void Initialize_WhenDefaultAuthIsEntraIdAccessTokenAndAccessTokenEnvironm
185185
Assert.That(Environment.GetEnvironmentVariable(ServiceEnvironmentVariable.PlaywrightServiceUri), Is.Not.Null);
186186

187187
service.InitializeAsync().Wait();
188-
defaultAzureCredentialMock.Verify(x => x.GetTokenAsync(It.IsAny<TokenRequestContext>(), It.IsAny<CancellationToken>()), Times.Once);
188+
defaultAzureCredentialMock.Verify(x => x.GetTokenAsync(It.IsAny<TokenRequestContext>(), It.IsAny<CancellationToken>()), Times.Never);
189189

190-
service.RotationTimer!.Dispose();
190+
Assert.That(service.RotationTimer, Is.Null);
191191

192192
Assert.That(Environment.GetEnvironmentVariable(ServiceEnvironmentVariable.PlaywrightServiceUri), Is.Null);
193193
}

0 commit comments

Comments
 (0)