Premiere commit - Omika
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Omika.Tests.Mobile.Local;
|
||||
|
||||
/// <summary>
|
||||
/// Vérifications ciblées du Design System pour les Views Documents / Photos :
|
||||
/// aucune couleur hexadécimale standard, aucun breakpoint local supplémentaire,
|
||||
/// réutilisation des styles sémantiques existants.
|
||||
/// </summary>
|
||||
public class DocumentDesignSystemTests
|
||||
{
|
||||
private static readonly string[] ViewFiles =
|
||||
[
|
||||
Path.Combine(AppContext.BaseDirectory, "..", "..", "..", "..", "..", "src", "Omika.App", "Views", "InterventionDocumentsView.axaml")
|
||||
];
|
||||
|
||||
private static readonly string[] Breakpoints =
|
||||
[
|
||||
"BreakpointPhone",
|
||||
"BreakpointTablet",
|
||||
"BreakpointDesktop"
|
||||
];
|
||||
|
||||
private static string ReadView(string path)
|
||||
{
|
||||
string full = Path.GetFullPath(path);
|
||||
if (!File.Exists(full))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
return File.ReadAllText(full);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AucuneCouleurHexadecimaleStandard()
|
||||
{
|
||||
// Regex des couleurs hexadécimales (#RGB, #RRGGBB, #AARRGGBB).
|
||||
var hexColor = new Regex(@"#[0-9A-Fa-f]{3,8}\b");
|
||||
|
||||
foreach (string file in ViewFiles)
|
||||
{
|
||||
string content = ReadView(file);
|
||||
if (string.IsNullOrEmpty(content))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Assert.False(hexColor.IsMatch(content),
|
||||
$"La View {Path.GetFileName(file)} introduit une couleur hexadécimale.");
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AucunBreakpointLocalSupplementaire()
|
||||
{
|
||||
// Les seuls breakpoints autorisés sont ceux du Design System.
|
||||
var breakpointRef = new Regex(@"Breakpoint[A-Za-z]+");
|
||||
|
||||
foreach (string file in ViewFiles)
|
||||
{
|
||||
string content = ReadView(file);
|
||||
if (string.IsNullOrEmpty(content))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (Match match in breakpointRef.Matches(content))
|
||||
{
|
||||
Assert.True(Breakpoints.Contains(match.Value),
|
||||
$"La View {Path.GetFileName(file)} utilise un breakpoint local non autorisé : {match.Value}.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReutiliseLesStylesSemantiquesExistants()
|
||||
{
|
||||
// La View Documents doit utiliser les styles sémantiques du Design System.
|
||||
string content = ReadView(ViewFiles[0]);
|
||||
if (string.IsNullOrEmpty(content))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Styles sémantiques attendus dans la liste Documents.
|
||||
Assert.Contains("Classes=\"card\"", content);
|
||||
Assert.Contains("Classes=\"listTitle\"", content);
|
||||
Assert.Contains("Classes=\"primary\"", content);
|
||||
Assert.Contains("Classes=\"secondary\"", content);
|
||||
Assert.Contains("Classes=\"badge", content);
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UtiliseDesDynamicResourcePourLesEspacements()
|
||||
{
|
||||
// Les espacements doivent venir du Design System via DynamicResource.
|
||||
string content = ReadView(ViewFiles[0]);
|
||||
if (string.IsNullOrEmpty(content))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Assert.Contains("DynamicResource Space", content);
|
||||
Assert.Contains("DynamicResource ThicknessPage", content);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user