mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-25 20:53:50 +00:00
49 lines
2.2 KiB
C#
49 lines
2.2 KiB
C#
using AIStudio.Components;
|
|
using AIStudio.Tools;
|
|
|
|
namespace AIStudio.Tests.Components;
|
|
|
|
/// <summary>
|
|
/// Checks which actions a path gets: those of a file, those of a web page, or none.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// A button which cannot work must not show: a relative path would open another file depending on
|
|
/// where it is opened from, and the address of a mail names it for AI Studio only.
|
|
/// </remarks>
|
|
[TestFixture]
|
|
public sealed class FileActionsTests
|
|
{
|
|
[Test]
|
|
public void AnAbsolutePathIsAFile() => Assert.That(FileActions.DetermineKind(Path.Combine(Path.GetTempPath(), "minutes.pdf")), Is.EqualTo(FileActions.FileActionsKind.FILE));
|
|
|
|
[TestCase("https://example.org/budget-2026")]
|
|
[TestCase("http://intranet.example.org/wiki/page")]
|
|
public void AWebAddressIsAWebPage(string address) => Assert.That(FileActions.DetermineKind(address), Is.EqualTo(FileActions.FileActionsKind.WEB_PAGE));
|
|
|
|
[TestCase("")]
|
|
[TestCase("notes/minutes.txt")]
|
|
public void ARelativePathOrNothingGetsNoActions(string path) => Assert.That(FileActions.DetermineKind(path), Is.EqualTo(FileActions.FileActionsKind.NONE));
|
|
|
|
[Test]
|
|
public void AMailGetsNoActions() => Assert.That(FileActions.DetermineKind(SourceExtensions.CreateMailSourceUrl("6a1f2b3c-4d5e-4f60-8a7b-9c0d1e2f3a4b", "mail-1")), Is.EqualTo(FileActions.FileActionsKind.NONE));
|
|
|
|
[Test]
|
|
public void WhatOnlyADataSourceKnowsGetsNoActions() => Assert.That(FileActions.DetermineKind(SourceExtensions.CreateRetrievalSourceUrl("handbook.pdf", "docs/handbook.pdf")), Is.EqualTo(FileActions.FileActionsKind.NONE));
|
|
|
|
/// <summary>
|
|
/// Inside a Flatpak, no page reaches the program, so the tooltip must not promise one. It still names
|
|
/// the page, since that is where the passage is. Nothing asserts on the wording, which I18N decides.
|
|
/// </summary>
|
|
[Test]
|
|
public void WhereNoPageCanArriveTheTooltipPromisesNone()
|
|
{
|
|
var promise = FileActions.GetOpenTooltip(33, canOpenAtPage: true);
|
|
var withoutPromise = FileActions.GetOpenTooltip(33, canOpenAtPage: false);
|
|
|
|
using (Assert.EnterMultipleScope())
|
|
{
|
|
Assert.That(withoutPromise, Is.Not.EqualTo(promise));
|
|
Assert.That(withoutPromise, Does.Contain("33"));
|
|
}
|
|
}
|
|
} |