test(ui): update design token and contrast guardrails for single theme
This commit is contained in:
+45
@@ -108,6 +108,51 @@ class DesignTokenGuardrailTest {
|
||||
.isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Código da UI e CSS não devem conter referências a .theme-dark, AppTheme ou isDark")
|
||||
void shouldNotContainDarkThemeReferencesInUiCodeOrCss() throws Exception {
|
||||
// 1. Valida theme.css e no-effects.css
|
||||
String[] cssFiles = {"/styles/theme.css", "/styles/no-effects.css"};
|
||||
for (String cssPath : cssFiles) {
|
||||
InputStream stream = getClass().getResourceAsStream(cssPath);
|
||||
if (stream != null) {
|
||||
String content = new String(stream.readAllBytes(), StandardCharsets.UTF_8);
|
||||
assertThat(content)
|
||||
.withFailMessage("Arquivo %s ainda contém referências a .theme-dark ou .theme-light!", cssPath)
|
||||
.doesNotContain(".theme-dark")
|
||||
.doesNotContain(".theme-light");
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Valida fontes Java em src/main/java
|
||||
java.nio.file.Path sourceRoot = java.nio.file.Files.exists(java.nio.file.Path.of("src/main/java"))
|
||||
? java.nio.file.Path.of("src/main/java")
|
||||
: java.nio.file.Path.of("modules/cybercore-ui/src/main/java");
|
||||
|
||||
List<String> violations = new ArrayList<>();
|
||||
try (var stream = java.nio.file.Files.walk(sourceRoot)) {
|
||||
List<java.nio.file.Path> javaFiles = stream
|
||||
.filter(java.nio.file.Files::isRegularFile)
|
||||
.filter(p -> p.toString().endsWith(".java"))
|
||||
.toList();
|
||||
|
||||
for (java.nio.file.Path file : javaFiles) {
|
||||
List<String> lines = java.nio.file.Files.readAllLines(file, StandardCharsets.UTF_8);
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
String line = lines.get(i);
|
||||
if (line.contains("AppTheme") || line.contains("isDark(") || line.contains(".theme-dark")) {
|
||||
violations.add(String.format("%s:%d -> %s", file.getFileName(), i + 1, line.trim()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assertThat(violations)
|
||||
.withFailMessage("Foram encontradas referências obsoletas a tema escuro no código da UI:\n%s",
|
||||
String.join("\n", violations))
|
||||
.isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("theme.css deve definir todos os tokens de cores semânticas primários e de superfície")
|
||||
void shouldDefineAllRequiredSemanticColorTokens() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user