Files
meeting-assistant/MeetingAssistant.Tests/MacOsDesktopControlManifestTests.cs

105 lines
3.7 KiB
C#

using MeetingAssistant.LaunchProfiles;
using MeetingAssistant.MacOs;
using MeetingAssistant.Workflow;
using MeetingAssistant.Notifications;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
namespace MeetingAssistant.Tests;
public sealed class MacOsDesktopControlManifestTests
{
[Fact]
public void AutomaticWorkflowChangeCannotSilentlyLoseItsPromptOnMacOs()
{
IWorkflowRulesEditorWindowService service = new MacOsWorkflowRulesEditorWindowService(
Options.Create(new MeetingAssistantOptions()));
Assert.Throws<PlatformNotSupportedException>(() => service.ShowWithPrompt("Update meeting rules"));
}
[Fact]
public async Task MacOsApplicationDeclinesUnavailableAutomaticApprovals()
{
using var factory = new WebApplicationFactory<Program>();
var approval = factory.Services.GetRequiredService<AgentApprovalService>();
Assert.False(await approval.ConfirmAsync("Test approval", "Do not apply a change", CancellationToken.None));
}
[Fact]
public void MacOsApplicationRegistersARealInteractiveAgentWindow()
{
using var factory = new WebApplicationFactory<Program>();
var service = factory.Services.GetRequiredService<IWorkflowRulesEditorWindowService>();
Assert.IsType<MacOsWorkflowRulesEditorWindowService>(service);
}
[Fact]
public void ManifestPreservesConfiguredWindowsEquivalentShortcutsAndControlEndpoints()
{
var profiles = new[]
{
Profile("default", "Ctrl+Alt+M", "Ctrl+Alt+Z", "Ctrl+Alt+S"),
Profile("english", "Ctrl+Alt+L", "", "")
};
var hotkeys = new[]
{
new LaunchProfileHotkey("default", "Ctrl+Alt+M", LaunchProfileHotkeyAction.ToggleRecording),
new LaunchProfileHotkey("default", "Ctrl+Alt+Z", LaunchProfileHotkeyAction.AbortRecording),
new LaunchProfileHotkey("default", "Ctrl+Alt+S", LaunchProfileHotkeyAction.CaptureScreenshot),
new LaunchProfileHotkey("english", "Ctrl+Alt+L", LaunchProfileHotkeyAction.ToggleRecording)
};
var manifest = MacOsDesktopControlManifest.Create(
"http://127.0.0.1:5090",
profiles,
hotkeys);
Assert.Collection(
manifest.Hotkeys,
hotkey =>
{
Assert.Equal("Ctrl+Alt+M", hotkey.Shortcut);
Assert.Equal("/profiles/default/recording/toggle", hotkey.Endpoint);
},
hotkey =>
{
Assert.Equal("Ctrl+Alt+Z", hotkey.Shortcut);
Assert.Equal("/profiles/default/recording/abort", hotkey.Endpoint);
},
hotkey =>
{
Assert.Equal("Ctrl+Alt+S", hotkey.Shortcut);
Assert.Equal("/profiles/default/meetings/screenshot/capture", hotkey.Endpoint);
},
hotkey =>
{
Assert.Equal("Ctrl+Alt+L", hotkey.Shortcut);
Assert.Equal("/profiles/english/recording/toggle", hotkey.Endpoint);
});
Assert.Equal("http://127.0.0.1:5090/recording/status", manifest.StatusUrl);
Assert.Equal("http://127.0.0.1:5090/diagnostics/settings-and-logs", manifest.OpenAgentUrl);
}
private static LaunchProfile Profile(string name, string toggle, string abort, string screenshot)
{
return new LaunchProfile(name, new MeetingAssistantOptions
{
Hotkey = new HotkeyOptions
{
Toggle = toggle,
Abort = abort
},
Screenshots = new ScreenshotOptions
{
Hotkey = screenshot
}
});
}
}