Skip to content

Commit

Permalink
test: Add more browser agent injection tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
nrcventura committed Aug 1, 2023
1 parent 40df5a4 commit e094ffa
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ public void BrowserMonitoringEnableAttributes(bool shouldEnableAttributes)
new[] { "configuration", "browserMonitoring", "attributes" }, "enabled", stringValue);
}

public void BrowserMonitoringLoader(string loaderType)
{
CommonUtils.ModifyOrCreateXmlAttributeInNewRelicConfig(_configFilePath,
new[] { "configuration", "browserMonitoring" }, "loader", loaderType);
}

public void PutForDataSend()
{
CommonUtils.ModifyOrCreateXmlAttributeInNewRelicConfig(_configFilePath, new[] { "configuration", "dataTransmission" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
// SPDX-License-Identifier: Apache-2.0

using NewRelic.Agent.IntegrationTestHelpers;
using NewRelic.Agent.IntegrationTests.RemoteServiceFixtures;
using NewRelic.Testing.Assertions;
using Xunit;
using Xunit.Abstractions;

namespace NewRelic.Agent.IntegrationTests.AgentFeatures
{
[NetFrameworkTest]
public class BrowserAgentAutoInjection : NewRelicIntegrationTest<RemoteServiceFixtures.BasicMvcApplicationTestFixture>
public abstract class BrowserAgentAutoInjectionBase : NewRelicIntegrationTest<RemoteServiceFixtures.BasicMvcApplicationTestFixture>
{
private readonly RemoteServiceFixtures.BasicMvcApplicationTestFixture _fixture;

private string _htmlContent;

public BrowserAgentAutoInjection(RemoteServiceFixtures.BasicMvcApplicationTestFixture fixture, ITestOutputHelper output)
protected BrowserAgentAutoInjectionBase(RemoteServiceFixtures.BasicMvcApplicationTestFixture fixture, ITestOutputHelper output, string loaderType)
: base(fixture)
{
_fixture = fixture;
Expand All @@ -30,6 +30,10 @@ public BrowserAgentAutoInjection(RemoteServiceFixtures.BasicMvcApplicationTestFi
configModifier.AutoInstrumentBrowserMonitoring(true);
configModifier.BrowserMonitoringEnableAttributes(true);
if (!string.IsNullOrEmpty(loaderType))
{
configModifier.BrowserMonitoringLoader(loaderType);
}
},
exerciseApplication: () =>
{
Expand All @@ -55,4 +59,40 @@ public void Test()
Assert.Equal(jsAgentFromConnectResponse, jsAgentFromHtmlContent);
}
}

[NetFrameworkTest]
public class BrowserAgentAutoInjectionDefault : BrowserAgentAutoInjectionBase
{
public BrowserAgentAutoInjectionDefault(BasicMvcApplicationTestFixture fixture, ITestOutputHelper output)
: base(fixture, output, null /* use default loader */)
{
}
}

[NetFrameworkTest]
public class BrowserAgentAutoInjectionRum : BrowserAgentAutoInjectionBase
{
public BrowserAgentAutoInjectionRum(BasicMvcApplicationTestFixture fixture, ITestOutputHelper output)
: base(fixture, output, "rum")
{
}
}

[NetFrameworkTest]
public class BrowserAgentAutoInjectionFull : BrowserAgentAutoInjectionBase
{
public BrowserAgentAutoInjectionFull(BasicMvcApplicationTestFixture fixture, ITestOutputHelper output)
: base(fixture, output, "full")
{
}
}

[NetFrameworkTest]
public class BrowserAgentAutoInjectionSpa : BrowserAgentAutoInjectionBase
{
public BrowserAgentAutoInjectionSpa(BasicMvcApplicationTestFixture fixture, ITestOutputHelper output)
: base(fixture, output, "spa")
{
}
}
}

0 comments on commit e094ffa

Please sign in to comment.