<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" />
<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>
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}"
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>
private bool IsSecret { get; set; }
private NoteType NoteType { get; set; }
- private NoteSeverity? NoteSeverity
+ public NoteSeverity? NoteSeverity
{
get => _noteSeverity;
set
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Content.Tests")]
+[assembly: InternalsVisibleTo("Content.IntegrationTests")]
--- /dev/null
+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}"));
+ }
+}
--- /dev/null
+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));
+ }
+}
- 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>();
{
[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)
{