From 457c6287a2ca5bc60f424ecc53378579ef2548e8 Mon Sep 17 00:00:00 2001 From: Kia Lam Date: Mon, 13 May 2019 14:56:36 -0400 Subject: [PATCH] General cleanup. - Fix tests. - Update snapshots. - Remove old import statement. - Add element ids for Sort and Search Components. --- __tests__/components/DataListToolbar.test.jsx | 27 +- .../DeleteToolbarButton.test.jsx.snap | 117 +- .../NotificationListItem.test.jsx.snap | 544 ++-- .../OrganizationNotifications.test.jsx.snap | 2811 +++++++++++------ .../DataListToolbar/DataListToolbar.jsx | 87 +- src/components/Search/Search.jsx | 1 + src/components/Sort/Sort.jsx | 3 +- src/index.jsx | 1 - 8 files changed, 2317 insertions(+), 1274 deletions(-) diff --git a/__tests__/components/DataListToolbar.test.jsx b/__tests__/components/DataListToolbar.test.jsx index 8bf673d693..c227291c77 100644 --- a/__tests__/components/DataListToolbar.test.jsx +++ b/__tests__/components/DataListToolbar.test.jsx @@ -57,10 +57,9 @@ describe('', () => { }); test('dropdown items sortable columns work', () => { - const sortDropdownToggleSelector = '.pf-l-toolbar__group.sortDropdownGroup .pf-l-toolbar__item button'; - const sortDropdownItemsSelector = '.pf-l-toolbar__group.sortDropdownGroup button.pf-c-dropdown__menu-item'; - const searchDropdownToggleSelector = '.pf-c-dropdown.searchKeyDropdown .pf-c-dropdown__toggle'; - const searchDropdownItemsSelector = '.pf-c-dropdown.searchKeyDropdown button.pf-c-dropdown__menu-item'; + const sortDropdownToggleSelector = 'button[id="awx-sort"]'; + const searchDropdownToggleSelector = 'button[id="awx-search"]'; + const dropdownMenuItems = 'DropdownMenu > ul'; const multipleColumns = [ { name: 'Foo', key: 'foo', isSortable: true }, @@ -80,12 +79,10 @@ describe('', () => { /> ); const sortDropdownToggle = toolbar.find(sortDropdownToggleSelector); - expect(sortDropdownToggle.length).toBe(2); - sortDropdownToggle.at(1).simulate('click'); - sortDropdownToggle.at(0).simulate('click'); + expect(sortDropdownToggle.length).toBe(1); + sortDropdownToggle.simulate('click'); toolbar.update(); - - const sortDropdownItems = toolbar.find(sortDropdownItemsSelector); + const sortDropdownItems = toolbar.find(dropdownMenuItems).children(); expect(sortDropdownItems.length).toBe(2); const mockedSortEvent = { target: { innerText: 'Bar' } }; @@ -101,13 +98,13 @@ describe('', () => { toolbar.update(); const sortDropdownToggleDescending = toolbar.find(sortDropdownToggleSelector); - expect(sortDropdownToggleDescending.length).toBe(2); - sortDropdownToggleDescending.at(1).simulate('click'); - sortDropdownToggleDescending.at(0).simulate('click'); + expect(sortDropdownToggleDescending.length).toBe(1); + sortDropdownToggleDescending.simulate('click'); toolbar.update(); - const sortDropdownItemsDescending = toolbar.find(sortDropdownItemsSelector); + const sortDropdownItemsDescending = toolbar.find(dropdownMenuItems).children(); expect(sortDropdownItemsDescending.length).toBe(2); + sortDropdownToggleDescending.simulate('click'); // toggle close the sort dropdown const mockedSortEventDescending = { target: { innerText: 'Bar' } }; sortDropdownItems.at(0).simulate('click', mockedSortEventDescending); @@ -115,10 +112,10 @@ describe('', () => { const searchDropdownToggle = toolbar.find(searchDropdownToggleSelector); expect(searchDropdownToggle.length).toBe(1); - searchDropdownToggle.at(0).simulate('click'); + searchDropdownToggle.simulate('click'); toolbar.update(); - const searchDropdownItems = toolbar.find(searchDropdownItemsSelector); + const searchDropdownItems = toolbar.find(dropdownMenuItems).children(); expect(searchDropdownItems.length).toBe(3); const mockedSearchEvent = { target: { innerText: 'Bar' } }; diff --git a/__tests__/components/PaginatedDataList/__snapshots__/DeleteToolbarButton.test.jsx.snap b/__tests__/components/PaginatedDataList/__snapshots__/DeleteToolbarButton.test.jsx.snap index 3a181290d8..3315e9feb0 100644 --- a/__tests__/components/PaginatedDataList/__snapshots__/DeleteToolbarButton.test.jsx.snap +++ b/__tests__/components/PaginatedDataList/__snapshots__/DeleteToolbarButton.test.jsx.snap @@ -69,57 +69,92 @@ exports[` should render button 1`] = ` trigger="mouseenter focus" zIndex={9999} > - - + + + + + + + + + diff --git a/__tests__/components/__snapshots__/NotificationListItem.test.jsx.snap b/__tests__/components/__snapshots__/NotificationListItem.test.jsx.snap index 47bf1aee3d..ad97bed524 100644 --- a/__tests__/components/__snapshots__/NotificationListItem.test.jsx.snap +++ b/__tests__/components/__snapshots__/NotificationListItem.test.jsx.snap @@ -41,20 +41,8 @@ exports[` initially renders succe className="" dataListCells={ Array [ - - + initially renders succe > Foo - - + slack - - , - + , + - - - , + , ] } key=".0" @@ -119,170 +89,366 @@ exports[` initially renders succe
- -
- - - - Foo - - - - - - slack - - -
-
- -
- -
+
+ + + + + +
+ - - - - - - - + - - - - - -
-
+ + + + + + +
+ + + diff --git a/__tests__/pages/Organizations/screens/Organization/__snapshots__/OrganizationNotifications.test.jsx.snap b/__tests__/pages/Organizations/screens/Organization/__snapshots__/OrganizationNotifications.test.jsx.snap index e7d882aac1..f804e903a0 100644 --- a/__tests__/pages/Organizations/screens/Organization/__snapshots__/OrganizationNotifications.test.jsx.snap +++ b/__tests__/pages/Organizations/screens/Organization/__snapshots__/OrganizationNotifications.test.jsx.snap @@ -222,117 +222,732 @@ exports[` initially renders succesfully 1`] = ` update={true} withHash={true} > -
- +
- -
- -
+ - -
+ - -
- + +
+ + Modified + , + + Created + , + ] + } + isOpen={false} + onSelect={[Function]} + onToggle={[Function]} + toggle={ + + Name + + } + > + + Modified + , + + Created + , + ] + } + forwardedComponent={ + Object { + "$$typeof": Symbol(react.forward_ref), + "attrs": Array [], + "componentStyle": ComponentStyle { + "componentId": "Search__Dropdown-sc-1dwuww3-2", + "isStatic": true, + "lastClassName": "kcnywV", + "rules": Array [ + "&&&{> button{min-height:30px;min-width:70px;height:30px;padding:0 10px;margin:0px;> span{width:auto;}> svg{margin:0px;padding-top:3px;padding-left:3px;}}}", + ], + }, + "displayName": "Search__Dropdown", + "foldedComponentIds": Array [], + "render": [Function], + "styledComponentId": "Search__Dropdown-sc-1dwuww3-2", + "target": [Function], + "toString": [Function], + "warnTooManyClasses": [Function], + "withComponent": [Function], + } + } + forwardedRef={null} + isOpen={false} + onSelect={[Function]} + onToggle={[Function]} + toggle={ + + Name + + } + > + + Modified + , + + Created + , + ] + } + isOpen={false} + isPlain={false} + onSelect={[Function]} + onToggle={[Function]} + position="left" + toggle={ + + Name + + } + > +
+ + +
+ } + > + + +
+ } + > + + + +
+ +
+ + + + + + + + + + + + + + +
+ + +
+ + + + +
+ +
+
+
+ + + + +
+ +
+ + + initially renders succesfully 1`] = ` ] } isOpen={false} - isPlain={false} onSelect={[Function]} onToggle={[Function]} - position="left" + style={ + Object { + "marginRight": "20px", + } + } toggle={ initially renders succesfully 1`] = ` } > -
- - -
+ Modified + , + + Created + , + ] + } + forwardedComponent={ + Object { + "$$typeof": Symbol(react.forward_ref), + "attrs": Array [], + "componentStyle": ComponentStyle { + "componentId": "Sort__Dropdown-sc-21g5aw-0", + "isStatic": true, + "lastClassName": "kdSQuN", + "rules": Array [ + "&&&{> button{min-height:30px;min-width:70px;height:30px;padding:0 10px;margin:0px;> span{width:auto;}> svg{margin:0px;padding-top:3px;padding-left:3px;}}}", + ], + }, + "displayName": "Sort__Dropdown", + "foldedComponentIds": Array [], + "render": [Function], + "styledComponentId": "Sort__Dropdown-sc-21g5aw-0", + "target": [Function], + "toString": [Function], + "warnTooManyClasses": [Function], + "withComponent": [Function], } - > + } + forwardedRef={null} + isOpen={false} + onSelect={[Function]} + onToggle={[Function]} + style={ + Object { + "marginRight": "20px", + } + } + toggle={ + Name + + } + > + + Modified + , + + Created + , + ] + } + isOpen={false} + isPlain={false} + onSelect={[Function]} + onToggle={[Function]} + position="left" + style={ + Object { + "marginRight": "20px", + } + } + toggle={ + + Name + + } + > +
+ + +
+ } + > + + +
+ } > -
- } - > - - - -
- - - - -