Skip to content

Commit

Permalink
Merge pull request #1785 from riganti/fix-compilation-page
Browse files Browse the repository at this point in the history
Fix compilation page (after AddContentDecorator refactor)
  • Loading branch information
tomasherceg committed Feb 25, 2024
2 parents aea6b0b + fd1aa24 commit ae2f6d5
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 16 deletions.
Expand Up @@ -125,8 +125,8 @@ public void Apply(DotvvmConfiguration config)
url: Url,
virtualPath: "embedded://DotVVM.Framework/Diagnostics/CompilationPage.dothtml");

config.Markup.AddMarkupControl("_dotvvm-internal", "CompilationDiagnostic", "embedded://DotVVM.Framework/Diagnostics/CompilationDiagnostic.dotcontrol");
config.Markup.AddMarkupControl("_dotvvm-internal", "CompilationDiagnosticRows", "embedded://DotVVM.Framework/Diagnostics/CompilationDiagnosticRows.dotcontrol");
config.Markup.AddMarkupControl("dotvvm-internal", "CompilationDiagnostic", "embedded://DotVVM.Framework/Diagnostics/CompilationDiagnostic.dotcontrol");
config.Markup.AddMarkupControl("dotvvm-internal", "CompilationDiagnosticRows", "embedded://DotVVM.Framework/Diagnostics/CompilationDiagnosticRows.dotcontrol");

config.Security.RequireSecFetchHeaders.EnableForRoutes(RouteName);
}
Expand Down
Expand Up @@ -8,7 +8,7 @@
<dot:Repeater DataSource={value: _control.Diagnostics.Take(_control.DisplayLimit)} RenderWrapperTag=false >
<tr Class="row-continues">
<td colspan="5">
<_dotvvm-internal:CompilationDiagnostic style="margin-left: 3rem" />
<dotvvm-internal:CompilationDiagnostic style="margin-left: 3rem" />
</td>
</tr>
</dot:Repeater>
Expand Down
25 changes: 12 additions & 13 deletions src/Framework/Framework/Diagnostics/CompilationPage.dothtml
Expand Up @@ -57,12 +57,12 @@
Class-success="{value: Status == 'CompletedSuccessfully' && Warnings.Length == 0}" />

<dot:AddTemplateDecorator>
<After>
<_dotvvm-internal:CompilationDiagnosticRows
<AfterTemplate>
<dotvvm-internal:CompilationDiagnosticRows
IncludeInPage={value: _root.ShowInlineDiagnostics && Errors.Length + Warnings.Length > 0}
Diagnostics={value: Enumerable.Concat(Errors, Warnings).ToArray()}
DisplayLimit={value: _root.DefaultShownDiagnosticLimit} />
</After>
</AfterTemplate>
</dot:AddTemplateDecorator>
</RowDecorators>
<Columns>
Expand Down Expand Up @@ -108,12 +108,12 @@
<dot:Decorator Class-failure="{value: Status == 'CompilationFailed'}"
Class-success="{value: Status == 'CompletedSuccessfully' && Warnings.Length == 0}" />
<dot:AddTemplateDecorator>
<After>
<_dotvvm-internal:CompilationDiagnosticRows
<AfterTemplate>
<dotvvm-internal:CompilationDiagnosticRows
IncludeInPage={value: _root.ShowInlineDiagnostics && Errors.Length + Warnings.Length > 0}
Diagnostics={value: Enumerable.Concat(Errors, Warnings).ToArray()}
DisplayLimit={value: _root.DefaultShownDiagnosticLimit} />
</After>
</AfterTemplate>
</dot:AddTemplateDecorator>
</RowDecorators>
<Columns>
Expand Down Expand Up @@ -143,17 +143,16 @@
<section IncludeInPage="{value: ActiveTab == 2}" Visible={value: _page.EvaluatingOnClient}>
<h2>Master pages</h2>
<dot:GridView DataSource="{value: MasterPages}" class="nowrap">

<RowDecorators>
<dot:Decorator Class-failure="{value: Status == 'CompilationFailed'}"
Class-success="{value: Status == 'CompletedSuccessfully' && Warnings.Length == 0}" />
<dot:AddTemplateDecorator>
<After>
<_dotvvm-internal:CompilationDiagnosticRows
<AfterTemplate>
<dotvvm-internal:CompilationDiagnosticRows
IncludeInPage={value: _root.ShowInlineDiagnostics && Errors.Length + Warnings.Length > 0}
Diagnostics={value: Enumerable.Concat(Errors, Warnings).ToArray()}
DisplayLimit={value: _root.DefaultShownDiagnosticLimit} />
</After>
</AfterTemplate>
</dot:AddTemplateDecorator>
</RowDecorators>
<Columns>
Expand Down Expand Up @@ -208,7 +207,7 @@
<dot:LinkButton Click="{command: _root.BuildView(_this)}" Text="Recompile" class="execute" />
</td>
</tr>
<_dotvvm-internal:CompilationDiagnosticRows
<dotvvm-internal:CompilationDiagnosticRows
IncludeInPage={value: _root.ShowInlineDiagnostics && Errors.Length + Warnings.Length > 0}
Diagnostics={value: Enumerable.Concat(Errors, Warnings).ToArray()}
DisplayLimit={value: _root.DefaultShownDiagnosticLimit} />
Expand All @@ -225,7 +224,7 @@
<dot:LinkButton Click="{command: _root.BuildView(_this)}" Text="Recompile" class="execute" />
</td>
</tr>
<_dotvvm-internal:CompilationDiagnosticRows
<dotvvm-internal:CompilationDiagnosticRows
IncludeInPage={value: _root.ShowInlineDiagnostics && Errors.Length + Warnings.Length > 0}
Diagnostics={value: Enumerable.Concat(Errors, Warnings).ToArray()}
DisplayLimit={value: _root.DefaultShownDiagnosticLimit} />
Expand All @@ -240,7 +239,7 @@
<dot:LinkButton Click="{command: _root.BuildView(_this)}" Text="Recompile" class="execute" />
</td>
</tr>
<_dotvvm-internal:CompilationDiagnosticRows
<dotvvm-internal:CompilationDiagnosticRows
IncludeInPage={value: _root.ShowInlineDiagnostics && Errors.Length + Warnings.Length > 0}
Diagnostics={value: Enumerable.Concat(Errors, Warnings).ToArray()}
DisplayLimit={value: _root.DefaultShownDiagnosticLimit} />
Expand Down
3 changes: 3 additions & 0 deletions src/Samples/Tests/Tests/Base/AppSeleniumTest.cs
Expand Up @@ -27,6 +27,9 @@ public By SelectByDataUi(string selector)
public By SelectByUiTestName(string selector)
=> SelectBy.CssSelector($"[data-uitest-name='{selector}']");

public By SelectByButtonText(string text) =>
By.XPath($".//button[normalize-space(.)='{text}'] | .//input[(@type='submit' or @type='button') and normalize-space(@value)='{text}']");

public virtual void RunInAllBrowsers(Action<IBrowserWrapper> testBody,
[CallerMemberName] string callerMemberName = "",
[CallerFilePath] string callerFilePath = "",
Expand Down
59 changes: 59 additions & 0 deletions src/Samples/Tests/Tests/Feature/CompilationPageTests.cs
@@ -0,0 +1,59 @@
using DotVVM.Samples.Tests.Base;
using DotVVM.Testing.Abstractions;
using OpenQA.Selenium;
using Riganti.Selenium.Core;
using Riganti.Selenium.Core.Abstractions;
using Riganti.Selenium.DotVVM;
using Xunit;
using Xunit.Abstractions;

namespace DotVVM.Samples.Tests.Feature
{
public class CompilationPageTest : AppSeleniumTest
{
IElementWrapper TableRow(IBrowserWrapper browser, string name) =>
browser.Single($"//tr[not(contains(@class, 'row-continues')) and td[normalize-space(.) = '{name}']]", By.XPath);
[Fact]
[Trait("Category", "dev-only")]
public void Feature_CompilationPage_SmokeTest()
{
RunInAllBrowsers(browser => {
browser.NavigateToUrl("/_dotvvm/diagnostics/compilation");
browser.Single("compile-all-button", By.Id).Click();
browser.Single("Routes", SelectByButtonText).Click();
// shows failed pages
Assert.InRange(browser.FindElements("tbody tr.success").Count, 10, int.MaxValue);
Assert.InRange(browser.FindElements("tbody tr.failure").Count, 10, int.MaxValue);
browser.WaitFor(() => {
AssertUI.HasClass(TableRow(browser, "FeatureSamples_CompilationPage_BindingsTestError"), "failure", waitForOptions: WaitForOptions.Disabled);
}, timeout: 10_000);
AssertUI.HasNotClass(TableRow(browser, "FeatureSamples_CompilationPage_BindingsTest"), "failure");
// shows some errors and warnings
Assert.InRange(browser.FindElements(".source-errorLine").Count, 20, int.MaxValue);
Assert.InRange(browser.FindElements(".source-warningLine").Count, 20, int.MaxValue);
// found master pages
browser.Single("Master pages", SelectByButtonText).Click();
AssertUI.IsDisplayed(TableRow(browser, "Views/Errors/Master.dotmaster"));
AssertUI.IsDisplayed(TableRow(browser, "Views/ControlSamples/SpaContentPlaceHolder_HistoryApi/SpaMaster.dotmaster"));
// found controls
browser.Single("Controls", SelectByButtonText).Click();
AssertUI.IsDisplayed(TableRow(browser, "MarkupControlPropertiesSameName"));
// filters errors and warnings
browser.Single("Errors", SelectByButtonText).Click();
browser.FindElements("tbody tr:not(.failure):not(.row-continues)").ThrowIfDifferentCountThan(0);
browser.Single("Warnings", SelectByButtonText).Click();
browser.FindElements("tbody tr.success").ThrowIfDifferentCountThan(0);
});
}

public CompilationPageTest(ITestOutputHelper output) : base(output)
{
}
}
}

0 comments on commit ae2f6d5

Please sign in to comment.