Skip to content

Commit

Permalink
feat: add forked sentry tests
Browse files Browse the repository at this point in the history
This adds tests for the features that Sentry has added
  • Loading branch information
billyvg committed Jul 7, 2023
1 parent 46df5cd commit 3a14f29
Show file tree
Hide file tree
Showing 17 changed files with 50,790 additions and 126 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
name: Tests

on: [push, pull_request]
on:
push:
branches:
- master
- release/**
pull_request:

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
release:
name: Tests
runs-on: ubuntu-latest
# For now, we know this will fail, so we allow failures
continue-on-error: true
steps:
- name: Checkout Repo
uses: actions/checkout@v3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,10 @@ exports[`integration tests [html file]: form-fields.html 1`] = `
<input type=\\"checkbox\\" checked=\\"\\" />
</label>
<label for=\\"textarea\\">
<textarea name=\\"\\" id=\\"\\" cols=\\"30\\" rows=\\"10\\">1234</textarea>
<textarea name=\\"\\" id=\\"textarea1\\" cols=\\"30\\" rows=\\"10\\">1234</textarea>
</label>
<label for=\\"textarea\\">
<textarea name=\\"\\" id=\\"textarea2\\" cols=\\"30\\" rows=\\"10\\">56785678</textarea>
</label>
<label for=\\"select\\">
<select name=\\"\\" id=\\"\\" value=\\"2\\">
Expand Down Expand Up @@ -363,6 +366,12 @@ exports[`integration tests [html file]: picture-in-frame.html 1`] = `
</body></html>"
`;
exports[`integration tests [html file]: picture-with-inline-onload.html 1`] = `
"<html xmlns=\\"http://www.w3.org/1999/xhtml\\"><head></head><body>
<img src=\\"http://localhost:3030/images/robot.png\\" alt=\\"This is a robot\\" style=\\"opacity: 1;\\" _onload=\\"this.style.opacity=1\\" />
</body></html>"
`;

exports[`integration tests [html file]: preload.html 1`] = `
"<!DOCTYPE html><html lang=\\"en\\"><head>
<meta charset=\\"UTF-8\\" />
Expand Down
8 changes: 6 additions & 2 deletions packages/rrweb-snapshot/test/html/form-fields.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
<input type="checkbox" />
</label>
<label for="textarea">
<textarea name="" id="" cols="30" rows="10"></textarea>
<textarea name="" id="textarea1" cols="30" rows="10"></textarea>
</label>
<label for="textarea">
<textarea name="" id="textarea2" cols="30" rows="10"></textarea>
</label>
<label for="select">
<select name="" id="">
Expand All @@ -36,7 +39,8 @@
document.querySelector('input[type="text"]').value = '1';
document.querySelector('input[type="radio"]').checked = true;
document.querySelector('input[type="checkbox"]').checked = true;
document.querySelector('textarea').value = '1234';
document.querySelector('#textarea1').value = '1234';
document.querySelector('#textarea2').textContent = '5678';
document.querySelector('select').value = '2';
</script>
</html>
24 changes: 23 additions & 1 deletion packages/rrweb-snapshot/test/snapshot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
* @jest-environment jsdom
*/
import { JSDOM } from 'jsdom';

// XXX(sentry)
import { TextEncoder, TextDecoder } from 'util';
// @ts-ignore for jsdom
global.TextEncoder = TextEncoder;
// @ts-ignore for jsdom
global.TextDecoder = TextDecoder;

import {
absoluteToStylesheet,
serializeNodeWithId,
Expand Down Expand Up @@ -112,7 +120,13 @@ describe('absolute url to stylesheet', () => {

describe('isBlockedElement()', () => {
const subject = (html: string, opt: any = {}) =>
_isBlockedElement(render(html), 'rr-block', opt.blockSelector);
_isBlockedElement(
render(html),
'rr-block',
opt.blockSelector,
// XXX(sentry)
// opt.unblockSelector,
);

const render = (html: string): HTMLElement =>
JSDOM.fragment(html).querySelector('div')!;
Expand Down Expand Up @@ -150,6 +164,14 @@ describe('style elements', () => {
maskTextFn: undefined,
maskInputFn: undefined,
slimDOMOptions: {},

// XXX(sentry)
// @ts-expect-error
unblockSelector: null,
unmaskTextSelector: null,
maskInputSelector: null,
unmaskInputSelector: null,
maskAllText: false,
});
};

Expand Down
16 changes: 16 additions & 0 deletions packages/rrweb/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,25 @@ export type recordOptions<T> = {
mousemoveWait?: number;
keepIframeSrcFn?: KeepIframeSrcFn;
errorHandler?: ErrorHandler;

// XXX(sentry)
// onMutation?: (mutations: MutationRecord[]) => boolean;
// maskInputSelector?: string;
// unmaskInputSelector?: string;
// unmaskTextSelector?: string;
// unblockSelector?: string;
// maskAllText?: boolean;
};

export type observerParam = {
// XXX(sentry)
// onMutation?: (mutations: MutationRecord[]) => boolean;
// maskInputSelector: string | null;
// unmaskInputSelector: string | null;
// unmaskTextSelector: string | null;
// unblockSelector: string | null;
// maskAllText: boolean;

mutationCb: mutationCallBack;
mousemoveCb: mousemoveCallBack;
mouseInteractionCb: mouseInteractionCallBack;
Expand Down
Loading

0 comments on commit 3a14f29

Please sign in to comment.