Skip to content

Commit

Permalink
Isolated test case and output if the error returns
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasherceg committed Mar 23, 2024
1 parent 4cd20f5 commit e0fd59d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/Samples/AspNetCoreLatest/DotvvmServiceConfigurator.cs
Expand Up @@ -10,7 +10,7 @@ public void ConfigureServices(IDotvvmServiceCollection services)
{
CommonConfiguration.ConfigureServices(services);
services.AddDefaultTempStorages("Temp");
// services.AddHotReload();
services.AddHotReload();
}
}
}
2 changes: 1 addition & 1 deletion src/Samples/AspNetCoreLatest/Startup.cs
Expand Up @@ -99,7 +99,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerF
app.UseStaticFiles();

app.UseEndpoints(endpoints => {
// endpoints.MapDotvvmHotReload();
endpoints.MapDotvvmHotReload();
endpoints.MapMetrics(); // prometheus metrics on /metrics
});
}
Expand Down
Expand Up @@ -39,7 +39,7 @@ public async Task ProcessRequest(IDotvvmRequestContext context)
}))
.OrderBy(m => m.Namespace).ThenBy(m => m.Name);

await context.HttpContext.Response.WriteAsync("ExtensionMethodsCache dump: " + JsonConvert.SerializeObject(dump));
await context.HttpContext.Response.WriteAsync("ExtensionMethodsCache dump: " + JsonConvert.SerializeObject(dump, Formatting.Indented));
}
}
}
36 changes: 20 additions & 16 deletions src/Samples/Tests/Tests/Feature/StaticCommandTests.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -817,35 +818,38 @@ public void Feature_List_Translation_Remove_Range()
Assert.Equal(new List<string> { "1", "2", "8", "9", "10" }, column);
});
}

[Fact]
public async Task Feature_List_Translation_Remove_Reverse()
public void Feature_List_Translation_Remove_Reverse()
{
var wasError = false;

RunInAllBrowsers(browser => {
browser.NavigateToUrl(SamplesRouteUrls.FeatureSamples_JavascriptTranslation_ListMethodTranslations);
browser.Wait(1000);
if (browser.FindElements(".exceptionMessage").Count > 0)
{
wasError = true;
return;
}
var rows = GetSortedRow(browser, "Reverse");
var column = GetColumnContent(rows, 0);
browser.WaitFor(() => Assert.Equal(10, column.Count), 500);
Assert.Equal(new List<string> { "10", "9", "8", "7", "6", "5", "4", "3", "2", "1" }, column);
});
}

[Fact]
public async Task Feature_ExtensionMethodsNotResolvedOnStartup()
{
var client = new HttpClient();

// try to visit the page
var pageResponse = await client.GetAsync(TestSuiteRunner.Configuration.BaseUrls[0].TrimEnd('/') + "/" + SamplesRouteUrls.FeatureSamples_JavascriptTranslation_ListMethodTranslations);
TestOutput.WriteLine($"Page response: {(int)pageResponse.StatusCode}");
var wasError = pageResponse.StatusCode != HttpStatusCode.OK;

// dump extension methods on the output
var json = await client.GetStringAsync(TestSuiteRunner.Configuration.BaseUrls[0].TrimEnd('/') + "/dump-extension-methods");
TestOutput.WriteLine(json);

if (wasError)
{
// error page - extension methods not found
var client = new HttpClient();
var json = await client.GetStringAsync(TestSuiteRunner.Configuration.BaseUrls[0].TrimEnd('/') + "/dump-extension-methods");
TestOutput.WriteLine(json);
throw new Exception("Test failed");
// fail the test on error
throw new Exception("Extension methods were not resolved on application startup.");
}
}

Expand Down

0 comments on commit e0fd59d

Please sign in to comment.