-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✅ [RUMF-815] import RRWeb integration tests #738
Conversation
await flushEvents() | ||
|
||
expect(events.sessionReplay.length).toBe(1) | ||
|
||
const segment = events.sessionReplay[0].segment.data | ||
const fullSnapshot = findFullSnapshot(segment)! | ||
const mutations = findAllIncrementalSnapshots(segment, IncrementalSource.Mutation) as Array<{ | ||
data: MutationData | ||
}> | ||
|
||
expect(mutations.length).toBe(1) | ||
|
||
expect(mutations[0].data.adds).toEqual([ | ||
{ | ||
nextId: null, | ||
parentId: findElementWithTagName(fullSnapshot, 'p')!.id, | ||
node: jasmine.objectContaining({ tagName: 'span' }), | ||
}, | ||
]) | ||
expect(mutations[0].data.removes).toEqual([ | ||
{ | ||
parentId: findElementWithTagName(fullSnapshot, 'body')!.id, | ||
id: findElementWithTagName(fullSnapshot, 'ul')!.id, | ||
}, | ||
]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, there are a lot of similarities across these tests, we could probably make something to reduce the boilerplate and make them more expressive.
what would you think of having a test API like:
flushSessionReplayEvents(events) // page object-like API to have acces to events, segment, full snapshot
.singleRecord() // select record to check and do something similar for filterRecordsByIdAttribute usages
.expectAdded ({ tag: 'span', parentTag: 'p' })
.expectRemoved({ tag: 'ul', parentTag: 'body' })
.expectNotAdded({ tag: 'li' })
.expectNotRemoved({ tag: 'li' })
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok so I did something to remove the boilerplate. Since I didn't write the original tests I wanted to keep some kind of exhaustive snapshot, so I did not use a expectAdded
/expectNotAdded
API, and instead add a helper to verify the whole mutations. Because nodes are referenced in the initial full snapshot or the previous mutations, it makes things a bit complex. Let me know what you think about it!
8f667d4
to
1ffb4f3
Compare
LGTM except flaky tests |
Codecov Report
@@ Coverage Diff @@
## master #738 +/- ##
==========================================
- Coverage 82.54% 82.41% -0.14%
==========================================
Files 74 74
Lines 3798 3798
Branches 903 903
==========================================
- Hits 3135 3130 -5
- Misses 663 668 +5
Continue to review full report at Codecov.
|
Motivation
Import RRWeb integration tests as E2E tests. Since we are running those tests in various browsers and snapshots are heavily dependent of the browse, we cannot really use snapshot testing like RRWeb does.
Changes
skipped, too big to test, already covered by other tests
skipped, feature have been removed
was already implemented
skipped, feature not used
skipped, feature not used
skipped, feature not used
skipped, no relation with RRWeb
skipped, feature not implemented
skipped, feature not implemented
Testing
E2E
I have gone over the contributing documentation.