WIP phase 39: school owners, my/others menu, guest restrictions.

This commit is contained in:
Leonid Pershin
2026-08-20 07:58:12 +03:00
parent 40929aa3ce
commit 26be7c87f8
27 changed files with 919 additions and 81 deletions
+34 -1
View File
@@ -22,7 +22,7 @@ public class GameSocketTests(AppHostFixture fixture)
Assert.Equal(ProtocolConstants.Version, welcome.ProtocolVersion);
Assert.Equal(20, welcome.TickRate);
Assert.Equal(6, welcome.MaxSchools);
Assert.Equal(2, welcome.MaxSchools);
}
[Fact]
@@ -387,6 +387,39 @@ public class GameSocketTests(AppHostFixture fixture)
Assert.True(runningLater.GameTime > running.GameTime, "Pausing one school stopped the other.");
}
[Fact]
public async Task Guest_SetRunning_DoesNotChangeOwnerRunning()
{
using var ownerClient = await SchoolApiTests.CreateIsolatedClientAsync(fixture.App, "GuestClockOwner");
await SchoolApiTests.WipeAllSavesAsync(ownerClient);
var school = await SchoolApiTests.CreateAsync(ownerClient, "Гостевые часы", StartDate);
var guestCookie = await SchoolApiTests.LoginAndGetCookieAsync(
fixture.App.CreateHttpClient("server"),
"GuestClockViewer");
using var socket = new ClientWebSocket();
socket.Options.SetRequestHeader("Cookie", guestCookie);
var http = fixture.App.GetEndpoint("server", "http");
var uri = new UriBuilder(http) { Scheme = "ws", Path = "/ws/game" }.Uri;
await socket.ConnectAsync(uri, TestContext.Current.CancellationToken).WaitAsync(DefaultTimeout);
await SendAsync(socket, buffer =>
ProtocolCodec.WriteHello(buffer, new ClientHelloMessage(ProtocolConstants.Version, ProtocolConstants.LocaleRussian)));
await ReceiveUntilAsync(socket, MessageType.ServerWelcome);
await SendAsync(socket, buffer =>
ProtocolCodec.WriteOpenSchool(buffer, new ClientOpenSchoolMessage(school.Id)));
_ = await ReceiveClockAsync(socket);
await SendAsync(socket, buffer =>
ProtocolCodec.WriteSetRunning(buffer, new ClientSetRunningMessage(Running: false)));
await Task.Delay(TimeSpan.FromMilliseconds(300), TestContext.Current.CancellationToken);
var ownerView = await FindAsync(ownerClient, school.Id);
Assert.True(ownerView.Running);
using var delete = await ownerClient.DeleteAsync($"/api/schools/{school.Id}", TestContext.Current.CancellationToken);
delete.EnsureSuccessStatusCode();
}
[Fact]
public async Task ReloadFromDisk_RestoresAPausedClock()
{