Some checks failed
CI / build-and-test (push) Failing after 28s
The IN-CALL pill now reads 'IN CALL · Weekly Standup' (or 'IN CALL' if Teams' window doesn't expose a meeting title), so operators using auto-hide know WHICH meeting they're in without restoring the Teams window. Implementation: TeamsLauncher.GetActiveWindowTitle uses EnumWindows + GetWindowTextW to read every Teams top-level window title (hidden windows too — title bar text is accessible even with SW_HIDE), picks the longest as a heuristic for 'most informative' (Teams creates several windows per process; the call window has the meaningful title). MainViewModel.ExtractMeetingTitle strips the ' | Microsoft Teams' / ' - Microsoft Teams' suffix variations and clamps overly long titles to 50 chars with an ellipsis. 10 new unit tests for ExtractMeetingTitle covering: standard formats with both separators, bare 'Microsoft Teams' (returns empty so the pill stays at 'IN CALL'), long-title truncation, outer-whitespace trimming, unrecognized formats passing through. 169/169 tests passing.
67 lines
2.3 KiB
C#
67 lines
2.3 KiB
C#
using TeamsISO.App.ViewModels;
|
|
using Xunit;
|
|
|
|
namespace TeamsISO.App.Tests;
|
|
|
|
/// <summary>
|
|
/// Validates the title-stripping heuristic used by the IN-CALL bar pill.
|
|
/// Teams' raw window title is the format the user actually sees (or doesn't —
|
|
/// when auto-hide is on); we want to surface the meaningful meeting-name
|
|
/// portion without the "| Microsoft Teams" suffix bloating the pill.
|
|
/// </summary>
|
|
public class MeetingTitleExtractionTests
|
|
{
|
|
[Theory]
|
|
[InlineData("Weekly Standup | Microsoft Teams", "Weekly Standup")]
|
|
[InlineData("Meeting with Alice | Microsoft Teams", "Meeting with Alice")]
|
|
[InlineData("Q4 Planning - Microsoft Teams", "Q4 Planning")]
|
|
[InlineData("Meeting | Teams", "Meeting")]
|
|
public void StripsTeamsSuffix(string raw, string expected)
|
|
{
|
|
Assert.Equal(expected, MainViewModel.ExtractMeetingTitle(raw));
|
|
}
|
|
|
|
[Fact]
|
|
public void EmptyInput_ReturnsEmpty()
|
|
{
|
|
Assert.Equal(string.Empty, MainViewModel.ExtractMeetingTitle(string.Empty));
|
|
}
|
|
|
|
[Fact]
|
|
public void Whitespace_ReturnsEmpty()
|
|
{
|
|
Assert.Equal(string.Empty, MainViewModel.ExtractMeetingTitle(" "));
|
|
}
|
|
|
|
[Fact]
|
|
public void BareAppTitle_ReturnsEmpty()
|
|
{
|
|
// "Microsoft Teams" alone means no meeting context — pill should
|
|
// stay at plain "IN CALL" rather than appending a meaningless title.
|
|
Assert.Equal(string.Empty, MainViewModel.ExtractMeetingTitle("Microsoft Teams"));
|
|
}
|
|
|
|
[Fact]
|
|
public void LongTitle_GetsTruncated()
|
|
{
|
|
var long_ = new string('A', 100) + " | Microsoft Teams";
|
|
var result = MainViewModel.ExtractMeetingTitle(long_);
|
|
Assert.True(result.Length <= 50);
|
|
Assert.EndsWith("…", result);
|
|
}
|
|
|
|
[Fact]
|
|
public void OuterWhitespaceIsTrimmed()
|
|
{
|
|
// Real Teams uses single-space format " | Microsoft Teams"; we only
|
|
// promise to trim outer whitespace, not normalize internal padding.
|
|
Assert.Equal("Project sync", MainViewModel.ExtractMeetingTitle(" Project sync | Microsoft Teams "));
|
|
}
|
|
|
|
[Fact]
|
|
public void TitleWithoutSeparator_PassesThrough()
|
|
{
|
|
// If Teams emits an unrecognized format, return it as-is (clamped to 50).
|
|
Assert.Equal("Quick chat", MainViewModel.ExtractMeetingTitle("Quick chat"));
|
|
}
|
|
}
|