123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- import constructSelector from 'sentry/views/replays/deadRageClick/constructSelector';
- describe('constructSelector', () => {
- it.each([
- {
- element: {
- alt: 'view more',
- aria_label: 'View More',
- class: ['classA'],
- id: 'ID1',
- role: 'button',
- tag: 'button',
- testid: 'button-test',
- title: 'cool title',
- },
- fullSelector:
- 'button#ID1.classA[role="button"][aria="View More"][data-test-id="button-test"][alt="view more"][title="cool title"]',
- selector:
- 'button#ID1.classA[role="button"][aria="View More"][data-test-id="button-test"][alt="view more"][title="cool title"]',
- },
- {
- element: {
- alt: '',
- aria_label: '',
- class: ['', ''],
- id: '',
- role: '',
- tag: 'a',
- testid: '',
- title: '',
- },
- fullSelector: 'a[role=""][aria=""][data-test-id=""][alt=""][title=""]',
- selector: 'a',
- },
- {
- element: {
- alt: '',
- aria_label: '',
- class: ['classA', ''],
- id: '',
- role: '',
- tag: 'a',
- testid: '',
- title: '',
- },
- fullSelector: 'a.classA[role=""][aria=""][data-test-id=""][alt=""][title=""]',
- selector: 'a.classA',
- },
- {
- element: {
- alt: '',
- aria_label: '',
- class: ['classA', ''],
- id: 'ID2',
- role: '',
- tag: 'a',
- testid: '',
- title: '',
- },
- fullSelector: 'a#ID2.classA[role=""][aria=""][data-test-id=""][alt=""][title=""]',
- selector: 'a#ID2.classA',
- },
- {
- element: {
- alt: '',
- aria_label: '',
- class: ['classA', 'classB'],
- id: 'ID2',
- role: '',
- tag: 'a',
- testid: '',
- title: '',
- },
- fullSelector:
- 'a#ID2.classA.classB[role=""][aria=""][data-test-id=""][alt=""][title=""]',
- selector: 'a#ID2.classA.classB',
- },
- {
- element: {
- alt: '',
- aria_label: 'hello',
- class: ['classA', 'classB'],
- id: 'ID2',
- role: '',
- tag: 'a',
- testid: '',
- title: '',
- },
- fullSelector:
- 'a#ID2.classA.classB[role=""][aria="hello"][data-test-id=""][alt=""][title=""]',
- selector: 'a#ID2.classA.classB[aria="hello"]',
- },
- {
- element: {
- alt: '',
- aria_label: 'hello',
- class: [''],
- id: 'ID2',
- role: '',
- tag: 'a',
- testid: '',
- title: '',
- },
- fullSelector: 'a#ID2[role=""][aria="hello"][data-test-id=""][alt=""][title=""]',
- selector: 'a#ID2[aria="hello"]',
- },
- ])(
- 'should construct the correct trimmed selector and full selector, for each element in the list',
- ({element, fullSelector, selector}) => {
- expect(constructSelector(element)).toStrictEqual({fullSelector, selector});
- }
- );
- });
|