Skip to content
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
e7dbbd2
VPR-157 feat(a11y): add Word and PDF accessibility helpers
rlorenzo May 1, 2026
c686a34
VPR-157 feat(a11y): tag Photo Gallery Word and PDF exports
rlorenzo May 1, 2026
6c3d387
VPR-157 feat(a11y): tag Emergency Contact PDFs for PDF/UA
rlorenzo May 1, 2026
60c2073
VPR-157 feat(a11y): tag Clinical Effort PDF and add Effort footer helper
rlorenzo May 1, 2026
894b901
VPR-157 feat(a11y): add Excel accessibility helper for ClosedXML
rlorenzo May 1, 2026
6220f77
VPR-157 feat(a11y): tag Clinical Schedule PDF and Excel for accessibi…
rlorenzo May 1, 2026
2307b17
VPR-157 feat(a11y): tag School Summary PDF and Excel for accessibility
rlorenzo May 1, 2026
d1dc969
VPR-157 feat(a11y): tag Department Summary PDF and Excel for accessib…
rlorenzo May 1, 2026
30c0c9a
VPR-157 feat(a11y): tag Teaching Activity PDF and Excel for accessibi…
rlorenzo May 1, 2026
23b2970
VPR-157 feat(a11y): tag Merit Summary PDF and Excel for accessibility
rlorenzo May 1, 2026
c8631ff
VPR-157 feat(a11y): tag Merit Report PDFs and Excel for accessibility
rlorenzo May 1, 2026
d3336bc
VPR-157 feat(a11y): tag Evaluation Report PDFs and Excel for accessib…
rlorenzo May 1, 2026
b686fd0
VPR-157 feat(a11y): tag Multi-Year Merit PDF and Excel for accessibility
rlorenzo May 1, 2026
37e151c
VPR-157 feat(a11y): tag Clinical Effort and Emergency Contact Excel e…
rlorenzo May 1, 2026
d920198
VPR-157 fix(a11y): address CodeRabbit review on accessible exports
rlorenzo May 1, 2026
e9c3a3a
VPR-157 fix(a11y): idempotent style helper and document export interf…
rlorenzo May 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions test/Classes/Utilities/ExcelAccessibilityHelperTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
using ClosedXML.Excel;
using Viper.Classes.Utilities;

namespace Test.Classes.Utilities;

public class ExcelAccessibilityHelperTests
{
[Fact]
public void SetCoreProperties_PopulatesTitleSubjectAuthor()
{
using var wb = new XLWorkbook();

ExcelAccessibilityHelper.SetCoreProperties(wb,
title: "Annual Report",
subject: "FY26 figures",
author: "Test Suite");

Assert.Equal("Annual Report", wb.Properties.Title);
Assert.Equal("FY26 figures", wb.Properties.Subject);
Assert.Equal("Test Suite", wb.Properties.Author);
}

[Fact]
public void SetCoreProperties_DefaultsAuthorToUcDavisSvm()
{
using var wb = new XLWorkbook();

ExcelAccessibilityHelper.SetCoreProperties(wb, title: "Doc");

Assert.Equal(ExcelAccessibilityHelper.DefaultAuthor, wb.Properties.Author);
}

[Fact]
public void SetCoreProperties_FallsBackSubjectToTitleWhenNull()
{
using var wb = new XLWorkbook();

ExcelAccessibilityHelper.SetCoreProperties(wb, title: "Just A Title");

Assert.Equal("Just A Title", wb.Properties.Subject);
}

[Fact]
public void PromoteToAccessibleTable_CreatesTableWithGivenName()
{
using var wb = new XLWorkbook();
var ws = wb.Worksheets.Add("Data");
ws.Cell(1, 1).Value = "Name";
ws.Cell(1, 2).Value = "Score";
ws.Cell(2, 1).Value = "Alice";
ws.Cell(2, 2).Value = 42;

var table = ExcelAccessibilityHelper.PromoteToAccessibleTable(
ws.Range(1, 1, 2, 2), "ScoresTable");

Assert.Equal("ScoresTable", table.Name);
Assert.True(table.ShowHeaderRow);
}

[Fact]
public void PromoteToAccessibleTable_SanitizesInvalidCharactersInTableName()
{
using var wb = new XLWorkbook();
var ws = wb.Worksheets.Add("Data");
ws.Cell(1, 1).Value = "Header";
ws.Cell(2, 1).Value = "Row";

var table = ExcelAccessibilityHelper.PromoteToAccessibleTable(
ws.Range(1, 1, 2, 1), "Cardiology - Group A");

Assert.Equal("Cardiology___Group_A", table.Name);
}

[Fact]
public void PromoteToAccessibleTable_PrependsLetterWhenNameStartsWithDigit()
{
using var wb = new XLWorkbook();
var ws = wb.Worksheets.Add("Data");
ws.Cell(1, 1).Value = "Header";
ws.Cell(2, 1).Value = "Row";

var table = ExcelAccessibilityHelper.PromoteToAccessibleTable(
ws.Range(1, 1, 2, 1), "2026Report");

Assert.StartsWith("T_", table.Name);
Assert.Contains("2026Report", table.Name);
}

[Fact]
public void PromoteToAccessibleTable_HidesAutoFilterDropdowns()
{
using var wb = new XLWorkbook();
var ws = wb.Worksheets.Add("Data");
ws.Cell(1, 1).Value = "Header";
ws.Cell(2, 1).Value = "Row";

var table = ExcelAccessibilityHelper.PromoteToAccessibleTable(
ws.Range(1, 1, 2, 1), "T1");

Assert.False(table.ShowAutoFilter);
}
}
82 changes: 82 additions & 0 deletions test/Classes/Utilities/PdfAccessibilityHelperTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
using QuestPDF.Fluent;
using QuestPDF.Infrastructure;
using Viper.Classes.Utilities;

