Skip to content

Commit

Permalink
Fix more context
Browse files Browse the repository at this point in the history
  • Loading branch information
Omry Zobel authored and ZobelOmry committed Oct 18, 2022
1 parent 94cf4fd commit 61874ec
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/modules/no-code-assessment/element-similarity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function getStructureSimilarityRating(recordedElementInfo, capturedElement): num
capturedElementChildNodeNames.join(''),
recordedElementChildNodeNames.join('')
);
Logger.info('*** Internal structure similarity ratio:', internalStructureSimilarity);
Logger.info('*** Internal structure similarity ratio:', { internalStructureSimilarity });

return internalStructureSimilarity;
}
Expand All @@ -62,7 +62,7 @@ function getTextSimilarityRating(recordedElementInfo: RecordedElementInfo, captu
capturedElementDirectInnerText
);

Logger.info('*** Text similarity ratio: ', textSimilarity);
Logger.info('*** Text similarity ratio: ', { textSimilarity });

return textSimilarity;
}
Expand Down Expand Up @@ -92,7 +92,7 @@ function getSimilarityRating(recordedElementInfo: RecordedElementInfo, capturedE
}

export function isSimilar(recordedElementInfo, capturedElement): boolean {
Logger.info('*** elementInfo', recordedElementInfo);
Logger.info('*** elementInfo', { recordedElementInfo });
const similarityRating = getSimilarityRating(recordedElementInfo, capturedElement);

if (similarityRating < configManager.getLocalStorageConfig()?.assessmentThresholds?.totalSimilarityThreshold) {
Expand Down
20 changes: 11 additions & 9 deletions src/modules/no-code-assessment/no-code-assessment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,14 @@ function countAndUpdateExampleElements(assessment: Assessment, locationElement:

// TODO: narrow the query down to start from the location element instead of the entire document
const exampleElements = document.querySelectorAll(exampleElementSelector) || [];
Logger.info('*** Example elements found:', exampleElements);
Logger.info('*** Example elements found:', { exampleElements });
const exampleElementsInsideTheLocationElement = Array.from(exampleElements).filter((exampleElement) =>
locationElement.contains(exampleElement)
);

Logger.info('*** Example elements that are inside the location element:', exampleElementsInsideTheLocationElement);
Logger.info('*** Example elements that are inside the location element:', {
exampleElementsInsideTheLocationElement,
});

const currentExampleElementCount = exampleElementsInsideTheLocationElement?.length || 0;
const previousAssessmentStorageState = window.sessionStorage.getItem(_id);
Expand Down Expand Up @@ -174,7 +176,7 @@ const getLocationElement = (
const isLocationElementStillOnDOM = window.document.contains(cachedLocationElement);

if (cachedLocationElement && isLocationElementStillOnDOM) {
Logger.info('*** Got a cached location element...', cachedLocationElement);
Logger.info('*** Got a cached location element...', { cachedLocationElement });
locationElement = cachedLocationElement;
locationElementSelector = assessmentState[assessmentId]?.locationElementSelector;
} else {
Expand All @@ -185,7 +187,7 @@ const getLocationElement = (
throw new Error('*** No location element selector was found fitting.');
}

Logger.info('*** Retrieving location element by selector:', locationElementSelector);
Logger.info('*** Retrieving location element by selector:', { locationElementSelector });
locationElement = window.document.querySelector(locationElementSelector);
Logger.info('*** Found location element:', {
locationElement,
Expand Down Expand Up @@ -249,7 +251,7 @@ const addAssessmentDebugUI = function (
const previousDebugAssessmentContextElement = window.document.getElementById(`${assessment._id}-context-overlay`);

if (previousDebugAssessmentContextElement) {
Logger.info('*** Already got an existing debug element for this assessment.', assessment);
Logger.info('*** Already got an existing debug element for this assessment.', { assessment });

return;
}
Expand Down Expand Up @@ -377,9 +379,9 @@ const evaluateAssessments = function (): void {
boundedAssessAddedItems([]);
locationHandlers[_id].observer.observe(locationElement, exampleElementCountObserverOptions);
Logger.info('Same reference - no need to observe again');
Logger.info(' *** Same reference - no need to observe again', locationElement);
Logger.info(' *** Same reference - no need to observe again', { locationElement });
} catch (e) {
Logger.info('*** Got an error in item count', e);
Logger.error('*** Got an error in item count', { err: e });
break;
}

Expand All @@ -391,9 +393,9 @@ const evaluateAssessments = function (): void {
boundedAssessAddedItems([]);
locationHandlers[_id].observer.observe(locationElement, exampleElementCountObserverOptions);
Logger.info('DOM Reference have changed - observing again');
Logger.info(' *** DOM Reference have changed - observing again', locationElement);
Logger.info(' *** DOM Reference have changed - observing again', { locationElement });
} catch (e) {
Logger.info('*** Got an error in item count', e);
Logger.error('*** Got an error in item count', { err: e });
break;
}

Expand Down

0 comments on commit 61874ec

Please sign in to comment.