1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 03:25:11 +08:00

Add test coverage of failing wiki return to page scenario

This commit is contained in:
Dean Herbert 2023-05-08 15:29:04 +09:00
parent 214bc40570
commit f002038137

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
#nullable disable
using System;
using System.Linq;
using System.Net;
@ -20,7 +18,7 @@ namespace osu.Game.Tests.Visual.Online
{
private DummyAPIAccess dummyAPI => (DummyAPIAccess)API;
private WikiOverlay wiki;
private WikiOverlay wiki = null!;
[SetUp]
public void SetUp() => Schedule(() => Child = wiki = new WikiOverlay());
@ -73,7 +71,23 @@ namespace osu.Game.Tests.Visual.Online
AddUntilStep("Error message correct", () => wiki.ChildrenOfType<SpriteText>().Any(text => text.Text == "\"This_page_will_error_out\"."));
}
private void setUpWikiResponse(APIWikiPage r, string redirectionPath = null)
[Test]
public void TestReturnAfterErrorPage()
{
setUpWikiResponse(responseArticlePage);
AddStep("Show article page", () => wiki.ShowPage("Article_styling_criteria/Formatting"));
AddUntilStep("Wait for non-error page", () => wiki.CurrentPath == "Article_styling_criteria/Formatting");
AddStep("Show nonexistent page", () => wiki.ShowPage("This_page_will_error_out"));
AddUntilStep("Wait for error page", () => wiki.CurrentPath == "error");
AddStep("Show article page", () => wiki.ShowPage("Article_styling_criteria/Formatting"));
AddUntilStep("Wait for non-error page", () => wiki.CurrentPath == "Article_styling_criteria/Formatting");
AddUntilStep("Error message not displayed", () => wiki.ChildrenOfType<SpriteText>().All(text => text.Text != "\"This_page_will_error_out\"."));
}
private void setUpWikiResponse(APIWikiPage r, string? redirectionPath = null)
=> AddStep("set up response", () =>
{
dummyAPI.HandleRequest = request =>