namespace Test.Classes.Utilities;

public class PdfAccessibilityHelperTests
{
private static Document MinimalDocument() =>
Document.Create(container =>
container.Page(page => page.Content().Text("placeholder")));

[Fact]
public void WithAccessibility_PopulatesAllMetadataFields()
{
var document = MinimalDocument().WithAccessibility(
title: "Annual Report",
subject: "FY26 figures",
keywords: "merit, evaluation",
author: "Test Suite",
language: "en-GB");

var meta = document.GetMetadata();
Assert.Equal("Annual Report", meta.Title);
Assert.Equal("FY26 figures", meta.Subject);
Assert.Equal("merit, evaluation", meta.Keywords);
Assert.Equal("Test Suite", meta.Author);
Assert.Equal("en-GB", meta.Language);
}

[Fact]
public void WithAccessibility_DefaultsAuthorToUcDavisSvm()
{
var document = MinimalDocument().WithAccessibility(title: "Doc");

Assert.Equal(PdfAccessibilityHelper.DefaultAuthor, document.GetMetadata().Author);
}

[Fact]
public void WithAccessibility_DefaultsLanguageToEnUs()
{
var document = MinimalDocument().WithAccessibility(title: "Doc");

Assert.Equal(PdfAccessibilityHelper.DefaultLanguage, document.GetMetadata().Language);
}

[Fact]
public void WithAccessibility_SubjectFallsBackToTitleWhenNull()
{
var document = MinimalDocument().WithAccessibility(title: "Title Only");

Assert.Equal("Title Only", document.GetMetadata().Subject);
}

[Fact]
public void WithAccessibility_KeywordsDefaultToEmptyStringWhenNull()
{
var document = MinimalDocument().WithAccessibility(title: "Doc");

Assert.Equal(string.Empty, document.GetMetadata().Keywords);
}

[Fact]
public void WithAccessibility_EnablesPdfUa1Conformance()
{
var document = MinimalDocument().WithAccessibility(title: "Doc");

Assert.Equal(PDFUA_Conformance.PDFUA_1, document.GetSettings().PDFUA_Conformance);
}

[Fact]
public void WithAccessibility_StampsCreationAndModifiedDates()
{
var before = DateTimeOffset.Now.AddSeconds(-5);
var document = MinimalDocument().WithAccessibility(title: "Doc");
var after = DateTimeOffset.Now.AddSeconds(5);

var meta = document.GetMetadata();
Assert.InRange(meta.CreationDate, before, after);
Assert.InRange(meta.ModifiedDate, before, after);
}
}
Loading
Loading