1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 11:42:56 +08:00

Merge pull request #23436 from peppy/fix-wiki-error-return-to-main

Fix "Return to main page" link not working on wiki after error
This commit is contained in:
Bartłomiej Dach 2023-05-08 21:56:29 +02:00 committed by GitHub
commit 2177dbf42a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 6 deletions

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());
@ -29,13 +27,13 @@ namespace osu.Game.Tests.Visual.Online
public void TestMainPage()
{
setUpWikiResponse(responseMainPage);
AddStep("Show main page", () => wiki.Show());
AddStep("Show main page", () => wiki.ShowPage());
}
[Test]
public void TestCancellationDoesntShowError()
{
AddStep("Show main page", () => wiki.Show());
AddStep("Show main page", () => wiki.ShowPage());
AddStep("Show another page", () => wiki.ShowPage("Article_styling_criteria/Formatting"));
AddUntilStep("Current path is not error", () => wiki.CurrentPath != "error");
@ -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 =>

View File

@ -157,7 +157,9 @@ namespace osu.Game.Overlays
private void onFail(string originalPath)
{
wikiData.Value = null;
path.Value = "error";
LoadDisplay(articlePage = new WikiArticlePage($@"{api.WebsiteRootUrl}/wiki/",
$"Something went wrong when trying to fetch page \"{originalPath}\".\n\n[Return to the main page](Main_Page)."));
}