-
-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
122 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,14 +57,14 @@ jobs: | |
run: | | ||
dotnet new bit-bp --name TestSqlite --database Sqlite --advancedTests --framework net9.0 | ||
cd TestSqlite/src/Server/TestSqlite.Server.Api/ | ||
dotnet build | ||
dotnet tool restore | ||
dotnet ef migrations add InitialMigration | ||
dotnet ef database update | ||
cd ../../Tests | ||
dotnet build | ||
pwsh bin/Debug/net9.0/playwright.ps1 install --with-deps | ||
dotnet test --logger GitHubActions | ||
dotnet test --logger GitHubActions --filter "FullyQualifiedName~Boilerplate.Tests.PageTests.BlazorServer|FullyQualifiedName!~PageTests" | ||
dotnet test --logger GitHubActions --filter Boilerplate.Tests.PageTests.BlazorWebAssembly | ||
- name: Upload Tests Artifact | ||
uses: actions/[email protected] | ||
|
@@ -79,13 +79,12 @@ jobs: | |
run: | | ||
dotnet new bit-bp --name TestSqlServer --database SqlServer | ||
cd TestSqlServer/src/Server/TestSqlServer.Server.Api/ | ||
dotnet build | ||
dotnet tool restore | ||
dotnet ef migrations add InitialMigration | ||
dotnet ef database update | ||
cd ../../Tests | ||
dotnet build | ||
dotnet test --logger GitHubActions | ||
dotnet test --logger GitHubActions --filter "FullyQualifiedName~Boilerplate.Tests.PageTests.BlazorServer|FullyQualifiedName!~PageTests" | ||
dotnet test --logger GitHubActions --filter Boilerplate.Tests.PageTests.BlazorWebAssembly | ||
- name: Upload Tests Artifact | ||
uses: actions/[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/appsettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/Templates/Boilerplate/Bit.Boilerplate/src/Tests/Extensions/PlaywrightCacheExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using System.Text.RegularExpressions; | ||
|
||
namespace Boilerplate.Tests.Extensions; | ||
|
||
public static partial class PlaywrightCacheExtensions | ||
{ | ||
public static Task EnableBlazorWasmCaching(this IPage page) => page.EnableAssetCaching(BlazorWasmRegex()); | ||
|
||
public static Task EnableBlazorWasmCaching(this IBrowserContext context) => context.EnableAssetCaching(BlazorWasmRegex()); | ||
|
||
public static Task EnableAssetCaching(this IPage page, string routePattern) => page.RouteAsync(routePattern, CacheHandler); | ||
|
||
public static Task EnableAssetCaching(this IPage page, Regex routePattern) => page.RouteAsync(routePattern, CacheHandler); | ||
|
||
public static Task EnableAssetCaching(this IPage page, Func<string, bool> predicate) => page.RouteAsync(predicate, CacheHandler); | ||
|
||
public static Task EnableAssetCaching(this IBrowserContext context, string routePattern) => context.RouteAsync(routePattern, CacheHandler); | ||
|
||
public static Task EnableAssetCaching(this IBrowserContext context, Regex routePattern) => context.RouteAsync(routePattern, CacheHandler); | ||
|
||
public static Task EnableAssetCaching(this IBrowserContext context, Func<string, bool> predicate) => context.RouteAsync(predicate, CacheHandler); | ||
|
||
private static async Task CacheHandler(this IRoute route) | ||
{ | ||
var url = new Uri(route.Request.Url).PathAndQuery; | ||
|
||
if (cachedResponses.TryGetValue(url, out var cachedResponse) is false) | ||
{ | ||
var response = await route.FetchAsync(); | ||
var body = await response.BodyAsync(); | ||
cachedResponse = (body, response.Headers); | ||
cachedResponses[url] = cachedResponse; | ||
} | ||
|
||
await route.FulfillAsync(new RouteFulfillOptions | ||
{ | ||
Status = 200, | ||
BodyBytes = cachedResponse.Body, | ||
Headers = cachedResponse.Headers | ||
}); | ||
} | ||
public static void ClearCache() => cachedResponses.Clear(); | ||
|
||
private static Dictionary<string, (byte[] Body, Dictionary<string, string> Headers)> cachedResponses = []; | ||
|
||
[GeneratedRegex(@"\/_framework\/[\w\.]+\.((wasm)|(pdb)|(dat))\?v=sha256-.+")] | ||
private static partial Regex BlazorWasmRegex(); | ||
} |
15 changes: 15 additions & 0 deletions
15
src/Templates/Boilerplate/Bit.Boilerplate/src/Tests/PageTests/BlazorWebAssemblyTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using Boilerplate.Client.Web; | ||
|
||
namespace Boilerplate.Tests.PageTests.BlazorWebAssembly; | ||
|
||
[TestClass] | ||
public partial class IdentityPagesTests : BlazorServer.IdentityPagesTests | ||
{ | ||
public override BlazorWebAppMode BlazorRenderMode => BlazorWebAppMode.BlazorWebAssembly; | ||
} | ||
|
||
[TestClass] | ||
public partial class LocalizationTests : BlazorServer.LocalizationTests | ||
{ | ||
public override BlazorWebAppMode BlazorRenderMode => BlazorWebAppMode.BlazorWebAssembly; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters