1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
- import UserEventContext, {
- UserEventContextData,
- } from 'sentry/components/events/contexts/user';
- // the values of this mock are correct and the types need to be updated
- export const userMockData = {
- data: null,
- email: null,
- id: '',
- ip_address: null,
- name: null,
- username: null,
- } as unknown as UserEventContextData;
- export const userMetaMockData = {
- email: null,
- id: {
- '': {
- chunks: [
- {
- remark: 'x',
- rule_id: 'project:0',
- text: '',
- type: 'redaction',
- },
- ],
- len: 9,
- rem: [['project:0', 'x', 0, 0]],
- },
- },
- ip_address: {
- '': {
- err: [
- [
- 'invalid_data',
- {
- reason: 'expected an ip address',
- },
- ],
- ],
- len: 14,
- rem: [['project:0', 'x', 0, 0]],
- val: '',
- },
- },
- name: null,
- username: null,
- };
- const event = {
- ...TestStubs.Event(),
- _meta: {
- user: userMetaMockData,
- },
- };
- describe('user event context', function () {
- it('display the right context data according to its value and meta', async function () {
- render(<UserEventContext event={event} data={userMockData} />);
- expect(screen.getByText('ID')).toBeInTheDocument(); // subject
- expect(screen.getByText(/redacted/)).toBeInTheDocument(); // value
- userEvent.hover(screen.getByText(/redacted/));
- expect(
- await screen.findByText('Removed because of PII rule "project:0"')
- ).toBeInTheDocument(); // tooltip description
- expect(screen.getByText('IP Address')).toBeInTheDocument(); // subject
- expect(screen.getByText('None')).toBeInTheDocument(); // value
- userEvent.hover(screen.getByText('None'));
- expect(
- await screen.findByText('Removed because of PII rule "project:0"')
- ).toBeInTheDocument(); // tooltip description
- });
- });
|