Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ namespace MUnique.OpenMU.Web.Tests.Pages;
/// <summary>
/// Tests for the <see cref="LoggingConfiguration"/> page.
/// </summary>
/// <remarks>
/// The page loads the configuration file asynchronously. When the tests interact with it right after
/// the content appeared, the page may still finish its initialization, and the event is handled after
/// <c>Click</c> or <c>Change</c> returned. So the tests wait for the result of each interaction.
/// </remarks>
[TestFixture]
[NonParallelizable]
public class LoggingConfigurationPageTests
Expand Down Expand Up @@ -75,9 +80,13 @@ public void SavesChangedLevels()
Assert.That(cut.Find("#defaultLogLevel").GetAttribute("value"), Is.EqualTo("Information"));

cut.Find("#defaultLogLevel").Change("Debug");
cut.WaitForState(() => cut.Find("#defaultLogLevel").GetAttribute("value") == "Debug");
cut.FindAll("button").First(b => b.TextContent.Contains(Resources.AddNew)).Click();
cut.WaitForState(() => cut.FindAll("tbody input").Count == 2);
cut.FindAll("tbody input")[1].Change("MUnique.OpenMU.GameLogic");
cut.WaitForState(() => cut.FindAll("tbody input")[1].GetAttribute("value") == "MUnique.OpenMU.GameLogic");
cut.FindAll("tbody select")[1].Change("Verbose");
cut.WaitForState(() => cut.FindAll("tbody select")[1].GetAttribute("value") == "Verbose");
cut.FindAll("button").First(b => b.TextContent.Contains(Resources.Save)).Click();

cut.WaitForAssertion(() => this._toastService.Verify(t => t.ShowSuccess(Resources.LoggingConfigurationSaved, null)));
Expand All @@ -98,9 +107,10 @@ public void DoesNotSaveOverrideWithoutSource()
cut.WaitForState(() => cut.FindAll("tbody tr").Count == 1);

cut.FindAll("button").First(b => b.TextContent.Contains(Resources.AddNew)).Click();
cut.WaitForState(() => cut.FindAll("tbody tr").Count == 2);
cut.FindAll("button").First(b => b.TextContent.Contains(Resources.Save)).Click();

this._toastService.Verify(t => t.ShowError(Resources.LogLevelOverridesInvalid, null));
cut.WaitForAssertion(() => this._toastService.Verify(t => t.ShowError(Resources.LogLevelOverridesInvalid, null)));
Assert.That(File.ReadAllText(this._filePath), Is.EqualTo(content));
}

Expand All @@ -115,7 +125,8 @@ public void DoesNotSaveInvalidJson()
cut.WaitForState(() => cut.FindAll("button.nav-link").Count == 2);

cut.FindAll("button.nav-link")[1].Click();
cut.Find("textarea").Change("{ \"MinimumLevel\": ");
cut.WaitForElement("textarea").Change("{ \"MinimumLevel\": ");
cut.WaitForState(() => cut.Find("textarea").GetAttribute("value") == "{ \"MinimumLevel\": ");
cut.FindAll("button").First(b => b.TextContent.Contains(Resources.Save)).Click();

cut.WaitForAssertion(() => this._toastService.Verify(t => t.ShowError(It.Is<string>(m => m.StartsWith("The JSON is invalid")), null)));
Expand Down
Loading