From 2de1105ecd83325f211a47379b4ca165e80b4b9a Mon Sep 17 00:00:00 2001 From: Alejandro Rosales Date: Thu, 17 Sep 2026 11:46:33 -0600 Subject: [PATCH] Customize welcome text from room and OU --- docs/welcome-wallpaper.md | 2 +- scripts/Set-SguWelcomeWallpaper.ps1 | 16 ++++++++++++---- tests/WelcomeWallpaper.Tests.ps1 | 18 +++++++++++++++--- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/docs/welcome-wallpaper.md b/docs/welcome-wallpaper.md index 3e2183b..35e9677 100644 --- a/docs/welcome-wallpaper.md +++ b/docs/welcome-wallpaper.md @@ -26,7 +26,7 @@ El saludo usa `Bienvenido/ubicado` para `Male` y `Bienvenida/ubicada` para neutral `Te damos la bienvenida` y `Ubicación:`. El texto secundario sigue estas reglas: -1. Con `location` y OU: `Estás ubicado en la Sala de Inmersión del Centro de Experiencia Digital.` +1. Con `location` y OU: `Acceso al Aula Flexible del Centro de Experiencia Digital.` 2. Con sólo uno de los datos: muestra únicamente el dato disponible. 3. Sin ambos: el texto adaptado `Bienvenido/Bienvenida al Laboratorio...`; sin sexo disponible, la forma neutral `Acceso al Laboratorio de Cómputo de Ingeniería.` diff --git a/scripts/Set-SguWelcomeWallpaper.ps1 b/scripts/Set-SguWelcomeWallpaper.ps1 index 6891c21..9de52c1 100644 --- a/scripts/Set-SguWelcomeWallpaper.ps1 +++ b/scripts/Set-SguWelcomeWallpaper.ps1 @@ -170,10 +170,10 @@ function Get-DirectoryWelcomeMetadata { function Get-SpanishArticle { param([Parameter(Mandatory)][string]$Value) - if ($Value -match '^(Sala|Aula|Facultad|Unidad|Biblioteca|Oficina|Coordinaci.n)\b') { + if ($Value -match '^(Sala|Facultad|Unidad|Biblioteca|Oficina|Coordinaci.n)\b') { return 'la' } - if ($Value -match '^(Laboratorio|Centro|Edificio|Campus|Taller|Auditorio)\b') { + if ($Value -match '^(Aula|Laboratorio|Centro|Edificio|Campus|Taller|Auditorio)\b') { return 'el' } return $null @@ -202,9 +202,17 @@ function Get-WelcomeLocationText { if ($Room -and $OuName) { $roomArticle = Get-SpanishArticle -Value $Room $ouArticle = Get-SpanishArticle -Value $OuName - $roomPhrase = if ($roomArticle) { "$roomArticle $Room" } else { $Room } + $roomPhrase = if ($roomArticle -eq 'el') { + "al $Room" + } + elseif ($roomArticle) { + "a $roomArticle $Room" + } + else { + "a $Room" + } $ouPhrase = if ($ouArticle -eq 'el') { "del $OuName" } elseif ($ouArticle) { "de $ouArticle $OuName" } else { "de $OuName" } - return "$located $roomPhrase $ouPhrase." + return "Acceso $roomPhrase $ouPhrase." } if ($Room) { $article = Get-SpanishArticle -Value $Room diff --git a/tests/WelcomeWallpaper.Tests.ps1 b/tests/WelcomeWallpaper.Tests.ps1 index e0aac62..6fe1755 100644 --- a/tests/WelcomeWallpaper.Tests.ps1 +++ b/tests/WelcomeWallpaper.Tests.ps1 @@ -12,15 +12,20 @@ $lookup = $ast.Find({ }, $true) function Invoke-WelcomeFixture { - param($DirectoryGender, [string]$ExplicitGender) + param( + $DirectoryGender, + [string]$ExplicitGender, + [string]$DirectoryLocation = 'Sala de pruebas', + [string]$DirectoryOu = 'Laboratorio' + ) # Replace only the external directory lookup. Execute the actual script, # including its validated parameters, metadata assignment and JPEG renderer. $fixtureJson = [pscustomobject]@{ DisplayName = 'Usuario de prueba' Gender = $DirectoryGender - Location = 'Sala de pruebas' - OrganizationalUnit = 'Laboratorio' + Location = $DirectoryLocation + OrganizationalUnit = $DirectoryOu } | ConvertTo-Json -Compress $fixtureFunction = 'function Get-DirectoryWelcomeMetadata { param($UserName, $MachineName); ConvertFrom-Json ''' + $fixtureJson.Replace("'", "''") + ''' }' @@ -69,4 +74,11 @@ Describe 'Welcome wallpaper with AD metadata' { It 'honors an explicit gender over directory metadata' { (Invoke-WelcomeFixture -DirectoryGender 'Female' -ExplicitGender 'Male').WelcomeHeading | Should Be 'Bienvenido,' } + + It 'renders the flexible classroom and immediate OU as an access label' { + $result = Invoke-WelcomeFixture -DirectoryGender $null ` + -DirectoryLocation 'Aula Flexible' ` + -DirectoryOu 'Centro de Experiencia Digital' + $result.LocationText | Should Be 'Acceso al Aula Flexible del Centro de Experiencia Digital.' + } }