From b40d9be80630870a355dda1d6054127ec18fb458 Mon Sep 17 00:00:00 2001 From: Elsa Perelli Date: Tue, 9 Apr 2024 13:05:09 -0400 Subject: [PATCH] Highlighting compliance (#301) * Make highlighting more resistant to external CSS, update unit tests * Make line height conditional in main.js, remove dashed line in coverage highlighting * Conditional in styling * Make uncoverage highlighting styling independent of coverage * Fix unit tests * Better variable naming --- src/calculation/HTMLBuilder.ts | 24 +++++++++++-------- src/templates/main.ts | 2 +- .../html/simpleCoverageAnnotation.html | 14 +++++------ .../html/simpleCoverageAnnotation2.html | 14 +++++------ .../fixtures/html/simpleFalseAnnotation.html | 4 ++-- .../fixtures/html/simpleTrueAnnotation.html | 4 ++-- 6 files changed, 33 insertions(+), 29 deletions(-) diff --git a/src/calculation/HTMLBuilder.ts b/src/calculation/HTMLBuilder.ts index 1fde3110..ef1a81c7 100644 --- a/src/calculation/HTMLBuilder.ts +++ b/src/calculation/HTMLBuilder.ts @@ -18,28 +18,31 @@ export const cqlLogicClauseTrueStyle = { 'background-color': '#ccebe0', color: '#20744c', 'border-bottom-color': '#20744c', - 'border-bottom-style': 'solid' + 'border-bottom-style': 'solid', + 'border-bottom-width': '0.35em' }; export const cqlLogicClauseFalseStyle = { 'background-color': '#edd8d0', color: '#a63b12', 'border-bottom-color': '#a63b12', - 'border-bottom-style': 'double' + 'border-bottom-style': 'double', + 'border-bottom-width': '0.35em' }; export const cqlLogicClauseCoveredStyle = { 'background-color': '#daeaf5', - color: '#004e82', - 'border-bottom-color': '#006cb4', - 'border-bottom-style': 'dashed' + color: '#004e82' }; export const cqlLogicUncoveredClauseStyle = { 'background-color': 'white', - color: 'black', - 'border-bottom-color': 'white', - 'border-bottom-style': 'solid' + color: 'black' +}; + +export const cqlLogicUncoveredUncoverageClauseStyle = { + 'background-color': '#edd8d0', + color: '#a63b12' }; /** @@ -102,7 +105,7 @@ Handlebars.registerHelper('highlightUncoverage', (localId, context) => { ) ) { // Mark with red styling if clause is found in uncoverage list - return objToCSS(cqlLogicClauseFalseStyle); + return objToCSS(cqlLogicUncoveredUncoverageClauseStyle); } else if ( (context.data.root.coveredClauses as ClauseResult[]).some( result => result.libraryName === libraryName && result.localId === localId @@ -211,7 +214,8 @@ export function generateHTML( libraryName: s.libraryName, statementName: s.statementName, clauseResults: clauseResults, - ...matchingExpression.annotation[0].s + ...matchingExpression.annotation[0].s, + highlightLogic: true }); overallHTML += statementHTML; if (options?.buildStatementLevelHTML) { diff --git a/src/templates/main.ts b/src/templates/main.ts index 2c4fd850..d6227963 100644 --- a/src/templates/main.ts +++ b/src/templates/main.ts @@ -1,4 +1,4 @@ -export default `
 
 {{> clause}}
diff --git a/test/unit/fixtures/html/simpleCoverageAnnotation.html b/test/unit/fixtures/html/simpleCoverageAnnotation.html
index bc5d40af..8b46bd65 100644
--- a/test/unit/fixtures/html/simpleCoverageAnnotation.html
+++ b/test/unit/fixtures/html/simpleCoverageAnnotation.html
@@ -1,25 +1,25 @@
 

test Clause Coverage: 100%

       
-        
+        
           define "Denominator": 
-          
-            
-              
+          
+            
+              
                 "Encounter with Atrial Ablation Procedure"
               
               union
-              
+              
                 "History of Atrial FibrillationFlutter"
               
             
             union
-            
+            
               "Current Diagnosis Atrial FibrillationFlutter"
             
           
diff --git a/test/unit/fixtures/html/simpleCoverageAnnotation2.html b/test/unit/fixtures/html/simpleCoverageAnnotation2.html
index 5dcb2e47..7d4f528c 100644
--- a/test/unit/fixtures/html/simpleCoverageAnnotation2.html
+++ b/test/unit/fixtures/html/simpleCoverageAnnotation2.html
@@ -1,25 +1,25 @@
 

test2 Clause Coverage: 100%

         
-          
+          
             define "Denominator": 
-            
-              
-                
+            
+              
+                
                   "Encounter with Atrial Ablation Procedure"
                 
                 union
-                
+                
                   "History of Atrial FibrillationFlutter"
                 
               
               union
-              
+              
                 "Current Diagnosis Atrial FibrillationFlutter"
               
             
diff --git a/test/unit/fixtures/html/simpleFalseAnnotation.html b/test/unit/fixtures/html/simpleFalseAnnotation.html
index fbf3f95b..cf1d4bb5 100644
--- a/test/unit/fixtures/html/simpleFalseAnnotation.html
+++ b/test/unit/fixtures/html/simpleFalseAnnotation.html
@@ -1,12 +1,12 @@
 

Population Group: test

     
-      
+      
         define "Denominator": 
         
           
diff --git a/test/unit/fixtures/html/simpleTrueAnnotation.html b/test/unit/fixtures/html/simpleTrueAnnotation.html
index 1ce90fdd..f1b616eb 100644
--- a/test/unit/fixtures/html/simpleTrueAnnotation.html
+++ b/test/unit/fixtures/html/simpleTrueAnnotation.html
@@ -1,12 +1,12 @@
 

Population Group: test

     
-      
+      
         define "Denominator":