diff --git a/packages/patternfly-4/react-core/src/components/Tabs/Tabs.test.tsx b/packages/patternfly-4/react-core/src/components/Tabs/Tabs.test.tsx index c7b410c4fc5..7ba820eef09 100644 --- a/packages/patternfly-4/react-core/src/components/Tabs/Tabs.test.tsx +++ b/packages/patternfly-4/react-core/src/components/Tabs/Tabs.test.tsx @@ -1,11 +1,10 @@ import React from 'react'; -import { shallow, mount } from 'enzyme'; +import { render, mount } from 'enzyme'; import { Tabs } from './Tabs'; import { Tab } from './Tab'; -import { TabContent } from './TabContent'; test('should render simple tabs', () => { - const view = shallow( + const view = render( Tab 1 section @@ -22,7 +21,7 @@ test('should render simple tabs', () => { }); test('should render accessible tabs', () => { - const view = shallow( + const view = render( Tab 1 section @@ -39,7 +38,7 @@ test('should render accessible tabs', () => { }); test('should render filled tabs', () => { - const view = shallow( + const view = render( Tab 1 section @@ -56,8 +55,8 @@ test('should render filled tabs', () => { }); test('should render secondary tabs', () => { - const view = shallow( - + const view = render( + @@ -143,8 +142,8 @@ test('should call handleScrollButtons tabs with scrolls', () => { }); test('should render tabs with eventKey Strings', () => { - const view = shallow( - + const view = render( + Tab 1 section diff --git a/packages/patternfly-4/react-core/src/components/Tabs/Tabs.tsx b/packages/patternfly-4/react-core/src/components/Tabs/Tabs.tsx index b57968ee2c9..fda27e83846 100644 --- a/packages/patternfly-4/react-core/src/components/Tabs/Tabs.tsx +++ b/packages/patternfly-4/react-core/src/components/Tabs/Tabs.tsx @@ -8,6 +8,7 @@ import { getUniqueId, isElementInView, sideElementIsOutOfView } from '../../help import { SIDE } from '../../helpers/constants'; import { TabContent } from './TabContent'; import { Tab } from './Tab'; +import { InjectedOuiaProps, withOuiaContext } from '../withOuia'; export enum TabsVariant { div = 'div', @@ -46,9 +47,9 @@ export interface TabsState { highlightRightScrollButton: boolean; } -export class Tabs extends React.Component { +class Tabs extends React.Component { tabList = React.createRef(); - constructor(props: TabsProps) { + constructor(props: TabsProps & InjectedOuiaProps) { super(props); this.state = { showLeftScrollButton: false, @@ -177,6 +178,8 @@ export class Tabs extends React.Component { rightScrollAriaLabel, 'aria-label': ariaLabel, variant, + ouiaContext, + ouiaId, ...props } = this.props; const { @@ -203,6 +206,10 @@ export class Tabs extends React.Component { highlightRightScrollButton && styles.modifiers.endCurrent, className )} + {...ouiaContext.isOuia && { + 'data-ouia-component-type': 'Tabs', + 'data-ouia-component-id': ouiaId || ouiaContext.ouiaId + }} {...props} > -
    -
  • - - + + + + + +
      +
    • - - - - - -
    • -
    • - - + + + + +
    • +
    • - - - - - -
    • -
    • - - + + + + +
    • +
    • - - - - - -
    • -
    -
  • +
+ - - + + + + + + + Tab 1 section + + } id="tab1" - title="Tab item 1" + key="0/.0" > - Tab 1 section - - } - id="tab1" - key="0/.0" - > - + Tab 1 section + + } id="tab1" - title="Tab item 1" + innerRef={null} > - Tab 1 section - - } - id="tab1" - innerRef={null} - > - - - - + Tab 2 section + + } id="tab2" - title="Tab item 2" + key="1/.1" > - Tab 2 section - - } - id="tab2" - key="1/.1" - > - + Tab 2 section + + } id="tab2" - title="Tab item 2" + innerRef={null} > - Tab 2 section - - } - id="tab2" - innerRef={null} - > - - - - + Tab 3 section + + } id="tab3" - title="Tab item 3" + key="2/.2" > - Tab 3 section - - } - id="tab3" - key="2/.2" - > - + Tab 3 section + + } id="tab3" - title="Tab item 3" + innerRef={null} > - Tab 3 section - - } - id="tab3" - innerRef={null} - > - - - -
+ + + +
+ + `; exports[`should call scrollLeft tabs with scrolls 1`] = ` - -
+ Tab 1 section + , + + Tab 2 section + , + + Tab 3 section + , + ], + "id": "scrollLeft", + "isFilled": true, + } + } + consumerContext={null} > - -
    -
  • - - + + + + + +
      +
    • - - - - - -
    • -
    • - - + + + + +
    • +
    • - - - - - -
    • -
    • - - + + + + +
    • +
    • - - - - - -
    • -
    -
  • +
+ -
- + + + + + + + Tab 1 section + + } id="tab1" - title="Tab item 1" + key="0/.0" > - Tab 1 section - - } - id="tab1" - key="0/.0" - > - + Tab 1 section + + } id="tab1" - title="Tab item 1" + innerRef={null} > - Tab 1 section - - } - id="tab1" - innerRef={null} - > - - - - + Tab 2 section + + } id="tab2" - title="Tab item 2" + key="1/.1" > - Tab 2 section - - } - id="tab2" - key="1/.1" - > - + Tab 2 section + + } id="tab2" - title="Tab item 2" + innerRef={null} > - Tab 2 section - - } - id="tab2" - innerRef={null} - > - - - - + Tab 3 section + + } id="tab3" - title="Tab item 3" + key="2/.2" > - Tab 3 section - - } - id="tab3" - key="2/.2" - > - + Tab 3 section + + } id="tab3" - title="Tab item 3" + innerRef={null} > - Tab 3 section - - } - id="tab3" - innerRef={null} - > - - - -
+ + + +
+ + `; exports[`should call scrollRight tabs with scrolls 1`] = ` - -
+ Tab 1 section + , + + Tab 2 section + , + + Tab 3 section + , + ], + "id": "scrollRight", + "isFilled": true, + } + } + consumerContext={null} > - -
    -
  • - - + + + + + +
      +
    • - - - - - -
    • -
    • - - + + + + +
    • +
    • - - - - - -
    • -
    • - - + + + + + +
    • +
    • - - - - - -
    • -
    -
  • +
