Skip to content
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

test(replay): Add additional tests for aria-label #8675

Merged
merged 5 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" />
</head>
<body>
<div role="button" id="error" class="btn btn-error" aria-label="An Error">An Error</div>
<div role="button" id="error" class="btn btn-error" aria-label="An Error in aria-label">An Error</div>
<button title="Button title">
<img id="img" alt="Alt Text" />
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ sentryTest(
expect.arrayContaining([
{
...expectedClickBreadcrumb,
message: 'body > div#error.btn.btn-error[aria-label="An Error"]',
message: 'body > div#error.btn.btn-error[aria-label="An Error in aria-label"]',
data: {
nodeId: expect.any(Number),
node: {
attributes: {
'aria-label': '** *****',
'aria-label': '** ***** ** **********',
class: 'btn btn-error',
id: 'error',
role: 'button',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
<input placeholder="Placeholder should be masked" />
<div title="Title should be masked">Title should be masked</div>
<svg style="width:200px;height:200px" viewBox="0 0 80 80"><path d=""/><area /><rect /></svg>
<div data-sentry-block>
<div>This should be blocked</div>
</div>
<svg style="width:200px;height:200px" viewBox="0 0 80 80" data-sentry-unblock><path d=""/><area /><rect /></svg>
<img style="width:100px;height:100px" src="file:///none.png" />
<img data-sentry-unblock style="width:100px;height:100px" src="file:///none.png" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<div>This should be masked by default</div>
<div data-sentry-unmask>This should be unmasked due to data attribute</div>
<input placeholder="Placeholder should be masked" />
<input data-sentry-unmask placeholder="Placeholder can be unmasked" />
<div title="Title should be masked">Title should be masked</div>
<svg style="width:200px;height:200px" viewBox="0 0 80 80"><path d=""/><area /><rect /></svg>
<svg style="width:200px;height:200px" viewBox="0 0 80 80" data-sentry-unblock><path d=""/><area /><rect /></svg>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@
<textarea id="textarea"></textarea>
<textarea id="textarea-masked" data-sentry-mask></textarea>
<textarea id="textarea-ignore" data-sentry-ignore></textarea>

<input type="submit" value="Submit form" />
<input data-sentry-unmask type="submit" value="Unmasked button" />
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import type { inputData } from '@sentry-internal/rrweb/typings/types';

import { sentryTest } from '../../../utils/fixtures';
import type { IncrementalRecordingSnapshot } from '../../../utils/replayHelpers';
import {
import { getFullRecordingSnapshots ,
getIncrementalRecordingSnapshots,
shouldSkipReplayTest,
waitForReplayRequest,
} from '../../../utils/replayHelpers';


function isInputMutation(
snap: IncrementalRecordingSnapshot,
): snap is IncrementalRecordingSnapshot & { data: inputData } {
Expand Down Expand Up @@ -81,6 +82,7 @@ sentryTest(
const lastSnapshot2 = snapshots2[snapshots2.length - 1];
expect(lastSnapshot2.data.text).toBe('*'.repeat(text.length));

// Note this test `ignoreSelector`
await page.locator('#input-ignore').fill(text);
await forceFlushReplay();
const snapshots3 = getIncrementalRecordingSnapshots(await reqPromise3).filter(isInputMutation);
Expand Down Expand Up @@ -136,7 +138,10 @@ sentryTest(
const url = await getLocalTestPath({ testDir: __dirname });

await page.goto(url);
await reqPromise0;
const fullSnapshot = getFullRecordingSnapshots(await reqPromise0)
const stringifiedSnapshot = JSON.stringify(fullSnapshot);
expect(stringifiedSnapshot.includes('Submit form')).toBe(false);
expect(stringifiedSnapshot.includes('Unmasked button')).toBe(true);

const text = 'test';
await page.locator('#textarea').fill(text);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@

<textarea id="textarea"></textarea>
<textarea id="textarea-unmasked" data-sentry-unmask></textarea>

<input type="submit" value="Submit form" />
<input data-sentry-unmask type="submit" value="Unmasked button" />
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { IncrementalSource } from '@sentry-internal/rrweb';
import type { inputData } from '@sentry-internal/rrweb/typings/types';

import { sentryTest } from '../../../utils/fixtures';
import type { IncrementalRecordingSnapshot } from '../../../utils/replayHelpers';
import { getFullRecordingSnapshots, IncrementalRecordingSnapshot } from '../../../utils/replayHelpers';
import {
getIncrementalRecordingSnapshots,
shouldSkipReplayTest,
Expand Down Expand Up @@ -56,7 +56,10 @@ sentryTest(
const url = await getLocalTestPath({ testDir: __dirname });

await page.goto(url);
await reqPromise0;
const fullSnapshot = getFullRecordingSnapshots(await reqPromise0)
const stringifiedSnapshot = JSON.stringify(fullSnapshot);
expect(stringifiedSnapshot.includes('Submit form')).toBe(false);
expect(stringifiedSnapshot.includes('Unmasked button')).toBe(true);

const text = 'test';

Expand Down
Loading