Add admin ui tests (#40914)
* Add admin ui tests * fix notes test * Apply suggestions from code review --------- Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
<Button Visible="True" Name="PopOut" Access="Public" Text="{Loc 'admin-logs-pop-out'}" StyleClasses="OpenBoth" HorizontalAlignment="Left" />
|
||||
<Control HorizontalExpand="True" />
|
||||
<Button Visible="False" Name="Bans" Text="{Loc 'admin-player-actions-bans'}" StyleClasses="OpenRight" />
|
||||
<Button Visible="False" Name="Notes" Text="{Loc 'admin-player-actions-notes'}" StyleClasses="OpenBoth" />
|
||||
<Button Visible="False" Access="Public" Name="Notes" Text="{Loc 'admin-player-actions-notes'}" StyleClasses="OpenBoth" />
|
||||
<controls:ConfirmButton Visible="False" Name="Kick" Text="{Loc 'admin-player-actions-kick'}" ConfirmationText="{Loc 'admin-player-actions-confirm'}" StyleClasses="OpenBoth" />
|
||||
<Button Visible="False" Name="Ban" Text="{Loc 'admin-player-actions-ban'}" StyleClasses="OpenBoth" />
|
||||
<controls:ConfirmButton Visible="False" Name="Respawn" Text="{Loc 'admin-player-actions-respawn'}" ConfirmationText="{Loc 'admin-player-actions-confirm'}" StyleClasses="OpenBoth" />
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<BoxContainer Orientation="Vertical" Name="Notes" Access="Public" VerticalExpand="True"/>
|
||||
</ScrollContainer>
|
||||
<Button Name="ShowMoreButton" Text="{Loc admin-notes-show-more}" Visible="False" HorizontalAlignment="Center" />
|
||||
<Button Name="NewNoteButton" Text="{Loc admin-notes-new-note}" Disabled="True" />
|
||||
<Button Name="NewNoteButton" Access="Public" Text="{Loc admin-notes-new-note}" Disabled="True" />
|
||||
</BoxContainer>
|
||||
</PanelContainer>
|
||||
</Control>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Title="Loading..."
|
||||
MinSize="400 200">
|
||||
<BoxContainer Orientation="Vertical" Margin="4">
|
||||
<TextEdit Name="NoteTextEdit" HorizontalExpand="True" VerticalExpand="True" />
|
||||
<TextEdit Name="NoteTextEdit" Access="Public" HorizontalExpand="True" VerticalExpand="True" />
|
||||
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
|
||||
<Label Name="ExpiryLabel" Text="{Loc admin-note-editor-expiry-label}" Visible="False" />
|
||||
<HistoryLineEdit Name="ExpiryLineEdit" PlaceHolder="{Loc admin-note-editor-expiry-placeholder}"
|
||||
@@ -17,7 +17,7 @@
|
||||
ToolTip="{Loc admin-note-editor-secret-tooltip}" />
|
||||
<CheckBox Name="PermanentCheckBox" Pressed="True" Text="{Loc admin-note-editor-expiry-checkbox}"
|
||||
ToolTip="{Loc admin-note-editor-expiry-checkbox-tooltip}" />
|
||||
<Button Name="SubmitButton" Text="{Loc admin-note-editor-submit}" HorizontalAlignment="Right" />
|
||||
<Button Name="SubmitButton" Access="Public" Text="{Loc admin-note-editor-submit}" HorizontalAlignment="Right" />
|
||||
</BoxContainer>
|
||||
</BoxContainer>
|
||||
</controls:FancyWindow>
|
||||
|
||||
@@ -133,7 +133,7 @@ public sealed partial class NoteEdit : FancyWindow
|
||||
private bool IsSecret { get; set; }
|
||||
private NoteType NoteType { get; set; }
|
||||
|
||||
private NoteSeverity? NoteSeverity
|
||||
public NoteSeverity? NoteSeverity
|
||||
{
|
||||
get => _noteSeverity;
|
||||
set
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: InternalsVisibleTo("Content.Tests")]
|
||||
[assembly: InternalsVisibleTo("Content.IntegrationTests")]
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
using System.Linq;
|
||||
using Content.Client.Administration.UI;
|
||||
using Content.Client.Administration.UI.CustomControls;
|
||||
using Content.Client.Administration.UI.Logs;
|
||||
using Content.Client.UserInterface.Controls;
|
||||
using Content.Client.UserInterface.Systems.MenuBar.Widgets;
|
||||
using Content.IntegrationTests.Tests.Interaction;
|
||||
using Content.Server.Administration.Commands;
|
||||
using Content.Server.Administration.Logs;
|
||||
using Content.Shared.Database;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.Administration.Logs;
|
||||
|
||||
public sealed class LogWindowTest : InteractionTest
|
||||
{
|
||||
protected override PoolSettings Settings => new() { Connected = true, Dirty = true, AdminLogsEnabled = true, DummyTicker = false };
|
||||
|
||||
[Test]
|
||||
public async Task TestAdminLogsWindow()
|
||||
{
|
||||
// First, generate a new log
|
||||
var log = Server.Resolve<IAdminLogManager>();
|
||||
var guid = Guid.NewGuid();
|
||||
await Server.WaitPost(() => log.Add(LogType.Unknown, $"{SPlayer} test log 1: {guid}"));
|
||||
|
||||
// Click the admin button in the menu bar
|
||||
await ClickWidgetControl<GameTopMenuBar, MenuButton>(nameof(GameTopMenuBar.AdminButton));
|
||||
var adminWindow = GetWindow<AdminMenuWindow>();
|
||||
|
||||
// Find and click the "open logs" button.
|
||||
Assert.That(TryGetControlFromChildren<CommandButton>(x => x.Command == OpenAdminLogsCommand.Cmd, adminWindow, out var btn));
|
||||
await ClickControl(btn!);
|
||||
var logWindow = GetWindow<AdminLogsWindow>();
|
||||
|
||||
// Find the log search field and refresh buttons
|
||||
var search = logWindow.Logs.LogSearch;
|
||||
var refresh = logWindow.Logs.RefreshButton;
|
||||
var cont = logWindow.Logs.LogsContainer;
|
||||
|
||||
// Search for the log we added earlier.
|
||||
await Client.WaitPost(() => search.Text = guid.ToString());
|
||||
await ClickControl(refresh);
|
||||
await RunTicks(5);
|
||||
var searchResult = cont.Children.Where(x => x.Visible && x is AdminLogLabel).Cast<AdminLogLabel>().ToArray();
|
||||
Assert.That(searchResult.Length, Is.EqualTo(1));
|
||||
Assert.That(searchResult[0].Log.Message, Contains.Substring($" test log 1: {guid}"));
|
||||
|
||||
// Add a new log
|
||||
guid = Guid.NewGuid();
|
||||
await Server.WaitPost(() => log.Add(LogType.Unknown, $"{SPlayer} test log 2: {guid}"));
|
||||
|
||||
// Update the search and refresh
|
||||
await Client.WaitPost(() => search.Text = guid.ToString());
|
||||
await ClickControl(refresh);
|
||||
await RunTicks(5);
|
||||
searchResult = cont.Children.Where(x => x.Visible && x is AdminLogLabel).Cast<AdminLogLabel>().ToArray();
|
||||
Assert.That(searchResult.Length, Is.EqualTo(1));
|
||||
Assert.That(searchResult[0].Log.Message, Contains.Substring($" test log 2: {guid}"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
using System.Linq;
|
||||
using Content.Client.Administration.UI.Bwoink;
|
||||
using Content.Client.Administration.UI.CustomControls;
|
||||
using Content.Client.Administration.UI.Notes;
|
||||
using Content.Client.UserInterface.Controls;
|
||||
using Content.Client.UserInterface.Systems.MenuBar.Widgets;
|
||||
using Content.IntegrationTests.Tests.Interaction;
|
||||
using Content.Shared.Database;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.Administration.Notes;
|
||||
|
||||
/// <summary>
|
||||
/// Test that the admin notes UI can be used to add a new note.
|
||||
/// </summary>
|
||||
public sealed class NotesControlTest : InteractionTest
|
||||
{
|
||||
protected override PoolSettings Settings => new() {Connected = true, Dirty = true, AdminLogsEnabled = true, DummyTicker = false};
|
||||
|
||||
[Test]
|
||||
public async Task TestNotesControl()
|
||||
{
|
||||
// Click the ahelp button in the menu bar
|
||||
await ClickWidgetControl<GameTopMenuBar, MenuButton>(nameof(GameTopMenuBar.AHelpButton));
|
||||
var bwoink = GetWindow<BwoinkWindow>();
|
||||
|
||||
// Damn, if only I had an excuse to use bwoink.Bwoink.BwoinkArea
|
||||
var players = bwoink.Bwoink.ChannelSelector.PlayerListContainer;
|
||||
|
||||
// Check that the player is in the menu, and make sure it is selected
|
||||
var entry = players.Data.Cast<PlayerListData>().Single(x => x.Info.SessionId == ServerSession.UserId);
|
||||
await Client.WaitPost(() => players.Select(entry));
|
||||
|
||||
// Open their notes
|
||||
await ClickControl(bwoink.Bwoink.Notes);
|
||||
var noteCtrl = GetWindow<AdminNotesWindow>().Notes;
|
||||
Assert.That(noteCtrl.Notes.ChildCount, Is.EqualTo(0));
|
||||
|
||||
// Add a new note
|
||||
await ClickControl(noteCtrl.NewNoteButton);
|
||||
var addNoteWindow = GetWindow<NoteEdit>();
|
||||
var msg = $"note: {Guid.NewGuid()}";
|
||||
await Client.WaitPost(() => addNoteWindow.NoteTextEdit.TextRope = new Rope.Leaf(msg));
|
||||
addNoteWindow.NoteSeverity = NoteSeverity.None;
|
||||
|
||||
// Have to click submit twice for confirmation?
|
||||
await ClickControl(addNoteWindow.SubmitButton);
|
||||
await ClickControl(addNoteWindow.SubmitButton);
|
||||
|
||||
// Check that the new note exists
|
||||
await RunTicks(5);
|
||||
Assert.That(noteCtrl.Notes.ChildCount, Is.EqualTo(1));
|
||||
var note = (AdminNotesLine)noteCtrl.Notes.Children[0];
|
||||
Assert.That(note.Note.Message, Is.EqualTo(msg));
|
||||
}
|
||||
}
|
||||
@@ -156,10 +156,13 @@ public abstract partial class InteractionTest
|
||||
- type: CombatMode
|
||||
";
|
||||
|
||||
protected static PoolSettings Default => new() { Connected = true, Dirty = true };
|
||||
protected virtual PoolSettings Settings => Default;
|
||||
|
||||
[SetUp]
|
||||
public virtual async Task Setup()
|
||||
{
|
||||
Pair = await PoolManager.GetServerClient(new PoolSettings { Connected = true, Dirty = true });
|
||||
Pair = await PoolManager.GetServerClient(Settings);
|
||||
|
||||
// server dependencies
|
||||
SEntMan = Server.ResolveDependency<IEntityManager>();
|
||||
|
||||
@@ -10,7 +10,8 @@ public sealed class OpenAdminLogsCommand : LocalizedEntityCommands
|
||||
{
|
||||
[Dependency] private readonly EuiManager _euiManager = default!;
|
||||
|
||||
public override string Command => "adminlogs";
|
||||
public override string Command => Cmd;
|
||||
public const string Cmd = "adminlogs";
|
||||
|
||||
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user