+ -
- + + + + + + + Tab 1 section + + } id="tab1" - title="Tab item 1" + key="0/.0" > - Tab 1 section - - } - id="tab1" - key="0/.0" - > - + Tab 1 section + + } id="tab1" - title="Tab item 1" + innerRef={null} > - Tab 1 section - - } - id="tab1" - innerRef={null} - > - - - - + Tab 2 section + + } id="tab2" - title="Tab item 2" + key="1/.1" > - Tab 2 section - - } - id="tab2" - key="1/.1" - > - + Tab 2 section + + } id="tab2" - title="Tab item 2" + innerRef={null} > - Tab 2 section - - } - id="tab2" - innerRef={null} - > - - - - + Tab 3 section + + } id="tab3" - title="Tab item 3" + key="2/.2" > - Tab 3 section - - } - id="tab3" - key="2/.2" - > - + Tab 3 section + + } id="tab3" - title="Tab item 3" + innerRef={null} > - Tab 3 section - - } - id="tab3" - innerRef={null} - > - - - -
+ + + +
+ + `; exports[`should render accessible tabs 1`] = ` - +Array [ - - Tab 1 section - - } - id="tab1" - key="0/.0" - /> - - Tab 2 section - - } - id="tab2" - key="1/.1" - /> - - } - id="tab3" - key="2/.2" - /> - + + + + , +
+ Tab 1 section +
, + , + , +] `; exports[`should render filled tabs 1`] = ` - +Array [
  • - Tab item 1 - +
  • - Tab item 2 - +
  • - Tab item 3 - +
-
- - Tab 1 section - - } - id="tab1" - key="0/.0" - /> - - Tab 2 section - - } - id="tab2" - key="1/.1" - /> - - } - id="tab3" - key="2/.2" - /> -
+ + + + , +
+ Tab 1 section +
, + , + , +] `; exports[`should render secondary tabs 1`] = ` - +Array [
  • - Tab item 1 - +
  • - Tab item 2 - +
  • - Tab item 3 - +
-
- , +
+
+ +
    +
  • +
  • +
  • +
  • +
  • +
  • +
+ +
+ + + +
, + , + , +] `; exports[`should render simple tabs 1`] = ` - +Array [
  • - Tab item 1 - +
  • - Tab item 2 - +
  • - Tab item 3 - +
-
- - Tab 1 section - - } - id="tab1" - key="0/.0" - /> - - Tab 2 section - - } - id="tab2" - key="1/.1" - /> - - } - id="tab3" - key="2/.2" - /> -
+ + + + , +
+ Tab 1 section +
, + , + , +] `; exports[`should render tabs with eventKey Strings 1`] = ` - +Array [
  • - Tab item 1 - +
  • - Tab item 2 - +
  • - Tab item 3 - +
-
- - } - id="tab1" - key="0/.0" - /> - - Tab 2 section - - } - id="tab2" - key="1/.1" - /> - - Tab 3 section - - } - id="tab3" - key="2/.2" - /> -
+ + + + , + , + , + , +] `;