Auto-Submit | +1 |
Commit-Queue | +1 |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
I'll have a look tomorrow. This CL is adding a lot of non-trivial logic I wanna grok.
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Code-Review | +1 |
lgtm with comments
function compareVeEvents(actual: TestLogEntry, expected: TestLogEntry): {difference: number, description?: string} {
Even though we don't export this function we should maybe add a doc comment that explains that `difference` is a value between [0, 1]. At least thats what I figured from the code?
return {difference: 1};
Would it be helpful here to have a description in this case that we expected an `interaction` but got `impressions` instead (or the other way around)?
export async function expectVeEvents(expectedEvents: TestLogEntry[]) {
We should also add a JSDoc comment here explicitly explaining the behavior. The code is somewhat hard to grok if anyone wanted to confirm what it's doing. Specifically:
1) It acts like a `contains`. It verifies only that the expected events are among all the logged events. It's not a "deep strict equal". (This might be obvious but better to document it explicitly).
2) Ordering is important. It verifies that the expected events show up in the specified order in the event stream.
function editDistance(a: string, b: string) {
Please add a comment which algorithm exactly this implements, ala `@returns the xyz distance". Googling for "edit distance" brings up a couple of algorithms.
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Auto-Submit | +1 |
function compareVeEvents(actual: TestLogEntry, expected: TestLogEntry): {difference: number, description?: string} {
Even though we don't export this function we should maybe add a doc comment that explains that `difference` is a value between [0, 1]. At least thats what I figured from the code?
Done
Would it be helpful here to have a description in this case that we expected an `interaction` but got `impressions` instead (or the other way around)?
This is unlikely to appear, but sure. Done.
export async function expectVeEvents(expectedEvents: TestLogEntry[]) {
We should also add a JSDoc comment here explicitly explaining the behavior. The code is somewhat hard to grok if anyone wanted to confirm what it's doing. Specifically:
1) It acts like a `contains`. It verifies only that the expected events are among all the logged events. It's not a "deep strict equal". (This might be obvious but better to document it explicitly).
2) Ordering is important. It verifies that the expected events show up in the specified order in the event stream.
Done
Please add a comment which algorithm exactly this implements, ala `@returns the xyz distance". Googling for "edit distance" brings up a couple of algorithms.
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
3 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:
```
The name of the file: test/e2e/helpers/visual-logging-helpers.ts
Insertions: 15, Deletions: 2.
@@ -27,6 +27,12 @@
return result.join('\n');
}
+// Compares the 'actual' log entry against the 'expected'. The difference of 0
+// indicates that events match. Positive values, maximum 1.0, means no match,
+// higher values represent larger difference.
+// For impressions events to match, all expected impressions need to be present
+// in the actual event. Unexected impressions in the actual event are ignored.
+// Interaction events need to match exactly.
function compareVeEvents(actual: TestLogEntry, expected: TestLogEntry): {difference: number, description?: string} {
if ('interaction' in expected && 'interaction' in actual) {
if (expected.interaction !== actual.interaction) {
@@ -46,12 +52,16 @@
if (missing.length) {
return {
difference: missing.length / expected.impressions.length,
- description: 'Missing VE events:\n' + formatImpressions(missing),
+ description: 'Missing VE impressions:\n' + formatImpressions(missing),
};
}
return {difference: 0};
}
- return {difference: 1};
+ return {
+ difference: 1,
+ description: 'interaction' in expected ? 'Missing VE interaction:\n' + expected.interaction :
+ 'Missing VE impressions:\n' + formatImpressions(expected.impressions),
+ };
}
export function veImpressionsUnder(key: string, children: TestImpressionLogEntry[]) {
@@ -171,6 +181,8 @@
]);
}
+// Verifies that VE events contains all the expected events in given order.
+// Unexpected VE events are ignored.
export async function expectVeEvents(expectedEvents: TestLogEntry[]) {
collapseConsecutiveImpressions(expectedEvents);
@@ -224,6 +236,7 @@
}
}
+// Computes the Levenshtein edit distance between two strings.
function editDistance(a: string, b: string) {
const v0: number[] = [];
const v1: number[] = [];
```
[ve] Also check for interaction in e2e tests
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |