Skip to content

Commit

Permalink
Update settings and use TOC model from core. Add descriptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
skrustev committed Nov 15, 2024
1 parent 6e1db48 commit bf7190f
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 236 deletions.
165 changes: 0 additions & 165 deletions azure-pipelines/test-pipeline-client.yml

This file was deleted.

14 changes: 12 additions & 2 deletions browser/IgBlazorSamples.Core/Services/SampleTOC.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Serialization;
using System.Threading.Tasks;

namespace Infragistics.Samples.Core
{
public class TOC : ObservableObject
{
[JsonPropertyName("groups")]
public TocGroup[] Groups { get; set; }
}

public class TocItem : ObservableObject
{
[JsonPropertyName("name")]
public string Name { get; set; }
public bool IsExpanded { get; set; }

Expand All @@ -25,6 +28,8 @@ public class TocGroup : TocItem
{
//public string Name { get; set; }
//public bool IsExpanded { get; set; }

[JsonPropertyName("components")]
public TocComponent[] Components { get; set; }

public TocGroup()
Expand All @@ -35,10 +40,12 @@ public TocGroup()

public class TocComponent : TocItem
{
public string Group { get; set; }
//public string Name { get; set; }
//public bool IsExpanded { get; set; }

public string Group { get; set; }

[JsonPropertyName("samples")]
public TocSample[] Samples { get; set; }

public TocComponent()
Expand All @@ -51,10 +58,13 @@ public TocComponent()
public class TocSample : TocItem
{
//public string Name { get; set; }
//public bool IsExpanded { get; set; }

[JsonPropertyName("route")]
public string Route { get; set; }
public string Component { get; set; }
public string Group { get; set; }
//public bool IsExpanded { get; set; }
[JsonPropertyName("showLink")]
public bool ShowLink { get; set; }

public TocSample()
Expand Down
2 changes: 1 addition & 1 deletion browser/IgBlazorSamples.Test/IgBlazorSamples.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<EmbeddedResource Include="..\IgBlazorSamples.Client\wwwroot\toc.json" Link="External\toc.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
<Content Include="Properties\testGenerationSettings.json">
<Content Include="testsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
Expand Down
14 changes: 12 additions & 2 deletions browser/IgBlazorSamples.Test/Infrastructure/BlazorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ namespace IgBlazorSamples.Test;

public class BlazorTest : PageTest
{
// Root Uri that the app can be accessed through and is being intercepted for netword requests. Each test connects to it to access the samples browser.
protected static readonly Uri RootUri = new("http://127.0.0.1");
// We use the Program.cs from the IgBlazorSamples.TestServer since WebApplicationFactory is used to create only servers and IgBlazorSamples.Client is only wasm app.
private readonly WebApplicationFactory<Program> _webAppFactory = new();
private HttpClient? _httpClient;

Expand All @@ -19,32 +21,37 @@ public async Task BlazorSetup()

await Context.RouteAsync($"{RootUri.AbsoluteUri}**", async route =>
{
// Get the request sent from Playwright
var request = route.Request;
var content = request.PostDataBuffer is { } postDataBuffer
? new ByteArrayContent(postDataBuffer)
: null;

// Create request to pass to the Test Server we have in memory based on the Playwright one.
var requestMessage = new HttpRequestMessage(new(request.Method), request.Url)
{
Content = content,
};

foreach (var header in request.Headers)
{
requestMessage.Headers.Add(header.Key, header.Value);
}

// Provide the Test Server with the request we passed from Playwright. Then wait and save the response.
var response = await _httpClient.SendAsync(requestMessage);

// Get the responce data from the Test Server and return it back to Playwright. We intercept all so no need to check for other cases.
var responseBody = await response.Content.ReadAsByteArrayAsync();
var responseHeaders = response.Content.Headers.Select(h => KeyValuePair.Create(h.Key, string.Join(",", h.Value)));

await route.FulfillAsync(new()
{
BodyBytes = responseBody,
Headers = responseHeaders,
Status = (int)response.StatusCode,
});

// Prepare each test for tracing, in case it fails. This is required as a part of it.
// We have to do it for each test, since we don't know if its gonna fail or on.
await Context.Tracing.StartAsync(new()
{
Title = $"{TestContext.CurrentContext.Test.ClassName}.{TestContext.CurrentContext.Test.Name}",
Expand All @@ -60,9 +67,12 @@ public async Task BlazorTearDown()
{
_httpClient?.Dispose();

// Check if test failed based on the outcome.
var failed = TestContext.CurrentContext.Result.Outcome == NUnit.Framework.Interfaces.ResultState.Error
|| TestContext.CurrentContext.Result.Outcome == NUnit.Framework.Interfaces.ResultState.Failure;

// Finish the test tracing and set the save path of the trace if it failed.
// Otherwise do not provide it and the trace will not be saved and discarded.
await Context.Tracing.StopAsync(new()
{
Path = failed ? Path.Combine(
Expand Down
4 changes: 2 additions & 2 deletions browser/IgBlazorSamples.Test/Models/SettingsModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public class ComponentMap
public string? InitialSelector { get; set; }
}

public class ExcludedRoute
public class ExcludedGroup
{
public string? Route { get; set; }
public string? Group { get; set; }
}

public class ExcludedSample
Expand Down
46 changes: 0 additions & 46 deletions browser/IgBlazorSamples.Test/Models/TocModel.cs

This file was deleted.

Loading

0 comments on commit bf7190f

Please sign in to comment.